diff options
author | raveit65 <[email protected]> | 2016-07-03 12:31:50 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2016-07-03 13:01:21 +0200 |
commit | 3ce8baf1ea9a7d7467811436c778b4446302829c (patch) | |
tree | 289683ef43c8239d01366a464319aaf48169582e /libview | |
parent | ccf6b7e9e9a831010c00d3802b3506e1d791e2c8 (diff) | |
download | atril-3ce8baf1ea9a7d7467811436c778b4446302829c.tar.bz2 atril-3ce8baf1ea9a7d7467811436c778b4446302829c.tar.xz |
GTK+-3 ev-view-presentation: Fix a crash during the build with introspection enabled
Using GI_SCANNER_DEBUG=save-temps, the temporal files remained.
It has been suggested that calling gtk_style_context_add_provider_for_screen()
should, inside a g_once_init(), be in the class's _init() (not class_init()) hook.
https://bugzilla.gnome.org/show_bug.cgi?id=726812
taken from:
https://git.gnome.org/browse/evince/commit/?id=a203fc1
Diffstat (limited to 'libview')
-rw-r--r-- | libview/ev-view-presentation.c | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/libview/ev-view-presentation.c b/libview/ev-view-presentation.c index 90a7a0d0..9c14aff6 100644 --- a/libview/ev-view-presentation.c +++ b/libview/ev-view-presentation.c @@ -1507,9 +1507,6 @@ ev_view_presentation_class_init (EvViewPresentationClass *klass) GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GtkBindingSet *binding_set; -#if GTK_CHECK_VERSION (3, 0, 0) - GtkCssProvider *provider; -#endif klass->change_page = ev_view_presentation_change_page; @@ -1627,25 +1624,35 @@ ev_view_presentation_class_init (EvViewPresentationClass *klass) gtk_binding_entry_add_signal (binding_set, GDK_KEY_K, 0, "change_page", 1, GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_PAGE_BACKWARD); - -#if GTK_CHECK_VERSION (3, 0, 0) - provider = gtk_css_provider_new (); - gtk_css_provider_load_from_data (provider, - "EvViewPresentation {\n" - " background-color: black; }", - -1, NULL); - gtk_style_context_add_provider_for_screen (gdk_screen_get_default (), - GTK_STYLE_PROVIDER (provider), - GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); - g_object_unref (provider); -#endif } static void ev_view_presentation_init (EvViewPresentation *pview) { +#if GTK_CHECK_VERSION (3, 0, 0) + static gsize initialization_value = 0; + + gtk_widget_set_can_focus (GTK_WIDGET (pview), TRUE); + pview->is_constructing = TRUE; + + if (g_once_init_enter (&initialization_value)) { + GtkCssProvider *provider; + + provider = gtk_css_provider_new (); + gtk_css_provider_load_from_data (provider, + "EvViewPresentation {\n" + " background-color: black; }", + -1, NULL); + gtk_style_context_add_provider_for_screen (gdk_screen_get_default (), + GTK_STYLE_PROVIDER (provider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + g_object_unref (provider); + g_once_init_leave (&initialization_value, 1); + } +#else gtk_widget_set_can_focus (GTK_WIDGET (pview), TRUE); pview->is_constructing = TRUE; +#endif } GtkWidget * |