[gnome-shell] st-theme: Add "custom-stylesheets-changed" signal



commit 2cf403a3e95087db87aee641d15cdcbb6388bff9
Author: Florian MÃllner <fmuellner gnome org>
Date:   Mon Jan 28 20:38:07 2013 +0100

    st-theme: Add "custom-stylesheets-changed" signal
    
    StThemeNodes cache matched properties from stylesheets, so when the
    list of custom stylesheets changes, the node may miss better matches
    (when a stylesheet was added) or have pointers to invalid memory in
    the list (when a stylesheet was removed).
    In order to allow theme nodes to listen for stylesheet changes, add
    an appropriate signal to StTheme.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=692994

 src/st/st-theme.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/src/st/st-theme.c b/src/st/st-theme.c
index 479645f..01d0455 100644
--- a/src/st/st-theme.c
+++ b/src/st/st-theme.c
@@ -87,6 +87,14 @@ enum
   PROP_DEFAULT_STYLESHEET
 };
 
+enum
+{
+  STYLESHEETS_CHANGED,
+  LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0, };
+
 G_DEFINE_TYPE (StTheme, st_theme, G_TYPE_OBJECT)
 
 /* Quick strcmp.  Test only for == 0 or != 0, not < 0 or > 0.  */
@@ -153,6 +161,13 @@ st_theme_class_init (StThemeClass *klass)
                                                         NULL,
                                                         G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
 
+  signals[STYLESHEETS_CHANGED] =
+    g_signal_new ("custom-stylesheets-changed",
+                  G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_LAST,
+                  0, /* no default handler slot */
+                  NULL, NULL, NULL,
+                  G_TYPE_NONE, 0);
 }
 
 static CRStyleSheet *
@@ -238,6 +253,7 @@ st_theme_load_stylesheet (StTheme    *theme,
   insert_stylesheet (theme, path, stylesheet);
   cr_stylesheet_ref (stylesheet);
   theme->custom_stylesheets = g_slist_prepend (theme->custom_stylesheets, stylesheet);
+  g_signal_emit (theme, signals[STYLESHEETS_CHANGED], 0);
 
   return TRUE;
 }
@@ -259,6 +275,7 @@ st_theme_unload_stylesheet (StTheme    *theme,
   g_hash_table_remove (theme->stylesheets_by_filename, path);
   g_hash_table_remove (theme->filenames_by_stylesheet, stylesheet);
   cr_stylesheet_unref (stylesheet);
+  g_signal_emit (theme, signals[STYLESHEETS_CHANGED], 0);
 }
 
 /**



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