aboutsummaryrefslogtreecommitdiff
path: root/libindicate
diff options
context:
space:
mode:
Diffstat (limited to 'libindicate')
-rw-r--r--libindicate/indicator.c9
-rw-r--r--libindicate/indicator.h2
-rw-r--r--libindicate/server.c49
3 files changed, 59 insertions, 1 deletions
diff --git a/libindicate/indicator.c b/libindicate/indicator.c
index 119a479..5d45c93 100644
--- a/libindicate/indicator.c
+++ b/libindicate/indicator.c
@@ -142,4 +142,13 @@ indicate_indicator_get_indicator_type (IndicateIndicator * indicator)
return NULL;
}
+void
+indicate_indicator_user_display (IndicateIndicator * indicator)
+{
+ if (!indicator->is_visible) {
+ return;
+ }
+ g_signal_emit(indicator, signals[USER_DISPLAY], 0, TRUE);
+ return;
+}
diff --git a/libindicate/indicator.h b/libindicate/indicator.h
index 2a15e3b..45c4128 100644
--- a/libindicate/indicator.h
+++ b/libindicate/indicator.h
@@ -65,6 +65,8 @@ guint indicate_indicator_get_id (IndicateIndicator * indicator);
* subclass and exported through this pretty function */
const gchar * indicate_indicator_get_indicator_type (IndicateIndicator * indicator);
+void indicate_indicator_user_display (IndicateIndicator * indicator);
+
G_END_DECLS
#endif /* INDICATE_INDICATOR_H_INCLUDED__ */
diff --git a/libindicate/server.c b/libindicate/server.c
index 08b6849..01e9e35 100644
--- a/libindicate/server.c
+++ b/libindicate/server.c
@@ -13,6 +13,7 @@ enum {
NO_GET_INDICATOR_PROPERTY_GROUP,
NO_GET_INDICATOR_PROPERTIES,
NO_SHOW_INDICATOR_TO_USER,
+ INVALID_INDICATOR_ID,
LAST_ERROR
};
@@ -331,6 +332,35 @@ get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** err
static gboolean
get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error)
{
+ g_return_val_if_fail(INDICATE_IS_SERVER(server), TRUE);
+
+ IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
+ g_return_val_if_fail(class->get_indicator_count != NULL, TRUE);
+
+ if (type != NULL && type[0] == '\0') {
+ type = NULL;
+ }
+
+ /* Can't be larger than this and it's not worth the reallocation
+ for the small number we have. The memory isn't worth the time. */
+ *indicators = g_array_sized_new(FALSE, FALSE, sizeof(guint), g_slist_length(server->indicators) - server->num_hidden);
+
+ GSList * iter;
+ int i;
+ for (iter = server->indicators, i = 0; iter != NULL; iter = iter->next) {
+ IndicateIndicator * indicator = INDICATE_INDICATOR(iter->data);
+ if (indicate_indicator_is_visible(indicator)) {
+ const gchar * itype = indicate_indicator_get_indicator_type(indicator);
+ guint id = indicate_indicator_get_id(indicator);
+
+ if (type == NULL && itype == NULL) {
+ g_array_insert_val(*indicators, i++, id);
+ } else if (type == NULL || itype == NULL) {
+ } else if (!strcmp(type, itype)) {
+ g_array_insert_val(*indicators, i++, id);
+ }
+ }
+ }
return TRUE;
}
@@ -359,8 +389,25 @@ get_indicator_properties (IndicateServer * server, guint id, gchar *** propertie
static gboolean
show_indicator_to_user (IndicateServer * server, guint id, GError ** error)
{
+ g_return_val_if_fail(INDICATE_IS_SERVER(server), TRUE);
- return TRUE;
+ GSList * iter;
+ for (iter = server->indicators; iter != NULL; iter = iter->next) {
+ IndicateIndicator * indicator = INDICATE_INDICATOR(iter->data);
+ if (indicate_indicator_get_id(indicator) == id) {
+ indicate_indicator_user_display(indicator);
+ return TRUE;
+ }
+ }
+
+ if (error) {
+ g_set_error(error,
+ indicate_server_error_quark(),
+ INVALID_INDICATOR_ID,
+ "show_indicator_id can't be done on and invalid ID: %d",
+ id);
+ }
+ return FALSE;
}