From 39ed3edbb90eec2f247e04a38aba5ed6f8987498 Mon Sep 17 00:00:00 2001 From: yggverse Date: Sun, 15 Sep 2024 13:09:18 +0300 Subject: [PATCH] draft local action group for page links navigation --- src/app/browser.cpp | 21 -------------- src/app/browser/main/tab/page.cpp | 29 +++++++++++++++++++ src/app/browser/main/tab/page.hpp | 1 + .../tab/page/content/text/gemini/reader.cpp | 2 +- 4 files changed, 31 insertions(+), 22 deletions(-) diff --git a/src/app/browser.cpp b/src/app/browser.cpp index aba23989..7c2497d2 100644 --- a/src/app/browser.cpp +++ b/src/app/browser.cpp @@ -26,27 +26,6 @@ Browser::Browser( } ); - add_action_with_parameter( - "open", - Glib::VARIANT_TYPE_STRING, - [this](const Glib::VariantBase & PARAMETER) - { - if (PARAMETER.is_of_type(Glib::VARIANT_TYPE_STRING)) - { - browserMain->update( - Glib::VariantBase::cast_dynamic>( - PARAMETER - ).get() - ); - - browserHeader->update( - browserMain->get_tab_page_title(), - browserMain->get_tab_page_description() - ); - } - } - ); - const auto ACTION__SESSION_CLEAN = add_action( "session_clean", [this] diff --git a/src/app/browser/main/tab/page.cpp b/src/app/browser/main/tab/page.cpp index 1d372265..0a6d636f 100644 --- a/src/app/browser/main/tab/page.cpp +++ b/src/app/browser/main/tab/page.cpp @@ -52,6 +52,35 @@ Page::Page( * 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>( + PARAMETER + ).get() + ); + + navigation_reload( + true + ); + } + } + ); + + insert_action_group( + "page", + GioSimpleActionGroup + ); + // Connect events /* activated twice on tab change @TODO signal_realize().connect( diff --git a/src/app/browser/main/tab/page.hpp b/src/app/browser/main/tab/page.hpp index 17a77f2d..bacc904a 100644 --- a/src/app/browser/main/tab/page.hpp +++ b/src/app/browser/main/tab/page.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/src/app/browser/main/tab/page/content/text/gemini/reader.cpp b/src/app/browser/main/tab/page/content/text/gemini/reader.cpp index e3654bba..ab0ceef4 100644 --- a/src/app/browser/main/tab/page/content/text/gemini/reader.cpp +++ b/src/app/browser/main/tab/page/content/text/gemini/reader.cpp @@ -126,7 +126,7 @@ Reader::Reader( if (SCHEME == NULL || SCHEME == Glib::ustring("gemini")) { return activate_action( - "win.open", // @TODO + "page.open", // @TODO use action argument Glib::Variant::create( URI )