draft tab actions

This commit is contained in:
yggverse 2024-08-14 07:56:34 +03:00
parent ebd2b843a4
commit 579ebfa037
4 changed files with 72 additions and 14 deletions

View File

@ -6,21 +6,30 @@ using namespace app::browser::main;
Tab::Tab()
{
// Init widget
set_scrollable(
true
);
// Init events
signal_switch_page().connect(
sigc::mem_fun(
* this,
& Tab::on_switch
)
);
}
Tab::~Tab() = default;
// Actions
void Tab::append(
const char * request,
bool open,
bool focus
) {
label = new tab::Label();
data = new tab::Data();
auto label = new tab::Label();
auto data = new tab::Data();
append_page(
* data,
@ -67,4 +76,25 @@ void Tab::close_all()
-1 // last
);
}
}
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
}

View File

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

View File

@ -10,12 +10,32 @@ Data::Data()
Gtk::Orientation::VERTICAL
);
// Init elements
// Init children components
navbar = new data::Navbar();
append(
* 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;
void Data::update()
{} // @TODO

View File

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