epiphany r7940 - trunk/embed/webkit



Author: xan
Date: Thu Feb 14 16:48:13 2008
New Revision: 7940
URL: http://svn.gnome.org/viewvc/epiphany?rev=7940&view=rev

Log:
Initial implementation of WebKit preferences.


Added:
   trunk/embed/webkit/webkit-embed-prefs.c
   trunk/embed/webkit/webkit-embed-prefs.h
Modified:
   trunk/embed/webkit/Makefile.am
   trunk/embed/webkit/webkit-embed-single.c
   trunk/embed/webkit/webkit-embed.c

Modified: trunk/embed/webkit/Makefile.am
==============================================================================
--- trunk/embed/webkit/Makefile.am	(original)
+++ trunk/embed/webkit/Makefile.am	Thu Feb 14 16:48:13 2008
@@ -7,6 +7,8 @@
 	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		\

Added: trunk/embed/webkit/webkit-embed-prefs.c
==============================================================================
--- (empty file)
+++ trunk/embed/webkit/webkit-embed-prefs.c	Thu Feb 14 16:48:13 2008
@@ -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);
+}

Added: trunk/embed/webkit/webkit-embed-prefs.h
==============================================================================
--- (empty file)
+++ trunk/embed/webkit/webkit-embed-prefs.h	Thu Feb 14 16:48:13 2008
@@ -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__ */

Modified: trunk/embed/webkit/webkit-embed-single.c
==============================================================================
--- trunk/embed/webkit/webkit-embed-single.c	(original)
+++ trunk/embed/webkit/webkit-embed-single.c	Thu Feb 14 16:48:13 2008
@@ -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 @@
 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 @@
 static gboolean
 impl_init (EphyEmbedSingle *esingle)
 {
+  webkit_embed_prefs_init ();
+
   return TRUE;
 }
 

Modified: trunk/embed/webkit/webkit-embed.c
==============================================================================
--- trunk/embed/webkit/webkit-embed.c	(original)
+++ trunk/embed/webkit/webkit-embed.c	Thu Feb 14 16:48:13 2008
@@ -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 @@
 }
 
 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 @@
                     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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]