From 2fc4ac954101d08e1c7e7968cb78af819a0cd5ba Mon Sep 17 00:00:00 2001 From: yggverse Date: Tue, 6 Aug 2024 21:07:55 +0300 Subject: [PATCH] init new tab button --- Makefile | 1 + src/app/browser/header.cpp | 12 ++++++++++++ src/app/browser/header.h | 3 +++ src/app/browser/header/tab.cpp | 29 +++++++++++++++++++++++++++++ src/app/browser/header/tab.h | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 79 insertions(+) create mode 100644 src/app/browser/header/tab.cpp create mode 100644 src/app/browser/header/tab.h diff --git a/Makefile b/Makefile index 739d1a38..f638eaee 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ SRCS = src/main.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/bar.cpp\ src/app/browser/header/bar/menu.cpp\ src/app/browser/header/bar/menu/main.cpp\ diff --git a/src/app/browser/header.cpp b/src/app/browser/header.cpp index 13431d41..a4c8e205 100644 --- a/src/app/browser/header.cpp +++ b/src/app/browser/header.cpp @@ -29,6 +29,18 @@ namespace app (new header::Bar(this))->gtk // @TODO ); + // Init new tab button + 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( diff --git a/src/app/browser/header.h b/src/app/browser/header.h index 9aed8a80..1035a851 100644 --- a/src/app/browser/header.h +++ b/src/app/browser/header.h @@ -6,6 +6,7 @@ // Requirements #include "header/bar.h" +#include "header/tab.h" namespace app { @@ -16,6 +17,7 @@ namespace app namespace header { class Bar; + class Tab; } class Header @@ -33,6 +35,7 @@ namespace app // Requirements header::Bar *bar; + header::Tab *tab; Header( Browser *browser diff --git a/src/app/browser/header/tab.cpp b/src/app/browser/header/tab.cpp new file mode 100644 index 00000000..a6b87a22 --- /dev/null +++ b/src/app/browser/header/tab.cpp @@ -0,0 +1,29 @@ +#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_label ( + GTK_BUTTON( + this->gtk + ), + Tab::LABEL + ); + + // Render + gtk_widget_show( + GTK_WIDGET( + this->gtk + ) + ); + } +} diff --git a/src/app/browser/header/tab.h b/src/app/browser/header/tab.h new file mode 100644 index 00000000..11814d3b --- /dev/null +++ b/src/app/browser/header/tab.h @@ -0,0 +1,34 @@ +#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 *LABEL = "New tab"; + + // Constructor + Tab( + Header *header + ); + }; + }; +}; + +#endif \ No newline at end of file