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 @@
#include "text.hpp" #include "text.hpp"
#include "text/gemini.hpp" #include "text/gemini.hpp"
#include "text/plain.hpp" // #include "text/plain.hpp" @TODO
using namespace app::browser::main::tab::page::content; using namespace app::browser::main::tab::page::content;
@ -8,31 +8,14 @@ Text::Text(
const Type & TYPE, const Type & TYPE,
const Glib::ustring & VALUE 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) switch (TYPE)
{ {
case GEMINI: case GEMINI:
textGemini = new text::Gemini( set_child(
VALUE * Gtk::make_managed<text::Gemini>(
); VALUE
)
viewport->set_child(
* textGemini
); );
break; break;
@ -47,16 +30,4 @@ Text::Text(
throw _("Invalid text type enum"); // @TODO 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 @@
#include <glibmm/i18n.h> #include <glibmm/i18n.h>
#include <glibmm/ustring.h> #include <glibmm/ustring.h>
#include <gtkmm/scrolledwindow.h> #include <gtkmm/scrolledwindow.h>
#include <gtkmm/viewport.h>
namespace app::browser::main::tab::page::content namespace app::browser::main::tab::page::content
{ {
namespace text
{
class Gemini;
class Plain;
}
class Text : public Gtk::ScrolledWindow class Text : public Gtk::ScrolledWindow
{ {
text::Gemini * textGemini;
text::Plain * textPlain;
public: public:
enum Type enum Type
@ -32,8 +22,6 @@ namespace app::browser::main::tab::page::content
const Type & TYPE, const Type & TYPE,
const Glib::ustring & VALUE 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;
Gemini::Gemini( Gemini::Gemini(
const Glib::ustring & GEMTEXT const Glib::ustring & GEMTEXT
) : Gtk::Viewport( // add scrolled window features support
NULL,
NULL
) { ) {
// Init widget set_scroll_to_focus(
set_valign( false
Gtk::Align::START
); );
set_wrap( auto label = Gtk::make_managed<Gtk::Label>( // @TODO separated file?
true GEMTEXT
); );
set_selectable( // Init widget
true label->set_valign(
); Gtk::Align::START
);
set_use_markup( label->set_wrap(
true true
); );
label->set_selectable(
true
);
label->set_use_markup(
true
);
set_markup( set_child(
GEMTEXT//markup * label
); );
} }

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

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

Loading…
Cancel
Save