aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier Jardón <javier.jardon@codethink.co.uk>2011-06-30 17:14:44 +0100
committerJavier Jardón <javier.jardon@codethink.co.uk>2011-06-30 17:14:44 +0100
commitad775de47a9c71ee37227bbf952e01f441068489 (patch)
treebeb0ffdfeb77fef057ccea3bbe30d06ef7cd008a
parent07ef8e08fbaa3c8fe299f58a74d91614c344cae1 (diff)
downloadayatana-indicator-power-ad775de47a9c71ee37227bbf952e01f441068489.tar.gz
ayatana-indicator-power-ad775de47a9c71ee37227bbf952e01f441068489.tar.bz2
ayatana-indicator-power-ad775de47a9c71ee37227bbf952e01f441068489.zip
Show the remaining time in the status icon depending of the check menu item status
-rw-r--r--src/indicator-power.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/indicator-power.c b/src/indicator-power.c
index 4009292..59e65ce 100644
--- a/src/indicator-power.c
+++ b/src/indicator-power.c
@@ -350,7 +350,19 @@ static void
option_toggled_cb (GtkCheckMenuItem *item,
gpointer user_data)
{
- /*TODO*/
+ IndicatorPower *self = INDICATOR_POWER (user_data);
+ IndicatorPowerPrivate *priv = self->priv;
+
+ if (gtk_check_menu_item_get_active (item))
+ {
+ g_debug ("Updating username label");
+ gtk_label_set_text (priv->label, "0:45 Remaining"); /*TODO*/
+ gtk_widget_show (GTK_WIDGET(priv->label));
+ }
+ else
+ {
+ gtk_widget_hide (GTK_WIDGET(priv->label));
+ }
}
static void
@@ -390,7 +402,7 @@ build_menu (IndicatorPower *self)
item = gtk_check_menu_item_new_with_label (_("Show Time Remining"));
g_object_set (item, "draw-as-radio", TRUE, NULL);
g_signal_connect (G_OBJECT (item), "toggled",
- G_CALLBACK (option_toggled_cb), item);
+ G_CALLBACK (option_toggled_cb), self);
gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), item);
/* separator */
@@ -461,10 +473,10 @@ get_label (IndicatorObject *io)
IndicatorPowerPrivate *priv = self->priv;
if (priv->label == NULL)
- {
- /* Create the label if it doesn't exist already */
- priv->label = GTK_LABEL (gtk_label_new ("Power"));
- }
+ {
+ /* Create the label if it doesn't exist already */
+ priv->label = GTK_LABEL (gtk_label_new (""));
+ }
return priv->label;
}