diff options
author | Ted Gould <ted@canonical.com> | 2009-01-29 12:44:17 -0600 |
---|---|---|
committer | Ted Gould <ted@canonical.com> | 2009-01-29 12:44:17 -0600 |
commit | dd60c6238ffa4e3e48bdb35a8f9235b732607926 (patch) | |
tree | b79b4122f1e2b9e8a3fb968b93ea83764d3aec6c /libindicate/indicator.c | |
parent | 759d62b0a1062dcf53289b42f30a8374ca6e9a33 (diff) | |
download | libayatana-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.c | 18 |
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; } |