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 | |
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
-rw-r--r-- | libindicate/indicator.c | 18 | ||||
-rw-r--r-- | libindicate/indicator.h | 2 |
2 files changed, 18 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; } diff --git a/libindicate/indicator.h b/libindicate/indicator.h index 3fd7afd..8823757 100644 --- a/libindicate/indicator.h +++ b/libindicate/indicator.h @@ -21,6 +21,7 @@ G_BEGIN_DECLS #define INDICATE_INDICATOR_SIGNAL_HIDE "hide" #define INDICATE_INDICATOR_SIGNAL_SHOW "show" #define INDICATE_INDICATOR_SIGNAL_DISPLAY "user-display" +#define INDICATE_INDICATOR_SIGNAL_MODIFIED "modified" typedef struct _IndicateIndicator IndicateIndicator; typedef struct _IndicateIndicatorClass IndicateIndicatorClass; @@ -35,6 +36,7 @@ struct _IndicateIndicatorClass { void (*hide) (IndicateIndicator * indicator, gpointer data); void (*show) (IndicateIndicator * indicator, gpointer data); void (*user_display) (IndicateIndicator * indicator, gpointer data); + void (*modified) (IndicateIndicator * indicator, gchar * property, gpointer data); const gchar * (*get_type) (IndicateIndicator * indicator); void (*set_property) (IndicateIndicator * indicator, const gchar * key, const gchar * data); |