aboutsummaryrefslogtreecommitdiffstats
path: root/embed/webkit/webkit-embed-prefs.c
diff options
context:
space:
mode:
authorXan Lopez <xan@src.gnome.org>2008-02-15 00:48:13 +0800
committerXan Lopez <xan@src.gnome.org>2008-02-15 00:48:13 +0800
commit34ac56cc9af0eb9464f9d207c6a726d5481ec495 (patch)
treea4fbbb3d36aa8e2a360cc4e21b0efe15af01451d /embed/webkit/webkit-embed-prefs.c
parent16cc4b4c0607cceb98fe898b6393441769510402 (diff)
downloadgsoc2013-epiphany-34ac56cc9af0eb9464f9d207c6a726d5481ec495.tar
gsoc2013-epiphany-34ac56cc9af0eb9464f9d207c6a726d5481ec495.tar.gz
gsoc2013-epiphany-34ac56cc9af0eb9464f9d207c6a726d5481ec495.tar.bz2
gsoc2013-epiphany-34ac56cc9af0eb9464f9d207c6a726d5481ec495.tar.lz
gsoc2013-epiphany-34ac56cc9af0eb9464f9d207c6a726d5481ec495.tar.xz
gsoc2013-epiphany-34ac56cc9af0eb9464f9d207c6a726d5481ec495.tar.zst
gsoc2013-epiphany-34ac56cc9af0eb9464f9d207c6a726d5481ec495.zip
Initial implementation of WebKit preferences.
svn path=/trunk/; revision=7940
Diffstat (limited to 'embed/webkit/webkit-embed-prefs.c')
-rw-r--r--embed/webkit/webkit-embed-prefs.c103
1 files changed, 103 insertions, 0 deletions
diff --git a/embed/webkit/webkit-embed-prefs.c b/embed/webkit/webkit-embed-prefs.c
new file mode 100644
index 000000000..be321a1e4
--- /dev/null
+++ b/embed/webkit/webkit-embed-prefs.c
@@ -0,0 +1,103 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
+/* Copyright © 2008 Xan Lopez <xan@gnome.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <glib.h>
+#include <webkit/webkit.h>
+
+#include "webkit-embed-prefs.h"
+#include "eel-gconf-extensions.h"
+#include "ephy-embed-prefs.h"
+
+static GSList *embeds = NULL;
+static WebKitWebSettings *settings = NULL;
+
+static void
+webkit_embed_prefs_apply (WebKitEmbed *embed, WebKitWebSettings *settings)
+{
+ webkit_web_view_set_settings (WEBKIT_WEB_VIEW (GTK_BIN (GTK_BIN (embed)->child)->child),
+ settings);
+}
+
+static void
+webkit_embed_prefs_apply_all (WebKitWebSettings *settings)
+{
+ GSList *p;
+
+ for (p = embeds; p != NULL; p = p->next)
+ webkit_embed_prefs_apply (WEBKIT_EMBED (p->data), settings);
+}
+
+static void
+notify_minimum_size_cb (GConfClient *client,
+ guint cnxn_id,
+ GConfEntry *entry,
+ gpointer data)
+{
+ GConfValue *gcvalue;
+ gint size = 0;
+
+ gcvalue = gconf_entry_get_value (entry);
+
+ /* happens on initial notify if the key doesn't exist */
+ if (gcvalue != NULL &&
+ gcvalue->type == GCONF_VALUE_INT) {
+ size = gconf_value_get_int (gcvalue);
+ size = MAX (size, 0);
+ }
+
+ g_object_set (settings, "minimum-font-size", size, NULL);
+
+ webkit_embed_prefs_apply_all (settings);
+}
+
+static guint min_font_size_cnxn_id;
+
+void
+webkit_embed_prefs_init (void)
+{
+ eel_gconf_monitor_add ("/apps/epiphany/web");
+
+ settings = webkit_web_settings_new ();
+
+ min_font_size_cnxn_id = eel_gconf_notification_add (CONF_RENDERING_FONT_MIN_SIZE,
+ (GConfClientNotifyFunc) notify_minimum_size_cb,
+ NULL);
+
+ eel_gconf_notify (CONF_RENDERING_FONT_MIN_SIZE);
+}
+
+void
+webkit_embed_prefs_shutdown (void)
+{
+ eel_gconf_notification_remove (min_font_size_cnxn_id);
+}
+
+void
+webkit_embed_prefs_add_embed (WebKitEmbed *embed)
+{
+ embeds = g_slist_prepend (embeds, embed);
+
+ webkit_embed_prefs_apply (embed, settings);
+}
+
+void
+webkit_embed_prefs_remove_embed (WebKitEmbed *embed)
+{
+ embeds = g_slist_remove (embeds, embed);
+}