Browse Source

add get_label_text, use lambda function on switch_page, rename page_number variables

CPP-GTK4
yggverse 3 months ago
parent
commit
fbfb8039b0
  1. 49
      src/app/browser/main/tab.cpp
  2. 11
      src/app/browser/main/tab.hpp

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

@ -15,9 +15,9 @@ Tab::Tab() @@ -15,9 +15,9 @@ Tab::Tab()
signal_switch_page().connect(
[this](Gtk::Widget * page, guint page_num)
{
on_switch(
page,
page_num
// Refresh window elements, e.g. tab label to header bar
activate_action(
"win.refresh"
);
}
);
@ -25,6 +25,26 @@ Tab::Tab() @@ -25,6 +25,26 @@ Tab::Tab()
Tab::~Tab() = default;
// Getters
Glib::ustring Tab::get_label_text(
int page_number
) {
auto page = get_nth_page(
page_number
);
if (page != nullptr)
{
return get_tab_label_text(
* get_nth_page(
page_number
)
);
}
return ""; // @TODO
};
// Actions
void Tab::append(
const char * request,
@ -92,22 +112,17 @@ void Tab::close_all() @@ -92,22 +112,17 @@ void Tab::close_all()
}
void Tab::update(
int number
int page_number
) {
auto page = get_nth_page(
number
);
page->activate_action(
"page.update"
page_number
);
} // @TODO
if (page != nullptr)
{
page->activate_action(
"page.update"
);
}
// Events
void Tab::on_switch(
Gtk::Widget * page,
guint page_num
) {
// @TODO update header text
}
} // @TODO

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

@ -2,24 +2,23 @@ @@ -2,24 +2,23 @@
#define APP_BROWSER_MAIN_TAB_HPP
#include <glibmm/i18n.h>
#include <gtkmm/widget.h>
#include <glibmm/ustring.h>
#include <gtkmm/notebook.h>
namespace app::browser::main
{
class Tab : public Gtk::Notebook
{
void on_switch(
Gtk::Widget * page,
guint page_num
);
public:
Tab();
~Tab();
Glib::ustring get_label_text(
int page_number
);
void append(
const char * request,
bool open,

Loading…
Cancel
Save