Browse Source

draft main tab features

CPP-GTK4
yggverse 4 months ago
parent
commit
ee890b9859
  1. 3
      Makefile
  2. 6
      po/POTFILES.in
  3. 34
      src/app/browser.cpp
  4. 13
      src/app/browser.hpp
  5. 4
      src/app/browser/header/menu.cpp
  6. 4
      src/app/browser/header/tab.hpp
  7. 28
      src/app/browser/main.cpp
  8. 27
      src/app/browser/main.hpp
  9. 22
      src/app/browser/main/tab.cpp
  10. 18
      src/app/browser/main/tab.hpp
  11. 10
      src/app/browser/page.cpp

3
Makefile

@ -10,7 +10,8 @@ SRCS = src/main.cpp\
src/app/browser/header.cpp\ src/app/browser/header.cpp\
src/app/browser/header/menu.cpp\ src/app/browser/header/menu.cpp\
src/app/browser/header/tab.cpp\ src/app/browser/header/tab.cpp\
src/app/browser/page.cpp\ src/app/browser/main.cpp\
src/app/browser/main/tab.cpp\
src/lib/database.cpp\ src/lib/database.cpp\
src/lib/database/session.cpp src/lib/database/session.cpp

6
po/POTFILES.in

@ -6,8 +6,10 @@ src/app/browser/header/menu.cpp
src/app/browser/header/menu.hpp src/app/browser/header/menu.hpp
src/app/browser/header/tab.cpp src/app/browser/header/tab.cpp
src/app/browser/header/tab.hpp src/app/browser/header/tab.hpp
src/app/browser/page.cpp src/app/browser/main.cpp
src/app/browser/page.hpp src/app/browser/main.hpp
src/app/browser/main/tab.cpp
src/app/browser/main/tab.hpp
src/lib/database.cpp src/lib/database.cpp
src/lib/database.hpp src/lib/database.hpp
src/lib/database/session.cpp src/lib/database/session.cpp

34
src/app/browser.cpp

@ -1,5 +1,6 @@
#include "browser.hpp" #include "browser.hpp"
#include "browser/header.hpp" #include "browser/header.hpp"
#include "browser/main.hpp"
using namespace app; using namespace app;
@ -7,6 +8,7 @@ Browser::Browser(
const Glib::RefPtr<Gtk::Application> & app, const Glib::RefPtr<Gtk::Application> & app,
const lib::Database & db const lib::Database & db
) { ) {
// Init window
set_title( set_title(
TITLE TITLE
); );
@ -16,8 +18,27 @@ Browser::Browser(
HEIGHT HEIGHT
); );
// Init header widget
header = new browser::Header();
set_titlebar( set_titlebar(
* new browser::Header() * header
);
// Init main widget
main = new browser::Main();
set_child(
* main
);
// Init actions
add_action(
"tab",
sigc::mem_fun(
* this,
& Browser::mainTabAppend
)
); );
add_action( add_action(
@ -28,12 +49,23 @@ Browser::Browser(
) )
); );
// Init
app->set_accel_for_action(
"win.tab",
"<Primary>t"
);
app->set_accel_for_action( app->set_accel_for_action(
"win.debug", "win.debug",
"<Primary>i" "<Primary>i"
); );
} }
void Browser::mainTabAppend()
{
main->tabAppend();
};
void Browser::debug() void Browser::debug()
{ {
gtk_window_set_interactive_debugging( gtk_window_set_interactive_debugging(

13
src/app/browser.hpp

@ -11,8 +11,19 @@ namespace lib
namespace app namespace app
{ {
namespace browser
{
class Header;
class Main;
}
class Browser : public Gtk::ApplicationWindow class Browser : public Gtk::ApplicationWindow
{ {
private:
app::browser::Header * header;
app::browser::Main * main;
public: public:
const char * TITLE = _("Yoda"); const char * TITLE = _("Yoda");
@ -24,6 +35,8 @@ namespace app
const lib::Database & db const lib::Database & db
); );
void mainTabAppend();
void debug(); void debug();
}; };
} }

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

@ -13,8 +13,8 @@ Menu::Menu()
auto tab = Gio::Menu::create(); auto tab = Gio::Menu::create();
tab->append( tab->append(
_("New tab"), _("New tab.."),
"tab.new" "win.tab"
); );
// Build tool submenu // Build tool submenu

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

@ -2,11 +2,11 @@
#define APP_BROWSER_HEADER_TAB_H #define APP_BROWSER_HEADER_TAB_H
#include <glibmm/i18n.h> #include <glibmm/i18n.h>
#include <gtkmm/menubutton.h> #include <gtkmm/button.h>
namespace app::browser::header namespace app::browser::header
{ {
class Tab : public Gtk::MenuButton class Tab : public Gtk::Button
{ {
public: public:

28
src/app/browser/main.cpp

@ -0,0 +1,28 @@
#include "main.hpp"
#include "main/tab.hpp"
using namespace app::browser;
Main::Main()
{
// Init container
set_homogeneous(
true
);
// Init tabs
tab = new main::Tab();
append(
* tab
);
}
void Main::tabAppend()
{
tab->append(
nullptr,
true,
true
);
};

27
src/app/browser/main.hpp

@ -0,0 +1,27 @@
#ifndef APP_BROWSER_MAIN_H
#define APP_BROWSER_MAIN_H
#include <gtkmm/box.h>
namespace app::browser
{
namespace main
{
class Tab;
}
class Main : public Gtk::Box
{
private:
app::browser::main::Tab * tab;
public:
Main();
void tabAppend();
};
}
#endif // APP_BROWSER_MAIN_H

22
src/app/browser/main/tab.cpp

@ -0,0 +1,22 @@
#include "tab.hpp"
#include "gtkmm/label.h"
using namespace app::browser::main;
Tab::Tab()
{
set_scrollable(
SCROLLABLE
);
}
void Tab::append(
const char * request,
bool open,
bool focus
) {
append_page( // @TODO
* new Gtk::Label("data"),
* new Gtk::Label("tab")
);
};

18
src/app/browser/page.hpp → src/app/browser/main/tab.hpp

@ -1,11 +1,11 @@
#ifndef APP_BROWSER_PAGE_H #ifndef APP_BROWSER_MAIN_TAB_H
#define APP_BROWSER_PAGE_H #define APP_BROWSER_MAIN_TAB_H
#include <gtkmm/notebook.h> #include <gtkmm/notebook.h>
namespace app::browser namespace app::browser::main
{ {
class Page : public Gtk::Notebook class Tab : public Gtk::Notebook
{ {
public: public:
@ -26,16 +26,16 @@ namespace app::browser
Body(); Body();
}; };
Page(); Tab();
void append( void append(
char* request, const char * request,
bool open = true, bool open,
bool focus = false bool focus
); );
void update(); void update();
}; };
} }
#endif // APP_BROWSER_PAGE_H #endif // APP_BROWSER_MAIN_TAB_H

10
src/app/browser/page.cpp

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