diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2012-08-31 07:16:03 -0500 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2012-08-31 07:16:03 -0500 |
commit | 64cf80553784cdee851cf7112fdc468ab46a61be (patch) | |
tree | f521d650e58a3b4706b4c04cf4923b45bb691d75 /src | |
parent | 3bcd1a92caefa661b4f0451bd91d66867e09a7c5 (diff) | |
download | ayatana-indicator-session-64cf80553784cdee851cf7112fdc468ab46a61be.tar.gz ayatana-indicator-session-64cf80553784cdee851cf7112fdc468ab46a61be.tar.bz2 ayatana-indicator-session-64cf80553784cdee851cf7112fdc468ab46a61be.zip |
have the a11y text follow the SystemMenu spec
Diffstat (limited to 'src')
-rw-r--r-- | src/indicator-session.c | 62 |
1 files changed, 42 insertions, 20 deletions
diff --git a/src/indicator-session.c b/src/indicator-session.c index d22cd33..72e3a0b 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -84,7 +84,7 @@ static gboolean build_restart_item (DbusmenuMenuitem * newitem, DbusmenuClient * client, gpointer user_data); static void on_menu_layout_updated (DbusmenuClient * client, IndicatorSession * session); -static void indicator_session_update_icon (IndicatorSession * self); +static void indicator_session_update_icon_and_a11y (IndicatorSession * self); static void indicator_session_update_users_label (IndicatorSession* self, const gchar* name); static void service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data); @@ -135,11 +135,17 @@ indicator_session_init (IndicatorSession *self) self->entry.image = GTK_IMAGE (gtk_image_new()); self->entry.menu = GTK_MENU (dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT)); - indicator_session_update_icon (self); + indicator_session_update_icon_and_a11y (self); g_settings_bind (self->settings, "show-real-name-on-panel", self->entry.label, "visible", G_SETTINGS_BIND_GET); + /* show-real-name-on-panel affects the a11y string */ + g_signal_connect_swapped (self->settings, + "notify::show-real-name-on-panel", + G_CALLBACK(indicator_session_update_icon_and_a11y), + self); + gtk_widget_show (GTK_WIDGET(self->entry.menu)); gtk_widget_show (GTK_WIDGET(self->entry.image)); g_object_ref_sink (self->entry.menu); @@ -422,16 +428,36 @@ enum }; static void -indicator_session_update_from_disposition (IndicatorSession * indicator, - int disposition) +indicator_session_update_a11y_from_disposition (IndicatorSession * indicator, + int disposition) { - const gchar * icon; - const gchar * a11y; + GString * a11y = g_string_new (_("System")); - if (disposition == DISPOSITION_NORMAL) - a11y = _("Session Menu"); - else - a11y = _("Session Menu (attention required)"); + if (g_settings_get_boolean (indicator->settings, "show-real-name-on-panel")) + { + const gchar * username = gtk_label_get_text (indicator->entry.label); + g_string_append_printf (a11y, " %s", username); + } + + if (disposition != DISPOSITION_NORMAL) + { + g_string_append (a11y, _(" (Attention Required)")); + } + + g_debug (G_STRLOC" setting a11y to \"%s\"", a11y->str); + g_clear_pointer (&indicator->entry.accessible_desc, g_free); + indicator->entry.accessible_desc = g_string_free (a11y, FALSE); + g_signal_emit (indicator, + INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE_ID, + 0, + &indicator->entry); +} + +static void +indicator_session_update_icon_from_disposition (IndicatorSession * indicator, + int disposition) +{ + const gchar * icon; if (greeter_mode) { @@ -450,17 +476,12 @@ indicator_session_update_from_disposition (IndicatorSession * indicator, icon = ICON_ALERT; } - g_debug (G_STRLOC" setting icon to \"%s\", a11y to \"%s\"", icon, a11y); + g_debug (G_STRLOC" setting icon to \"%s\"", icon); gtk_image_set_from_icon_name (GTK_IMAGE(indicator->entry.image), icon, GTK_ICON_SIZE_BUTTON); - indicator->entry.accessible_desc = a11y; - g_signal_emit (indicator, - INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE_ID, - 0, - &indicator->entry); } - + static int calculate_disposition (IndicatorSession * indicator) { @@ -492,10 +513,11 @@ calculate_disposition (IndicatorSession * indicator) } static void -indicator_session_update_icon (IndicatorSession * indicator) +indicator_session_update_icon_and_a11y (IndicatorSession * indicator) { const int disposition = calculate_disposition (indicator); - indicator_session_update_from_disposition (indicator, disposition); + indicator_session_update_a11y_from_disposition (indicator, disposition); + indicator_session_update_icon_from_disposition (indicator, disposition); } static void @@ -505,7 +527,7 @@ on_menuitem_property_changed (DbusmenuMenuitem * mi, gpointer indicator) { if (!g_strcmp0 (property, DBUSMENU_MENUITEM_PROP_DISPOSITION)) - indicator_session_update_icon (indicator); + indicator_session_update_icon_and_a11y (indicator); } static void |