Browse Source

update viewport level, make managed

CPP-GTK4
yggverse 2 months ago
parent
commit
b71eec6944
  1. 39
      src/app/browser/main/tab/page/content/text.cpp
  2. 12
      src/app/browser/main/tab/page/content/text.hpp
  3. 37
      src/app/browser/main/tab/page/content/text/gemini.cpp
  4. 5
      src/app/browser/main/tab/page/content/text/gemini.hpp

39
src/app/browser/main/tab/page/content/text.cpp

@ -1,6 +1,6 @@ @@ -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( @@ -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<text::Gemini>(
VALUE
)
);
break;
@ -47,16 +30,4 @@ Text::Text( @@ -47,16 +30,4 @@ Text::Text(
throw _("Invalid text type enum"); // @TODO
}
set_child(
* viewport
);
}
Text::~Text()
{
delete textGemini;
delete textPlain;
// @TODO
}

12
src/app/browser/main/tab/page/content/text.hpp

@ -5,21 +5,11 @@ @@ -5,21 +5,11 @@
#include <glibmm/i18n.h>
#include <glibmm/ustring.h>
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/viewport.h>
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 @@ -32,8 +22,6 @@ namespace app::browser::main::tab::page::content
const Type & TYPE,
const Glib::ustring & VALUE
);
~Text();
};
}

37
src/app/browser/main/tab/page/content/text/gemini.cpp

@ -4,25 +4,36 @@ using namespace app::browser::main::tab::page::content::text; @@ -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<Gtk::Label>( // @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
);
}

5
src/app/browser/main/tab/page/content/text/gemini.hpp

@ -4,13 +4,12 @@ @@ -4,13 +4,12 @@
#include <glibmm/regex.h>
#include <glibmm/ustring.h>
#include <gtkmm/label.h>
#include <gtkmm/viewport.h>
namespace app::browser::main::tab::page::content::text
{
class Gemini : public Gtk::Label
class Gemini : public Gtk::Viewport
{
Glib::ustring markup;
public:
Gemini(

Loading…
Cancel
Save