From ad775de47a9c71ee37227bbf952e01f441068489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Thu, 30 Jun 2011 17:14:44 +0100 Subject: Show the remaining time in the status icon depending of the check menu item status --- src/indicator-power.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src') 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; } -- cgit v1.2.3