use separated class files, use hpp header extension, update include model

This commit is contained in:
yggverse 2024-08-10 17:57:15 +03:00
parent 9b6dceddd8
commit 0f96ff851e
15 changed files with 235 additions and 145 deletions

View File

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

View File

@ -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
src/main.hpp

View File

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

View File

@ -1,98 +0,0 @@
#ifndef APP_BROWSER_H
#define APP_BROWSER_H
#include <glibmm/i18n.h>
#include <gtkmm/application.h>
#include <gtkmm/applicationwindow.h>
#include <gtkmm/headerbar.h>
#include <gtkmm/menubutton.h>
#include <gtkmm/notebook.h>
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

21
src/app/browser.hpp Normal file
View File

@ -0,0 +1,21 @@
#ifndef APP_BROWSER_H
#define APP_BROWSER_H
#include <glibmm/i18n.h>
#include <gtkmm/applicationwindow.h>
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

View File

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

View File

@ -0,0 +1,18 @@
#ifndef APP_BROWSER_HEADER_H
#define APP_BROWSER_HEADER_H
#include <gtkmm/headerbar.h>
namespace app::browser
{
class Header : public Gtk::HeaderBar
{
public:
const bool SHOW_TITLE_BUTTONS = true;
Header();
};
}
#endif // APP_BROWSER_HEADER_H

View File

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

View File

@ -0,0 +1,21 @@
#ifndef APP_BROWSER_HEADER_MENU_H
#define APP_BROWSER_HEADER_MENU_H
#include <giomm/menu.h>
#include <glibmm/i18n.h>
#include <gtkmm/menubutton.h>
namespace app::browser::header
{
class Menu : public Gtk::MenuButton
{
public:
const char* TOOLTIP = _("Menu");
Menu();
};
}
#endif // APP_BROWSER_HEADER_MENU_H

View File

@ -0,0 +1,14 @@
#include "tab.hpp"
using namespace app::browser::header;
Tab::Tab()
{
set_tooltip_text(
TOOLTIP
);
set_icon_name(
ICON
);
}

View File

@ -0,0 +1,20 @@
#ifndef APP_BROWSER_HEADER_TAB_H
#define APP_BROWSER_HEADER_TAB_H
#include <glibmm/i18n.h>
#include <gtkmm/menubutton.h>
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

10
src/app/browser/page.cpp Normal file
View File

@ -0,0 +1,10 @@
#include "page.hpp"
using namespace app::browser;
Page::Page()
{
set_scrollable(
SCROLLABLE
);
}

41
src/app/browser/page.hpp Normal file
View File

@ -0,0 +1,41 @@
#ifndef APP_BROWSER_PAGE_H
#define APP_BROWSER_PAGE_H
#include <gtkmm/notebook.h>
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

View File

@ -1,4 +1,5 @@
#include "main.h"
#include "main.hpp"
#include "app/browser.hpp"
int main(
int argc,

View File

@ -1,4 +1,4 @@
#include "app/browser.h"
#include <glibmm.h>
const Glib::ustring APPLICATION_ID = "io.github.yggverse.Yoda";