From 37f109bec4f92ae1422f43b194bf1d48bab4db99 Mon Sep 17 00:00:00 2001 From: yggverse Date: Tue, 6 Aug 2024 03:38:21 +0300 Subject: [PATCH] implement popover menu --- src/app/browser/header/bar/menu/main.cpp | 25 ++++++++++++++++++++++-- src/app/browser/header/bar/menu/main.h | 13 ++++++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/app/browser/header/bar/menu/main.cpp b/src/app/browser/header/bar/menu/main.cpp index 7311dbde..610e4019 100644 --- a/src/app/browser/header/bar/menu/main.cpp +++ b/src/app/browser/header/bar/menu/main.cpp @@ -9,7 +9,28 @@ namespace app::browser::header::bar::menu // Init dependencies this->menu = menu; - // Init GTK - this->gtk = gtk_popover_new(); + // Init GMenu Model + this->_model = g_menu_new(); + + // Init menu items + this->quit = new main::Quit( + this + ); + + g_menu_append_item( + G_MENU( + this->_model + ), + G_MENU_ITEM( + this->quit->item + ) + ); + + // Create a new GtkPopoverMenu from the GMenuModel + this->gtk = gtk_popover_menu_new_from_model( + G_MENU_MODEL( + this->_model + ) + ); } } diff --git a/src/app/browser/header/bar/menu/main.h b/src/app/browser/header/bar/menu/main.h index 378f91b3..b91f5d22 100644 --- a/src/app/browser/header/bar/menu/main.h +++ b/src/app/browser/header/bar/menu/main.h @@ -5,7 +5,7 @@ #include "../menu.h" // Requirements -// .. +#include "main/quit.h" namespace app::browser::header::bar { @@ -13,8 +13,17 @@ namespace app::browser::header::bar namespace menu { + namespace main + { + class Quit; + }; + class Main { + private: + + GMenu* _model; + public: // GTK @@ -24,7 +33,7 @@ namespace app::browser::header::bar Menu *menu; // Requirements - // .. + main::Quit *quit; // Constructor Main(