aboutsummaryrefslogtreecommitdiff
path: root/libindicate/indicator.c
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-01-29 12:44:17 -0600
committerTed Gould <ted@canonical.com>2009-01-29 12:44:17 -0600
commitdd60c6238ffa4e3e48bdb35a8f9235b732607926 (patch)
treeb79b4122f1e2b9e8a3fb968b93ea83764d3aec6c /libindicate/indicator.c
parent759d62b0a1062dcf53289b42f30a8374ca6e9a33 (diff)
downloadlibayatana-indicator-dd60c6238ffa4e3e48bdb35a8f9235b732607926.tar.gz
libayatana-indicator-dd60c6238ffa4e3e48bdb35a8f9235b732607926.tar.bz2
libayatana-indicator-dd60c6238ffa4e3e48bdb35a8f9235b732607926.zip
Adding a property modified signal to the indicator object
Diffstat (limited to 'libindicate/indicator.c')
-rw-r--r--libindicate/indicator.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/libindicate/indicator.c b/libindicate/indicator.c
index f1eb6f3..94af726 100644
--- a/libindicate/indicator.c
+++ b/libindicate/indicator.c
@@ -9,6 +9,7 @@ enum {
HIDE,
SHOW,
USER_DISPLAY,
+ MODIFIED,
LAST_SIGNAL
};
@@ -68,6 +69,13 @@ indicate_indicator_class_init (IndicateIndicatorClass * class)
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+ signals[MODIFIED] = g_signal_new(INDICATE_INDICATOR_SIGNAL_MODIFIED,
+ G_TYPE_FROM_CLASS(class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(IndicateIndicatorClass, modified),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
class->get_type = NULL;
class->set_property = set_property;
@@ -235,8 +243,14 @@ set_property (IndicateIndicator * indicator, const gchar * key, const gchar * da
IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);
- g_hash_table_insert(priv->properties, g_strdup(key), g_strdup(data));
- // TODO: Signal
+ gchar * current = g_hash_table_lookup(priv->properties, key);
+ if (current == NULL || strcmp(current, data)) {
+ /* If the value has changed or there is no value */
+ gchar * newkey = g_strdup(key);
+ g_hash_table_insert(priv->properties, newkey, g_strdup(data));
+ g_signal_emit(indicator, signals[MODIFIED], 0, newkey, TRUE);
+ }
+
return;
}