mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
update content container init by type
This commit is contained in:
parent
d5ce67fbec
commit
afa4261b0e
7 changed files with 131 additions and 75 deletions
|
|
@ -319,7 +319,8 @@ void Page::navigation_reload(
|
||||||
progress_fraction = 1;
|
progress_fraction = 1;
|
||||||
|
|
||||||
// Set content driver
|
// Set content driver
|
||||||
pageContent->set_text_gemini( // @TODO
|
pageContent->update(
|
||||||
|
page::Content::MIME::TEXT_GEMINI,
|
||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ using namespace app::browser::main::tab::page;
|
||||||
|
|
||||||
Content::Content()
|
Content::Content()
|
||||||
{
|
{
|
||||||
|
// Init widget
|
||||||
set_orientation(
|
set_orientation(
|
||||||
Gtk::Orientation::VERTICAL
|
Gtk::Orientation::VERTICAL
|
||||||
);
|
);
|
||||||
|
|
@ -21,53 +22,56 @@ Content::Content()
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
widget = nullptr;
|
// Init child types
|
||||||
|
contentText = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Content::~Content()
|
Content::~Content()
|
||||||
{
|
{
|
||||||
delete widget;
|
delete contentText;
|
||||||
};
|
|
||||||
|
|
||||||
// Public actions
|
|
||||||
void Content::set_text_gemini(
|
|
||||||
const Glib::ustring & GEMTEXT
|
|
||||||
) {
|
|
||||||
auto contentText = new content::Text; // @TODO manage
|
|
||||||
|
|
||||||
contentText->set_gemini(
|
|
||||||
GEMTEXT
|
|
||||||
);
|
|
||||||
|
|
||||||
set_widget(
|
|
||||||
contentText
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Content::set_text_plain(
|
// Setters
|
||||||
const Glib::ustring & TEXT
|
void Content::update(
|
||||||
|
const MIME & MIME,
|
||||||
|
const Glib::ustring & DATA
|
||||||
) {
|
) {
|
||||||
// @TODO
|
// Cleanup, free memory
|
||||||
}
|
if (contentText != nullptr)
|
||||||
|
|
||||||
// @TODO text_plain, picture, video, etc.
|
|
||||||
|
|
||||||
// Private helpers
|
|
||||||
void Content::set_widget(
|
|
||||||
Gtk::Widget * object
|
|
||||||
) {
|
|
||||||
if (widget != nullptr)
|
|
||||||
{
|
{
|
||||||
remove(
|
remove(
|
||||||
* widget
|
* contentText
|
||||||
);
|
);
|
||||||
|
|
||||||
delete widget;
|
delete contentText;
|
||||||
|
|
||||||
|
contentText = nullptr;
|
||||||
|
} // @TODO other types..
|
||||||
|
|
||||||
|
// Create new content widget for MIME type requested
|
||||||
|
switch (MIME)
|
||||||
|
{
|
||||||
|
case MIME::TEXT_GEMINI:
|
||||||
|
|
||||||
|
contentText = new content::Text(
|
||||||
|
content::Text::Type::GEMINI,
|
||||||
|
DATA
|
||||||
|
);
|
||||||
|
|
||||||
|
append(
|
||||||
|
* contentText
|
||||||
|
);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MIME::TEXT_PLAIN:
|
||||||
|
|
||||||
|
// @TODO
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
|
||||||
|
throw _("Invalid content MIME type");
|
||||||
}
|
}
|
||||||
|
|
||||||
widget = object;
|
|
||||||
|
|
||||||
append(
|
|
||||||
* widget
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
@ -7,26 +7,38 @@
|
||||||
|
|
||||||
namespace app::browser::main::tab::page
|
namespace app::browser::main::tab::page
|
||||||
{
|
{
|
||||||
|
namespace content
|
||||||
|
{
|
||||||
|
class Text;
|
||||||
|
}
|
||||||
|
|
||||||
class Content : public Gtk::Box
|
class Content : public Gtk::Box
|
||||||
{
|
{
|
||||||
Gtk::Widget * widget;
|
/*
|
||||||
|
* Internal members
|
||||||
|
*/
|
||||||
|
private:
|
||||||
|
|
||||||
void set_widget(
|
// Components
|
||||||
Gtk::Widget * object
|
content::Text * contentText;
|
||||||
);
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class API
|
||||||
|
*/
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Content();
|
enum MIME
|
||||||
|
{
|
||||||
|
TEXT_GEMINI,
|
||||||
|
TEXT_PLAIN
|
||||||
|
};
|
||||||
|
|
||||||
|
Content();
|
||||||
~Content();
|
~Content();
|
||||||
|
|
||||||
void set_text_gemini(
|
void update(
|
||||||
const Glib::ustring & GEMTEXT
|
const MIME & MIME,
|
||||||
);
|
const Glib::ustring & DATA
|
||||||
|
|
||||||
void set_text_plain(
|
|
||||||
const Glib::ustring & TEXT
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,36 +4,59 @@
|
||||||
|
|
||||||
using namespace app::browser::main::tab::page::content;
|
using namespace app::browser::main::tab::page::content;
|
||||||
|
|
||||||
Text::Text()
|
Text::Text(
|
||||||
{
|
const Type & TYPE,
|
||||||
// @TODO GtkViewport?
|
const Glib::ustring & VALUE
|
||||||
}
|
|
||||||
|
|
||||||
void Text::set_gemini(
|
|
||||||
const Glib::ustring & GEMTEXT
|
|
||||||
) {
|
) {
|
||||||
auto viewport = new Gtk::Viewport( // @TODO
|
// 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::H
|
||||||
NULL //Gtk::Adjustment::V
|
NULL //Gtk::Adjustment::V
|
||||||
);
|
); // @TODO manage, optimize
|
||||||
|
|
||||||
viewport->set_scroll_to_focus(
|
viewport->set_scroll_to_focus(
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
viewport->set_child(
|
// Detect text driver by text type requested
|
||||||
* new text::Gemini( // @TODO manage
|
switch (TYPE)
|
||||||
GEMTEXT
|
{
|
||||||
)
|
case GEMINI:
|
||||||
);
|
|
||||||
|
textGemini = new text::Gemini(
|
||||||
|
VALUE
|
||||||
|
);
|
||||||
|
|
||||||
|
viewport->set_child(
|
||||||
|
* textGemini
|
||||||
|
);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PLAIN:
|
||||||
|
|
||||||
|
// @TODO
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
|
||||||
|
throw _("Invalid text type enum"); // @TODO
|
||||||
|
}
|
||||||
|
|
||||||
set_child(
|
set_child(
|
||||||
* viewport
|
* viewport
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Text::set_plain(
|
Text::~Text()
|
||||||
const Glib::ustring & TEXT
|
{
|
||||||
) {
|
delete textGemini;
|
||||||
|
delete textPlain;
|
||||||
|
|
||||||
// @TODO
|
// @TODO
|
||||||
}
|
}
|
||||||
|
|
@ -1,26 +1,39 @@
|
||||||
#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 <glibmm/ustring.h>
|
|
||||||
//#include <gtkmm/adjustment.h> @TODO
|
//#include <gtkmm/adjustment.h> @TODO
|
||||||
|
#include <glibmm/i18n.h>
|
||||||
|
#include <glibmm/ustring.h>
|
||||||
#include <gtkmm/scrolledwindow.h>
|
#include <gtkmm/scrolledwindow.h>
|
||||||
#include <gtkmm/viewport.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:
|
||||||
|
|
||||||
Text();
|
enum Type
|
||||||
|
{
|
||||||
|
GEMINI,
|
||||||
|
PLAIN
|
||||||
|
};
|
||||||
|
|
||||||
void set_gemini(
|
Text(
|
||||||
const Glib::ustring & GEMTEXT
|
const Type & TYPE,
|
||||||
|
const Glib::ustring & VALUE
|
||||||
);
|
);
|
||||||
|
|
||||||
void set_plain(
|
~Text();
|
||||||
const Glib::ustring & TEXT
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ using namespace app::browser::main::tab::page::content::text;
|
||||||
Gemini::Gemini(
|
Gemini::Gemini(
|
||||||
const Glib::ustring & GEMTEXT
|
const Glib::ustring & GEMTEXT
|
||||||
) {
|
) {
|
||||||
|
// Init widget
|
||||||
set_valign(
|
set_valign(
|
||||||
Gtk::Align::START
|
Gtk::Align::START
|
||||||
);
|
);
|
||||||
|
|
@ -22,6 +23,6 @@ Gemini::Gemini(
|
||||||
);
|
);
|
||||||
|
|
||||||
set_markup(
|
set_markup(
|
||||||
GEMTEXT // @TODO
|
GEMTEXT//markup
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -1,14 +1,16 @@
|
||||||
#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 <glibmm/regex.h>
|
||||||
#include <glibmm/ustring.h>
|
#include <glibmm/ustring.h>
|
||||||
#include <gtkmm/enums.h>
|
|
||||||
#include <gtkmm/label.h>
|
#include <gtkmm/label.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::Label
|
||||||
{
|
{
|
||||||
|
Glib::ustring markup;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Gemini(
|
Gemini(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue