mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
use open_link_variant action
This commit is contained in:
parent
0a75ca7671
commit
18c16e9e95
9 changed files with 68 additions and 35 deletions
|
|
@ -24,7 +24,35 @@ Page::Page(
|
||||||
// Init shared actions
|
// Init shared actions
|
||||||
action__update = ACTION__UPDATE;
|
action__update = ACTION__UPDATE;
|
||||||
|
|
||||||
|
// Init additional local action group (for clickable content)
|
||||||
|
const auto ACTION_GROUP__PAGE = Gio::SimpleActionGroup::create();
|
||||||
|
|
||||||
|
const auto ACTION__OPEN_LINK_VARIANT = ACTION_GROUP__PAGE->add_action_with_parameter(
|
||||||
|
"open_link_variant",
|
||||||
|
Glib::VARIANT_TYPE_STRING,
|
||||||
|
[this](const Glib::VariantBase & PARAMETER)
|
||||||
|
{
|
||||||
|
if (PARAMETER.is_of_type(Glib::VARIANT_TYPE_STRING))
|
||||||
|
{
|
||||||
|
pageNavigation->set_request_text(
|
||||||
|
Glib::VariantBase::cast_dynamic<Glib::Variant<Glib::ustring>>(
|
||||||
|
PARAMETER
|
||||||
|
).get()
|
||||||
|
);
|
||||||
|
|
||||||
|
navigation_reload(
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// Init widget
|
// Init widget
|
||||||
|
insert_action_group(
|
||||||
|
"page",
|
||||||
|
ACTION_GROUP__PAGE
|
||||||
|
);
|
||||||
|
|
||||||
set_orientation(
|
set_orientation(
|
||||||
Gtk::Orientation::VERTICAL
|
Gtk::Orientation::VERTICAL
|
||||||
);
|
);
|
||||||
|
|
@ -42,41 +70,14 @@ Page::Page(
|
||||||
* pageNavigation
|
* pageNavigation
|
||||||
);
|
);
|
||||||
|
|
||||||
pageContent = Gtk::make_managed<page::Content>();
|
pageContent = Gtk::make_managed<page::Content>(
|
||||||
|
ACTION__OPEN_LINK_VARIANT
|
||||||
|
);
|
||||||
|
|
||||||
append(
|
append(
|
||||||
* pageContent
|
* pageContent
|
||||||
);
|
);
|
||||||
|
|
||||||
// Init widget action group @TODO
|
|
||||||
auto GioSimpleActionGroup = Gio::SimpleActionGroup::create();
|
|
||||||
|
|
||||||
// Define group actions
|
|
||||||
GioSimpleActionGroup->add_action_with_parameter(
|
|
||||||
"open",
|
|
||||||
Glib::VARIANT_TYPE_STRING,
|
|
||||||
[this](const Glib::VariantBase & PARAMETER)
|
|
||||||
{
|
|
||||||
if (PARAMETER.is_of_type(Glib::VARIANT_TYPE_STRING))
|
|
||||||
{
|
|
||||||
pageNavigation->set_request_text(
|
|
||||||
Glib::VariantBase::cast_dynamic<Glib::Variant<Glib::ustring>>(
|
|
||||||
PARAMETER
|
|
||||||
).get()
|
|
||||||
);
|
|
||||||
|
|
||||||
navigation_reload(
|
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
insert_action_group(
|
|
||||||
"page",
|
|
||||||
GioSimpleActionGroup
|
|
||||||
);
|
|
||||||
|
|
||||||
// Connect events
|
// Connect events
|
||||||
/* activated twice on tab change @TODO
|
/* activated twice on tab change @TODO
|
||||||
signal_realize().connect(
|
signal_realize().connect(
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,12 @@
|
||||||
|
|
||||||
using namespace app::browser::main::tab::page;
|
using namespace app::browser::main::tab::page;
|
||||||
|
|
||||||
Content::Content()
|
Content::Content(
|
||||||
{
|
const Glib::RefPtr<Gio::SimpleAction> & ACTION__OPEN_LINK_VARIANT
|
||||||
|
) {
|
||||||
|
// Init actions
|
||||||
|
action__open_link_variant = ACTION__OPEN_LINK_VARIANT;
|
||||||
|
|
||||||
// Init widget
|
// Init widget
|
||||||
set_orientation(
|
set_orientation(
|
||||||
Gtk::Orientation::VERTICAL
|
Gtk::Orientation::VERTICAL
|
||||||
|
|
@ -63,6 +67,7 @@ void Content::update(
|
||||||
case MIME::TEXT_GEMINI:
|
case MIME::TEXT_GEMINI:
|
||||||
|
|
||||||
contentText = new content::Text(
|
contentText = new content::Text(
|
||||||
|
action__open_link_variant,
|
||||||
content::Text::Type::GEMINI,
|
content::Text::Type::GEMINI,
|
||||||
SOURCE,
|
SOURCE,
|
||||||
uri
|
uri
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef APP_BROWSER_MAIN_TAB_PAGE_CONTENT_HPP
|
#ifndef APP_BROWSER_MAIN_TAB_PAGE_CONTENT_HPP
|
||||||
#define APP_BROWSER_MAIN_TAB_PAGE_CONTENT_HPP
|
#define APP_BROWSER_MAIN_TAB_PAGE_CONTENT_HPP
|
||||||
|
|
||||||
|
#include <giomm/simpleaction.h>
|
||||||
#include <glibmm/ustring.h>
|
#include <glibmm/ustring.h>
|
||||||
#include <gtkmm/box.h>
|
#include <gtkmm/box.h>
|
||||||
#include <gtkmm/enums.h>
|
#include <gtkmm/enums.h>
|
||||||
|
|
@ -19,6 +20,9 @@ namespace app::browser::main::tab::page
|
||||||
*/
|
*/
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
// Actions
|
||||||
|
Glib::RefPtr<Gio::SimpleAction> action__open_link_variant;
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
content::Text * contentText;
|
content::Text * contentText;
|
||||||
|
|
||||||
|
|
@ -36,7 +40,10 @@ namespace app::browser::main::tab::page
|
||||||
TEXT_PLAIN
|
TEXT_PLAIN
|
||||||
};
|
};
|
||||||
|
|
||||||
Content();
|
Content(
|
||||||
|
const Glib::RefPtr<Gio::SimpleAction> & ACTION__OPEN_LINK_VARIANT
|
||||||
|
);
|
||||||
|
|
||||||
~Content();
|
~Content();
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
using namespace app::browser::main::tab::page::content;
|
using namespace app::browser::main::tab::page::content;
|
||||||
|
|
||||||
Text::Text(
|
Text::Text(
|
||||||
|
const Glib::RefPtr<Gio::SimpleAction> & ACTION__OPEN_LINK_VARIANT,
|
||||||
const Type & TYPE,
|
const Type & TYPE,
|
||||||
const Glib::ustring & SOURCE,
|
const Glib::ustring & SOURCE,
|
||||||
GUri * uri
|
GUri * uri
|
||||||
|
|
@ -15,6 +16,7 @@ Text::Text(
|
||||||
|
|
||||||
set_child(
|
set_child(
|
||||||
* Gtk::make_managed<text::Gemini>(
|
* Gtk::make_managed<text::Gemini>(
|
||||||
|
ACTION__OPEN_LINK_VARIANT,
|
||||||
SOURCE,
|
SOURCE,
|
||||||
title,
|
title,
|
||||||
uri
|
uri
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef APP_BROWSER_MAIN_TAB_PAGE_CONTENT_TEXT_HPP
|
#ifndef APP_BROWSER_MAIN_TAB_PAGE_CONTENT_TEXT_HPP
|
||||||
#define APP_BROWSER_MAIN_TAB_PAGE_CONTENT_TEXT_HPP
|
#define APP_BROWSER_MAIN_TAB_PAGE_CONTENT_TEXT_HPP
|
||||||
|
|
||||||
|
#include <giomm/simpleaction.h>
|
||||||
#include <glibmm/i18n.h>
|
#include <glibmm/i18n.h>
|
||||||
#include <glibmm/ustring.h>
|
#include <glibmm/ustring.h>
|
||||||
#include <gtkmm/scrolledwindow.h>
|
#include <gtkmm/scrolledwindow.h>
|
||||||
|
|
@ -29,6 +30,7 @@ namespace app::browser::main::tab::page::content
|
||||||
* Text class API
|
* Text class API
|
||||||
*/
|
*/
|
||||||
Text(
|
Text(
|
||||||
|
const Glib::RefPtr<Gio::SimpleAction> & ACTION__OPEN_LINK_VARIANT,
|
||||||
const Type & TYPE,
|
const Type & TYPE,
|
||||||
const Glib::ustring & SOURCE,
|
const Glib::ustring & SOURCE,
|
||||||
GUri * uri
|
GUri * uri
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
using namespace app::browser::main::tab::page::content::text;
|
using namespace app::browser::main::tab::page::content::text;
|
||||||
|
|
||||||
Gemini::Gemini(
|
Gemini::Gemini(
|
||||||
|
const Glib::RefPtr<Gio::SimpleAction> & ACTION__OPEN_LINK_VARIANT,
|
||||||
const Glib::ustring & GEMTEXT,
|
const Glib::ustring & GEMTEXT,
|
||||||
Glib::ustring & title,
|
Glib::ustring & title,
|
||||||
GUri * uri
|
GUri * uri
|
||||||
|
|
@ -18,6 +19,7 @@ Gemini::Gemini(
|
||||||
|
|
||||||
set_child(
|
set_child(
|
||||||
* Gtk::make_managed<gemini::Reader>(
|
* Gtk::make_managed<gemini::Reader>(
|
||||||
|
ACTION__OPEN_LINK_VARIANT,
|
||||||
GEMTEXT,
|
GEMTEXT,
|
||||||
title,
|
title,
|
||||||
uri
|
uri
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef APP_BROWSER_MAIN_TAB_PAGE_CONTENT_TEXT_GEMINI_HPP
|
#ifndef APP_BROWSER_MAIN_TAB_PAGE_CONTENT_TEXT_GEMINI_HPP
|
||||||
#define APP_BROWSER_MAIN_TAB_PAGE_CONTENT_TEXT_GEMINI_HPP
|
#define APP_BROWSER_MAIN_TAB_PAGE_CONTENT_TEXT_GEMINI_HPP
|
||||||
|
|
||||||
|
#include <giomm/simpleaction.h>
|
||||||
#include <glibmm/ustring.h>
|
#include <glibmm/ustring.h>
|
||||||
#include <gtkmm/viewport.h>
|
#include <gtkmm/viewport.h>
|
||||||
|
|
||||||
|
|
@ -14,6 +15,7 @@ namespace app::browser::main::tab::page::content::text
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Gemini(
|
Gemini(
|
||||||
|
const Glib::RefPtr<Gio::SimpleAction> & ACTION__OPEN_LINK_VARIANT,
|
||||||
const Glib::ustring & GEMTEXT,
|
const Glib::ustring & GEMTEXT,
|
||||||
Glib::ustring & title,
|
Glib::ustring & title,
|
||||||
GUri * uri
|
GUri * uri
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,14 @@
|
||||||
using namespace app::browser::main::tab::page::content::text::gemini;
|
using namespace app::browser::main::tab::page::content::text::gemini;
|
||||||
|
|
||||||
Reader::Reader(
|
Reader::Reader(
|
||||||
|
const Glib::RefPtr<Gio::SimpleAction> & ACTION__OPEN_LINK_VARIANT,
|
||||||
const Glib::ustring & GEMTEXT,
|
const Glib::ustring & GEMTEXT,
|
||||||
Glib::ustring & title,
|
Glib::ustring & title,
|
||||||
GUri * base
|
GUri * base
|
||||||
) {
|
) {
|
||||||
|
// Init shared actions
|
||||||
|
action__open_link_variant = ACTION__OPEN_LINK_VARIANT;
|
||||||
|
|
||||||
// Build markup
|
// Build markup
|
||||||
Glib::ustring markup;
|
Glib::ustring markup;
|
||||||
|
|
||||||
|
|
@ -125,12 +129,13 @@ Reader::Reader(
|
||||||
|
|
||||||
if (SCHEME == NULL || SCHEME == Glib::ustring("gemini"))
|
if (SCHEME == NULL || SCHEME == Glib::ustring("gemini"))
|
||||||
{
|
{
|
||||||
return activate_action(
|
action__open_link_variant->activate_variant(
|
||||||
"page.open", // @TODO use action argument
|
|
||||||
Glib::Variant<Glib::ustring>::create(
|
Glib::Variant<Glib::ustring>::create(
|
||||||
URI
|
URI
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false; // delegate unsupported URI to external application
|
return false; // delegate unsupported URI to external application
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef APP_BROWSER_MAIN_TAB_PAGE_CONTENT_TEXT_GEMINI_READER_HPP
|
#ifndef APP_BROWSER_MAIN_TAB_PAGE_CONTENT_TEXT_GEMINI_READER_HPP
|
||||||
#define APP_BROWSER_MAIN_TAB_PAGE_CONTENT_TEXT_GEMINI_READER_HPP
|
#define APP_BROWSER_MAIN_TAB_PAGE_CONTENT_TEXT_GEMINI_READER_HPP
|
||||||
|
|
||||||
|
#include <giomm/simpleaction.h>
|
||||||
#include <glibmm/i18n.h>
|
#include <glibmm/i18n.h>
|
||||||
#include <glibmm/markup.h>
|
#include <glibmm/markup.h>
|
||||||
#include <glibmm/regex.h>
|
#include <glibmm/regex.h>
|
||||||
|
|
@ -63,12 +64,18 @@ namespace app::browser::main::tab::page::content::text::gemini
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Internal members
|
||||||
|
*/
|
||||||
|
Glib::RefPtr<Gio::SimpleAction> action__open_link_variant;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reader class API
|
* Reader class API
|
||||||
*/
|
*/
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Reader(
|
Reader(
|
||||||
|
const Glib::RefPtr<Gio::SimpleAction> & ACTION__OPEN_LINK_VARIANT,
|
||||||
const Glib::ustring & GEMTEXT,
|
const Glib::ustring & GEMTEXT,
|
||||||
Glib::ustring & title,
|
Glib::ustring & title,
|
||||||
GUri * uri
|
GUri * uri
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue