Browse Source

switch to gtkmm

CPP-GTK4
yggverse 4 months ago
parent
commit
d3e894e0ac
  1. 30
      Makefile
  2. 4
      README.md
  3. 83
      src/app/browser.cpp
  4. 53
      src/app/browser.h
  5. 46
      src/app/browser/container.cpp
  6. 43
      src/app/browser/container.h
  7. 49
      src/app/browser/container/page.cpp
  8. 42
      src/app/browser/container/page.h
  9. 113
      src/app/browser/container/tab.cpp
  10. 50
      src/app/browser/container/tab.h
  11. 56
      src/app/browser/header.cpp
  12. 49
      src/app/browser/header.h
  13. 44
      src/app/browser/header/menu.cpp
  14. 47
      src/app/browser/header/menu.h
  15. 65
      src/app/browser/header/menu/main.cpp
  16. 53
      src/app/browser/header/menu/main.h
  17. 84
      src/app/browser/header/menu/main/debug.cpp
  18. 52
      src/app/browser/header/menu/main/debug.h
  19. 88
      src/app/browser/header/menu/main/quit.cpp
  20. 52
      src/app/browser/header/menu/main/quit.h
  21. 36
      src/app/browser/header/menu/main/tab.cpp
  22. 52
      src/app/browser/header/menu/main/tab.h
  23. 84
      src/app/browser/header/menu/main/tab/append.cpp
  24. 53
      src/app/browser/header/menu/main/tab/append.h
  25. 36
      src/app/browser/header/tab.cpp
  26. 37
      src/app/browser/header/tab.h
  27. 45
      src/main.cpp
  28. 11
      src/main.h

30
Makefile

@ -1,23 +1,23 @@
# Define compiler and flags # Define compiler and flags
CXX = g++ CXX = g++
CXXFLAGS = `pkg-config --cflags gtk4` CXXFLAGS = `pkg-config --cflags gtkmm-4.0`
LDFLAGS = `pkg-config --libs gtk4` LDFLAGS = `pkg-config --libs gtkmm-4.0`
# Define target executable and source files # Define target executable and source files
TARGET = bin/Yoda TARGET = bin/Yoda
SRCS = src/main.cpp\ SRCS = src/main.cpp src/app/browser.cpp
src/app/browser.cpp\ # src/app/browser.cpp\
src/app/browser/container.cpp\ # src/app/browser/container.cpp\
src/app/browser/container/page.cpp\ # src/app/browser/container/page.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/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/tab.cpp\
src/app/browser/header/menu/main/tab/append.cpp\ # src/app/browser/header/menu/main/tab/append.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
OBJS = $(SRCS:.cpp=.o) OBJS = $(SRCS:.cpp=.o)

4
README.md

@ -10,7 +10,7 @@ GTK 4 / C++ implementation branch
### Linux ### Linux
* `sudo apt install git libgtk-4-dev` * `sudo apt install git libgtkmm-4.0-dev`
* `git clone https://github.com/YGGverse/Yoda.git` * `git clone https://github.com/YGGverse/Yoda.git`
* `cd Yoda` * `cd Yoda`
* `git checkout master` * `git checkout master`
@ -26,7 +26,7 @@ GTK 4 / C++ implementation branch
### Environment ### Environment
* `pkg-config --cflags --libs gtk4` * `pkg-config --cflags --libs gtkmm-4.0`
### Contribution ### Contribution

83
src/app/browser.cpp

@ -1,82 +1,15 @@
#include "browser.h" #include "browser.h"
namespace app using 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( Browser::Browser()
GTK_WINDOW( {
this->gtk set_title(
), TITLE
GTK_WIDGET(
this->header->gtk
)
);
// 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 set_default_size(
g_signal_connect( WIDTH,
G_APPLICATION( HEIGHT
this->app
),
"shutdown",
G_CALLBACK(
_shutdown
),
NULL
); );
}
// Events
void Browser::_shutdown(
GtkApplication *application
) {
// @TODO save session, clean cache, etc
g_print("Shutdown..\n");
}
} }

