mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
implement base button action
This commit is contained in:
parent
9ea8fadd67
commit
893a9d92e1
5 changed files with 52 additions and 10 deletions
|
|
@ -62,6 +62,7 @@ Page::Page(
|
|||
this->db,
|
||||
ACTION__HISTORY_BACK,
|
||||
ACTION__HISTORY_FORWARD,
|
||||
ACTION__OPEN_LINK_VARIANT,
|
||||
ACTION__RELOAD,
|
||||
ACTION__UPDATE
|
||||
);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ Navigation::Navigation(
|
|||
sqlite3 * db,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_FORWARD,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__OPEN_LINK_VARIANT,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__RELOAD,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE
|
||||
) {
|
||||
|
|
@ -45,7 +46,9 @@ Navigation::Navigation(
|
|||
);
|
||||
|
||||
// Init components
|
||||
navigationBase = Gtk::make_managed<navigation::Base>();
|
||||
navigationBase = Gtk::make_managed<navigation::Base>(
|
||||
ACTION__OPEN_LINK_VARIANT
|
||||
);
|
||||
|
||||
append(
|
||||
* navigationBase
|
||||
|
|
|
|||
|
|
@ -82,10 +82,11 @@ namespace app::browser::main::tab::page
|
|||
|
||||
Navigation(
|
||||
sqlite3 * db,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_RELOAD
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_FORWARD,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__OPEN_LINK_VARIANT,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__RELOAD,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE
|
||||
);
|
||||
|
||||
// Actions
|
||||
|
|
|
|||
|
|
@ -2,8 +2,13 @@
|
|||
|
||||
using namespace app::browser::main::tab::page::navigation;
|
||||
|
||||
Base::Base()
|
||||
{
|
||||
Base::Base(
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__OPEN_LINK_VARIANT
|
||||
) {
|
||||
// Init shared actions
|
||||
action__open_link_variant = ACTION__OPEN_LINK_VARIANT;
|
||||
|
||||
// Init widget
|
||||
set_icon_name(
|
||||
"go-home-symbolic"
|
||||
);
|
||||
|
|
@ -16,13 +21,29 @@ Base::Base()
|
|||
false
|
||||
);
|
||||
|
||||
// @TODO add action
|
||||
// Init events
|
||||
signal_clicked().connect(
|
||||
[this]
|
||||
{
|
||||
// Currently, there is
|
||||
action__open_link_variant->activate_variant(
|
||||
Glib::Variant<Glib::ustring>::create(
|
||||
Glib::ustring::sprintf(
|
||||
"%s://%s/",
|
||||
g_uri_get_scheme(uri), // @TODO NULL validate?
|
||||
g_uri_get_host(uri)
|
||||
) // at this moment, there is no G_URI_HIDE_*HOST option for g_uri_to_string_partial,
|
||||
// build address manually using sprintf @TODO
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void Base::update(
|
||||
const Glib::ustring & URI
|
||||
) {
|
||||
GUri * uri = g_uri_parse(
|
||||
uri = g_uri_parse(
|
||||
URI.c_str(),
|
||||
G_URI_FLAGS_NONE,
|
||||
NULL // @TODO GError *
|
||||
|
|
|
|||
|
|
@ -1,17 +1,33 @@
|
|||
#ifndef APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_BASE_HPP
|
||||
#define APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_BASE_HPP
|
||||
|
||||
#include <giomm/simpleaction.h>
|
||||
#include <glib.h>
|
||||
#include <glibmm/i18n.h>
|
||||
#include <glibmm/ustring.h>
|
||||
#include <gtkmm/button.h>
|
||||
|
||||
namespace app::browser::main::tab::page::navigation
|
||||
{
|
||||
class Base : public Gtk::Button
|
||||
{
|
||||
/*
|
||||
* Internal members
|
||||
*/
|
||||
Glib::RefPtr<Gio::SimpleAction> action__open_link_variant;
|
||||
|
||||
GUri * uri;
|
||||
|
||||
/*
|
||||
* Base class API
|
||||
*/
|
||||
public:
|
||||
|
||||
Base();
|
||||
Base(
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__OPEN_LINK_VARIANT
|
||||
);
|
||||
|
||||
// Actions
|
||||
void update(
|
||||
const Glib::ustring & URI
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue