From 2cf403a3e95087db87aee641d15cdcbb6388bff9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Mon, 28 Jan 2013 20:38:07 +0100 Subject: [PATCH] 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 file changed, 17 insertions(+) diff --git a/src/st/st-theme.c b/src/st/st-theme.c index 479645fed..01d045568 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); } /**