aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-08-05 14:49:09 -0500
committerTed Gould <ted@gould.cx>2010-08-05 14:49:09 -0500
commit83aa68f55f7c6418f12d49e0d208964ec92b3056 (patch)
tree77692ebbb8057c983c698ac1eadfe8969c49f68d
parent7f912154152119356baf01baff03d96af25d053d (diff)
parent23e9b56c533e25febfa8c83c353492403cb1b4d5 (diff)
downloadayatana-indicator-application-83aa68f55f7c6418f12d49e0d208964ec92b3056.tar.gz
ayatana-indicator-application-83aa68f55f7c6418f12d49e0d208964ec92b3056.tar.bz2
ayatana-indicator-application-83aa68f55f7c6418f12d49e0d208964ec92b3056.zip
Add the ability to toggle the label
-rw-r--r--debian/changelog3
-rw-r--r--example/simple-client.c32
2 files changed, 31 insertions, 4 deletions
diff --git a/debian/changelog b/debian/changelog
index 72e09bf..2d76d5a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,8 +2,9 @@ indicator-application (0.2.3-0ubuntu2~ppa1~label5) UNRELEASED; urgency=low
* Upstream Merge
* Handle label updating and use the guide to guess the size.
+ * Add the ability to toggle the label
- -- Ted Gould <ted@ubuntu.com> Thu, 05 Aug 2010 14:48:04 -0500
+ -- Ted Gould <ted@ubuntu.com> Thu, 05 Aug 2010 14:48:58 -0500
indicator-application (0.2.3-0ubuntu2~ppa1~label4) lucid; urgency=low
diff --git a/example/simple-client.c b/example/simple-client.c
index 20cb281..f2fac6f 100644
--- a/example/simple-client.c
+++ b/example/simple-client.c
@@ -26,6 +26,21 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
GMainLoop * mainloop = NULL;
static gboolean active = TRUE;
+static gboolean can_haz_label = TRUE;
+
+static void
+label_toggle_cb (GtkWidget * widget, gpointer data)
+{
+ can_haz_label = !can_haz_label;
+
+ if (can_haz_label) {
+ gtk_menu_item_set_label(GTK_MENU_ITEM(widget), "Hide label");
+ } else {
+ gtk_menu_item_set_label(GTK_MENU_ITEM(widget), "Show label");
+ }
+
+ return;
+}
static void
activate_clicked_cb (GtkWidget *widget, gpointer data)
@@ -103,9 +118,13 @@ static gboolean
percent_change (gpointer user_data)
{
percentage = (percentage + 1) % 100;
- gchar * percentstr = g_strdup_printf("%d%%", percentage + 1);
- app_indicator_set_label (APP_INDICATOR(user_data), percentstr, "100%");
- g_free(percentstr);
+ if (can_haz_label) {
+ gchar * percentstr = g_strdup_printf("%d%%", percentage + 1);
+ app_indicator_set_label (APP_INDICATOR(user_data), percentstr, "100%");
+ g_free(percentstr);
+ } else {
+ app_indicator_set_label (APP_INDICATOR(user_data), NULL, NULL);
+ }
return TRUE;
}
@@ -166,6 +185,13 @@ main (int argc, char ** argv)
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show(item);
+ item = gtk_menu_item_new_with_label ("Show label");
+ label_toggle_cb(item, ci);
+ g_signal_connect (item, "activate",
+ G_CALLBACK (label_toggle_cb), ci);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ gtk_widget_show(item);
+
app_indicator_set_menu (ci, GTK_MENU (menu));
mainloop = g_main_loop_new(NULL, FALSE);