Browse Source

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

CPP-GTK4
yggverse 3 months ago
parent
commit
0f96ff851e
  1. 7
      Makefile
  2. 12
      po/POTFILES.in
  3. 45
      src/app/browser.cpp
  4. 98
      src/app/browser.h
  5. 21
      src/app/browser.hpp
  6. 20
      src/app/browser/header.cpp
  7. 18
      src/app/browser/header.hpp
  8. 48
      src/app/browser/header/menu.cpp
  9. 21
      src/app/browser/header/menu.hpp
  10. 14
      src/app/browser/header/tab.cpp
  11. 20
      src/app/browser/header/tab.hpp
  12. 10
      src/app/browser/page.cpp
  13. 41
      src/app/browser/page.hpp
  14. 3
      src/main.cpp
  15. 2
      src/main.hpp

7
Makefile

@ -5,7 +5,12 @@ LDFLAGS = `pkg-config --libs gtkmm-4.0 glibmm-2.68` @@ -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)

12
po/POTFILES.in

@ -1,4 +1,12 @@ @@ -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

45
src/app/browser.cpp

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "browser.h"
#include "browser.hpp"
#include "browser/header.hpp"
using namespace app;
@ -14,46 +15,6 @@ Browser::Browser() @@ -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()
);
}

98
src/app/browser.h

@ -1,98 +0,0 @@ @@ -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

@ -0,0 +1,21 @@ @@ -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

20
src/app/browser/header.cpp

@ -0,0 +1,20 @@ @@ -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()
);
}

18
src/app/browser/header.hpp

@ -0,0 +1,18 @@ @@ -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

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

@ -0,0 +1,48 @@ @@ -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
);
}

21
src/app/browser/header/menu.hpp

@ -0,0 +1,21 @@ @@ -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

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

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

20
src/app/browser/header/tab.hpp

@ -0,0 +1,20 @@ @@ -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

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

41
src/app/browser/page.hpp

@ -0,0 +1,41 @@ @@ -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

3
src/main.cpp

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

2
src/main.h → src/main.hpp

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