Browse Source

draft tab actions

CPP-GTK4
yggverse 4 months ago
parent
commit
579ebfa037
  1. 36
      src/app/browser/main/tab.cpp
  2. 22
      src/app/browser/main/tab.hpp
  3. 22
      src/app/browser/main/tab/data.cpp
  4. 6
      src/app/browser/main/tab/data.hpp

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

@ -6,21 +6,30 @@ using namespace app::browser::main;
Tab::Tab() Tab::Tab()
{ {
// Init widget
set_scrollable( set_scrollable(
true true
); );
// Init events
signal_switch_page().connect(
sigc::mem_fun(
* this,
& Tab::on_switch
)
);
} }
Tab::~Tab() = default; Tab::~Tab() = default;
// Actions
void Tab::append( void Tab::append(
const char * request, const char * request,
bool open, bool open,
bool focus bool focus
) { ) {
label = new tab::Label(); auto label = new tab::Label();
auto data = new tab::Data();
data = new tab::Data();
append_page( append_page(
* data, * data,
@ -68,3 +77,24 @@ void Tab::close_all()
); );
} }
} }
void Tab::update(
int number
) {
auto page = get_nth_page(
number
);
page->activate_action(
"tab.update"
);
} // @TODO
// Events
void Tab::on_switch(
Gtk::Widget * page,
guint page_num
) {
// @TODO update header
}

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

@ -2,22 +2,22 @@
#define APP_BROWSER_MAIN_TAB_HPP #define APP_BROWSER_MAIN_TAB_HPP
#include <glibmm/i18n.h> #include <glibmm/i18n.h>
#include <gtkmm/widget.h>
#include <gtkmm/notebook.h> #include <gtkmm/notebook.h>
#include <sigc++/functors/mem_fun.h>
namespace app::browser::main namespace app::browser::main
{ {
namespace tab
{
class Data;
class Label;
}
class Tab : public Gtk::Notebook class Tab : public Gtk::Notebook
{ {
public: private:
tab::Data * data; void on_switch(
tab::Label * label; Gtk::Widget * page,
guint page_num
);
public:
Tab(); Tab();
@ -37,7 +37,9 @@ namespace app::browser::main
void close_right(); void close_right();
void close_all(); void close_all();
void update(); void update(
int number
);
}; };
} }

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

@ -10,12 +10,32 @@ Data::Data()
Gtk::Orientation::VERTICAL Gtk::Orientation::VERTICAL
); );
// Init elements // Init children components
navbar = new data::Navbar(); navbar = new data::Navbar();
append( append(
* navbar * navbar
); );
// Init actions group
action_group = Gio::SimpleActionGroup::create();
// Define actions
action_group->add_action(
"update",
sigc::mem_fun(
* this,
& Data::update
)
);
insert_action_group(
"tab",
action_group
);
} }
Data::~Data() = default; Data::~Data() = default;
void Data::update()
{} // @TODO

6
src/app/browser/main/tab/data.hpp

@ -2,6 +2,8 @@
#define APP_BROWSER_MAIN_TAB_DATA_HPP #define APP_BROWSER_MAIN_TAB_DATA_HPP
#include <gtkmm/box.h> #include <gtkmm/box.h>
#include <giomm/simpleactiongroup.h>
#include <sigc++/functors/mem_fun.h>
namespace app::browser::main::tab namespace app::browser::main::tab
{ {
@ -14,6 +16,8 @@ namespace app::browser::main::tab
{ {
private: private:
Glib::RefPtr<Gio::SimpleActionGroup> action_group;
data::Navbar * navbar; data::Navbar * navbar;
public: public:
@ -21,6 +25,8 @@ namespace app::browser::main::tab
Data(); Data();
~Data(); ~Data();
void update();
}; };
} }

Loading…
Cancel
Save