Browse Source

add text/plain content support

CPP-GTK4
yggverse 4 months ago
parent
commit
30e3ae691a
  1. 1
      Makefile
  2. 1
      po/POTFILES.in
  3. 8
      src/app/browser/main/tab/page.cpp
  4. 1
      src/app/browser/main/tab/page.hpp
  5. 11
      src/app/browser/main/tab/page/content.cpp
  6. 4
      src/app/browser/main/tab/page/content.hpp
  7. 21
      src/app/browser/main/tab/page/content/text/plain.cpp
  8. 21
      src/app/browser/main/tab/page/content/text/plain.hpp

1
Makefile

@ -15,6 +15,7 @@ SRCS = src/main.cpp\ @@ -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\

1
po/POTFILES.in

@ -7,6 +7,7 @@ src/app/browser/main/tab.cpp @@ -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

8
src/app/browser/main/tab/page.cpp

@ -120,13 +120,17 @@ void Page::update() @@ -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();

1
src/app/browser/main/tab/page.hpp

@ -7,6 +7,7 @@ @@ -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>

11
src/app/browser/main/tab/page/content.cpp

@ -1,5 +1,6 @@ @@ -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( @@ -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

4
src/app/browser/main/tab/page/content.hpp

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

21
src/app/browser/main/tab/page/content/text/plain.cpp

@ -0,0 +1,21 @@ @@ -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;

21
src/app/browser/main/tab/page/content/text/plain.hpp

@ -0,0 +1,21 @@ @@ -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
Loading…
Cancel
Save