Browse Source

init header menu

CPP-GTK4
yggverse 4 months ago
parent
commit
f6e855e4b2
  1. 3
      Makefile
  2. 12
      src/app/browser/header.cpp
  3. 14
      src/app/browser/header.h
  4. 21
      src/app/browser/menu.cpp
  5. 25
      src/app/browser/menu.h

3
Makefile

@ -10,7 +10,8 @@ SRCS = src/main.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/menu.cpp
OBJS = $(SRCS:.cpp=.o) OBJS = $(SRCS:.cpp=.o)

12
src/app/browser/header.cpp

@ -8,6 +8,9 @@ namespace app
Header::Header( Header::Header(
Browser *browser Browser *browser
) { ) {
// Init dependencies
this->browser = browser;
// Init GTK // Init GTK
this->gtk = gtk_header_bar_new(); this->gtk = gtk_header_bar_new();
@ -18,6 +21,15 @@ namespace app
Header::SHOW_TITLE_BUTTONS Header::SHOW_TITLE_BUTTONS
); );
// Init title widget
gtk_header_bar_set_title_widget(
GTK_HEADER_BAR(
this->gtk
),
(new Menu(this->browser))->gtk // @TODO
);
// Render
gtk_widget_show( gtk_widget_show(
GTK_WIDGET( GTK_WIDGET(
this->gtk this->gtk

14
src/app/browser/header.h

@ -1,22 +1,36 @@
#ifndef APP_BROWSER_HEADER_H #ifndef APP_BROWSER_HEADER_H
#define APP_BROWSER_HEADER_H #define APP_BROWSER_HEADER_H
// Dependencies
#include "../browser.h" #include "../browser.h"
// Requirements
#include "menu.h"
namespace app namespace app
{ {
class Browser; class Browser;
namespace browser namespace browser
{ {
class Menu;
class Header class Header
{ {
public: public:
// GTK
GtkWidget *gtk; GtkWidget *gtk;
// Defaults
const gboolean SHOW_TITLE_BUTTONS = true; const gboolean SHOW_TITLE_BUTTONS = true;
// Dependencies
Browser *browser;
// Requirements
Menu *menu;
Header( Header(
Browser *browser Browser *browser
); );

21
src/app/browser/menu.cpp

@ -0,0 +1,21 @@
#include "header.h"
namespace app
{
namespace browser
{
// Construct
Menu::Menu(
Browser *browser
) {
// Init GTK
this->gtk = gtk_menu_button_new();
gtk_widget_show(
GTK_WIDGET(
this->gtk
)
);
}
}
}

25
src/app/browser/menu.h

@ -0,0 +1,25 @@
#ifndef APP_BROWSER_MENU_H
#define APP_BROWSER_MENU_H
#include "../menu.h"
namespace app
{
class Browser;
namespace browser
{
class Menu
{
public:
GtkWidget *gtk;
Menu(
Browser *browser
);
};
};
};
#endif
Loading…
Cancel
Save