From b71eec6944b6173740dccc9ad9bb20d716ff45c6 Mon Sep 17 00:00:00 2001 From: yggverse Date: Fri, 13 Sep 2024 12:31:14 +0300 Subject: [PATCH] update viewport level, make managed --- .../browser/main/tab/page/content/text.cpp | 39 +++---------------- .../browser/main/tab/page/content/text.hpp | 12 ------ .../main/tab/page/content/text/gemini.cpp | 37 +++++++++++------- .../main/tab/page/content/text/gemini.hpp | 5 +-- 4 files changed, 31 insertions(+), 62 deletions(-) diff --git a/src/app/browser/main/tab/page/content/text.cpp b/src/app/browser/main/tab/page/content/text.cpp index 82fc9b8e..29f6e966 100644 --- a/src/app/browser/main/tab/page/content/text.cpp +++ b/src/app/browser/main/tab/page/content/text.cpp @@ -1,6 +1,6 @@ #include "text.hpp" #include "text/gemini.hpp" -#include "text/plain.hpp" +// #include "text/plain.hpp" @TODO using namespace app::browser::main::tab::page::content; @@ -8,31 +8,14 @@ Text::Text( const Type & TYPE, const Glib::ustring & VALUE ) { - // Init components - textGemini = nullptr; - textPlain = nullptr; - - // GtkLabel does not support ScrolledWindow features, create GtkViewport - auto viewport = new Gtk::Viewport( // @TODO manage - NULL, //Gtk::Adjustment::H - NULL //Gtk::Adjustment::V - ); // @TODO manage, optimize - - viewport->set_scroll_to_focus( - false - ); - - // Detect text driver by text type requested switch (TYPE) { case GEMINI: - textGemini = new text::Gemini( - VALUE - ); - - viewport->set_child( - * textGemini + set_child( + * Gtk::make_managed( + VALUE + ) ); break; @@ -47,16 +30,4 @@ Text::Text( throw _("Invalid text type enum"); // @TODO } - - set_child( - * viewport - ); -} - -Text::~Text() -{ - delete textGemini; - delete textPlain; - - // @TODO } \ No newline at end of file diff --git a/src/app/browser/main/tab/page/content/text.hpp b/src/app/browser/main/tab/page/content/text.hpp index 1d0c3bf4..33217f20 100644 --- a/src/app/browser/main/tab/page/content/text.hpp +++ b/src/app/browser/main/tab/page/content/text.hpp @@ -5,21 +5,11 @@ #include #include #include -#include namespace app::browser::main::tab::page::content { - namespace text - { - class Gemini; - class Plain; - } - class Text : public Gtk::ScrolledWindow { - text::Gemini * textGemini; - text::Plain * textPlain; - public: enum Type @@ -32,8 +22,6 @@ namespace app::browser::main::tab::page::content const Type & TYPE, const Glib::ustring & VALUE ); - - ~Text(); }; } diff --git a/src/app/browser/main/tab/page/content/text/gemini.cpp b/src/app/browser/main/tab/page/content/text/gemini.cpp index d5572f7a..b4c1a530 100644 --- a/src/app/browser/main/tab/page/content/text/gemini.cpp +++ b/src/app/browser/main/tab/page/content/text/gemini.cpp @@ -4,25 +4,36 @@ using namespace app::browser::main::tab::page::content::text; Gemini::Gemini( const Glib::ustring & GEMTEXT +) : Gtk::Viewport( // add scrolled window features support + NULL, + NULL ) { - // Init widget - set_valign( - Gtk::Align::START + set_scroll_to_focus( + false ); - set_wrap( - true + auto label = Gtk::make_managed( // @TODO separated file? + GEMTEXT ); - set_selectable( - true - ); + // Init widget + label->set_valign( + Gtk::Align::START + ); - set_use_markup( - true - ); + label->set_wrap( + true + ); + + label->set_selectable( + true + ); + + label->set_use_markup( + true + ); - set_markup( - GEMTEXT//markup + set_child( + * label ); } \ No newline at end of file diff --git a/src/app/browser/main/tab/page/content/text/gemini.hpp b/src/app/browser/main/tab/page/content/text/gemini.hpp index e317888c..767c734f 100644 --- a/src/app/browser/main/tab/page/content/text/gemini.hpp +++ b/src/app/browser/main/tab/page/content/text/gemini.hpp @@ -4,13 +4,12 @@ #include #include #include +#include namespace app::browser::main::tab::page::content::text { - class Gemini : public Gtk::Label + class Gemini : public Gtk::Viewport { - Glib::ustring markup; - public: Gemini(