[pan2] html preview
- From: Heinrich MÃller <henmull src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2] html preview
- Date: Mon, 1 Oct 2012 21:12:14 +0000 (UTC)
commit 6a2a9df9bd6a72593be66b673f2f419ce8487b16
Author: Heinrich MÃller <henmull src gnome org>
Date: Mon Oct 1 22:46:05 2012 +0200
html preview
configure.in | 1 +
pan/gui/Makefile.am | 8 ++++----
pan/gui/body-pane.cc | 26 ++++++++++++++++++++++++--
pan/gui/body-pane.h | 6 ++++++
pan/usenet-utils/mime-utils.cc | 40 ----------------------------------------
pan/usenet-utils/mime-utils.h | 5 -----
6 files changed, 35 insertions(+), 51 deletions(-)
---
diff --git a/configure.in b/configure.in
index bc1ab69..63f366d 100644
--- a/configure.in
+++ b/configure.in
@@ -95,6 +95,7 @@ else
AM_PATH_GLIB_2_0($GLIB_REQUIRED,,exit 1,gobject gmodule gthread)
fi
+PKG_CHECK_MODULES([WEBKITGTK], [webkitgtk-3.0 >= 1.8.1],AC_DEFINE(HAVE_WEBKIT,[1],[webkit support for embedded html]),[])
dnl Check for GMime
PKG_CHECK_MODULES([GMIME], [gmime-2.6 >= $GMIME26_REQUIRED],[have_gmime26=yes],
diff --git a/pan/gui/Makefile.am b/pan/gui/Makefile.am
index 39cb9a6..ca82ce3 100644
--- a/pan/gui/Makefile.am
+++ b/pan/gui/Makefile.am
@@ -1,5 +1,5 @@
AM_CPPFLAGS = -I top_srcdir@ @GTKSPELL_CFLAGS@ @ENCHANT_CFLAGS@ @GTK_CFLAGS@ @GMIME_CFLAGS@ @GLIB_CFLAGS@ \
- @GNUTLS_CFLAGS@ @LIBNOTIFY_CFLAGS@ @LIBGNOME_KEYRING_1_CFLAGS@ -DPANLOCALEDIR=\""$(panlocaledir)"\"
+ @GNUTLS_CFLAGS@ @LIBNOTIFY_CFLAGS@ @LIBGNOME_KEYRING_1_CFLAGS@ @WEBKITGTK_CFLAGS@ -DPANLOCALEDIR=\""$(panlocaledir)"\"
noinst_LIBRARIES = libpangui.a
@@ -36,7 +36,7 @@ libpangui_a_SOURCES = \
server-ui.cc \
task-pane.cc \
xface.c \
- url.cc
+ url.cc
noinst_HEADERS = \
action-manager.h \
@@ -86,7 +86,7 @@ noinst_HEADERS = \
url.h \
wait.h \
xface.h \
- pan-colors.h
+ pan-colors.h
EXTRA_DIST = \
panrc.rc
@@ -106,7 +106,7 @@ endif
pan_SOURCES = gui.cc pan.cc $(WINRC)
pan_LDADD = ./libpangui.a $(WINRCOBJ) ../data-impl/libpandata.a ../tasks/libtasks.a ../data/libdata.a ../usenet-utils/libusenetutils.a ../general/libgeneralutils.a ../../uulib/libuu.a \
- @GTKSPELL_LIBS@ @ENCHANT_LIBS@ @GTK_LIBS@ @GMIME_LIBS@ @GLIB_LIBS@ @GNUTLS_LIBS@ @LIBNOTIFY_LIBS@ @LIBGNOME_KEYRING_1_LIBS@
+ @GTKSPELL_LIBS@ @ENCHANT_LIBS@ @GTK_LIBS@ @GMIME_LIBS@ @GLIB_LIBS@ @GNUTLS_LIBS@ @LIBNOTIFY_LIBS@ @LIBGNOME_KEYRING_1_LIBS@ @WEBKITGTK_LIBS@
if HAVE_WIN32
pan_LDFLAGS = -mwindows
endif
diff --git a/pan/gui/body-pane.cc b/pan/gui/body-pane.cc
index 465e495..f79b2a7 100644
--- a/pan/gui/body-pane.cc
+++ b/pan/gui/body-pane.cc
@@ -45,6 +45,10 @@ extern "C" {
#include "gtk-compat.h"
#include "save-attach-ui.h"
+#ifdef HAVE_WEBKIT
+ #include <webkitgtk-1.0/webkit/webkit.h>
+#endif
+
#define FIRST_PICTURE "first-picture"
using namespace pan;
@@ -1239,6 +1243,12 @@ BodyPane :: set_text_from_message (GMimeMessage * message)
// set the text buffer...
if (message)
g_mime_message_foreach (message, foreach_part_cb, this);
+ // set the html view
+ GtkTextBuffer* buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(_text));
+ GtkTextIter _start, _end;
+ gtk_text_buffer_get_bounds (buffer, &_start, &_end);
+ char* buf (gtk_text_buffer_get_text (buffer, &_start, &_end, false));
+ if (buf) set_html_text(buf);
// if there was a picture, scroll to it.
// otherwise scroll to the top of the body.
@@ -1650,6 +1660,12 @@ BodyPane :: add_attachment_to_toolbar (const char* fn)
gtk_widget_show_all(_att_toolbar);
}
+void
+BodyPane :: set_html_text (const char* text)
+{
+ webkit_web_view_load_string (WEBKIT_WEB_VIEW (_web_view), text, NULL, NULL, "");
+}
+
GtkWidget*
BodyPane :: create_attachments_toolbar (GtkWidget* frame)
{
@@ -1693,7 +1709,8 @@ BodyPane :: BodyPane (Data& data, ArticleCache& cache, Prefs& prefs, GroupPrefs
#endif
_attachments(0),
_current_attachment(0),
- _cleared (true)
+ _cleared (true),
+ _web_view (webkit_web_view_new ())
{
GtkWidget * w, * l, * hbox;
@@ -1788,7 +1805,12 @@ BodyPane :: BodyPane (Data& data, ArticleCache& cache, Prefs& prefs, GroupPrefs
gtk_expander_set_expanded (GTK_EXPANDER(_expander), expanded);
expander_activated_idle (this);
- _root = vbox;
+ w = gtk_notebook_new ();
+ GtkNotebook * n (GTK_NOTEBOOK (w));
+ gtk_notebook_append_page (n, vbox, gtk_label_new (_("Text View")));
+ gtk_notebook_append_page (n, _web_view, gtk_label_new (_("HTML View")));
+
+ _root = w;
_prefs.add_listener (this);
// listen for user interaction
diff --git a/pan/gui/body-pane.h b/pan/gui/body-pane.h
index b41e296..43f50bf 100644
--- a/pan/gui/body-pane.h
+++ b/pan/gui/body-pane.h
@@ -123,6 +123,12 @@ namespace pan
void copy_url ();
GtkWidget* create_attachments_toolbar(GtkWidget*);
+
+ private:
+ void set_html_text (const char* text);
+ GtkWidget* _web_view;
+
+ private:
void add_attachment_to_toolbar (const char* fn);
void clear_attachments();
GtkWidget* new_attachment (const char* filename);
diff --git a/pan/usenet-utils/mime-utils.cc b/pan/usenet-utils/mime-utils.cc
index c87967a..dad1007 100644
--- a/pan/usenet-utils/mime-utils.cc
+++ b/pan/usenet-utils/mime-utils.cc
@@ -324,18 +324,6 @@ namespace
!yenc_parse_end_line (line, NULL, NULL, NULL, NULL);
}
-// bool
-// html_is_beginning_line(const char *line)
-// {
-// return !strncmp (line, HTML_MARKER_BEGIN, HTML_MARKER_BEGIN_LEN) ;
-// }
-//
-// bool
-// html_is_ending_line(const char *line)
-// {
-// return !strncmp (line, HTML_MARKER_END, HTML_MARKER_END_LEN) ;
-// }
-
};
@@ -481,10 +469,6 @@ enum EncType
ENC_PLAIN ,
ENC_YENC,
ENC_UU
-// ,
-// ENC_BASE64,
-// ENC_QP,
-// ENC_HTML
};
namespace pan
@@ -697,12 +681,6 @@ namespace pan
yenc_looking_for_part_line = cur->y_part!=0;
}
}
-// else if (html_is_beginning_line (line_str))
-// {
-// found = true;
-// sub_begin = linestart_pos;
-//
-// }
else if (state.uu_temp != NULL && is_uu_line(line_str, line_len) )
{
// continue an incomplete uu decode
@@ -793,24 +771,6 @@ namespace pan
}
break;
}
-// case ENC_HTML:
-// {
-// if (html_is_ending_line (line_str))
-// {
-// GMimeStream * stream = g_mime_stream_substream (istream, sub_begin, linestart_pos+line_len);
-// apply_source_and_maybe_filter (cur, stream);
-// if( append_if_not_present (master, cur) )
-// append_if_not_present (appendme, cur);
-//
-// cur = NULL;
-// type = ENC_PLAIN;
-// }
-// else
-// {
-// ++cur->valid_lines;
-// }
-// break;
-// }
}
}
diff --git a/pan/usenet-utils/mime-utils.h b/pan/usenet-utils/mime-utils.h
index a00c9af..ac8c58a 100644
--- a/pan/usenet-utils/mime-utils.h
+++ b/pan/usenet-utils/mime-utils.h
@@ -56,11 +56,6 @@
#define YENC_SHIFT 42
#define YENC_QUOTE_SHIFT 64
-#define HTML_MARKER_BEGIN "<html>"
-#define HTML_MARKER_BEGIN_LEN 6
-#define HTML_MARKER_END "</html>"
-#define HTML_MARKER_END_LEN 7
-
#define NEEDS_DECODING(encoding) ((encoding == GMIME_CONTENT_ENCODING_BASE64) || \
(encoding == GMIME_CONTENT_ENCODING_QUOTEDPRINTABLE))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]