Browse Source

make submenus build by separated class methods

CPP-GTK4
yggverse 3 months ago
parent
commit
f43d1ef725
  1. 164
      src/app/browser/header/menu.cpp
  2. 35
      src/app/browser/header/menu.hpp

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

@ -4,114 +4,156 @@ using namespace app::browser::header;
Menu::Menu() Menu::Menu()
{ {
// Set widget defaults
set_tooltip_text( set_tooltip_text(
_("Menu") _("Menu")
); );
// Build tab submenu model set_menu_model(
main_tab = Gio::Menu::create(); main(
main_tab(
main_tab_page(
main_tab_page_navigation(
main_tab_page_navigation_history()
)
),
main_tab_close()
),
main_tools()
)
);
}
main_tab->append( Glib::RefPtr<Gio::Menu> Menu::main(
_("New tab.."), Glib::RefPtr<Gio::Menu> main_tab,
"win.main_tab_append" Glib::RefPtr<Gio::Menu> main_tools
) {
auto model = Gio::Menu::create();
model->append_submenu(
_("Tab"),
main_tab
);
model->append_submenu(
_("Tools"),
main_tools
); );
// Build tab page submenu model model->append(
main_tab_page = Gio::Menu::create(); _("Quit"),
"app.quit"
);
// Build tab page navigation submenu model return model;
main_tab_page_navigation = Gio::Menu::create(); }
// Build tab page navigation history submenu model Glib::RefPtr<Gio::Menu> Menu::main_tab(
main_tab_page_navigation_history = Gio::Menu::create(); Glib::RefPtr<Gio::Menu> main_tab_page,
Glib::RefPtr<Gio::Menu> main_tab_close
) {
auto model = Gio::Menu::create();
main_tab_page_navigation_history->append( model->append(
_("Back"), _("New.."),
"win.main_tab_page_navigation_history_try_back" "win.main_tab_append"
); );
main_tab_page_navigation_history->append( model->append_submenu(
_("Forward"), _("Page"),
"win.main_tab_page_navigation_history_try_forward" main_tab_page
);
model->append_submenu(
_("Close"),
main_tab_close
);
return model;
}
Glib::RefPtr<Gio::Menu> Menu::main_tab_page(
Glib::RefPtr<Gio::Menu> main_tab_page_navigation
) {
auto model = Gio::Menu::create();
model->append_submenu(
_("Navigation"),
main_tab_page_navigation
); );
main_tab_page_navigation->append_submenu( return model;
}
Glib::RefPtr<Gio::Menu> Menu::main_tab_page_navigation(
Glib::RefPtr<Gio::Menu> main_tab_page_navigation_history
) {
auto model = Gio::Menu::create();
model->append_submenu(
_("History"), _("History"),
main_tab_page_navigation_history main_tab_page_navigation_history
); );
main_tab_page_navigation->append( model->append(
_("Update"), _("Update"),
"win.main_tab_page_update" "win.main_tab_page_update"
); );
main_tab_page->append_submenu( return model;
_("Navigation"), }
main_tab_page_navigation
Glib::RefPtr<Gio::Menu> Menu::main_tab_page_navigation_history()
{
auto model = Gio::Menu::create();
model->append(
_("Back"),
"win.main_tab_page_navigation_history_try_back"
); );
main_tab->append_submenu( model->append(
_("Page"), _("Forward"),
main_tab_page "win.main_tab_page_navigation_history_try_forward"
); );
// Build tab close submenu model return model;
main_tab_close = Gio::Menu::create(); }
main_tab_close->append( Glib::RefPtr<Gio::Menu> Menu::main_tab_close()
{
auto model = Gio::Menu::create();
model->append(
_("Active tab"), _("Active tab"),
"win.main_tab_close" "win.main_tab_close"
); );
main_tab_close->append( model->append(
_("All tabs to left"), _("All tabs to left"),
"win.main_tab_close_left" "win.main_tab_close_left"
); );
main_tab_close->append( model->append(
_("All tabs to right"), _("All tabs to right"),
"win.main_tab_close_right" "win.main_tab_close_right"
); );
main_tab_close->append( model->append(
_("All tabs"), _("All tabs"),
"win.main_tab_close_all" "win.main_tab_close_all"
); );
main_tab->append_submenu( return model;
_("Close"), }
main_tab_close
);
// Build tools submenu model Glib::RefPtr<Gio::Menu> Menu::main_tools()
main_tools = Gio::Menu::create(); {
auto model = Gio::Menu::create();
main_tools->append( model->append(
_("Debug"), _("Debug"),
"win.debug" "win.debug"
); );
// Build main menu model return model;
main = Gio::Menu::create();
main->append_submenu(
_("Tab"),
main_tab
);
main->append_submenu(
_("Tools"),
main_tools
);
main->append(
_("Quit"),
"app.quit"
);
// Apply model
set_menu_model(
main
);
} }

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

@ -9,13 +9,34 @@ namespace app::browser::header
{ {
class Menu : public Gtk::MenuButton class Menu : public Gtk::MenuButton
{ {
Glib::RefPtr<Gio::Menu> main, // 1 level
main_tab, Glib::RefPtr<Gio::Menu> main(
main_tab_page, Glib::RefPtr<Gio::Menu> main_tab,
main_tab_page_navigation, Glib::RefPtr<Gio::Menu> main_tools
main_tab_page_navigation_history, );
main_tab_close,
main_tools; // 2 level
Glib::RefPtr<Gio::Menu> main_tab(
Glib::RefPtr<Gio::Menu> main_tab_page,
Glib::RefPtr<Gio::Menu> main_tab_close
);
// 3 level
Glib::RefPtr<Gio::Menu> main_tab_page(
Glib::RefPtr<Gio::Menu> main_tab_page_navigation
);
// 4 level
Glib::RefPtr<Gio::Menu> main_tab_page_navigation(
Glib::RefPtr<Gio::Menu> main_tab_page_navigation_history
);
// 5 level
Glib::RefPtr<Gio::Menu> main_tab_page_navigation_history();
Glib::RefPtr<Gio::Menu> main_tab_close();
Glib::RefPtr<Gio::Menu> main_tools();
public: public:

Loading…
Cancel
Save