Browse Source

draft tab actions

CPP-GTK4
yggverse 5 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; @@ -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() @@ -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
}

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

@ -2,22 +2,22 @@ @@ -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:
void on_switch(
Gtk::Widget * page,
guint page_num
);
tab::Data * data;
tab::Label * label;
public:
Tab();
@ -37,7 +37,9 @@ namespace app::browser::main @@ -37,7 +37,9 @@ namespace app::browser::main
void close_right();
void close_all();
void update();
void update(
int number
);
};
}

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

@ -10,12 +10,32 @@ Data::Data() @@ -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

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

@ -2,6 +2,8 @@ @@ -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 @@ -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 @@ -21,6 +25,8 @@ namespace app::browser::main::tab
Data();
~Data();
void update();
};
}

Loading…
Cancel
Save