|
|
@ -1,4 +1,6 @@ |
|
|
|
#include "label.hpp" |
|
|
|
#include "label.hpp" |
|
|
|
|
|
|
|
#include "label/pin.hpp" |
|
|
|
|
|
|
|
#include "label/title.hpp" |
|
|
|
|
|
|
|
|
|
|
|
using namespace app::browser::main::tab; |
|
|
|
using namespace app::browser::main::tab; |
|
|
|
|
|
|
|
|
|
|
@ -15,25 +17,34 @@ Label::Label( |
|
|
|
action__tab_close = ACTION__TAB_CLOSE; |
|
|
|
action__tab_close = ACTION__TAB_CLOSE; |
|
|
|
|
|
|
|
|
|
|
|
// Init extras
|
|
|
|
// Init extras
|
|
|
|
text = _("New page"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
is_pinned = false; |
|
|
|
is_pinned = false; |
|
|
|
|
|
|
|
|
|
|
|
// Init widget
|
|
|
|
// Init widget
|
|
|
|
set_ellipsize( |
|
|
|
set_orientation( |
|
|
|
Pango::EllipsizeMode::END |
|
|
|
Gtk::Orientation::HORIZONTAL |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
set_has_tooltip( |
|
|
|
set_halign( |
|
|
|
true |
|
|
|
Gtk::Align::CENTER |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
set_single_line_mode( |
|
|
|
// Init components
|
|
|
|
true |
|
|
|
labelPin = Gtk::make_managed<label::Pin>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
labelPin->hide(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
append( |
|
|
|
|
|
|
|
* labelPin |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
set_width_chars( |
|
|
|
labelTitle = Gtk::make_managed<label::Title>(); |
|
|
|
WIDTH_CHARS |
|
|
|
|
|
|
|
|
|
|
|
set_tooltip_text( |
|
|
|
|
|
|
|
labelTitle->get_text() |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
append( |
|
|
|
|
|
|
|
* labelTitle |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// Init primary button controller
|
|
|
|
// Init primary button controller
|
|
|
@ -53,7 +64,7 @@ Label::Label( |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (n == 2) // double click
|
|
|
|
if (n == 2) // double click
|
|
|
|
{ |
|
|
|
{ |
|
|
|
pin( |
|
|
|
update( |
|
|
|
!is_pinned // toggle
|
|
|
|
!is_pinned // toggle
|
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
@ -112,12 +123,6 @@ int Label::session_restore( |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Restore widget data
|
|
|
|
// Restore widget data
|
|
|
|
update( |
|
|
|
update( |
|
|
|
reinterpret_cast<const char*>( |
|
|
|
|
|
|
|
sqlite3_column_text( |
|
|
|
|
|
|
|
statement, |
|
|
|
|
|
|
|
Database::Session::TEXT |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
sqlite3_column_int( |
|
|
|
sqlite3_column_int( |
|
|
|
statement, |
|
|
|
statement, |
|
|
|
Database::Session::IS_PINNED |
|
|
|
Database::Session::IS_PINNED |
|
|
@ -125,6 +130,7 @@ int Label::session_restore( |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// Restore children components here (on available)
|
|
|
|
// Restore children components here (on available)
|
|
|
|
|
|
|
|
// @TODO
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -142,76 +148,57 @@ int Label::session_save( |
|
|
|
return Database::Session::add( |
|
|
|
return Database::Session::add( |
|
|
|
database, |
|
|
|
database, |
|
|
|
APP_BROWSER_MAIN_TAB__SESSION__ID, |
|
|
|
APP_BROWSER_MAIN_TAB__SESSION__ID, |
|
|
|
is_pinned, |
|
|
|
is_pinned |
|
|
|
text |
|
|
|
|
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Label::pin( |
|
|
|
void Label::pin() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
update( |
|
|
|
|
|
|
|
!is_pinned |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Label::update( |
|
|
|
const bool & IS_PINNED |
|
|
|
const bool & IS_PINNED |
|
|
|
) { |
|
|
|
) { |
|
|
|
// Toggle status
|
|
|
|
// Toggle status
|
|
|
|
is_pinned = IS_PINNED; |
|
|
|
is_pinned = IS_PINNED; |
|
|
|
|
|
|
|
|
|
|
|
// Update widget
|
|
|
|
|
|
|
|
if (is_pinned) |
|
|
|
if (is_pinned) |
|
|
|
{ |
|
|
|
{ |
|
|
|
set_width_chars( |
|
|
|
labelPin->show(); |
|
|
|
1 |
|
|
|
labelTitle->hide(); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set_text( |
|
|
|
|
|
|
|
"•" // @TODO GTK icon
|
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
set_width_chars( |
|
|
|
labelPin->hide(); |
|
|
|
WIDTH_CHARS |
|
|
|
labelTitle->show(); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set_text( |
|
|
|
|
|
|
|
text |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Label::pin() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
pin( |
|
|
|
|
|
|
|
!is_pinned |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Label::update( |
|
|
|
void Label::update( |
|
|
|
const Glib::ustring & TEXT |
|
|
|
const Glib::ustring & TITLE |
|
|
|
) { |
|
|
|
) { |
|
|
|
// Keep new value in memory (used for pin actions)
|
|
|
|
|
|
|
|
text = TEXT; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Update widget
|
|
|
|
|
|
|
|
set_tooltip_text( |
|
|
|
set_tooltip_text( |
|
|
|
TEXT // same value for tooltip (ellipsize mode)
|
|
|
|
TITLE |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if (!is_pinned) |
|
|
|
labelTitle->set_text( |
|
|
|
{ |
|
|
|
TITLE |
|
|
|
set_text( |
|
|
|
|
|
|
|
TEXT |
|
|
|
|
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Label::update( |
|
|
|
void Label::update( |
|
|
|
const Glib::ustring & TEXT, |
|
|
|
const Glib::ustring & TITLE, |
|
|
|
const int & IS_PINNED |
|
|
|
const int & IS_PINNED |
|
|
|
) { |
|
|
|
) { |
|
|
|
update( |
|
|
|
update( |
|
|
|
TEXT |
|
|
|
TITLE |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
pin( |
|
|
|
update( |
|
|
|
IS_PINNED |
|
|
|
IS_PINNED |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
@ -229,8 +216,7 @@ int Label::Database::Session::init( |
|
|
|
( |
|
|
|
( |
|
|
|
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `app_browser_main_tab__session__id` INTEGER NOT NULL, |
|
|
|
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `app_browser_main_tab__session__id` INTEGER NOT NULL, |
|
|
|
`time` INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP, |
|
|
|
`time` INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP, |
|
|
|
`is_pinned` INTEGER NOT NULL, |
|
|
|
`is_pinned` INTEGER NOT NULL |
|
|
|
`text` VARCHAR (1024) NOT NULL |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
)SQL", |
|
|
|
)SQL", |
|
|
|
nullptr, |
|
|
|
nullptr, |
|
|
@ -298,8 +284,7 @@ int Label::Database::Session::clean( |
|
|
|
sqlite3_int64 Label::Database::Session::add( |
|
|
|
sqlite3_int64 Label::Database::Session::add( |
|
|
|
sqlite3 * database, |
|
|
|
sqlite3 * database, |
|
|
|
const sqlite3_int64 & APP_BROWSER_MAIN_TAB__SESSION__ID, |
|
|
|
const sqlite3_int64 & APP_BROWSER_MAIN_TAB__SESSION__ID, |
|
|
|
const bool & IS_PINNED, |
|
|
|
const bool & IS_PINNED |
|
|
|
const Glib::ustring & TEXT |
|
|
|
|
|
|
|
) { |
|
|
|
) { |
|
|
|
char * error; // @TODO
|
|
|
|
char * error; // @TODO
|
|
|
|
|
|
|
|
|
|
|
@ -309,17 +294,14 @@ sqlite3_int64 Label::Database::Session::add( |
|
|
|
R"SQL( |
|
|
|
R"SQL( |
|
|
|
INSERT INTO `app_browser_main_tab_label__session` ( |
|
|
|
INSERT INTO `app_browser_main_tab_label__session` ( |
|
|
|
`app_browser_main_tab__session__id`, |
|
|
|
`app_browser_main_tab__session__id`, |
|
|
|
`is_pinned`, |
|
|
|
`is_pinned` |
|
|
|
`text` |
|
|
|
|
|
|
|
) VALUES ( |
|
|
|
) VALUES ( |
|
|
|
'%d', |
|
|
|
%d, |
|
|
|
'%d', |
|
|
|
%d |
|
|
|
'%s' |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
)SQL", |
|
|
|
)SQL", |
|
|
|
APP_BROWSER_MAIN_TAB__SESSION__ID, |
|
|
|
APP_BROWSER_MAIN_TAB__SESSION__ID, |
|
|
|
IS_PINNED, |
|
|
|
IS_PINNED |
|
|
|
TEXT |
|
|
|
|
|
|
|
).c_str(), |
|
|
|
).c_str(), |
|
|
|
nullptr, |
|
|
|
nullptr, |
|
|
|
nullptr, |
|
|
|
nullptr, |
|
|
|