diff options
author | Carlos Garcia Campos <cgarcia@igalia.com> | 2015-09-21 18:44:20 +0200 |
---|---|---|
committer | Shaun McCance <shaunm@gnome.org> | 2015-09-21 13:11:17 -0400 |
commit | a1ab4092a425709814add4a449ddc133434eae9b (patch) | |
tree | 3a478b0c5428226a280d7faacd7938e7041b66ad | |
parent | 1695dc05c2ab1bdc3fbc4d9cc2180e7e37bbb1f2 (diff) | |
download | yelp-a1ab4092a425709814add4a449ddc133434eae9b.tar.gz |
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
-rw-r--r-- | 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 a8190f8d..1aa647b2 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)); } /******************************************************************************/ |