From 3fe34686965d029eb13dd19abde8fcc0cdf5af7a Mon Sep 17 00:00:00 2001 From: yggverse Date: Tue, 6 Aug 2024 21:34:52 +0300 Subject: [PATCH] update header menu namespace --- Makefile | 9 ++-- src/app/browser/header.cpp | 10 +++-- src/app/browser/header.h | 6 +-- src/app/browser/header/bar.cpp | 45 ------------------- src/app/browser/header/bar.h | 44 ------------------ src/app/browser/header/{bar => }/menu.cpp | 6 +-- src/app/browser/header/{bar => }/menu.h | 18 ++++---- .../browser/header/{bar => }/menu/main.cpp | 2 +- src/app/browser/header/{bar => }/menu/main.h | 6 +-- .../header/{bar => }/menu/main/debug.cpp | 6 +-- .../header/{bar => }/menu/main/debug.h | 8 ++-- .../header/{bar => }/menu/main/quit.cpp | 8 ++-- .../browser/header/{bar => }/menu/main/quit.h | 8 ++-- 13 files changed, 45 insertions(+), 131 deletions(-) delete mode 100644 src/app/browser/header/bar.cpp delete mode 100644 src/app/browser/header/bar.h rename src/app/browser/header/{bar => }/menu.cpp (87%) rename src/app/browser/header/{bar => }/menu.h (64%) rename src/app/browser/header/{bar => }/menu/main.cpp (95%) rename src/app/browser/header/{bar => }/menu/main.h (84%) rename src/app/browser/header/{bar => }/menu/main/debug.cpp (90%) rename src/app/browser/header/{bar => }/menu/main/debug.h (79%) rename src/app/browser/header/{bar => }/menu/main/quit.cpp (88%) rename src/app/browser/header/{bar => }/menu/main/quit.h (79%) diff --git a/Makefile b/Makefile index f638eaee..fa60c1d0 100644 --- a/Makefile +++ b/Makefile @@ -12,11 +12,10 @@ SRCS = src/main.cpp\ src/app/browser/container/tab.cpp\ src/app/browser/header.cpp\ src/app/browser/header/tab.cpp\ - src/app/browser/header/bar.cpp\ - src/app/browser/header/bar/menu.cpp\ - src/app/browser/header/bar/menu/main.cpp\ - src/app/browser/header/bar/menu/main/debug.cpp\ - src/app/browser/header/bar/menu/main/quit.cpp + src/app/browser/header/menu.cpp\ + src/app/browser/header/menu/main.cpp\ + src/app/browser/header/menu/main/debug.cpp\ + src/app/browser/header/menu/main/quit.cpp OBJS = $(SRCS:.cpp=.o) diff --git a/src/app/browser/header.cpp b/src/app/browser/header.cpp index a4c8e205..1086e04e 100644 --- a/src/app/browser/header.cpp +++ b/src/app/browser/header.cpp @@ -21,15 +21,19 @@ namespace app Header::SHOW_TITLE_BUTTONS ); - // Init title widget + // Init menu element + this->menu = new header::Menu( + this + ); + gtk_header_bar_pack_start( GTK_HEADER_BAR( 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 ); diff --git a/src/app/browser/header.h b/src/app/browser/header.h index 1035a851..0f1877bd 100644 --- a/src/app/browser/header.h +++ b/src/app/browser/header.h @@ -5,7 +5,7 @@ #include "../browser.h" // Requirements -#include "header/bar.h" +#include "header/menu.h" #include "header/tab.h" namespace app @@ -16,7 +16,7 @@ namespace app { namespace header { - class Bar; + class Menu; class Tab; } @@ -34,7 +34,7 @@ namespace app Browser *browser; // Requirements - header::Bar *bar; + header::Menu *menu; header::Tab *tab; Header( diff --git a/src/app/browser/header/bar.cpp b/src/app/browser/header/bar.cpp deleted file mode 100644 index df00de30..00000000 --- a/src/app/browser/header/bar.cpp +++ /dev/null @@ -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 - ) - ); - } - } - } -} diff --git a/src/app/browser/header/bar.h b/src/app/browser/header/bar.h deleted file mode 100644 index bf857e18..00000000 --- a/src/app/browser/header/bar.h +++ /dev/null @@ -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 \ No newline at end of file diff --git a/src/app/browser/header/bar/menu.cpp b/src/app/browser/header/menu.cpp similarity index 87% rename from src/app/browser/header/bar/menu.cpp rename to src/app/browser/header/menu.cpp index e022c573..b4dc88bf 100644 --- a/src/app/browser/header/bar/menu.cpp +++ b/src/app/browser/header/menu.cpp @@ -1,13 +1,13 @@ #include "menu.h" -namespace app::browser::header::bar +namespace app::browser::header { // Construct Menu::Menu( - Bar *bar + Header *header ) { // Init dependencies - this->bar = bar; + this->header = header; // Init GTK this->gtk = gtk_menu_button_new(); diff --git a/src/app/browser/header/bar/menu.h b/src/app/browser/header/menu.h similarity index 64% rename from src/app/browser/header/bar/menu.h rename to src/app/browser/header/menu.h index 38de3794..e47ed1c4 100644 --- a/src/app/browser/header/bar/menu.h +++ b/src/app/browser/header/menu.h @@ -1,22 +1,22 @@ -#ifndef APP_BROWSER_HEADER_BAR_MENU_H -#define APP_BROWSER_HEADER_BAR_MENU_H +#ifndef APP_BROWSER_HEADER_MENU_H +#define APP_BROWSER_HEADER_MENU_H // Dependencies -#include "../bar.h" +#include "../header.h" // Requirements #include "menu/main.h" -namespace app::browser::header +namespace app::browser { - class Bar; + class Header; - namespace bar + namespace header { namespace menu { class Main; - }; + } class Menu { @@ -26,14 +26,14 @@ namespace app::browser::header GtkWidget *gtk; // Dependencies - Bar *bar; + Header *header; // Requirements menu::Main *main; // Constructor Menu( - Bar *bar + Header *header ); }; }; diff --git a/src/app/browser/header/bar/menu/main.cpp b/src/app/browser/header/menu/main.cpp similarity index 95% rename from src/app/browser/header/bar/menu/main.cpp rename to src/app/browser/header/menu/main.cpp index 2eed90bb..c14a15e8 100644 --- a/src/app/browser/header/bar/menu/main.cpp +++ b/src/app/browser/header/menu/main.cpp @@ -1,6 +1,6 @@ #include "main.h" -namespace app::browser::header::bar::menu +namespace app::browser::header::menu { // Construct Main::Main( diff --git a/src/app/browser/header/bar/menu/main.h b/src/app/browser/header/menu/main.h similarity index 84% rename from src/app/browser/header/bar/menu/main.h rename to src/app/browser/header/menu/main.h index fee7f56b..c6ccfb6f 100644 --- a/src/app/browser/header/bar/menu/main.h +++ b/src/app/browser/header/menu/main.h @@ -1,5 +1,5 @@ -#ifndef APP_BROWSER_HEADER_BAR_MENU_MAIN_H -#define APP_BROWSER_HEADER_BAR_MENU_MAIN_H +#ifndef APP_BROWSER_HEADER_MENU_MAIN_H +#define APP_BROWSER_HEADER_MENU_MAIN_H // Dependencies #include "../menu.h" @@ -8,7 +8,7 @@ #include "main/debug.h" #include "main/quit.h" -namespace app::browser::header::bar +namespace app::browser::header { class Menu; diff --git a/src/app/browser/header/bar/menu/main/debug.cpp b/src/app/browser/header/menu/main/debug.cpp similarity index 90% rename from src/app/browser/header/bar/menu/main/debug.cpp rename to src/app/browser/header/menu/main/debug.cpp index 5e2084b6..a702ae62 100644 --- a/src/app/browser/header/bar/menu/main/debug.cpp +++ b/src/app/browser/header/menu/main/debug.cpp @@ -1,6 +1,6 @@ #include "debug.h" -namespace app::browser::header::bar::menu::main +namespace app::browser::header::menu::main { // Construct Debug::Debug( @@ -17,7 +17,7 @@ namespace app::browser::header::bar::menu::main g_action_map_add_action( G_ACTION_MAP( - this->main->menu->bar->header->browser->app + this->main->menu->header->browser->app ), G_ACTION( this->action @@ -46,7 +46,7 @@ namespace app::browser::header::bar::menu::main gtk_application_set_accels_for_action( GTK_APPLICATION( - this->main->menu->bar->header->browser->app + this->main->menu->header->browser->app ), action, accels diff --git a/src/app/browser/header/bar/menu/main/debug.h b/src/app/browser/header/menu/main/debug.h similarity index 79% rename from src/app/browser/header/bar/menu/main/debug.h rename to src/app/browser/header/menu/main/debug.h index bc96a63c..baae27cd 100644 --- a/src/app/browser/header/bar/menu/main/debug.h +++ b/src/app/browser/header/menu/main/debug.h @@ -1,9 +1,9 @@ -#ifndef APP_BROWSER_HEADER_BAR_MENU_DEBUG_H -#define APP_BROWSER_HEADER_BAR_MENU_DEBUG_H +#ifndef APP_BROWSER_HEADER_MENU_MAIN_DEBUG_H +#define APP_BROWSER_HEADER_MENU_MAIN_DEBUG_H #include "../main.h" -namespace app::browser::header::bar::menu +namespace app::browser::header::menu { class Main; @@ -28,7 +28,7 @@ namespace app::browser::header::bar::menu const gchar *ACCEL_2 = "I"; 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 Debug( diff --git a/src/app/browser/header/bar/menu/main/quit.cpp b/src/app/browser/header/menu/main/quit.cpp similarity index 88% rename from src/app/browser/header/bar/menu/main/quit.cpp rename to src/app/browser/header/menu/main/quit.cpp index afa26706..6f452373 100644 --- a/src/app/browser/header/bar/menu/main/quit.cpp +++ b/src/app/browser/header/menu/main/quit.cpp @@ -1,6 +1,6 @@ #include "quit.h" -namespace app::browser::header::bar::menu::main +namespace app::browser::header::menu::main { // Construct Quit::Quit( @@ -17,7 +17,7 @@ namespace app::browser::header::bar::menu::main g_action_map_add_action( G_ACTION_MAP( - this->main->menu->bar->header->browser->app + this->main->menu->header->browser->app ), G_ACTION( this->action @@ -46,7 +46,7 @@ namespace app::browser::header::bar::menu::main gtk_application_set_accels_for_action( GTK_APPLICATION( - this->main->menu->bar->header->browser->app + this->main->menu->header->browser->app ), action, accels @@ -68,7 +68,7 @@ namespace app::browser::header::bar::menu::main Quit::_activate ), G_APPLICATION( - this->main->menu->bar->header->browser->app + this->main->menu->header->browser->app ) ); } diff --git a/src/app/browser/header/bar/menu/main/quit.h b/src/app/browser/header/menu/main/quit.h similarity index 79% rename from src/app/browser/header/bar/menu/main/quit.h rename to src/app/browser/header/menu/main/quit.h index f1b150aa..90fb57be 100644 --- a/src/app/browser/header/bar/menu/main/quit.h +++ b/src/app/browser/header/menu/main/quit.h @@ -1,9 +1,9 @@ -#ifndef APP_BROWSER_HEADER_BAR_MENU_QUIT_H -#define APP_BROWSER_HEADER_BAR_MENU_QUIT_H +#ifndef APP_BROWSER_HEADER_MENU_MAIN_QUIT_H +#define APP_BROWSER_HEADER_MENU_MAIN_QUIT_H #include "../main.h" -namespace app::browser::header::bar::menu +namespace app::browser::header::menu { class Main; @@ -28,7 +28,7 @@ namespace app::browser::header::bar::menu const gchar *ACCEL_2 = "Q"; 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 Quit(