Browse Source

init navbar actions

CPP-GTK4
yggverse 5 months ago
parent
commit
d95b85932f
  1. 25
      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

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

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

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

@ -34,7 +34,7 @@ Navbar::Navbar() @@ -34,7 +34,7 @@ Navbar::Navbar()
MARGIN
);
// Init elements
// Init components
base = new navbar::Base();
append(
@ -64,6 +64,38 @@ Navbar::Navbar() @@ -64,6 +64,38 @@ Navbar::Navbar()
append(
* 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;
// 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 @@ @@ -1,7 +1,11 @@
#ifndef 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 <sigc++/functors/mem_fun.h>
namespace app::browser::main::tab::data
{
@ -18,9 +22,8 @@ namespace app::browser::main::tab::data @@ -18,9 +22,8 @@ namespace app::browser::main::tab::data
{
private:
// Defaults
const int SPACING = 8;
const int MARGIN = 8;
// Actions
Glib::RefPtr<Gio::SimpleActionGroup> action_group;
// Components
navbar::Base * base;
@ -29,11 +32,20 @@ namespace app::browser::main::tab::data @@ -29,11 +32,20 @@ namespace app::browser::main::tab::data
navbar::Request * request;
navbar::Update * update;
// Defaults
const int SPACING = 8;
const int MARGIN = 8;
public:
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() @@ -33,4 +33,8 @@ void Request::on_activate()
{} // @TODO
void Request::on_change()
{} // @TODO
{
activate_action(
"navbar.refresh"
);
}

Loading…
Cancel
Save