diff --git a/Makefile b/Makefile index 5b866dd2..6421b15b 100644 --- a/Makefile +++ b/Makefile @@ -6,8 +6,8 @@ LDFLAGS = `pkg-config --libs gtk4` # Define target executable and source files TARGET = bin/Yoda SRCS = src/main.cpp\ - src/Yoda/Browser.cpp\ - src/Yoda/Browser/Header.cpp + src/app/browser.cpp\ + src/app/browser/header.cpp OBJS = $(SRCS:.cpp=.o) diff --git a/src/Yoda/Browser.cpp b/src/Yoda/Browser.cpp deleted file mode 100644 index cb139cba..00000000 --- a/src/Yoda/Browser.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "Browser.h" - -Yoda::Browser::Browser( - GtkApplication *application -) { - this->gtk = gtk_application_window_new( - GTK_APPLICATION( - application - ) - ); - - gtk_window_set_default_size( - GTK_WINDOW( - this->gtk - ), - Browser::WIDTH, - Browser::HEIGHT - ); - - gtk_window_set_titlebar( - GTK_WINDOW( - this->gtk - ), - (new YodaBrowser::Header())->gtk - ); - - gtk_widget_show( - GTK_WIDGET( - this->gtk - ) - ); -} \ No newline at end of file diff --git a/src/Yoda/Browser/Header.cpp b/src/Yoda/Browser/Header.cpp deleted file mode 100644 index ccb2a137..00000000 --- a/src/Yoda/Browser/Header.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "Header.h" - -YodaBrowser::Header::Header() -{ - // Init GTK - this->gtk = gtk_header_bar_new(); - - gtk_header_bar_set_show_title_buttons( - GTK_HEADER_BAR( - this->gtk - ), - Header::SHOW_TITLE_BUTTONS - ); - - gtk_widget_show( - GTK_WIDGET( - this->gtk - ) - ); -} \ No newline at end of file diff --git a/src/Yoda/Browser/Header.h b/src/Yoda/Browser/Header.h deleted file mode 100644 index 1f50e6fb..00000000 --- a/src/Yoda/Browser/Header.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef YODA_BROWSER_HEADER_H -#define YODA_BROWSER_HEADER_H - -// Dependencies -#include "../Browser.h" - -namespace YodaBrowser -{ - class Header - { - public: - - GtkWidget *gtk; - - const gboolean SHOW_TITLE_BUTTONS = true; - - Header(); - }; -}; - -#endif \ No newline at end of file diff --git a/src/app/browser.cpp b/src/app/browser.cpp new file mode 100644 index 00000000..c93e4391 --- /dev/null +++ b/src/app/browser.cpp @@ -0,0 +1,43 @@ +#include "browser.h" + +namespace app +{ + // Construct + Browser::Browser( + GtkApplication *application + ) { + // Init GTK + this->gtk = gtk_application_window_new( + GTK_APPLICATION( + application + ) + ); + + gtk_window_set_default_size( + GTK_WINDOW( + this->gtk + ), + Browser::WIDTH, + Browser::HEIGHT + ); + + // Init requirements + this->header = new browser::Header( + this + ); + + gtk_window_set_titlebar( + GTK_WINDOW( + this->gtk + ), + this->header->gtk + ); + + // Render + gtk_widget_show( + GTK_WIDGET( + this->gtk + ) + ); + } +} diff --git a/src/Yoda/Browser.h b/src/app/browser.h similarity index 53% rename from src/Yoda/Browser.h rename to src/app/browser.h index 101872bb..adaa1245 100644 --- a/src/Yoda/Browser.h +++ b/src/app/browser.h @@ -1,23 +1,33 @@ -#ifndef YODA_BROWSER_H -#define YODA_BROWSER_H +#ifndef APP_BROWSER_H +#define APP_BROWSER_H // Dependencies #include "../main.h" // Requirements -#include "Browser/Header.h" +#include "browser/header.h" -namespace Yoda +namespace app { + namespace browser + { + class Header; + } + class Browser { public: + // GTK GtkWidget *gtk; + // Defaults const guint WIDTH = 640; const guint HEIGHT = 480; + // Requirements + browser::Header *header; + Browser( GtkApplication *application ); diff --git a/src/app/browser/header.cpp b/src/app/browser/header.cpp new file mode 100644 index 00000000..4bbf8504 --- /dev/null +++ b/src/app/browser/header.cpp @@ -0,0 +1,28 @@ +#include "header.h" + +namespace app +{ + namespace browser + { + // Construct + Header::Header( + Browser *browser + ) { + // Init GTK + this->gtk = gtk_header_bar_new(); + + gtk_header_bar_set_show_title_buttons( + GTK_HEADER_BAR( + this->gtk + ), + Header::SHOW_TITLE_BUTTONS + ); + + gtk_widget_show( + GTK_WIDGET( + this->gtk + ) + ); + } + } +} diff --git a/src/app/browser/header.h b/src/app/browser/header.h new file mode 100644 index 00000000..36df7803 --- /dev/null +++ b/src/app/browser/header.h @@ -0,0 +1,27 @@ +#ifndef APP_BROWSER_HEADER_H +#define APP_BROWSER_HEADER_H + +#include "../browser.h" + +namespace app +{ + class Browser; + + namespace browser + { + class Header + { + public: + + GtkWidget *gtk; + + const gboolean SHOW_TITLE_BUTTONS = true; + + Header( + Browser *browser + ); + }; + }; +}; + +#endif \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 4dcbc9a9..f9a9d15f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,7 +4,7 @@ void activate( GtkApplication *application ) { // Init default component - new Yoda::Browser( + new app::Browser( application ); } diff --git a/src/main.h b/src/main.h index 89af56cd..9616cf5e 100644 --- a/src/main.h +++ b/src/main.h @@ -1,7 +1,7 @@ #include #include -#include "Yoda/Browser.h" +#include "app/browser.h" void static activate( GtkApplication *application