add text/plain content support

This commit is contained in:
yggverse 2024-08-18 15:32:31 +03:00
parent a73bb3aea6
commit 30e3ae691a
8 changed files with 66 additions and 2 deletions

View File

@ -15,6 +15,7 @@ SRCS = src/main.cpp\
src/app/browser/main/tab/page.cpp\
src/app/browser/main/tab/page/content.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/navbar.cpp\
src/app/browser/main/tab/page/navbar/base.cpp\
src/app/browser/main/tab/page/navbar/bookmark.cpp\

View File

@ -7,6 +7,7 @@ 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/gemini.cpp
src/app/browser/main/tab/page/content/text/plain.cpp
src/app/browser/main/tab/page/navbar.cpp
src/app/browser/main/tab/page/navbar/base.cpp
src/app/browser/main/tab/page/navbar/bookmark.cpp

View File

@ -120,13 +120,17 @@ void Page::update()
else
{
// @TODO exception
content->text_plain(
_("MIME type not supported")
);
}
}
else
{
// @TODO exception
content->text_plain(
_("Could not open page")
);
}
socket_connection->close();

View File

@ -7,6 +7,7 @@
#include <giomm/simpleactiongroup.h>
#include <giomm/socketclient.h>
#include <giomm/socketconnection.h>
#include <glibmm/i18n.h>
#include <glibmm/refptr.h>
#include <glibmm/regex.h>
#include <glibmm/ustring.h>

View File

@ -1,5 +1,6 @@
#include "content.hpp"
#include "content/text/gemini.hpp"
#include "content/text/plain.hpp"
using namespace app::browser::main::tab::page;
@ -32,6 +33,16 @@ void Content::text_gemini(
);
}
void Content::text_plain(
const Glib::ustring & text
) {
update(
new content::text::Plain(
text
)
);
}
// @TODO text_plain, picture, video, etc.
// Private helpers

View File

@ -24,6 +24,10 @@ namespace app::browser::main::tab::page
void text_gemini(
const Glib::ustring & gemtext
);
void text_plain(
const Glib::ustring & text
);
};
}

View File

@ -0,0 +1,21 @@
#include "plain.hpp"
using namespace app::browser::main::tab::page::content::text;
Plain::Plain(
const Glib::ustring & text
) {
set_wrap(
true
);
set_selectable(
true
);
set_text(
text
);
}
Plain::~Plain() = default;

View File

@ -0,0 +1,21 @@
#ifndef APP_BROWSER_MAIN_TAB_PAGE_CONTENT_TEXT_PLAIN_HPP
#define APP_BROWSER_MAIN_TAB_PAGE_CONTENT_TEXT_PLAIN_HPP
#include <glibmm/ustring.h>
#include <gtkmm/label.h>
namespace app::browser::main::tab::page::content::text
{
class Plain : public Gtk::Label
{
public:
Plain(
const Glib::ustring & text
);
~Plain();
};
}
#endif // APP_BROWSER_MAIN_TAB_PAGE_CONTENT_TEXT_PLAIN_HPP