53
src/app/browser.h

@ -1,53 +1,32 @@
#pragma once
#ifndef APP_BROWSER_H #ifndef APP_BROWSER_H
#define APP_BROWSER_H #define APP_BROWSER_H
// Dependencies #include <gtkmm/window.h>
#include "../main.h" #include <gtkmm/headerbar.h>
#include <gtkmm/notebook.h>
// Requirements
#include "browser/header.h"
#include "browser/container.h"
namespace app namespace app
{ {
namespace browser class Browser : public Gtk::Window
{
class Header;
class Container;
}
class Browser
{ {
public: public:
// GTK const char* TITLE = "Basic application";
GtkWidget *gtk;
// Dependencies
GtkApplication *app;
// Requirements
browser::Header *header;
browser::Container *container;
// Defaults
const guint WIDTH = 640; const guint WIDTH = 640;
const guint HEIGHT = 480; const guint HEIGHT = 480;
// Constructor Browser();
Browser(
GtkApplication *application
);
private: class Header : Gtk::HeaderBar
{
};
// Events class Container : Gtk::Notebook
static void _shutdown( {
GtkApplication *application
); };
}; };
}; }
#endif #endif // APP_BROWSER_H

46
src/app/browser/container.cpp

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

43
src/app/browser/container.h

@ -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

49
src/app/browser/container/page.cpp

@ -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
}
}
}
}

42
src/app/browser/container/page.h

@ -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

113
src/app/browser/container/tab.cpp

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

50
src/app/browser/container/tab.h

@ -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

56
src/app/browser/header.cpp

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

49
src/app/browser/header.h

@ -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

44
src/app/browser/header/menu.cpp

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

47
src/app/browser/header/menu.h

@ -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

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

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

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

@ -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

84
src/app/browser/header/menu/main/debug.cpp

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

52
src/app/browser/header/menu/main/debug.h

@ -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 = "<Control><Shift>i";
const gchar *ACCEL_2 = "<Control><Shift>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

88
src/app/browser/header/menu/main/quit.cpp

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

52
src/app/browser/header/menu/main/quit.h

@ -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 = "<Control>q";
const gchar *ACCEL_2 = "<Control>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

36
src/app/browser/header/menu/main/tab.cpp

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

52
src/app/browser/header/menu/main/tab.h

@ -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

84
src/app/browser/header/menu/main/tab/append.cpp

@ -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
}
}

53
src/app/browser/header/menu/main/tab/append.h

@ -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 = "<Control>t";
const gchar *ACCEL_2 = "<Control>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

36
src/app/browser/header/tab.cpp

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

37
src/app/browser/header/tab.h

@ -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

45
src/main.cpp

@ -1,52 +1,15 @@
#include "main.h" #include "main.h"
void activate(
GtkApplication *application
) {
// Init default component
new app::Browser(
application
);
}
int main( int main(
int argc, int argc,
char *argv[] char* argv[]
) { ) {
// Create a new application auto app = Gtk::Application::create(
GtkApplication *application = gtk_application_new( "Yoda"
NULL,
G_APPLICATION_DEFAULT_FLAGS
); );
// Connect events return app->make_window_and_run<app::Browser>(
g_signal_connect(
G_APPLICATION(
application
),
"activate",
G_CALLBACK(
activate
),
NULL
);
// Run the application
int status = g_application_run(
G_APPLICATION(
application
),
argc, argc,
argv argv
); );
// Clean up
g_object_unref(
G_APPLICATION(
application
)
);
// Result
return status;
} }

11
src/main.h

@ -1,15 +1,8 @@
#pragma once #include <gtkmm/application.h>
#include <iostream>
#include <gtk/gtk.h>
#include "app/browser.h" #include "app/browser.h"
void static activate(
GtkApplication *application
);
int main( int main(
int argc, int argc,
char *argv[] char* argv[]
); );
Loading…
Cancel
Save