aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--embed/webkit/Makefile.am2
-rw-r--r--embed/webkit/webkit-embed-prefs.c103
-rw-r--r--embed/webkit/webkit-embed-prefs.h34
-rw-r--r--embed/webkit/webkit-embed-single.c5
-rw-r--r--embed/webkit/webkit-embed.c14
5 files changed, 158 insertions, 0 deletions
diff --git a/embed/webkit/Makefile.am b/embed/webkit/Makefile.am
index 70e5d796c..ea327f855 100644
--- a/embed/webkit/Makefile.am
+++ b/embed/webkit/Makefile.am
@@ -7,6 +7,8 @@ libephywebkitembed_la_SOURCES = \
webkit-embed-find.h \
webkit-embed-persist.c \
webkit-embed-persist.h \
+ webkit-embed-prefs.c \
+ webkit-embed-prefs.h \
webkit-embed-single.c \
webkit-embed-single.h \
webkit-history-item.c \
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);
+}
diff --git a/embed/webkit/webkit-embed-prefs.h b/embed/webkit/webkit-embed-prefs.h
new file mode 100644
index 000000000..21f2bc40e
--- /dev/null
+++ b/embed/webkit/webkit-embed-prefs.h
@@ -0,0 +1,34 @@
+/* -*- 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.
+ *
+ */
+
+#ifndef __WEBKIT_EMBED_PREFS_H__
+#define __WEBKIT_EMBED_PREFS_H__
+
+#include "webkit-embed.h"
+
+G_BEGIN_DECLS
+
+void webkit_embed_prefs_init (void);
+void webkit_embed_prefs_shutdown (void);
+void webkit_embed_prefs_add_embed (WebKitEmbed *embed);
+void webkit_embed_prefs_remove_embed (WebKitEmbed *embed);
+
+G_END_DECLS
+
+#endif /* __WEBKIT_EMBED_PREFS_H__ */
diff --git a/embed/webkit/webkit-embed-single.c b/embed/webkit/webkit-embed-single.c
index 36bf6c932..3c3fd2cde 100644
--- a/embed/webkit/webkit-embed-single.c
+++ b/embed/webkit/webkit-embed-single.c
@@ -22,6 +22,7 @@
#include <webkit/webkit.h>
#include "webkit-embed-single.h"
+#include "webkit-embed-prefs.h"
#include "ephy-embed-single.h"
#include "ephy-cookie-manager.h"
#include "ephy-password-manager.h"
@@ -96,6 +97,8 @@ webkit_embed_single_dispose (GObject *object)
static void
webkit_embed_single_finalize (GObject *object)
{
+ webkit_embed_prefs_shutdown ();
+
G_OBJECT_CLASS (webkit_embed_single_parent_class)->finalize (object);
}
@@ -209,6 +212,8 @@ impl_permission_manager_test (EphyPermissionManager *manager,
static gboolean
impl_init (EphyEmbedSingle *esingle)
{
+ webkit_embed_prefs_init ();
+
return TRUE;
}
diff --git a/embed/webkit/webkit-embed.c b/embed/webkit/webkit-embed.c
index 429f6bfa1..623d4b81d 100644
--- a/embed/webkit/webkit-embed.c
+++ b/embed/webkit/webkit-embed.c
@@ -32,6 +32,7 @@
#include <string.h>
#include "webkit-embed.h"
+#include "webkit-embed-prefs.h"
#include "webkit-history-item.h"
#include "ephy-embed.h"
#include "ephy-base-embed.h"
@@ -268,10 +269,21 @@ webkit_embed_finalize (GObject *object)
}
static void
+webkit_embed_dispose (GObject *object)
+{
+ WebKitEmbed *wembed = WEBKIT_EMBED (object);
+
+ webkit_embed_prefs_remove_embed (wembed);
+
+ G_OBJECT_CLASS (webkit_embed_parent_class)->dispose (object);
+}
+
+static void
webkit_embed_class_init (WebKitEmbedClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->dispose = webkit_embed_dispose;
object_class->finalize = webkit_embed_finalize;
g_type_class_add_private (object_class, sizeof(WebKitEmbedPrivate));
@@ -310,6 +322,8 @@ webkit_embed_init (WebKitEmbed *embed)
G_CALLBACK (webkit_embed_load_progress_changed_cb), embed);
g_signal_connect (G_OBJECT (web_view), "hovering-over-link",
G_CALLBACK (webkit_embed_hovering_over_link_cb), embed);
+
+ webkit_embed_prefs_add_embed (embed);
}
static void