aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-01-13 23:24:39 -0600
committerTed Gould <ted@canonical.com>2009-01-13 23:24:39 -0600
commita72a4cec884ad2da923084c23e16cda6717c97b2 (patch)
treee0e3e7e7470454935135318970b87be09dbd8719
parentcb3ce99f56585ff6f4c5b9ca2fe1e6b1eb7a972c (diff)
downloadlibayatana-indicator-a72a4cec884ad2da923084c23e16cda6717c97b2.tar.gz
libayatana-indicator-a72a4cec884ad2da923084c23e16cda6717c97b2.tar.bz2
libayatana-indicator-a72a4cec884ad2da923084c23e16cda6717c97b2.zip
Making the indicator lookup it's own function and trying it out in another function to get a property.
-rw-r--r--libindicate/server.c52
1 files changed, 33 insertions, 19 deletions
diff --git a/libindicate/server.c b/libindicate/server.c
index 01e9e35..41b8d56 100644
--- a/libindicate/server.c
+++ b/libindicate/server.c
@@ -365,10 +365,38 @@ get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indi
return TRUE;
}
+static IndicateIndicator *
+get_indicator (IndicateServer * server, guint id, GError **error)
+{
+ g_return_val_if_fail(INDICATE_IS_SERVER(server), 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) {
+ return indicator;
+ }
+ }
+
+ if (error) {
+ g_set_error(error,
+ indicate_server_error_quark(),
+ INVALID_INDICATOR_ID,
+ "Invalid Indicator ID: %d",
+ id);
+ }
+ return NULL;
+}
+
static gboolean
get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error)
{
+ IndicateIndicator * indicator = get_indicator(server, id, error);
+ if (indicator == NULL) {
+ return FALSE;
+ }
+ *value = indicate_indicator_get_property(indicator, property);
return TRUE;
}
@@ -376,38 +404,24 @@ static gboolean
get_indicator_property_group (IndicateServer * server, guint id, gchar ** properties, gchar *** value, GError **error)
{
- return TRUE;
}
static gboolean
get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error)
{
- return TRUE;
}
static gboolean
show_indicator_to_user (IndicateServer * server, guint id, GError ** error)
{
- g_return_val_if_fail(INDICATE_IS_SERVER(server), 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;
- }
+ IndicateIndicator * indicator = get_indicator(server, id, error);
+ if (indicator == NULL) {
+ return FALSE;
}
- 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;
+ indicate_indicator_user_display(indicator);
+ return TRUE;
}