implement pin tab menu item

This commit is contained in:
yggverse 2024-09-16 19:07:39 +03:00
parent 0c638026e3
commit 30a1872fa5
11 changed files with 55 additions and 0 deletions

View File

@ -69,6 +69,14 @@ Browser::Browser(
}
);
const auto ACTION__TAB_PIN = add_action(
"tab_pin",
[this]
{
browserMain->tab_pin();
}
);
const auto ACTION__TAB_CLOSE = add_action(
"tab_close",
[this]
@ -177,6 +185,7 @@ Browser::Browser(
ACTION__SESSION_RESTORE,
ACTION__SESSION_SAVE,
ACTION__TAB_APPEND,
ACTION__TAB_PIN,
ACTION__TAB_CLOSE,
ACTION__TAB_CLOSE_ALL,
ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK,
@ -218,6 +227,11 @@ Browser::Browser(
"<Primary>t"
);
APP->set_accel_for_action(
"win.tab_pin",
"<Primary>p"
);
APP->set_accel_for_action(
"win.tab_close",
"<Primary>Escape"

View File

@ -12,6 +12,7 @@ Header::Header(
const Glib::RefPtr<Gio::SimpleAction> & ACTION__SESSION_RESTORE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__SESSION_SAVE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_APPEND,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PIN,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE_ALL,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK,
@ -31,6 +32,7 @@ Header::Header(
ACTION__SESSION_RESTORE,
ACTION__SESSION_SAVE,
ACTION__TAB_APPEND,
ACTION__TAB_PIN,
ACTION__TAB_CLOSE,
ACTION__TAB_CLOSE_ALL,
ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK,

View File

@ -35,6 +35,7 @@ namespace app::browser
const Glib::RefPtr<Gio::SimpleAction> & ACTION__SESSION_RESTORE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__SESSION_SAVE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_APPEND,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PIN,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE_ALL,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK,

View File

@ -9,6 +9,7 @@ Menu::Menu(
const Glib::RefPtr<Gio::SimpleAction> & ACTION__SESSION_RESTORE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__SESSION_SAVE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_APPEND,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PIN,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE_ALL,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK,
@ -60,6 +61,13 @@ Menu::Menu(
)
);
MENU__TAB->append(
_("Pin"),
get_action_detailed_name(
ACTION__TAB_PIN
)
);
const auto MENU__TAB_PAGE = Gio::Menu::create();
const auto MENU__TAB_PAGE_NAVIGATION = Gio::Menu::create();

View File

@ -24,6 +24,7 @@ namespace app::browser::header
const Glib::RefPtr<Gio::SimpleAction> & ACTION__SESSION_RESTORE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__SESSION_SAVE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_APPEND,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PIN,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE_ALL,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK,

View File

@ -114,6 +114,13 @@ void Main::tab_append()
);
};
void Main::tab_pin()
{
mainTab->pin(
mainTab->get_current_page()
);
};
void Main::tab_close()
{
mainTab->close(

View File

@ -85,6 +85,7 @@ namespace app::browser
// Actions
void tab_append();
void tab_pin();
void tab_close_all();
void tab_close_left();

View File

@ -205,6 +205,14 @@ int Tab::append(
return PAGE_NUMBER;
};
void Tab::pin(
const int & PAGE_NUMBER
) {
get_tabLabel(
PAGE_NUMBER
)->pin();
}
void Tab::close(
const int & PAGE_NUMBER
) {

View File

@ -98,6 +98,10 @@ namespace app::browser::main
const bool & IS_CURRENT
);
void pin(
const int & PAGE_NUMBER
);
void close(
const int & PAGE_NUMBER
);

View File

@ -177,6 +177,13 @@ void Label::pin(
}
}
void Label::pin()
{
pin(
!is_pinned
);
}
void Label::update(
const Glib::ustring & TEXT
) {

View File

@ -95,6 +95,8 @@ namespace app::browser::main::tab
const bool & IS_PINNED
);
void pin();
void update(
const Glib::ustring & TEXT
);