Commit 34ac56cc authored by Xan Lopez's avatar Xan Lopez

Initial implementation of WebKit preferences.

svn path=/trunk/; revision=7940
parent 16cc4b4c
......@@ -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 \
......
/* -*- 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);
}
/* -*- 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__ */
......@@ -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;
}
......
......@@ -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"
......@@ -267,11 +268,22 @@ webkit_embed_finalize (GObject *object)
G_OBJECT_CLASS (webkit_embed_parent_class)->finalize (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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment