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
This commit is contained in:
Florian Müllner 2013-01-28 20:38:07 +01:00
parent 4351ad2414
commit 2cf403a3e9

View File

@ -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);
}
/**