diff --git a/Makefile b/Makefile index 4c62f03e..53049a7d 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,12 @@ LDFLAGS = `pkg-config --libs gtkmm-4.0 glibmm-2.68` # Define target executable and source files TARGET = bin/Yoda -SRCS = src/main.cpp $(wildcard src/app/*.cpp) +SRCS = src/main.cpp\ + src/app/browser.cpp\ + src/app/browser/header.cpp\ + src/app/browser/header/menu.cpp\ + src/app/browser/header/tab.cpp\ + src/app/browser/page.cpp OBJS = $(SRCS:.cpp=.o) diff --git a/po/POTFILES.in b/po/POTFILES.in index 3fbea413..1f3febaf 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,4 +1,12 @@ src/app/browser.cpp -src/app/browser.h +src/app/browser.hpp +src/app/browser/header.cpp +src/app/browser/header.hpp +src/app/browser/header/menu.cpp +src/app/browser/header/menu.hpp +src/app/browser/header/tab.cpp +src/app/browser/header/tab.hpp +src/app/browser/page.cpp +src/app/browser/page.hpp src/main.cpp -src/main.h \ No newline at end of file +src/main.hpp \ No newline at end of file diff --git a/src/app/browser.cpp b/src/app/browser.cpp index bcaac5b6..f53d67f0 100644 --- a/src/app/browser.cpp +++ b/src/app/browser.cpp @@ -1,4 +1,5 @@ -#include "browser.h" +#include "browser.hpp" +#include "browser/header.hpp" using namespace app; @@ -14,46 +15,6 @@ Browser::Browser() ); set_titlebar( - * new Header() - ); -} - -Browser::Header::Header() -{ - set_show_title_buttons( - SHOW_TITLE_BUTTONS - ); - - pack_start( - * new Menu() - ); - - pack_start( - * new Tab() - ); -} - -Browser::Header::Menu::Menu() -{ - set_tooltip_text( - TOOLTIP - ); -} - -Browser::Header::Tab::Tab() -{ - set_tooltip_text( - TOOLTIP - ); - - set_icon_name( - ICON - ); -} - -Browser::Container::Container() -{ - set_scrollable( - SCROLLABLE + * new browser::Header() ); } \ No newline at end of file diff --git a/src/app/browser.h b/src/app/browser.h deleted file mode 100644 index 6bb136d4..00000000 --- a/src/app/browser.h +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef APP_BROWSER_H -#define APP_BROWSER_H - -#include - -#include -#include -#include -#include -#include - -namespace app -{ - class Browser : public Gtk::ApplicationWindow - { - public: - - const char* TITLE = _("Yoda"); - const int WIDTH = 640; - const int HEIGHT = 480; - - Browser(); - - class Header : public Gtk::HeaderBar - { - public: - - const bool SHOW_TITLE_BUTTONS = true; - - Header(); - - class Menu : public Gtk::MenuButton - { - public: - - const char* TOOLTIP = _("Menu"); - - Menu(); - }; - - class Tab : public Gtk::MenuButton - { - public: - - const char* ICON = "tab-new-symbolic"; - const char* TOOLTIP = _("New tab"); - - Tab(); - }; - }; - - class Container : public Gtk::Notebook - { - public: - - class Page - { - public: - - class Navbar - { - public: - - Navbar(); - }; - - class Body - { - public: - - Body(); - }; - - Page(); - - private: - - Navbar _navbar; - Body _body; - }; - - const bool SCROLLABLE = true; - const bool REORDERABLE = true; - - Container(); - - Page append( - char* request, - bool open = true, - bool focus = false - ); - - void update(); - }; - }; -} - -#endif // APP_BROWSER_H \ No newline at end of file diff --git a/src/app/browser.hpp b/src/app/browser.hpp new file mode 100644 index 00000000..755a0273 --- /dev/null +++ b/src/app/browser.hpp @@ -0,0 +1,21 @@ +#ifndef APP_BROWSER_H +#define APP_BROWSER_H + +#include +#include + +namespace app +{ + class Browser : public Gtk::ApplicationWindow + { + public: + + const char * TITLE = _("Yoda"); + const int WIDTH = 640; + const int HEIGHT = 480; + + Browser(); + }; +} + +#endif // APP_BROWSER_H \ No newline at end of file diff --git a/src/app/browser/header.cpp b/src/app/browser/header.cpp new file mode 100644 index 00000000..e6e0e160 --- /dev/null +++ b/src/app/browser/header.cpp @@ -0,0 +1,20 @@ +#include "header.hpp" +#include "header/menu.hpp" +#include "header/tab.hpp" + +using namespace app::browser; + +Header::Header() +{ + set_show_title_buttons( + SHOW_TITLE_BUTTONS + ); + + pack_start( + * new header::Menu() + ); + + pack_start( + * new header::Tab() + ); +} \ No newline at end of file diff --git a/src/app/browser/header.hpp b/src/app/browser/header.hpp new file mode 100644 index 00000000..6e5f061b --- /dev/null +++ b/src/app/browser/header.hpp @@ -0,0 +1,18 @@ +#ifndef APP_BROWSER_HEADER_H +#define APP_BROWSER_HEADER_H + +#include + +namespace app::browser +{ + class Header : public Gtk::HeaderBar + { + public: + + const bool SHOW_TITLE_BUTTONS = true; + + Header(); + }; +} + +#endif // APP_BROWSER_HEADER_H \ No newline at end of file diff --git a/src/app/browser/header/menu.cpp b/src/app/browser/header/menu.cpp new file mode 100644 index 00000000..4ce142d2 --- /dev/null +++ b/src/app/browser/header/menu.cpp @@ -0,0 +1,48 @@ +#include "menu.hpp" + +using namespace app::browser::header; + +Menu::Menu() +{ + set_tooltip_text( + TOOLTIP + ); + + // Build tab submenu + auto tab = Gio::Menu::create(); + + tab->append( + _("New tab"), + "app.tab.new" + ); + + // Build tool submenu + auto tool = Gio::Menu::create(); + + tool->append( + _("Debug"), + "app.tool.debug" + ); + + // Build main menu + auto main = Gio::Menu::create(); + + main->append_submenu( + _("Tab"), + tab + ); + + main->append_submenu( + _("Tool"), + tool + ); + + main->append( + _("Quit"), + "win.quit" + ); + + set_menu_model( + main + ); +} \ No newline at end of file diff --git a/src/app/browser/header/menu.hpp b/src/app/browser/header/menu.hpp new file mode 100644 index 00000000..b4c9fc1f --- /dev/null +++ b/src/app/browser/header/menu.hpp @@ -0,0 +1,21 @@ +#ifndef APP_BROWSER_HEADER_MENU_H +#define APP_BROWSER_HEADER_MENU_H + +#include + +#include +#include + +namespace app::browser::header +{ + class Menu : public Gtk::MenuButton + { + public: + + const char* TOOLTIP = _("Menu"); + + Menu(); + }; +} + +#endif // APP_BROWSER_HEADER_MENU_H \ No newline at end of file diff --git a/src/app/browser/header/tab.cpp b/src/app/browser/header/tab.cpp new file mode 100644 index 00000000..edd39932 --- /dev/null +++ b/src/app/browser/header/tab.cpp @@ -0,0 +1,14 @@ +#include "tab.hpp" + +using namespace app::browser::header; + +Tab::Tab() +{ + set_tooltip_text( + TOOLTIP + ); + + set_icon_name( + ICON + ); +} \ No newline at end of file diff --git a/src/app/browser/header/tab.hpp b/src/app/browser/header/tab.hpp new file mode 100644 index 00000000..3ea3550d --- /dev/null +++ b/src/app/browser/header/tab.hpp @@ -0,0 +1,20 @@ +#ifndef APP_BROWSER_HEADER_TAB_H +#define APP_BROWSER_HEADER_TAB_H + +#include +#include + +namespace app::browser::header +{ + class Tab : public Gtk::MenuButton + { + public: + + const char* ICON = "tab-new-symbolic"; + const char* TOOLTIP = _("New tab"); + + Tab(); + }; +} + +#endif // APP_BROWSER_HEADER_TAB_H \ No newline at end of file diff --git a/src/app/browser/page.cpp b/src/app/browser/page.cpp new file mode 100644 index 00000000..e96a15da --- /dev/null +++ b/src/app/browser/page.cpp @@ -0,0 +1,10 @@ +#include "page.hpp" + +using namespace app::browser; + +Page::Page() +{ + set_scrollable( + SCROLLABLE + ); +} \ No newline at end of file diff --git a/src/app/browser/page.hpp b/src/app/browser/page.hpp new file mode 100644 index 00000000..3fa6e1d7 --- /dev/null +++ b/src/app/browser/page.hpp @@ -0,0 +1,41 @@ +#ifndef APP_BROWSER_PAGE_H +#define APP_BROWSER_PAGE_H + +#include + +namespace app::browser +{ + class Page : public Gtk::Notebook + { + public: + + const bool SCROLLABLE = true; + const bool REORDERABLE = true; + + class Navbar + { + public: + + Navbar(); + }; + + class Body + { + public: + + Body(); + }; + + Page(); + + void append( + char* request, + bool open = true, + bool focus = false + ); + + void update(); + }; +} + +#endif // APP_BROWSER_PAGE_H \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 0650b75a..ea53d416 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,5 @@ -#include "main.h" +#include "main.hpp" +#include "app/browser.hpp" int main( int argc, diff --git a/src/main.h b/src/main.hpp similarity index 79% rename from src/main.h rename to src/main.hpp index 81c01117..3f75d908 100644 --- a/src/main.h +++ b/src/main.hpp @@ -1,4 +1,4 @@ -#include "app/browser.h" +#include const Glib::ustring APPLICATION_ID = "io.github.yggverse.Yoda";