init tab submenu

This commit is contained in:
yggverse 2024-08-06 23:47:08 +03:00
parent c9306bb4cd
commit 494964e64a
5 changed files with 86 additions and 8 deletions

View File

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

View File

@ -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
)
);
}

View File

@ -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;

View File

@ -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
)
);
}
}

View File

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