changeset 32454:126420f99f6f

Add a WebView setup function.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Wed, 04 Jan 2012 23:56:07 +0000
parents 215f7f125f4d
children c5e5938bb89a
files pidgin/gtkutils.c pidgin/gtkutils.h
diffstat 2 files changed, 35 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkutils.c	Wed Jan 04 09:46:23 2012 +0000
+++ b/pidgin/gtkutils.c	Wed Jan 04 23:56:07 2012 +0000
@@ -128,6 +128,32 @@
 
 }
 
+void
+pidgin_setup_webview(GtkWidget *webview)
+{
+	g_return_if_fail(webview != NULL);
+	g_return_if_fail(GTK_IS_WEBVIEW(webview));
+
+#if 0
+/* TODO: WebKit this stuff... */
+	pidgin_themes_smiley_themeize(webview);
+#endif
+
+#ifdef _WIN32
+	if (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/use_theme_font")) {
+		WebKitWebSettings *settings = webkit_web_settings_new();
+		g_object_set(G_OBJECT(settings), "default-font-size",
+		             purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/font_size"),
+		             NULL);
+		g_object_set(G_OBJECT(settings), "default-font-family",
+		             purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/custom_font"),
+		             NULL);
+
+		webkit_web_view_set_settings(WEBKIT_WEB_VIEW(webview), settings);
+	}
+#endif
+}
+
 static
 void pidgin_window_init(GtkWindow *wnd, const char *title, guint border_width, const char *role, gboolean resizable)
 {
@@ -319,6 +345,7 @@
 		gtk_webviewtoolbar_attach(GTK_WEBVIEWTOOLBAR(toolbar), webview);
 		gtk_webviewtoolbar_associate_smileys(GTK_WEBVIEWTOOLBAR(toolbar), "default");
 	}
+	pidgin_setup_webview(webview);
 
 	sw = pidgin_make_scrollable(webview, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC, GTK_SHADOW_NONE, -1, -1);
 	gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
--- a/pidgin/gtkutils.h	Wed Jan 04 09:46:23 2012 +0000
+++ b/pidgin/gtkutils.h	Wed Jan 04 23:56:07 2012 +0000
@@ -107,6 +107,14 @@
 GtkWidget *pidgin_create_imhtml(gboolean editable, GtkWidget **imhtml_ret, GtkWidget **toolbar_ret, GtkWidget **sw_ret);
 
 /**
+ * Sets up a gtkwebview widget, loads it with smileys, and sets the
+ * default signal handlers.
+ *
+ * @param webview The gtkwebview widget to setup.
+ */
+void pidgin_setup_webview(GtkWidget *webview);
+
+/**
  * Create an GtkWebView widget and associated GtkIMHtmlToolbar widget.  This
  * function puts both widgets in a nice GtkFrame.  They're separated by an
  * attractive GtkSeparator.