[yelp] yelp-view: Do not initialize global settings in class_init
- From: Shaun McCance <shaunm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [yelp] yelp-view: Do not initialize global settings in class_init
- Date: Mon, 21 Sep 2015 19:51:50 +0000 (UTC)
commit a1ab4092a425709814add4a449ddc133434eae9b
Author: Carlos Garcia Campos <cgarcia igalia com>
Date: Mon Sep 21 18:44:20 2015 +0200
yelp-view: Do not initialize global settings in class_init
Use a helper getter instead that creates the object on demand. Since the
settings were created in class_init, we were always passing a NULL
settings object to g_object_new in yelp_view_new(), so all settings set
in the global settings were actually ignored.
https://bugzilla.gnome.org/show_bug.cgi?id=754912
libyelp/yelp-view.c | 23 +++++++++++++----------
1 files changed, 13 insertions(+), 10 deletions(-)
---
diff --git a/libyelp/yelp-view.c b/libyelp/yelp-view.c
index a8190f8..1aa647b 100644
--- a/libyelp/yelp-view.c
+++ b/libyelp/yelp-view.c
@@ -147,7 +147,16 @@ static gint signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (YelpView, yelp_view, WEBKIT_TYPE_WEB_VIEW)
#define GET_PRIV(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), YELP_TYPE_VIEW, YelpViewPrivate))
-static WebKitSettings *websettings;
+static WebKitSettings *
+yelp_view_get_global_settings (void)
+{
+ static WebKitSettings *websettings = NULL;
+
+ if (!websettings)
+ websettings = webkit_settings_new_with_settings ("default-charset", "utf-8", NULL);
+
+ return websettings;
+}
typedef struct _YelpActionEntry YelpActionEntry;
struct _YelpActionEntry {
@@ -466,10 +475,6 @@ yelp_view_class_init (YelpViewClass *klass)
nautilus_sendto = g_find_program_in_path ("nautilus-sendto");
- websettings = webkit_settings_new_with_settings (
- "default-charset", "utf-8",
- NULL);
-
g_signal_connect (settings,
"notify::show-text-cursor",
G_CALLBACK (settings_show_text_cursor),
@@ -651,7 +656,7 @@ GtkWidget *
yelp_view_new (void)
{
return GTK_WIDGET (g_object_new (YELP_TYPE_VIEW,
- "settings", websettings, NULL));
+ "settings", yelp_view_get_global_settings (), NULL));
}
void
@@ -2146,10 +2151,8 @@ settings_set_fonts (YelpSettings *settings,
static void
settings_show_text_cursor (YelpSettings *settings)
{
- g_object_set (websettings,
- "enable-caret-browsing",
- yelp_settings_get_show_text_cursor (settings),
- NULL);
+ webkit_settings_set_enable_caret_browsing (yelp_view_get_global_settings (),
+ yelp_settings_get_show_text_cursor (settings));
}
/******************************************************************************/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]