Browse Source

init tab submenu

CPP-GTK4
yggverse 4 months ago
parent
commit
494964e64a
  1. 1
      Makefile
  2. 23
      src/app/browser/header/menu/main.cpp
  3. 10
      src/app/browser/header/menu/main.h
  4. 22
      src/app/browser/header/menu/main/tab.cpp
  5. 38
      src/app/browser/header/menu/main/tab.h

1
Makefile

@ -14,6 +14,7 @@ SRCS = src/main.cpp\
src/app/browser/header/tab.cpp\ src/app/browser/header/tab.cpp\
src/app/browser/header/menu.cpp\ src/app/browser/header/menu.cpp\
src/app/browser/header/menu/main.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/debug.cpp\
src/app/browser/header/menu/main/quit.cpp src/app/browser/header/menu/main/quit.cpp

23
src/app/browser/header/menu/main.cpp

@ -10,7 +10,22 @@ namespace app::browser::header::menu
this->menu = menu; this->menu = menu;
// Init model // 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 // Init debug menu
this->debug = new main::Debug( this->debug = new main::Debug(
@ -19,7 +34,7 @@ namespace app::browser::header::menu
g_menu_append_item( g_menu_append_item(
G_MENU( G_MENU(
this->_model this->model
), ),
G_MENU_ITEM( G_MENU_ITEM(
this->debug->item this->debug->item
@ -33,7 +48,7 @@ namespace app::browser::header::menu
g_menu_append_item( g_menu_append_item(
G_MENU( G_MENU(
this->_model this->model
), ),
G_MENU_ITEM( G_MENU_ITEM(
this->quit->item this->quit->item
@ -43,7 +58,7 @@ namespace app::browser::header::menu
// Create a new GtkPopoverMenu from the GMenuModel // Create a new GtkPopoverMenu from the GMenuModel
this->gtk = gtk_popover_menu_new_from_model( this->gtk = gtk_popover_menu_new_from_model(
G_MENU_MODEL( G_MENU_MODEL(
this->_model this->model
) )
); );
} }

10
src/app/browser/header/menu/main.h

@ -5,6 +5,7 @@
#include "../menu.h" #include "../menu.h"
// Requirements // Requirements
#include "main/tab.h"
#include "main/debug.h" #include "main/debug.h"
#include "main/quit.h" #include "main/quit.h"
@ -16,25 +17,26 @@ namespace app::browser::header
{ {
namespace main namespace main
{ {
class Tab;
class Debug; class Debug;
class Quit; class Quit;
}; };
class Main class Main
{ {
private:
GMenu* _model;
public: public:
// GTK // GTK
GtkWidget *gtk; GtkWidget *gtk;
// Gio
GMenu* model;
// Dependencies // Dependencies
Menu *menu; Menu *menu;
// Requirements // Requirements
main::Tab *tab;
main::Debug *debug; main::Debug *debug;
main::Quit *quit; main::Quit *quit;

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

38
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
Loading…
Cancel
Save