Browse Source

init navbar actions

CPP-GTK4
yggverse 3 months ago
parent
commit
d95b85932f
  1. 11
      src/app/browser/main/tab/data.cpp
  2. 34
      src/app/browser/main/tab/data/navbar.cpp
  3. 20
      src/app/browser/main/tab/data/navbar.hpp
  4. 6
      src/app/browser/main/tab/data/navbar/request.cpp

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

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

34
src/app/browser/main/tab/data/navbar.cpp

@ -34,7 +34,7 @@ Navbar::Navbar()
MARGIN MARGIN
); );
// Init elements // Init components
base = new navbar::Base(); base = new navbar::Base();
append( append(
@ -64,6 +64,38 @@ Navbar::Navbar()
append( append(
* bookmark * bookmark
); );
// Init actions group
action_group = Gio::SimpleActionGroup::create();
// Define group actions
action_group->add_action(
"refresh",
sigc::mem_fun(
* this,
& Navbar::refresh
)
);
insert_action_group(
"navbar",
action_group
);
} }
Navbar::~Navbar() = default; Navbar::~Navbar() = default;
// Actions
void Navbar::refresh()
{
// Deactivate on request value is empty
update->set_sensitive(
(bool) request->get_text_length()
);
}
// Getters
Glib::ustring Navbar::get_request_value()
{
return request->get_text();
}

20
src/app/browser/main/tab/data/navbar.hpp

@ -1,7 +1,11 @@
#ifndef APP_BROWSER_MAIN_TAB_DATA_NAVBAR_HPP #ifndef APP_BROWSER_MAIN_TAB_DATA_NAVBAR_HPP
#define APP_BROWSER_MAIN_TAB_DATA_NAVBAR_HPP #define APP_BROWSER_MAIN_TAB_DATA_NAVBAR_HPP
#include <giomm/simpleactiongroup.h>
#include <glibmm/refptr.h>
#include <glibmm/ustring.h>
#include <gtkmm/box.h> #include <gtkmm/box.h>
#include <sigc++/functors/mem_fun.h>
namespace app::browser::main::tab::data namespace app::browser::main::tab::data
{ {
@ -18,9 +22,8 @@ namespace app::browser::main::tab::data
{ {
private: private:
// Defaults // Actions
const int SPACING = 8; Glib::RefPtr<Gio::SimpleActionGroup> action_group;
const int MARGIN = 8;
// Components // Components
navbar::Base * base; navbar::Base * base;
@ -29,11 +32,20 @@ namespace app::browser::main::tab::data
navbar::Request * request; navbar::Request * request;
navbar::Update * update; navbar::Update * update;
// Defaults
const int SPACING = 8;
const int MARGIN = 8;
public: public:
Navbar(); Navbar();
~Navbar(); ~Navbar();
// Actions
void refresh();
// Getters
Glib::ustring get_request_value();
}; };
} }

6
src/app/browser/main/tab/data/navbar/request.cpp

@ -33,4 +33,8 @@ void Request::on_activate()
{} // @TODO {} // @TODO
void Request::on_change() void Request::on_change()
{} // @TODO {
activate_action(
"navbar.refresh"
);
}

Loading…
Cancel
Save