diff options
author | Luke Yelavich <luke.yelavich@canonical.com> | 2011-02-04 13:57:23 +1100 |
---|---|---|
committer | Luke Yelavich <luke.yelavich@canonical.com> | 2011-02-04 13:57:23 +1100 |
commit | b13fa490fb368b779a99543d18d5c68c01f8eb31 (patch) | |
tree | 0b81c50cc1bc8b9f04fcf22d3cfa540ab082aa89 /example/simple-client.c | |
parent | 19c543fd42571ef3e011db21a6d93e93d7da4483 (diff) | |
download | libayatana-appindicator-b13fa490fb368b779a99543d18d5c68c01f8eb31.tar.gz libayatana-appindicator-b13fa490fb368b779a99543d18d5c68c01f8eb31.tar.bz2 libayatana-appindicator-b13fa490fb368b779a99543d18d5c68c01f8eb31.zip |
Add accessible_name support
Diffstat (limited to 'example/simple-client.c')
-rw-r--r-- | example/simple-client.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/example/simple-client.c b/example/simple-client.c index ac8360f..9c9a14b 100644 --- a/example/simple-client.c +++ b/example/simple-client.c @@ -27,6 +27,7 @@ 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 gboolean can_haz_a11yname = TRUE; static void label_toggle_cb (GtkWidget * widget, gpointer data) @@ -43,6 +44,20 @@ label_toggle_cb (GtkWidget * widget, gpointer data) } static void +a11yname_toggle_cb (GtkWidget * widget, gpointer data) +{ + can_haz_a11yname = !can_haz_a11yname; + + if (can_haz_a11yname) { + gtk_menu_item_set_label(GTK_MENU_ITEM(widget), "Hide accessible name"); + } else { + gtk_menu_item_set_label(GTK_MENU_ITEM(widget), "Show accessible name"); + } + + return; +} + +static void activate_clicked_cb (GtkWidget *widget, gpointer data) { AppIndicator * ci = APP_INDICATOR(data); @@ -140,6 +155,13 @@ percent_change (gpointer user_data) } else { app_indicator_set_label (APP_INDICATOR(user_data), NULL, NULL); } + if (can_haz_a11yname) { + gchar * percentstr = g_strdup_printf("%d%%", percentage + 1); + app_indicator_set_accessible_name (APP_INDICATOR(user_data), percentstr); + g_free(percentstr); + } else { + app_indicator_set_accessible_name (APP_INDICATOR(user_data), NULL); + } return TRUE; } @@ -213,6 +235,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 accessible name"); + a11yname_toggle_cb(item, ci); + g_signal_connect (item, "activate", + G_CALLBACK (a11yname_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); |