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( @@ -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( @@ -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( @@ -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"

2
src/app/browser/header.cpp

@ -12,6 +12,7 @@ Header::Header( @@ -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( @@ -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,

1
src/app/browser/header.hpp

@ -35,6 +35,7 @@ namespace app::browser @@ -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,

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

@ -9,6 +9,7 @@ Menu::Menu( @@ -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( @@ -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();

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

@ -24,6 +24,7 @@ namespace app::browser::header @@ -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,

7
src/app/browser/main.cpp

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

1
src/app/browser/main.hpp

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

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

@ -205,6 +205,14 @@ int Tab::append( @@ -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
) {

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

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

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

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

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

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

Loading…
Cancel
Save