Merge lp:~charlesk/indicator-session/lp-1044015 into lp:indicator-session/12.10

Proposed by Charles Kerr
Status: Merged
Approved by: Ted Gould
Approved revision: 355
Merged at revision: 353
Proposed branch: lp:~charlesk/indicator-session/lp-1044015
Merge into: lp:indicator-session/12.10
Diff against target: 247 lines (+161/-17)
2 files modified
src/indicator-session.c (+158/-16)
src/shared-names.h (+3/-1)
To merge this branch: bzr merge lp:~charlesk/indicator-session/lp-1044015
Reviewer Review Type Date Requested Status
jenkins (community) continuous-integration Approve
Ted Gould (community) Approve
Review via email: mp+122179@code.launchpad.net

Description of the change

This code is ready for review but I'm marking it "work in progress" because I don't want Tarmac to autoland it before Design has a chance to say what the indicator's a11y text should be here.

To post a comment you must log in.
Revision history for this message
Charles Kerr (charlesk) wrote :

Neither mpt nor JohnLea had an opinion on the error state a11y text, changing from "work in progress" to "ready for review"

Revision history for this message
Ted Gould (ted) :
review: Approve
356. By Charles Kerr

add a11y case for attention needed, but username display disabled

Revision history for this message
jenkins (martin-mrazik+qa) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/indicator-session.c'
--- src/indicator-session.c 2012-08-22 00:12:32 +0000
+++ src/indicator-session.c 2012-08-31 16:38:18 +0000
@@ -63,6 +63,7 @@
63 GCancellable * service_proxy_cancel;63 GCancellable * service_proxy_cancel;
64 GDBusProxy * service_proxy;64 GDBusProxy * service_proxy;
65 GSettings * settings;65 GSettings * settings;
66 DbusmenuClient * menu_client;
66};67};
6768
68static gboolean greeter_mode;69static gboolean greeter_mode;
@@ -82,6 +83,8 @@
82 DbusmenuMenuitem * parent,83 DbusmenuMenuitem * parent,
83 DbusmenuClient * client,84 DbusmenuClient * client,
84 gpointer user_data);85 gpointer user_data);
86static void on_menu_layout_updated (DbusmenuClient * client, IndicatorSession * session);
87static void indicator_session_update_icon_and_a11y (IndicatorSession * self);
85static void indicator_session_update_users_label (IndicatorSession* self,88static void indicator_session_update_users_label (IndicatorSession* self,
86 const gchar* name);89 const gchar* name);
87static void service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data);90static void service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data);
@@ -116,8 +119,6 @@
116static void119static void
117indicator_session_init (IndicatorSession *self)120indicator_session_init (IndicatorSession *self)
118{121{
119 const gchar * icon_name;
120
121 self->settings = g_settings_new ("com.canonical.indicator.session");122 self->settings = g_settings_new ("com.canonical.indicator.session");
122123
123 /* Now let's fire these guys up. */124 /* Now let's fire these guys up. */
@@ -130,30 +131,38 @@
130 greeter_mode = !g_strcmp0(g_getenv("INDICATOR_GREETER_MODE"), "1");131 greeter_mode = !g_strcmp0(g_getenv("INDICATOR_GREETER_MODE"), "1");
131132
132 self->entry.name_hint = PACKAGE;133 self->entry.name_hint = PACKAGE;
133 self->entry.accessible_desc = _("Session Menu");
134 self->entry.label = GTK_LABEL (gtk_label_new ("User Name"));134 self->entry.label = GTK_LABEL (gtk_label_new ("User Name"));
135 icon_name = greeter_mode ? GREETER_ICON_DEFAULT : ICON_DEFAULT;135 self->entry.image = GTK_IMAGE (gtk_image_new());
136 self->entry.image = GTK_IMAGE (gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON));
137 self->entry.menu = GTK_MENU (dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME,136 self->entry.menu = GTK_MENU (dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME,
138 INDICATOR_SESSION_DBUS_OBJECT));137 INDICATOR_SESSION_DBUS_OBJECT));
138 indicator_session_update_icon_and_a11y (self);
139 g_settings_bind (self->settings, "show-real-name-on-panel",139 g_settings_bind (self->settings, "show-real-name-on-panel",
140 self->entry.label, "visible",140 self->entry.label, "visible",
141 G_SETTINGS_BIND_GET);141 G_SETTINGS_BIND_GET);
142142
143 /* show-real-name-on-panel affects the a11y string */
144 g_signal_connect_swapped (self->settings,
145 "notify::show-real-name-on-panel",
146 G_CALLBACK(indicator_session_update_icon_and_a11y),
147 self);
148
143 gtk_widget_show (GTK_WIDGET(self->entry.menu));149 gtk_widget_show (GTK_WIDGET(self->entry.menu));
144 gtk_widget_show (GTK_WIDGET(self->entry.image));150 gtk_widget_show (GTK_WIDGET(self->entry.image));
145 g_object_ref_sink (self->entry.menu);151 g_object_ref_sink (self->entry.menu);
146 g_object_ref_sink (self->entry.image);152 g_object_ref_sink (self->entry.image);
147153
148 // set up the handlers154 // set up the handlers
149 DbusmenuClient * menu_client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(DBUSMENU_GTKMENU(self->entry.menu)));155 self->menu_client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(DBUSMENU_GTKMENU(self->entry.menu)));
150 dbusmenu_client_add_type_handler (menu_client,156 g_signal_connect (self->menu_client, "layout-updated",
157 G_CALLBACK(on_menu_layout_updated), self);
158
159 dbusmenu_client_add_type_handler (self->menu_client,
151 USER_ITEM_TYPE,160 USER_ITEM_TYPE,
152 new_user_item);161 new_user_item);
153 dbusmenu_client_add_type_handler (menu_client,162 dbusmenu_client_add_type_handler (self->menu_client,
154 RESTART_ITEM_TYPE,163 RESTART_ITEM_TYPE,
155 build_restart_item);164 build_restart_item);
156 dbusmenu_gtkclient_set_accel_group (DBUSMENU_GTKCLIENT(menu_client),165 dbusmenu_gtkclient_set_accel_group (DBUSMENU_GTKCLIENT(self->menu_client),
157 gtk_accel_group_new());166 gtk_accel_group_new());
158}167}
159168
@@ -339,13 +348,6 @@
339 g_variant_get (parameters, "(&s)", &username);348 g_variant_get (parameters, "(&s)", &username);
340 indicator_session_update_users_label (self, username); 349 indicator_session_update_users_label (self, username);
341 }350 }
342 else if (!g_strcmp0(signal_name, "RestartRequired"))
343 {
344 const gchar * icon_name = greeter_mode ? GREETER_ICON_RESTART : ICON_RESTART;
345 gtk_image_set_from_icon_name (GTK_IMAGE(self->entry.image), icon_name, GTK_ICON_SIZE_MENU);
346 self->entry.accessible_desc = _("Device Menu (reboot required)");
347 g_signal_emit (G_OBJECT(self), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE_ID, 0, &self->entry);
348 }
349}351}
350352
351353
@@ -412,3 +414,143 @@
412{414{
413 gtk_label_set_text (self->entry.label, name ? name : "");415 gtk_label_set_text (self->entry.label, name ? name : "");
414}416}
417
418/***
419**** Disposition
420***/
421
422enum
423{
424 DISPOSITION_NORMAL,
425 DISPOSITION_INFO,
426 DISPOSITION_WARNING,
427 DISPOSITION_ALERT
428};
429
430static void
431indicator_session_update_a11y_from_disposition (IndicatorSession * indicator,
432 int disposition)
433{
434 gchar * a11y;
435 const gchar * username = gtk_label_get_text (indicator->entry.label);
436 const gboolean need_attn = disposition != DISPOSITION_NORMAL;
437 const gboolean show_name = g_settings_get_boolean (indicator->settings,
438 "show-real-name-on-panel");
439
440 if (show_name && need_attn)
441 a11y = g_strdup_printf (_("System %s (Attention Required)"), username);
442 else if (show_name)
443 a11y = g_strdup_printf (_("System %s"), username);
444 else if (need_attn)
445 a11y = g_strdup (_("System (Attention Required)"));
446 else
447 a11y = g_strdup (_("System"));
448
449 g_debug (G_STRLOC" setting a11y to \"%s\"", a11y);
450 g_clear_pointer (&indicator->entry.accessible_desc, g_free);
451 indicator->entry.accessible_desc = a11y;
452 g_signal_emit (indicator,
453 INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE_ID,
454 0,
455 &indicator->entry);
456}
457
458static void
459indicator_session_update_icon_from_disposition (IndicatorSession * indicator,
460 int disposition)
461{
462 const gchar * icon;
463
464 if (greeter_mode)
465 {
466 if (disposition == DISPOSITION_NORMAL)
467 icon = GREETER_ICON_DEFAULT;
468 else
469 icon = GREETER_ICON_RESTART;
470 }
471 else
472 {
473 if (disposition == DISPOSITION_NORMAL)
474 icon = ICON_DEFAULT;
475 else if (disposition == DISPOSITION_INFO)
476 icon = ICON_INFO;
477 else
478 icon = ICON_ALERT;
479 }
480
481 g_debug (G_STRLOC" setting icon to \"%s\"", icon);
482 gtk_image_set_from_icon_name (GTK_IMAGE(indicator->entry.image),
483 icon,
484 GTK_ICON_SIZE_BUTTON);
485}
486
487static int
488calculate_disposition (IndicatorSession * indicator)
489{
490 GList * l;
491 DbusmenuMenuitem * root = dbusmenu_client_get_root (indicator->menu_client);
492 GList * children = dbusmenu_menuitem_get_children (root);
493 int ret = DISPOSITION_NORMAL;
494
495 for (l=children; l!=NULL; l=l->next)
496 {
497 int val;
498 const gchar * key = DBUSMENU_MENUITEM_PROP_DISPOSITION;
499 const gchar * val_str = dbusmenu_menuitem_property_get (l->data, key);
500
501 if (!g_strcmp0 (val_str, DBUSMENU_MENUITEM_DISPOSITION_ALERT))
502 val = DISPOSITION_ALERT;
503 else if (!g_strcmp0 (val_str, DBUSMENU_MENUITEM_DISPOSITION_WARNING))
504 val = DISPOSITION_WARNING;
505 else if (!g_strcmp0 (val_str, DBUSMENU_MENUITEM_DISPOSITION_INFORMATIVE))
506 val = DISPOSITION_INFO;
507 else
508 val = DISPOSITION_NORMAL;
509
510 if (ret < val)
511 ret = val;
512 }
513
514 return ret;
515}
516
517static void
518indicator_session_update_icon_and_a11y (IndicatorSession * indicator)
519{
520 const int disposition = calculate_disposition (indicator);
521 indicator_session_update_a11y_from_disposition (indicator, disposition);
522 indicator_session_update_icon_from_disposition (indicator, disposition);
523}
524
525static void
526on_menuitem_property_changed (DbusmenuMenuitem * mi,
527 gchar * property,
528 GValue * value,
529 gpointer indicator)
530{
531 if (!g_strcmp0 (property, DBUSMENU_MENUITEM_PROP_DISPOSITION))
532 indicator_session_update_icon_and_a11y (indicator);
533}
534
535static void
536on_menu_layout_updated (DbusmenuClient * client, IndicatorSession * session)
537{
538 GList * l;
539 DbusmenuMenuitem * root = dbusmenu_client_get_root (client);
540 GList * children = dbusmenu_menuitem_get_children (root);
541 static GQuark tag = 0;
542
543 if (G_UNLIKELY (tag == 0))
544 {
545 tag = g_quark_from_static_string ("x-tagged-by-indicator-session");
546 }
547
548 for (l=children; l!=NULL; l=l->next)
549 {
550 if (g_object_get_qdata (l->data, tag) == NULL)
551 {
552 g_object_set_qdata (l->data, tag, GINT_TO_POINTER(1));
553 g_signal_connect (l->data, "property-changed", G_CALLBACK(on_menuitem_property_changed), session);
554 }
555 }
556}
415557
=== modified file 'src/shared-names.h'
--- src/shared-names.h 2012-06-18 17:35:05 +0000
+++ src/shared-names.h 2012-08-31 16:38:18 +0000
@@ -41,7 +41,9 @@
41#define RESTART_ITEM_ICON "restart-icon"41#define RESTART_ITEM_ICON "restart-icon"
4242
43#define ICON_DEFAULT "system-devices-panel"43#define ICON_DEFAULT "system-devices-panel"
44#define ICON_RESTART "system-devices-panel-alert"44#define ICON_INFO "system-devices-panel-information"
45#define ICON_ALERT "system-devices-panel-alert"
46
45#define GREETER_ICON_DEFAULT "system-shutdown-panel"47#define GREETER_ICON_DEFAULT "system-shutdown-panel"
46#define GREETER_ICON_RESTART "system-shutdown-panel-restart"48#define GREETER_ICON_RESTART "system-shutdown-panel-restart"
4749

Subscribers

People subscribed via source and target branches