Browse Source

implement pin tab menu item

CPP-GTK4
yggverse 2 months ago
parent
commit
30a1872fa5
  1. 14
      src/app/browser.cpp
  2. 2
      src/app/browser/header.cpp
  3. 1
      src/app/browser/header.hpp
  4. 8
      src/app/browser/header/menu.cpp
  5. 1
      src/app/browser/header/menu.hpp
  6. 7
      src/app/browser/main.cpp
  7. 1
      src/app/browser/main.hpp
  8. 8
      src/app/browser/main/tab.cpp
  9. 4
      src/app/browser/main/tab.hpp
  10. 7
      src/app/browser/main/tab/label.cpp
  11. 2
      src/app/browser/main/tab/label.hpp

14
src/app/browser.cpp

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

2
src/app/browser/header.cpp

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

1
src/app/browser/header.hpp

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

8
src/app/browser/header/menu.cpp

@ -9,6 +9,7 @@ Menu::Menu(
const Glib::RefPtr<Gio::SimpleAction> & ACTION__SESSION_RESTORE, const Glib::RefPtr<Gio::SimpleAction> & ACTION__SESSION_RESTORE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__SESSION_SAVE, const Glib::RefPtr<Gio::SimpleAction> & ACTION__SESSION_SAVE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_APPEND, 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,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE_ALL, const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE_ALL,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK, 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 = Gio::Menu::create();
const auto MENU__TAB_PAGE_NAVIGATION = Gio::Menu::create(); const auto MENU__TAB_PAGE_NAVIGATION = Gio::Menu::create();

1
src/app/browser/header/menu.hpp

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

7
src/app/browser/main.cpp

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

1
src/app/browser/main.hpp

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

8
src/app/browser/main/tab.cpp

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

4
src/app/browser/main/tab.hpp

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

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

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

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

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

Loading…
Cancel
Save