Browse Source

update header menu namespace

CPP-GTK4
yggverse 4 months ago
parent
commit
3fe3468696
  1. 9
      Makefile
  2. 10
      src/app/browser/header.cpp
  3. 6
      src/app/browser/header.h
  4. 45
      src/app/browser/header/bar.cpp
  5. 44
      src/app/browser/header/bar.h
  6. 6
      src/app/browser/header/menu.cpp
  7. 18
      src/app/browser/header/menu.h
  8. 2
      src/app/browser/header/menu/main.cpp
  9. 6
      src/app/browser/header/menu/main.h
  10. 6
      src/app/browser/header/menu/main/debug.cpp
  11. 8
      src/app/browser/header/menu/main/debug.h
  12. 8
      src/app/browser/header/menu/main/quit.cpp
  13. 8
      src/app/browser/header/menu/main/quit.h

9
Makefile

@ -12,11 +12,10 @@ SRCS = src/main.cpp\
src/app/browser/container/tab.cpp\ src/app/browser/container/tab.cpp\
src/app/browser/header.cpp\ src/app/browser/header.cpp\
src/app/browser/header/tab.cpp\ src/app/browser/header/tab.cpp\
src/app/browser/header/bar.cpp\ src/app/browser/header/menu.cpp\
src/app/browser/header/bar/menu.cpp\ src/app/browser/header/menu/main.cpp\
src/app/browser/header/bar/menu/main.cpp\ src/app/browser/header/menu/main/debug.cpp\
src/app/browser/header/bar/menu/main/debug.cpp\ src/app/browser/header/menu/main/quit.cpp
src/app/browser/header/bar/menu/main/quit.cpp
OBJS = $(SRCS:.cpp=.o) OBJS = $(SRCS:.cpp=.o)

10
src/app/browser/header.cpp

@ -21,15 +21,19 @@ namespace app
Header::SHOW_TITLE_BUTTONS Header::SHOW_TITLE_BUTTONS
); );
// Init title widget // Init menu element
this->menu = new header::Menu(
this
);
gtk_header_bar_pack_start( gtk_header_bar_pack_start(
GTK_HEADER_BAR( GTK_HEADER_BAR(
this->gtk this->gtk
), ),
(new header::Bar(this))->gtk // @TODO this->menu->gtk
); );
// Init new tab button // Init new tab element
this->tab = new header::Tab( this->tab = new header::Tab(
this this
); );

6
src/app/browser/header.h

