From bbc1046c2a299afd4a79420eb04ed17ae1aad3f0 Mon Sep 17 00:00:00 2001 From: yggverse Date: Thu, 12 Sep 2024 08:17:17 +0300 Subject: [PATCH] draft text container --- Makefile | 1 + po/POTFILES.in | 1 + src/app/browser/main/tab/page/content.cpp | 23 ++++++++-------- src/app/browser/main/tab/page/content.hpp | 4 +-- .../browser/main/tab/page/content/text.cpp | 26 +++++++++++++++++++ .../browser/main/tab/page/content/text.hpp | 25 ++++++++++++++++++ .../main/tab/page/content/text/gemini.cpp | 4 +-- .../main/tab/page/content/text/gemini.hpp | 2 +- .../main/tab/page/content/text/plain.cpp | 4 +-- .../main/tab/page/content/text/plain.hpp | 2 +- 10 files changed, 72 insertions(+), 20 deletions(-) create mode 100644 src/app/browser/main/tab/page/content/text.cpp create mode 100644 src/app/browser/main/tab/page/content/text.hpp diff --git a/Makefile b/Makefile index 8bcd3c48..8524716d 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,7 @@ SRCS = src/app.cpp\ src/app/browser/main/tab.cpp\ src/app/browser/main/tab/page.cpp\ src/app/browser/main/tab/page/content.cpp\ + src/app/browser/main/tab/page/content/text.cpp\ src/app/browser/main/tab/page/content/text/gemini.cpp\ src/app/browser/main/tab/page/content/text/plain.cpp\ src/app/browser/main/tab/page/navigation.cpp\ diff --git a/po/POTFILES.in b/po/POTFILES.in index bf8a0156..bb18332d 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -12,6 +12,7 @@ src/app/browser/main.cpp src/app/browser/main/tab.cpp src/app/browser/main/tab/page.cpp src/app/browser/main/tab/page/content.cpp +src/app/browser/main/tab/page/content/text.cpp src/app/browser/main/tab/page/content/text/gemini.cpp src/app/browser/main/tab/page/content/text/plain.cpp src/app/browser/main/tab/page/navigation.cpp diff --git a/src/app/browser/main/tab/page/content.cpp b/src/app/browser/main/tab/page/content.cpp index 5cddaf2d..0f8a0375 100644 --- a/src/app/browser/main/tab/page/content.cpp +++ b/src/app/browser/main/tab/page/content.cpp @@ -1,6 +1,5 @@ #include "content.hpp" -#include "content/text/gemini.hpp" -#include "content/text/plain.hpp" +#include "content/text.hpp" using namespace app::browser::main::tab::page; @@ -24,23 +23,23 @@ Content::~Content() // Public actions void Content::set_text_gemini( - const Glib::ustring & gemtext + const Glib::ustring & GEMTEXT ) { + auto contentText = new content::Text; // @TODO manage + + contentText->set_gemini( + GEMTEXT + ); + set_widget( - new content::text::Gemini( - gemtext - ) + contentText ); } void Content::set_text_plain( - const Glib::ustring & text + const Glib::ustring & TEXT ) { - set_widget( - new content::text::Plain( - text - ) - ); + // @TODO } // @TODO text_plain, picture, video, etc. diff --git a/src/app/browser/main/tab/page/content.hpp b/src/app/browser/main/tab/page/content.hpp index 17322ba2..a6c50ad0 100644 --- a/src/app/browser/main/tab/page/content.hpp +++ b/src/app/browser/main/tab/page/content.hpp @@ -22,11 +22,11 @@ namespace app::browser::main::tab::page ~Content(); void set_text_gemini( - const Glib::ustring & gemtext + const Glib::ustring & GEMTEXT ); void set_text_plain( - const Glib::ustring & text + const Glib::ustring & TEXT ); }; } diff --git a/src/app/browser/main/tab/page/content/text.cpp b/src/app/browser/main/tab/page/content/text.cpp new file mode 100644 index 00000000..f1398d8b --- /dev/null +++ b/src/app/browser/main/tab/page/content/text.cpp @@ -0,0 +1,26 @@ +#include "text.hpp" +#include "text/gemini.hpp" +#include "text/plain.hpp" + +using namespace app::browser::main::tab::page::content; + +Text::Text() +{ + // @TODO GtkViewport? +} + +void Text::set_gemini( + const Glib::ustring & GEMTEXT +) { + set_child( + * new text::Gemini( // @TODO manage + GEMTEXT + ) + ); +} + +void Text::set_plain( + const Glib::ustring & TEXT +) { + // @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 new file mode 100644 index 00000000..ee3fe8cb --- /dev/null +++ b/src/app/browser/main/tab/page/content/text.hpp @@ -0,0 +1,25 @@ +#ifndef APP_BROWSER_MAIN_TAB_PAGE_CONTENT_TEXT_HPP +#define APP_BROWSER_MAIN_TAB_PAGE_CONTENT_TEXT_HPP + +#include +#include + +namespace app::browser::main::tab::page::content +{ + class Text : public Gtk::ScrolledWindow + { + public: + + Text(); + + void set_gemini( + const Glib::ustring & GEMTEXT + ); + + void set_plain( + const Glib::ustring & TEXT + ); + }; +} + +#endif // APP_BROWSER_MAIN_TAB_PAGE_CONTENT_TEXT_HPP \ No newline at end of file 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 365d2ef6..e5235b2e 100644 --- a/src/app/browser/main/tab/page/content/text/gemini.cpp +++ b/src/app/browser/main/tab/page/content/text/gemini.cpp @@ -3,7 +3,7 @@ using namespace app::browser::main::tab::page::content::text; Gemini::Gemini( - const Glib::ustring & gemtext + const Glib::ustring & GEMTEXT ) { set_wrap( true @@ -14,6 +14,6 @@ Gemini::Gemini( ); set_markup( - gemtext // @TODO + GEMTEXT // @TODO ); } \ 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 85b6fa87..aa6b56b1 100644 --- a/src/app/browser/main/tab/page/content/text/gemini.hpp +++ b/src/app/browser/main/tab/page/content/text/gemini.hpp @@ -11,7 +11,7 @@ namespace app::browser::main::tab::page::content::text public: Gemini( - const Glib::ustring & gemtext + const Glib::ustring & GEMTEXT ); }; } diff --git a/src/app/browser/main/tab/page/content/text/plain.cpp b/src/app/browser/main/tab/page/content/text/plain.cpp index 15555a9f..58347134 100644 --- a/src/app/browser/main/tab/page/content/text/plain.cpp +++ b/src/app/browser/main/tab/page/content/text/plain.cpp @@ -3,7 +3,7 @@ using namespace app::browser::main::tab::page::content::text; Plain::Plain( - const Glib::ustring & text + const Glib::ustring & TEXT ) { set_wrap( true @@ -14,6 +14,6 @@ Plain::Plain( ); set_text( - text + TEXT ); } \ No newline at end of file diff --git a/src/app/browser/main/tab/page/content/text/plain.hpp b/src/app/browser/main/tab/page/content/text/plain.hpp index bc666258..1deff1cb 100644 --- a/src/app/browser/main/tab/page/content/text/plain.hpp +++ b/src/app/browser/main/tab/page/content/text/plain.hpp @@ -11,7 +11,7 @@ namespace app::browser::main::tab::page::content::text public: Plain( - const Glib::ustring & text + const Glib::ustring & TEXT ); }; }