/pidgin/main: e82a9f0fa7ec: Convert plugin prefs to GtkWebView.

Elliott Sales de Andrade qulogic at pidgin.im
Thu Jul 26 17:59:19 EDT 2012


Changeset: e82a9f0fa7ecf5f9f8c311aaef73cc950efd4df4
Author:	 Elliott Sales de Andrade <qulogic at pidgin.im>
Date:	 2012-07-26 02:33 -0400
Branch:	 default
URL: http://hg.pidgin.im/pidgin/main/rev/e82a9f0fa7ec

Description:

Convert plugin prefs to GtkWebView.

I don't really know if this works right, though.

diffstat:

 pidgin/gtkpluginpref.c |  39 ++++++++++++++++++---------------------
 1 files changed, 18 insertions(+), 21 deletions(-)

diffs (88 lines):

diff --git a/pidgin/gtkpluginpref.c b/pidgin/gtkpluginpref.c
--- a/pidgin/gtkpluginpref.c
+++ b/pidgin/gtkpluginpref.c
@@ -32,10 +32,10 @@
 #include "pluginpref.h"
 #include "prefs.h"
 
-#include "gtkimhtml.h"
 #include "gtkpluginpref.h"
 #include "gtkprefs.h"
 #include "gtkutils.h"
+#include "gtkwebview.h"
 
 static gboolean
 entry_cb(GtkWidget *entry, gpointer data) {
@@ -48,27 +48,20 @@ entry_cb(GtkWidget *entry, gpointer data
 
 
 static void
-imhtml_cb(GtkTextBuffer *buffer, gpointer data)
+webview_cb(GtkWebView *webview, gpointer data)
 {
 	char *pref;
 	char *text;
-	GtkIMHtml *imhtml = data;
 
-	pref = g_object_get_data(G_OBJECT(imhtml), "pref-key");
+	pref = g_object_get_data(G_OBJECT(webview), "pref-key");
 	g_return_if_fail(pref);
 
-	text = gtk_imhtml_get_markup(imhtml);
+	text = gtk_webview_get_body_html(webview);
 	purple_prefs_set_string(pref, text);
 	g_free(text);
 }
 
 static void
-imhtml_format_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, gpointer data)
-{
-	imhtml_cb(gtk_text_view_get_buffer(GTK_TEXT_VIEW(imhtml)), data);
-}
-
-static void
 make_string_pref(GtkWidget *parent, PurplePluginPref *pref, GtkSizeGroup *sg) {
 	GtkWidget *box, *gtk_label, *entry;
 	const gchar *pref_name;
@@ -115,7 +108,7 @@ make_string_pref(GtkWidget *parent, Purp
 			{
 				GtkWidget *hbox;
 				GtkWidget *spacer;
-				GtkWidget *imhtml;
+				GtkWidget *webview;
 				GtkWidget *toolbar;
 				GtkWidget *frame;
 
@@ -140,19 +133,23 @@ make_string_pref(GtkWidget *parent, Purp
 				gtk_box_pack_start(GTK_BOX(hbox), spacer, FALSE, FALSE, 0);
 				gtk_widget_show(spacer);
 
-				frame = pidgin_create_imhtml(TRUE, &imhtml, &toolbar, NULL);
+				frame = pidgin_create_webview(TRUE, &webview, &toolbar, NULL);
 				if (!(format & PURPLE_STRING_FORMAT_TYPE_HTML))
 					gtk_widget_destroy(toolbar);
 
-				gtk_imhtml_append_text(GTK_IMHTML(imhtml), purple_prefs_get_string(pref_name),
-						(format & PURPLE_STRING_FORMAT_TYPE_MULTILINE) ? 0 : GTK_IMHTML_NO_NEWLINE);
-				gtk_label_set_mnemonic_widget(GTK_LABEL(gtk_label), imhtml);
+				if (format & PURPLE_STRING_FORMAT_TYPE_MULTILINE) {
+					gchar *tmp = purple_strreplace(purple_prefs_get_string(pref_name), "\n", "<br>");
+					gtk_webview_append_html(GTK_WEBVIEW(webview), tmp);
+					g_free(tmp);
+				} else
+					gtk_webview_append_html(GTK_WEBVIEW(webview), purple_prefs_get_string(pref_name));
+				gtk_label_set_mnemonic_widget(GTK_LABEL(gtk_label), webview);
 				gtk_widget_show_all(frame);
-				g_object_set_data(G_OBJECT(imhtml), "pref-key", (gpointer)pref_name);
-				g_signal_connect(G_OBJECT(gtk_text_view_get_buffer(GTK_TEXT_VIEW(imhtml))),
-								"changed", G_CALLBACK(imhtml_cb), imhtml);
-				g_signal_connect(G_OBJECT(imhtml),
-								"format_function_toggle", G_CALLBACK(imhtml_format_cb), imhtml);
+				g_object_set_data(G_OBJECT(webview), "pref-key", (gpointer)pref_name);
+				g_signal_connect(G_OBJECT(webview), "changed",
+				                 G_CALLBACK(webview_cb), NULL);
+				g_signal_connect(G_OBJECT(webview), "format-toggled",
+				                 G_CALLBACK(webview_cb), NULL);
 				gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 0);
 			}
 



More information about the Commits mailing list