@ -5,7 +5,7 @@
#include "../browser.h" #include "../browser.h"
// Requirements // Requirements
#include "header/bar.h" #include "header/menu.h"
#include "header/tab.h" #include "header/tab.h"
namespace app namespace app
@ -16,7 +16,7 @@ namespace app
{ {
namespace header namespace header
{ {
class Bar; class Menu;
class Tab; class Tab;
} }
@ -34,7 +34,7 @@ namespace app
Browser *browser; Browser *browser;
// Requirements // Requirements
header::Bar *bar; header::Menu *menu;
header::Tab *tab; header::Tab *tab;
Header( Header(

45
src/app/browser/header/bar.cpp

@ -1,45 +0,0 @@
#include "bar.h"
namespace app
{
namespace browser
{
namespace header
{
// Construct
Bar::Bar(
Header *header
) {
// Init dependencies
this->header = header;
// Init GTK
this->gtk = gtk_box_new(
GTK_ORIENTATION_HORIZONTAL,
Bar::SPACING
);
// Init menu
this->menu = new bar::Menu(
this
);
gtk_box_append(
GTK_BOX(
this->gtk
),
GTK_WIDGET(
this->menu->gtk
)
);
// Render
gtk_widget_show(
GTK_WIDGET(
this->gtk
)
);
}
}
}
}

44
src/app/browser/header/bar.h

@ -1,44 +0,0 @@
#ifndef APP_BROWSER_HEADER_BAR_H
#define APP_BROWSER_HEADER_BAR_H
// Dependencies
#include "../header.h"
// Requirements
#include "bar/menu.h"
namespace app::browser
{
class Header;
namespace header
{
namespace bar
{
class Menu;
};
class Bar
{
public:
// GTK
GtkWidget *gtk;
// Defaults
const gint SPACING = 0;
// Dependencies
Header *header;
// Requirements
bar::Menu *menu;
Bar(
Header *header
);
};
};
};
#endif

6
src/app/browser/header/bar/menu.cpp → src/app/browser/header/menu.cpp

@ -1,13 +1,13 @@
#include "menu.h" #include "menu.h"
namespace app::browser::header::bar namespace app::browser::header
{ {
// Construct // Construct
Menu::Menu( Menu::Menu(
Bar *bar Header *header
) { ) {
// Init dependencies // Init dependencies
this->bar = bar; this->header = header;
// Init GTK // Init GTK
this->gtk = gtk_menu_button_new(); this->gtk = gtk_menu_button_new();

18
src/app/browser/header/bar/menu.h → src/app/browser/header/menu.h

@ -1,22 +1,22 @@
#ifndef APP_BROWSER_HEADER_BAR_MENU_H #ifndef APP_BROWSER_HEADER_MENU_H
#define APP_BROWSER_HEADER_BAR_MENU_H #define APP_BROWSER_HEADER_MENU_H
// Dependencies // Dependencies
#include "../bar.h" #include "../header.h"
// Requirements // Requirements
#include "menu/main.h" #include "menu/main.h"
namespace app::browser::header namespace app::browser
{ {
class Bar; class Header;
namespace bar namespace header
{ {
namespace menu namespace menu
{ {
class Main; class Main;
}; }
class Menu class Menu
{ {
@ -26,14 +26,14 @@ namespace app::browser::header
GtkWidget *gtk; GtkWidget *gtk;
// Dependencies // Dependencies
Bar *bar; Header *header;
// Requirements // Requirements
menu::Main *main; menu::Main *main;
// Constructor // Constructor
Menu( Menu(
Bar *bar Header *header
); );
}; };
}; };

2
src/app/browser/header/bar/menu/main.cpp → src/app/browser/header/menu/main.cpp

@ -1,6 +1,6 @@
#include "main.h" #include "main.h"
namespace app::browser::header::bar::menu namespace app::browser::header::menu
{ {
// Construct // Construct
Main::Main( Main::Main(

6
src/app/browser/header/bar/menu/main.h → src/app/browser/header/menu/main.h

@ -1,5 +1,5 @@
#ifndef APP_BROWSER_HEADER_BAR_MENU_MAIN_H #ifndef APP_BROWSER_HEADER_MENU_MAIN_H
#define APP_BROWSER_HEADER_BAR_MENU_MAIN_H #define APP_BROWSER_HEADER_MENU_MAIN_H
// Dependencies // Dependencies
#include "../menu.h" #include "../menu.h"
@ -8,7 +8,7 @@
#include "main/debug.h" #include "main/debug.h"
#include "main/quit.h" #include "main/quit.h"
namespace app::browser::header::bar namespace app::browser::header
{ {
class Menu; class Menu;

6
src/app/browser/header/bar/menu/main/debug.cpp → src/app/browser/header/menu/main/debug.cpp

@ -1,6 +1,6 @@
#include "debug.h" #include "debug.h"
namespace app::browser::header::bar::menu::main namespace app::browser::header::menu::main
{ {
// Construct // Construct
Debug::Debug( Debug::Debug(
@ -17,7 +17,7 @@ namespace app::browser::header::bar::menu::main
g_action_map_add_action( g_action_map_add_action(
G_ACTION_MAP( G_ACTION_MAP(
this->main->menu->bar->header->browser->app this->main->menu->header->browser->app
), ),
G_ACTION( G_ACTION(
this->action this->action
@ -46,7 +46,7 @@ namespace app::browser::header::bar::menu::main
gtk_application_set_accels_for_action( gtk_application_set_accels_for_action(
GTK_APPLICATION( GTK_APPLICATION(
this->main->menu->bar->header->browser->app this->main->menu->header->browser->app
), ),
action, action,
accels accels

8
src/app/browser/header/bar/menu/main/debug.h → src/app/browser/header/menu/main/debug.h

@ -1,9 +1,9 @@
#ifndef APP_BROWSER_HEADER_BAR_MENU_DEBUG_H #ifndef APP_BROWSER_HEADER_MENU_MAIN_DEBUG_H
#define APP_BROWSER_HEADER_BAR_MENU_DEBUG_H #define APP_BROWSER_HEADER_MENU_MAIN_DEBUG_H
#include "../main.h" #include "../main.h"
namespace app::browser::header::bar::menu namespace app::browser::header::menu
{ {
class Main; class Main;
@ -28,7 +28,7 @@ namespace app::browser::header::bar::menu
const gchar *ACCEL_2 = "<Control><Shift>I"; const gchar *ACCEL_2 = "<Control><Shift>I";
const gchar *ACTION_NS = "app.%s"; const gchar *ACTION_NS = "app.%s";
const gchar *ACTION_ID = "browser.header.bar.menu.main.debug.activate"; const gchar *ACTION_ID = "browser.header.menu.main.debug.activate";
// Construct // Construct
Debug( Debug(

8
src/app/browser/header/bar/menu/main/quit.cpp → src/app/browser/header/menu/main/quit.cpp

@ -1,6 +1,6 @@
#include "quit.h" #include "quit.h"
namespace app::browser::header::bar::menu::main namespace app::browser::header::menu::main
{ {
// Construct // Construct
Quit::Quit( Quit::Quit(
@ -17,7 +17,7 @@ namespace app::browser::header::bar::menu::main
g_action_map_add_action( g_action_map_add_action(
G_ACTION_MAP( G_ACTION_MAP(
this->main->menu->bar->header->browser->app this->main->menu->header->browser->app
), ),
G_ACTION( G_ACTION(
this->action this->action
@ -46,7 +46,7 @@ namespace app::browser::header::bar::menu::main
gtk_application_set_accels_for_action( gtk_application_set_accels_for_action(
GTK_APPLICATION( GTK_APPLICATION(
this->main->menu->bar->header->browser->app this->main->menu->header->browser->app
), ),
action, action,
accels accels
@ -68,7 +68,7 @@ namespace app::browser::header::bar::menu::main
Quit::_activate Quit::_activate
), ),
G_APPLICATION( G_APPLICATION(
this->main->menu->bar->header->browser->app this->main->menu->header->browser->app
) )
); );
} }

8
src/app/browser/header/bar/menu/main/quit.h → src/app/browser/header/menu/main/quit.h

@ -1,9 +1,9 @@
#ifndef APP_BROWSER_HEADER_BAR_MENU_QUIT_H #ifndef APP_BROWSER_HEADER_MENU_MAIN_QUIT_H
#define APP_BROWSER_HEADER_BAR_MENU_QUIT_H #define APP_BROWSER_HEADER_MENU_MAIN_QUIT_H
#include "../main.h" #include "../main.h"
namespace app::browser::header::bar::menu namespace app::browser::header::menu
{ {
class Main; class Main;
@ -28,7 +28,7 @@ namespace app::browser::header::bar::menu
const gchar *ACCEL_2 = "<Control>Q"; const gchar *ACCEL_2 = "<Control>Q";
const gchar *ACTION_NS = "app.%s"; const gchar *ACTION_NS = "app.%s";
const gchar *ACTION_ID = "browser.header.bar.menu.main.quit.activate"; const gchar *ACTION_ID = "browser.header.menu.main.quit.activate";
// Construct // Construct
Quit( Quit(
Loading…
Cancel
Save