diff --git a/Makefile b/Makefile index 59482c45..f2ab077c 100644 --- a/Makefile +++ b/Makefile @@ -1,23 +1,23 @@ # Define compiler and flags CXX = g++ -CXXFLAGS = `pkg-config --cflags gtk4` -LDFLAGS = `pkg-config --libs gtk4` +CXXFLAGS = `pkg-config --cflags gtkmm-4.0` +LDFLAGS = `pkg-config --libs gtkmm-4.0` # Define target executable and source files TARGET = bin/Yoda -SRCS = src/main.cpp\ - src/app/browser.cpp\ - src/app/browser/container.cpp\ - src/app/browser/container/page.cpp\ - src/app/browser/container/tab.cpp\ - src/app/browser/header.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/tab/append.cpp\ - src/app/browser/header/menu/main/debug.cpp\ - src/app/browser/header/menu/main/quit.cpp +SRCS = src/main.cpp src/app/browser.cpp +# src/app/browser.cpp\ +# src/app/browser/container.cpp\ +# src/app/browser/container/page.cpp\ +# src/app/browser/container/tab.cpp\ +# src/app/browser/header.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/tab/append.cpp\ +# src/app/browser/header/menu/main/debug.cpp\ +# src/app/browser/header/menu/main/quit.cpp OBJS = $(SRCS:.cpp=.o) diff --git a/README.md b/README.md index 8b731bcf..29d34fe4 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ GTK 4 / C++ implementation branch ### Linux -* `sudo apt install git libgtk-4-dev` +* `sudo apt install git libgtkmm-4.0-dev` * `git clone https://github.com/YGGverse/Yoda.git` * `cd Yoda` * `git checkout master` @@ -26,7 +26,7 @@ GTK 4 / C++ implementation branch ### Environment -* `pkg-config --cflags --libs gtk4` +* `pkg-config --cflags --libs gtkmm-4.0` ### Contribution diff --git a/src/app/browser.cpp b/src/app/browser.cpp index d47499d4..b6c57ecf 100644 --- a/src/app/browser.cpp +++ b/src/app/browser.cpp @@ -1,82 +1,15 @@ #include "browser.h" -namespace app -{ - // Construct - Browser::Browser( - GtkApplication *application - ) { - // Init dependencies - this->app = application; - - // Init GTK - this->gtk = gtk_application_window_new( - GTK_APPLICATION( - this->app - ) - ); - - gtk_window_set_default_size( - GTK_WINDOW( - this->gtk - ), - Browser::WIDTH, - Browser::HEIGHT - ); - - // Init header - this->header = new browser::Header( - this - ); - - gtk_window_set_titlebar( - GTK_WINDOW( - this->gtk - ), - GTK_WIDGET( - this->header->gtk - ) - ); +using namespace app; - // Init container - this->container = new browser::Container( - this - ); - - gtk_window_set_child( - GTK_WINDOW( - this->gtk - ), - GTK_WIDGET( - this->container->gtk - ) - ); - - // Render - gtk_widget_show( - GTK_WIDGET( - this->gtk - ) - ); - - // Connect signals - g_signal_connect( - G_APPLICATION( - this->app - ), - "shutdown", - G_CALLBACK( - _shutdown - ), - NULL - ); - } - - // Events - void Browser::_shutdown( - GtkApplication *application - ) { - // @TODO save session, clean cache, etc - g_print("Shutdown..\n"); - } -} +Browser::Browser() +{ + set_title( + TITLE + ); + + set_default_size( + WIDTH, + HEIGHT + ); +} \ No newline at end of file diff --git a/src/app/browser.h b/src/app/browser.h index be0ad693..e42f9d75 100644 --- a/src/app/browser.h +++ b/src/app/browser.h @@ -1,53 +1,32 @@ -#pragma once - #ifndef APP_BROWSER_H #define APP_BROWSER_H -// Dependencies -#include "../main.h" - -// Requirements -#include "browser/header.h" -#include "browser/container.h" +#include +#include +#include namespace app { - namespace browser - { - class Header; - class Container; - } - - class Browser + class Browser : public Gtk::Window { public: - // GTK - GtkWidget *gtk; - - // Dependencies - GtkApplication *app; - - // Requirements - browser::Header *header; - browser::Container *container; - - // Defaults + const char* TITLE = "Basic application"; const guint WIDTH = 640; const guint HEIGHT = 480; - // Constructor - Browser( - GtkApplication *application - ); + Browser(); + + class Header : Gtk::HeaderBar + { + + }; - private: + class Container : Gtk::Notebook + { - // Events - static void _shutdown( - GtkApplication *application - ); + }; }; -}; +} -#endif \ No newline at end of file +#endif // APP_BROWSER_H \ No newline at end of file diff --git a/src/app/browser/container.cpp b/src/app/browser/container.cpp deleted file mode 100644 index 6bffbad2..00000000 --- a/src/app/browser/container.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "container.h" - -namespace app -{ - namespace browser - { - // Construct - Container::Container( - Browser *browser - ) { - // Init GTK - this->gtk = gtk_box_new( - GTK_ORIENTATION_VERTICAL, - Container::SPACING - ); - - // Init tabs component - this->tab = new container::Tab( - this - ); - - gtk_box_append( - GTK_BOX( - this->gtk - ), - GTK_WIDGET( - this->tab->gtk - ) - ); - - // @TODO append testing tab - this->tab->append( - NULL, - false, - true - ); - - // Render - gtk_widget_show( - GTK_WIDGET( - this->gtk - ) - ); - } - } -} diff --git a/src/app/browser/container.h b/src/app/browser/container.h deleted file mode 100644 index bc1a7601..00000000 --- a/src/app/browser/container.h +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once - -#ifndef APP_BROWSER_CONTAINER_H -#define APP_BROWSER_CONTAINER_H - -// Dependencies -#include "../browser.h" - -// Requirements -#include "container/tab.h" - -namespace app -{ - class Browser; - - namespace browser - { - namespace container - { - class Tab; - } - - class Container - { - public: - - // GTK - GtkWidget *gtk; - - // Defaults - const gint SPACING = 0; - - // Requirements - container::Tab *tab; - - Container( - Browser *browser - ); - }; - }; -}; - -#endif \ No newline at end of file diff --git a/src/app/browser/container/page.cpp b/src/app/browser/container/page.cpp deleted file mode 100644 index 02a2c8ab..00000000 --- a/src/app/browser/container/page.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "page.h" - -namespace app -{ - namespace browser - { - namespace container - { - /** - * Construct - */ - Page::Page( - Container *container - ) { - // Init GTK - this->gtk = gtk_box_new( - GTK_ORIENTATION_VERTICAL, - Page::SPACING - ); - - gtk_widget_show( - GTK_WIDGET( - this->gtk - ) - ); - } - - /** - * Init empty page - */ - void Page::init( - char *request, - bool focus - ) { - // @TODO - } - - /** - * Open page request - */ - void Page::open( - char *request, - bool history - ) { - // @TODO - } - } - } -} \ No newline at end of file diff --git a/src/app/browser/container/page.h b/src/app/browser/container/page.h deleted file mode 100644 index db8b486b..00000000 --- a/src/app/browser/container/page.h +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once - -#ifndef APP_BROWSER_CONTAINER_PAGE_H -#define APP_BROWSER_CONTAINER_PAGE_H - -#include "../container.h" - -namespace app -{ - namespace browser - { - class Container; - - namespace container - { - class Page - { - public: - - GtkWidget *gtk; - - const gint SPACING = 0; - - Page( - Container *container - ); - - void init( - char *request, - bool focus - ); - - void open( - char *request, - bool history - ); - }; - }; - }; -}; - -#endif \ No newline at end of file diff --git a/src/app/browser/container/tab.cpp b/src/app/browser/container/tab.cpp deleted file mode 100644 index e19d0f93..00000000 --- a/src/app/browser/container/tab.cpp +++ /dev/null @@ -1,113 +0,0 @@ -#include "tab.h" - -namespace app -{ - namespace browser - { - namespace container - { - /** - * Construct - */ - Tab::Tab( - Container *container - ) { - // Init dependencies - this->container = container; - - // Init GTK - this->gtk = gtk_notebook_new(); - - gtk_notebook_set_scrollable( - GTK_NOTEBOOK( - this->gtk - ), - Tab::SCROLLABLE - ); - - gtk_widget_show( - GTK_WIDGET( - this->gtk - ) - ); - } - - /** - * Append new tab - */ - void Tab::append( - char *request, - bool open = true, - bool focus = true - ) { - - // Init new page - Page *page = new Page( - this->container - ); - - gtk_notebook_append_page( - GTK_NOTEBOOK( - this->gtk - ), - GTK_WIDGET( - page->gtk - ), - NULL // @TODO label - ); - - gtk_notebook_set_tab_reorderable( - GTK_NOTEBOOK( - this->gtk - ), - GTK_WIDGET( - page->gtk - ), - Tab::REORDERABLE - ); - - // Page open requested - if (open) - { - page->open( - request, - false // history - ); - } - - else - { - page->init( - request, - true // focus @TODO boolean empty(request) - ); - } - - // Focus requested - if (focus) - { - gtk_notebook_set_current_page( - GTK_NOTEBOOK( - this->gtk - ), - gtk_notebook_page_num( - GTK_NOTEBOOK( - this->gtk - ), - GTK_WIDGET( - page->gtk - ) - ) - ); - } - - // Render - gtk_widget_show( - GTK_WIDGET( - this->gtk - ) - ); - } - } - } -} diff --git a/src/app/browser/container/tab.h b/src/app/browser/container/tab.h deleted file mode 100644 index d168256b..00000000 --- a/src/app/browser/container/tab.h +++ /dev/null @@ -1,50 +0,0 @@ -#pragma once - -#ifndef APP_BROWSER_CONTAINER_TAB_H -#define APP_BROWSER_CONTAINER_TAB_H - -// Dependencies -#include "../container.h" - -// Requirements -#include "page.h" - -namespace app -{ - namespace browser - { - class Container; - - namespace container - { - class Page; // @TODO not required here - - class Tab - { - public: - - // GTK - GtkWidget *gtk; - - // Defaults - const gboolean REORDERABLE = true; - const gboolean SCROLLABLE = true; - - // Dependencies - Container *container; - - Tab( - Container *container - ); - - void append( - char *request, - bool open, - bool focus - ); - }; - }; - }; -}; - -#endif \ No newline at end of file diff --git a/src/app/browser/header.cpp b/src/app/browser/header.cpp deleted file mode 100644 index 1086e04e..00000000 --- a/src/app/browser/header.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#include "header.h" - -namespace app -{ - namespace browser - { - // Construct - Header::Header( - Browser *browser - ) { - // Init dependencies - this->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 - ); - - // Init menu element - this->menu = new header::Menu( - this - ); - - gtk_header_bar_pack_start( - GTK_HEADER_BAR( - this->gtk - ), - this->menu->gtk - ); - - // Init new tab element - this->tab = new header::Tab( - this - ); - - gtk_header_bar_pack_start( - GTK_HEADER_BAR( - this->gtk - ), - this->tab->gtk - ); - - // Render - gtk_widget_show( - GTK_WIDGET( - this->gtk - ) - ); - } - } -} diff --git a/src/app/browser/header.h b/src/app/browser/header.h deleted file mode 100644 index 8c1dd95a..00000000 --- a/src/app/browser/header.h +++ /dev/null @@ -1,49 +0,0 @@ -#pragma once - -#ifndef APP_BROWSER_HEADER_H -#define APP_BROWSER_HEADER_H - -// Dependencies -#include "../browser.h" - -// Requirements -#include "header/menu.h" -#include "header/tab.h" - -namespace app -{ - class Browser; - - namespace browser - { - namespace header - { - class Menu; - class Tab; - } - - class Header - { - public: - - // GTK - GtkWidget *gtk; - - // Defaults - const gboolean SHOW_TITLE_BUTTONS = true; - - // Dependencies - Browser *browser; - - // Requirements - header::Menu *menu; - header::Tab *tab; - - Header( - Browser *browser - ); - }; - }; -}; - -#endif \ No newline at end of file diff --git a/src/app/browser/header/menu.cpp b/src/app/browser/header/menu.cpp deleted file mode 100644 index ac97afe1..00000000 --- a/src/app/browser/header/menu.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "menu.h" - -namespace app::browser::header -{ - // Construct - Menu::Menu( - Header *header - ) { - // Init dependencies - this->header = header; - - // Init GTK - this->gtk = gtk_menu_button_new(); - - gtk_widget_set_tooltip_text( - GTK_WIDGET( - this->gtk - ), - Menu::TOOLTIP - ); - - // Init requirements - this->main = new menu::Main( - this - ); - - // Init main popover - gtk_menu_button_set_popover( - GTK_MENU_BUTTON( - this->gtk - ), - GTK_WIDGET( - this->main->gtk - ) - ); - - // Render - gtk_widget_show( - GTK_WIDGET( - this->gtk - ) - ); - } -} diff --git a/src/app/browser/header/menu.h b/src/app/browser/header/menu.h deleted file mode 100644 index 0d239aa7..00000000 --- a/src/app/browser/header/menu.h +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once - -#ifndef APP_BROWSER_HEADER_MENU_H -#define APP_BROWSER_HEADER_MENU_H - -// Dependencies -#include "../header.h" - -// Requirements -#include "menu/main.h" - -namespace app::browser -{ - class Header; - - namespace header - { - namespace menu - { - class Main; - } - - class Menu - { - public: - - // GTK - GtkWidget *gtk; - - // Dependencies - Header *header; - - // Requirements - menu::Main *main; - - // Defaults - const gchar *TOOLTIP = "Menu"; - - // Constructor - Menu( - Header *header - ); - }; - }; -}; - -#endif \ No newline at end of file diff --git a/src/app/browser/header/menu/main.cpp b/src/app/browser/header/menu/main.cpp deleted file mode 100644 index c890b608..00000000 --- a/src/app/browser/header/menu/main.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "main.h" - -namespace app::browser::header::menu -{ - // Construct - Main::Main( - Menu *menu - ) { - // Init dependencies - this->menu = menu; - - // Init model - 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( - this - ); - - g_menu_append_item( - G_MENU( - this->model - ), - G_MENU_ITEM( - this->debug->item - ) - ); - - // Init quit menu - this->quit = new main::Quit( - this - ); - - g_menu_append_item( - G_MENU( - this->model - ), - G_MENU_ITEM( - this->quit->item - ) - ); - - // Create a new GtkPopoverMenu from the GMenuModel - this->gtk = gtk_popover_menu_new_from_model( - G_MENU_MODEL( - this->model - ) - ); - } -} diff --git a/src/app/browser/header/menu/main.h b/src/app/browser/header/menu/main.h deleted file mode 100644 index 56becbd5..00000000 --- a/src/app/browser/header/menu/main.h +++ /dev/null @@ -1,53 +0,0 @@ -#pragma once - -#ifndef APP_BROWSER_HEADER_MENU_MAIN_H -#define APP_BROWSER_HEADER_MENU_MAIN_H - -// Dependencies -#include "../menu.h" - -// Requirements -#include "main/tab.h" -#include "main/debug.h" -#include "main/quit.h" - -namespace app::browser::header -{ - class Menu; - - namespace menu - { - namespace main - { - class Tab; - class Debug; - class Quit; - }; - - class Main - { - public: - - // GTK - GtkWidget *gtk; - - // Gio - GMenu* model; - - // Dependencies - Menu *menu; - - // Requirements - main::Tab *tab; - main::Debug *debug; - main::Quit *quit; - - // Constructor - Main( - Menu *menu - ); - }; - }; -}; - -#endif \ No newline at end of file diff --git a/src/app/browser/header/menu/main/debug.cpp b/src/app/browser/header/menu/main/debug.cpp deleted file mode 100644 index a702ae62..00000000 --- a/src/app/browser/header/menu/main/debug.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "debug.h" - -namespace app::browser::header::menu::main -{ - // Construct - Debug::Debug( - Main *main - ) { - // Init dependencies - this->main = main; - - // Init action object - this->action = g_simple_action_new( - Debug::ACTION_ID, - NULL - ); - - g_action_map_add_action( - G_ACTION_MAP( - this->main->menu->header->browser->app - ), - G_ACTION( - this->action - ) - ); - - // Init action NS - gchar action[255]; - - g_snprintf( - action, - sizeof( - action - ), - Debug::ACTION_NS, - Debug::ACTION_ID - ); - - // Init keyboard accelerators - // https://docs.gtk.org/gtk4/func.accelerator_parse.html - const gchar *accels[] = { - Debug::ACCEL_1, // First accelerator - Debug::ACCEL_2, // Second accelerator - NULL - }; - - gtk_application_set_accels_for_action( - GTK_APPLICATION( - this->main->menu->header->browser->app - ), - action, - accels - ); - - // Init menu item object - this->item = g_menu_item_new( - Debug::LABEL, - action - ); - - // Connect events - g_signal_connect( - G_SIMPLE_ACTION( - this->action - ), - "activate", - G_CALLBACK( - Debug::_activate - ), - NULL - ); - } - - // Events - void Debug::_activate( - GSimpleAction* action, - GVariant* parameter, - gpointer user_data - ) { - gtk_window_set_interactive_debugging( - true - ); - } -} diff --git a/src/app/browser/header/menu/main/debug.h b/src/app/browser/header/menu/main/debug.h deleted file mode 100644 index 01548bea..00000000 --- a/src/app/browser/header/menu/main/debug.h +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once - -#ifndef APP_BROWSER_HEADER_MENU_MAIN_DEBUG_H -#define APP_BROWSER_HEADER_MENU_MAIN_DEBUG_H - -#include "../main.h" - -namespace app::browser::header::menu -{ - class Main; - - namespace main - { - class Debug - { - public: - - // GTK - GMenuItem *item; - - GSimpleAction *action; - - // Dependencies - Main *main; - - // Defaults - const gchar *LABEL = "Debug"; - - const gchar *ACCEL_1 = "i"; - const gchar *ACCEL_2 = "I"; - - const gchar *ACTION_NS = "app.%s"; - const gchar *ACTION_ID = "browser.header.menu.main.debug.activate"; - - // Construct - Debug( - Main *main - ); - - private: - - // Events - static void _activate( - GSimpleAction* action, - GVariant* parameter, - gpointer user_data - ); - }; - }; -}; - -#endif \ No newline at end of file diff --git a/src/app/browser/header/menu/main/quit.cpp b/src/app/browser/header/menu/main/quit.cpp deleted file mode 100644 index 6f452373..00000000 --- a/src/app/browser/header/menu/main/quit.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include "quit.h" - -namespace app::browser::header::menu::main -{ - // Construct - Quit::Quit( - Main *main - ) { - // Init dependencies - this->main = main; - - // Init action object - this->action = g_simple_action_new( - Quit::ACTION_ID, - NULL - ); - - g_action_map_add_action( - G_ACTION_MAP( - this->main->menu->header->browser->app - ), - G_ACTION( - this->action - ) - ); - - // Init action NS - gchar action[255]; - - g_snprintf( - action, - sizeof( - action - ), - Quit::ACTION_NS, - Quit::ACTION_ID - ); - - // Init keyboard accelerators - // https://docs.gtk.org/gtk4/func.accelerator_parse.html - const gchar *accels[] = { - Quit::ACCEL_1, // First accelerator - Quit::ACCEL_2, // Second accelerator - NULL - }; - - gtk_application_set_accels_for_action( - GTK_APPLICATION( - this->main->menu->header->browser->app - ), - action, - accels - ); - - // Init menu item object - this->item = g_menu_item_new( - Quit::LABEL, - action - ); - - // Connect events - g_signal_connect( - G_SIMPLE_ACTION( - this->action - ), - "activate", - G_CALLBACK( - Quit::_activate - ), - G_APPLICATION( - this->main->menu->header->browser->app - ) - ); - } - - // Events - void Quit::_activate( - GSimpleAction* action, - GVariant* parameter, - gpointer user_data - ) { - g_application_quit( - G_APPLICATION( - user_data - ) - ); - } -} diff --git a/src/app/browser/header/menu/main/quit.h b/src/app/browser/header/menu/main/quit.h deleted file mode 100644 index faf4a31e..00000000 --- a/src/app/browser/header/menu/main/quit.h +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once - -#ifndef APP_BROWSER_HEADER_MENU_MAIN_QUIT_H -#define APP_BROWSER_HEADER_MENU_MAIN_QUIT_H - -#include "../main.h" - -namespace app::browser::header::menu -{ - class Main; - - namespace main - { - class Quit - { - public: - - // GTK - GMenuItem *item; - - GSimpleAction *action; - - // Dependencies - Main *main; - - // Defaults - const gchar *LABEL = "Quit"; - - const gchar *ACCEL_1 = "q"; - const gchar *ACCEL_2 = "Q"; - - const gchar *ACTION_NS = "app.%s"; - const gchar *ACTION_ID = "browser.header.menu.main.quit.activate"; - - // Construct - Quit( - Main *main - ); - - private: - - // Events - static void _activate( - GSimpleAction* action, - GVariant* parameter, - gpointer user_data - ); - }; - }; -}; - -#endif \ No newline at end of file diff --git a/src/app/browser/header/menu/main/tab.cpp b/src/app/browser/header/menu/main/tab.cpp deleted file mode 100644 index 8febd4e5..00000000 --- a/src/app/browser/header/menu/main/tab.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#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 new tab menu - this->append = new tab::Append( - this - ); - - g_menu_append_item( - G_MENU( - this->model - ), - G_MENU_ITEM( - this->append->item - ) - ); - - // Init menu - this->gtk = gtk_popover_menu_new_from_model( - G_MENU_MODEL( - this->model - ) - ); - } -} diff --git a/src/app/browser/header/menu/main/tab.h b/src/app/browser/header/menu/main/tab.h deleted file mode 100644 index d575313a..00000000 --- a/src/app/browser/header/menu/main/tab.h +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once - -#ifndef APP_BROWSER_HEADER_MENU_MAIN_TAB_H -#define APP_BROWSER_HEADER_MENU_MAIN_TAB_H - -// Dependencies -#include "../main.h" - -// Requirements -#include "tab/append.h" - -namespace app::browser::header::menu -{ - class Main; - - namespace main - { - namespace tab - { - class Append; - } - - class Tab - { - public: - - // GTK - GtkWidget *gtk; - - // Gio - GMenu* model; - - GMenuItem *item; - - // Dependencies - Main *main; - - // Requirements - tab::Append *append; - - // Defaults - const gchar *LABEL = "Tab"; - - // Construct - Tab( - Main *main - ); - }; - }; -}; - -#endif \ No newline at end of file diff --git a/src/app/browser/header/menu/main/tab/append.cpp b/src/app/browser/header/menu/main/tab/append.cpp deleted file mode 100644 index 91fff684..00000000 --- a/src/app/browser/header/menu/main/tab/append.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "append.h" - -namespace app::browser::header::menu::main::tab -{ - // Construct - Append::Append( - Tab *tab - ) { - // Init dependencies - this->tab = tab; - - // Init action object - this->action = g_simple_action_new( - Append::ACTION_ID, - NULL - ); - - g_action_map_add_action( - G_ACTION_MAP( - this->tab->main->menu->header->browser->app - ), - G_ACTION( - this->action - ) - ); - - // Init action NS - gchar action[255]; - - g_snprintf( - action, - sizeof( - action - ), - Append::ACTION_NS, - Append::ACTION_ID - ); - - // Init keyboard accelerators - // https://docs.gtk.org/gtk4/func.accelerator_parse.html - const gchar *accels[] = { - Append::ACCEL_1, // First accelerator - Append::ACCEL_2, // Second accelerator - NULL - }; - - gtk_application_set_accels_for_action( - GTK_APPLICATION( - this->tab->main->menu->header->browser->app - ), - action, - accels - ); - - // Init menu item object - this->item = g_menu_item_new( - Append::LABEL, - action - ); - - // Connect events - g_signal_connect( - G_SIMPLE_ACTION( - this->action - ), - "activate", - G_CALLBACK( - Append::_activate - ), - G_APPLICATION( - this->tab->main->menu->header->browser->app - ) - ); - } - - // Events - void Append::_activate( - GSimpleAction* action, - GVariant* parameter, - gpointer user_data - ) { - // @TODO - } -} diff --git a/src/app/browser/header/menu/main/tab/append.h b/src/app/browser/header/menu/main/tab/append.h deleted file mode 100644 index 2ed6e028..00000000 --- a/src/app/browser/header/menu/main/tab/append.h +++ /dev/null @@ -1,53 +0,0 @@ -#pragma once - -#ifndef APP_BROWSER_HEADER_MENU_MAIN_TAB_APPEND_H -#define APP_BROWSER_HEADER_MENU_MAIN_TAB_APPEND_H - -#include "../tab.h" - -namespace app::browser::header::menu::main -{ - class Tab; - - namespace tab - { - class Append - { - public: - - // GTK - GMenuItem *item; - - // Gio - GSimpleAction *action; - - // Dependencies - Tab *tab; - - // Defaults - const gchar *LABEL = "New tab"; - - const gchar *ACCEL_1 = "t"; - const gchar *ACCEL_2 = "T"; - - const gchar *ACTION_NS = "app.%s"; - const gchar *ACTION_ID = "browser.header.menu.main.tab.append.activate"; - - // Construct - Append( - Tab *tab - ); - - private: - - // Events - static void _activate( - GSimpleAction* action, - GVariant* parameter, - gpointer user_data - ); - }; - }; -}; - -#endif \ No newline at end of file diff --git a/src/app/browser/header/tab.cpp b/src/app/browser/header/tab.cpp deleted file mode 100644 index e3d0a3a9..00000000 --- a/src/app/browser/header/tab.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "tab.h" - -namespace app::browser::header -{ - // Construct - Tab::Tab( - Header *header - ) { - // Init dependencies - this->header = header; - - // Init GTK - this->gtk = gtk_button_new(); - - gtk_button_set_icon_name( - GTK_BUTTON( - this->gtk - ), - Tab::ICON - ); - - gtk_widget_set_tooltip_text( - GTK_WIDGET( - this->gtk - ), - Tab::TOOLTIP - ); - - // Render - gtk_widget_show( - GTK_WIDGET( - this->gtk - ) - ); - } -} diff --git a/src/app/browser/header/tab.h b/src/app/browser/header/tab.h deleted file mode 100644 index f4fd98f6..00000000 --- a/src/app/browser/header/tab.h +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once - -#ifndef APP_BROWSER_HEADER_TAB_H -#define APP_BROWSER_HEADER_TAB_H - -// Dependencies -#include "../header.h" - -namespace app::browser -{ - class Header; - - namespace header - { - class Tab - { - public: - - // GTK - GtkWidget *gtk; - - // Dependencies - Header *header; - - // Defaults - const gchar *ICON = "tab-new-symbolic"; - const gchar *TOOLTIP = "New tab"; - - // Constructor - Tab( - Header *header - ); - }; - }; -}; - -#endif \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index d84cba3a..b9209139 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,52 +1,15 @@ #include "main.h" -void activate( - GtkApplication *application -) { - // Init default component - new app::Browser( - application - ); -} - int main( int argc, - char *argv[] + char* argv[] ) { - // Create a new application - GtkApplication *application = gtk_application_new( - NULL, - G_APPLICATION_DEFAULT_FLAGS - ); - - // Connect events - g_signal_connect( - G_APPLICATION( - application - ), - "activate", - G_CALLBACK( - activate - ), - NULL + auto app = Gtk::Application::create( + "Yoda" ); - // Run the application - int status = g_application_run( - G_APPLICATION( - application - ), + return app->make_window_and_run( argc, argv ); - - // Clean up - g_object_unref( - G_APPLICATION( - application - ) - ); - - // Result - return status; } \ No newline at end of file diff --git a/src/main.h b/src/main.h index 2fe4cf77..90dab2ff 100644 --- a/src/main.h +++ b/src/main.h @@ -1,15 +1,8 @@ -#pragma once - -#include -#include +#include #include "app/browser.h" -void static activate( - GtkApplication *application -); - int main( int argc, - char *argv[] + char* argv[] ); \ No newline at end of file