diff options
author | Javier Jardón <javier.jardon@codethink.co.uk> | 2011-07-01 11:51:12 +0100 |
---|---|---|
committer | Javier Jardón <javier.jardon@codethink.co.uk> | 2011-07-01 11:51:12 +0100 |
commit | 866c7d371476aebafe73d367274320dc3cca4101 (patch) | |
tree | 28c59eefcccd2f3fa8de39e8df287045a010a612 /src/indicator-power.c | |
parent | 6d4b1e00de7fdacbcda48d90090cdd03e2590716 (diff) | |
download | ayatana-indicator-power-866c7d371476aebafe73d367274320dc3cca4101.tar.gz ayatana-indicator-power-866c7d371476aebafe73d367274320dc3cca4101.tar.bz2 ayatana-indicator-power-866c7d371476aebafe73d367274320dc3cca4101.zip |
Return the correct accessible description
Diffstat (limited to 'src/indicator-power.c')
-rw-r--r-- | src/indicator-power.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/src/indicator-power.c b/src/indicator-power.c index 0a7694e..f7d64d4 100644 --- a/src/indicator-power.c +++ b/src/indicator-power.c @@ -71,6 +71,7 @@ struct _IndicatorPowerPrivate GtkLabel *label; GtkImage *status_image; + gchar *accessible_desc; GCancellable *proxy_cancel; GDBusProxy *proxy; @@ -210,11 +211,27 @@ device_kind_to_localised_string (UpDeviceKind kind) } static void +set_accessible_desc (IndicatorPower *self, + const gchar *desc) +{ + IndicatorPowerPrivate *priv = self->priv; + + if (desc == NULL || strlen(desc) == 0) + return; + + g_free (priv->accessible_desc); + + priv->accessible_desc = g_strdup (desc); +} + + +static void get_primary_device_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { - IndicatorPowerPrivate *priv = INDICATOR_POWER (user_data)->priv; + IndicatorPower *self = INDICATOR_POWER (user_data); + IndicatorPowerPrivate *priv = self->priv; UpDeviceKind kind; UpDeviceState state; GVariant *result; @@ -294,6 +311,7 @@ get_primary_device_cb (GObject *source_object, } gtk_label_set_label (GTK_LABEL (priv->label), label_text); + set_accessible_desc (self, details); g_free (label_text); g_free (details); @@ -460,6 +478,7 @@ indicator_power_init (IndicatorPower *self) /* Init variables */ priv->menu = NULL; + priv->accessible_desc = NULL; build_menu (self); @@ -538,14 +557,6 @@ get_accessible_desc (IndicatorObject *io) { IndicatorPower *self = INDICATOR_POWER (io); IndicatorPowerPrivate *priv = self->priv; - const gchar *name; - - if (priv->label != NULL) - { - name = gtk_label_get_text (priv->label); - - return name; - } - return NULL; + return priv->accessible_desc; } |