Browse Source

customize tabl labels view, add tooltip support for ellipsize mode, add label update action

CPP-GTK4
yggverse 2 months ago
parent
commit
51b41e21e7
  1. 38
      src/app/browser/main/tab/label.cpp
  2. 9
      src/app/browser/main/tab/label.hpp

38
src/app/browser/main/tab/label.cpp

@ -37,10 +37,26 @@ Label::Label( @@ -37,10 +37,26 @@ Label::Label(
);
// Init widget
/* not in use, overwritten by page init @TODO
set_text(
_("New page")
);*/
set_ellipsize(
Pango::EllipsizeMode::END
);
/* @TODO require als set_xalign(0)
set_halign(
Gtk::Align::START
); */
set_has_tooltip(
true
);
set_single_line_mode(
true
);
set_width_chars(
WIDTH_CHARS
);
}
// Actions
@ -71,7 +87,7 @@ int Label::session_restore( @@ -71,7 +87,7 @@ int Label::session_restore(
while (sqlite3_step(statement) == SQLITE_ROW)
{
// Restore widget data
set_text(
update(
reinterpret_cast<const char*>(
sqlite3_column_text(
statement,
@ -102,6 +118,18 @@ int Label::session_save( @@ -102,6 +118,18 @@ int Label::session_save(
);
}
void Label::update(
const Glib::ustring & TEXT
) {
set_text(
TEXT
);
set_tooltip_text(
TEXT // same value for tooltip (ellipsize mode)
);
}
// Database model
int Label::DB::SESSION::init(
sqlite3 * db

9
src/app/browser/main/tab/label.hpp

@ -5,8 +5,10 @@ @@ -5,8 +5,10 @@
#include <glibmm/i18n.h>
#include <glibmm/refptr.h>
#include <glibmm/ustring.h>
#include <gtkmm/enums.h>
#include <gtkmm/gestureclick.h>
#include <gtkmm/label.h>
#include <pangomm/layout.h>
#include <sqlite3.h>
namespace app::browser::main::tab
@ -61,6 +63,9 @@ namespace app::browser::main::tab @@ -61,6 +63,9 @@ namespace app::browser::main::tab
// Actions
Glib::RefPtr<Gio::SimpleAction> action__tab_close;
// Defaults
int WIDTH_CHARS = 16;
/*
* Class API
*/
@ -79,6 +84,10 @@ namespace app::browser::main::tab @@ -79,6 +84,10 @@ namespace app::browser::main::tab
int session_save(
const sqlite3_int64 & APP_BROWSER_MAIN_TAB__SESSION__ID
); // return sqlite3_finalize status code
void update(
const Glib::ustring & TEXT
);
};
}

Loading…
Cancel
Save