[totem] totem-glow-button: Do not add the custom CSS provider for every instance



commit 595dac6cc23a5fb32881c1e329791dbb8559d84c
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Mon Mar 31 14:49:49 2014 +0200

    totem-glow-button: Do not add the custom CSS provider for every instance
    
    Since we are adding a global CSS for the default screen, we don't need
    to load and add the CSS for every instance we create.

 browser-plugin/totem-glow-button.c |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/browser-plugin/totem-glow-button.c b/browser-plugin/totem-glow-button.c
index d7ded10..ad5e504 100644
--- a/browser-plugin/totem-glow-button.c
+++ b/browser-plugin/totem-glow-button.c
@@ -105,14 +105,20 @@ totem_glow_button_class_init (TotemGlowButtonClass *klass)
 static void
 totem_glow_button_init (TotemGlowButton *button)
 {
-       GtkCssProvider *provider;
-
-       provider = gtk_css_provider_new ();
-       gtk_css_provider_load_from_data (provider, css, -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);
+        static gsize initialization_value = 0;
+
+        if (g_once_init_enter (&initialization_value)) {
+                GtkCssProvider *provider;
+
+                provider = gtk_css_provider_new ();
+                gtk_css_provider_load_from_data (provider, css, -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);
+        }
 }
 
 GtkWidget *


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