From 494964e64af0f5089a242349a85ac670a6728566 Mon Sep 17 00:00:00 2001 From: yggverse Date: Tue, 6 Aug 2024 23:47:08 +0300 Subject: [PATCH] init tab submenu --- Makefile | 1 + src/app/browser/header/menu/main.cpp | 23 +++++++++++--- src/app/browser/header/menu/main.h | 10 ++++--- src/app/browser/header/menu/main/tab.cpp | 22 ++++++++++++++ src/app/browser/header/menu/main/tab.h | 38 ++++++++++++++++++++++++ 5 files changed, 86 insertions(+), 8 deletions(-) create mode 100644 src/app/browser/header/menu/main/tab.cpp create mode 100644 src/app/browser/header/menu/main/tab.h diff --git a/Makefile b/Makefile index fa60c1d0..b0b74614 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,7 @@ SRCS = src/main.cpp\ src/app/browser/header/tab.cpp\ src/app/browser/header/menu.cpp\ src/app/browser/header/menu/main.cpp\ + src/app/browser/header/menu/main/tab.cpp\ src/app/browser/header/menu/main/debug.cpp\ src/app/browser/header/menu/main/quit.cpp diff --git a/src/app/browser/header/menu/main.cpp b/src/app/browser/header/menu/main.cpp index c14a15e8..c890b608 100644 --- a/src/app/browser/header/menu/main.cpp +++ b/src/app/browser/header/menu/main.cpp @@ -10,7 +10,22 @@ namespace app::browser::header::menu this->menu = menu; // Init model - this->_model = g_menu_new(); + this->model = g_menu_new(); + + // Init tab submenu + this->tab = new main::Tab( + this + ); + + g_menu_append_submenu( + G_MENU( + this->model + ), + this->tab->LABEL, + G_MENU_MODEL( + this->tab->model + ) + ); // Init debug menu this->debug = new main::Debug( @@ -19,7 +34,7 @@ namespace app::browser::header::menu g_menu_append_item( G_MENU( - this->_model + this->model ), G_MENU_ITEM( this->debug->item @@ -33,7 +48,7 @@ namespace app::browser::header::menu g_menu_append_item( G_MENU( - this->_model + this->model ), G_MENU_ITEM( this->quit->item @@ -43,7 +58,7 @@ namespace app::browser::header::menu // Create a new GtkPopoverMenu from the GMenuModel this->gtk = gtk_popover_menu_new_from_model( G_MENU_MODEL( - this->_model + this->model ) ); } diff --git a/src/app/browser/header/menu/main.h b/src/app/browser/header/menu/main.h index c6ccfb6f..bf8f65cd 100644 --- a/src/app/browser/header/menu/main.h +++ b/src/app/browser/header/menu/main.h @@ -5,6 +5,7 @@ #include "../menu.h" // Requirements +#include "main/tab.h" #include "main/debug.h" #include "main/quit.h" @@ -16,25 +17,26 @@ namespace app::browser::header { namespace main { + class Tab; class Debug; class Quit; }; class Main { - private: - - GMenu* _model; - public: // GTK GtkWidget *gtk; + // Gio + GMenu* model; + // Dependencies Menu *menu; // Requirements + main::Tab *tab; main::Debug *debug; main::Quit *quit; diff --git a/src/app/browser/header/menu/main/tab.cpp b/src/app/browser/header/menu/main/tab.cpp new file mode 100644 index 00000000..27a27240 --- /dev/null +++ b/src/app/browser/header/menu/main/tab.cpp @@ -0,0 +1,22 @@ +#include "tab.h" + +namespace app::browser::header::menu::main +{ + // Construct + Tab::Tab( + Main *main + ) { + // Init dependencies + this->main = main; + + // Init model + this->model = g_menu_new(); + + // Init menu + this->gtk = gtk_popover_menu_new_from_model( + G_MENU_MODEL( + this->model + ) + ); + } +} diff --git a/src/app/browser/header/menu/main/tab.h b/src/app/browser/header/menu/main/tab.h new file mode 100644 index 00000000..278ea626 --- /dev/null +++ b/src/app/browser/header/menu/main/tab.h @@ -0,0 +1,38 @@ +#ifndef APP_BROWSER_HEADER_MENU_MAIN_TAB_H +#define APP_BROWSER_HEADER_MENU_MAIN_TAB_H + +#include "../main.h" + +namespace app::browser::header::menu +{ + class Main; + + namespace main + { + class Tab + { + public: + + // GTK + GtkWidget *gtk; + + // Gio + GMenu* model; + + GMenuItem *item; + + // Dependencies + Main *main; + + // Defaults + const gchar *LABEL = "Tab"; + + // Construct + Tab( + Main *main + ); + }; + }; +}; + +#endif \ No newline at end of file