Merge lp:~themuso/unity/improve-shutdown-dialog-a11y into lp:unity

Proposed by Luke Yelavich
Status: Merged
Approved by: Stephen M. Webb
Approved revision: no longer in the source branch.
Merged at revision: 3698
Proposed branch: lp:~themuso/unity/improve-shutdown-dialog-a11y
Merge into: lp:unity
Diff against target: 381 lines (+324/-0)
4 files modified
plugins/unityshell/src/nux-layout-accessible.cpp (+5/-0)
plugins/unityshell/src/unity-session-button-accessible.cpp (+260/-0)
plugins/unityshell/src/unity-session-button-accessible.h (+53/-0)
plugins/unityshell/src/unitya11y.cpp (+6/-0)
To merge this branch: bzr merge lp:~themuso/unity/improve-shutdown-dialog-a11y
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+207089@code.launchpad.net

Commit message

Implement accessibility for the optino buttons in the shutdown dialog.

Also improve the parent-child relationship between objects such that the shutdown message can be read with Orca flat review.

Description of the change

Implement accessibility for the optino buttons in the shutdown dialog.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

412 + highlight_change.emit();

424 + sigc::signal<void> highlight_change;

You don't need that, I'm using a nux::Property for highlighted, and it already supports signaling.

Just connect to highlighted.changed signal ;)

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

376 + if (object->Type().IsDerivedFromType(Button::StaticObjectType))
377 + return unity_session_button_accessible_new(object);

It shuold work anyway, but I think it's better to use IsDerivedFromType(session::Button::StaticObjectType), to avoid future conflicts.

Anyway this looks good now, thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/unityshell/src/nux-layout-accessible.cpp'
--- plugins/unityshell/src/nux-layout-accessible.cpp 2012-08-15 14:05:18 +0000
+++ plugins/unityshell/src/nux-layout-accessible.cpp 2014-02-25 01:48:00 +0000
@@ -137,6 +137,7 @@
137 std::list<nux::Area*> element_list;137 std::list<nux::Area*> element_list;
138 gint num = 0;138 gint num = 0;
139 std::list<nux::Area*>::iterator it;139 std::list<nux::Area*>::iterator it;
140 AtkObject* parent = NULL;
140141
141 g_return_val_if_fail(NUX_IS_LAYOUT_ACCESSIBLE(obj), 0);142 g_return_val_if_fail(NUX_IS_LAYOUT_ACCESSIBLE(obj), 0);
142 num = atk_object_get_n_accessible_children(obj);143 num = atk_object_get_n_accessible_children(obj);
@@ -156,6 +157,10 @@
156 child = dynamic_cast<nux::Object*>(*it);157 child = dynamic_cast<nux::Object*>(*it);
157 child_accessible = unity_a11y_get_accessible(child);158 child_accessible = unity_a11y_get_accessible(child);
158159
160 parent = atk_object_get_parent(child_accessible);
161 if (parent != obj)
162 atk_object_set_parent(child_accessible, obj);
163
159 g_object_ref(child_accessible);164 g_object_ref(child_accessible);
160165
161 return child_accessible;166 return child_accessible;
162167
=== added file 'plugins/unityshell/src/unity-session-button-accessible.cpp'
--- plugins/unityshell/src/unity-session-button-accessible.cpp 1970-01-01 00:00:00 +0000
+++ plugins/unityshell/src/unity-session-button-accessible.cpp 2014-02-25 01:48:00 +0000
@@ -0,0 +1,260 @@
1/*
2 * Copyright (C) 2011 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Luke Yelavich <luke.yelavich@canonical.com>
17 */
18
19/**
20 * SECTION:unity-session_button_accessible
21 * @Title: UnitySessionButtonAccessible
22 * @short_description: Implementation of the ATK interfaces for #unity::session::Button
23 *
24 * #UnitySessionButtonAccessible implements the required ATK interfaces of
25 * unity::Button, exposing the common elements on each basic individual
26 * element (position, extents, etc)
27 *
28 */
29
30#include "unity-session-button-accessible.h"
31#include "SessionButton.h"
32
33#include "unitya11y.h"
34
35using namespace unity::session;
36
37/* GObject */
38static void unity_session_button_accessible_class_init(UnitySessionButtonAccessibleClass* klass);
39static void unity_session_button_accessible_init(UnitySessionButtonAccessible* session_button_accessible);
40static void unity_session_button_accessible_dispose(GObject* object);
41static void unity_session_button_accessible_finalize(GObject* object);
42
43
44/* AtkObject.h */
45static void unity_session_button_accessible_initialize(AtkObject* accessible,
46 gpointer data);
47static AtkStateSet* unity_session_button_accessible_ref_state_set(AtkObject* obj);
48static const gchar* unity_session_button_accessible_get_name(AtkObject* obj);
49
50
51/* AtkAction */
52static void atk_action_interface_init(AtkActionIface *iface);
53static gboolean unity_session_button_accessible_do_action(AtkAction *action,
54 gint i);
55static gint unity_session_button_accessible_get_n_actions(AtkAction *action);
56static const gchar* unity_session_button_accessible_get_name(AtkAction *action,
57 gint i);
58
59/* private/utility methods*/
60static void on_focus_change_cb(bool const& value, UnitySessionButtonAccessible* accessible);
61
62G_DEFINE_TYPE_WITH_CODE(UnitySessionButtonAccessible,
63 unity_session_button_accessible,
64 NUX_TYPE_OBJECT_ACCESSIBLE,
65 G_IMPLEMENT_INTERFACE(ATK_TYPE_ACTION,
66 atk_action_interface_init))
67
68static void
69unity_session_button_accessible_class_init(UnitySessionButtonAccessibleClass* klass)
70{
71 GObjectClass* gobject_class = G_OBJECT_CLASS(klass);
72 AtkObjectClass* atk_class = ATK_OBJECT_CLASS(klass);
73
74 gobject_class->dispose = unity_session_button_accessible_dispose;
75 gobject_class->finalize = unity_session_button_accessible_finalize;
76
77 /* AtkObject */
78 atk_class->initialize = unity_session_button_accessible_initialize;
79 atk_class->get_name = unity_session_button_accessible_get_name;
80 atk_class->ref_state_set = unity_session_button_accessible_ref_state_set;
81}
82
83static void
84unity_session_button_accessible_init(UnitySessionButtonAccessible* session_button_accessible)
85{
86}
87
88static void
89unity_session_button_accessible_dispose(GObject* object)
90{
91 G_OBJECT_CLASS(unity_session_button_accessible_parent_class)->dispose(object);
92}
93
94static void
95unity_session_button_accessible_finalize(GObject* object)
96{
97 G_OBJECT_CLASS(unity_session_button_accessible_parent_class)->finalize(object);
98}
99
100AtkObject*
101unity_session_button_accessible_new(nux::Object* object)
102{
103 AtkObject* accessible = NULL;
104
105 g_return_val_if_fail(dynamic_cast<Button*>(object), NULL);
106
107 accessible = ATK_OBJECT(g_object_new(UNITY_TYPE_SESSION_BUTTON_ACCESSIBLE, NULL));
108
109 atk_object_initialize(accessible, object);
110
111 return accessible;
112}
113
114/* AtkObject.h */
115static void
116unity_session_button_accessible_initialize(AtkObject* accessible,
117 gpointer data)
118{
119 UnitySessionButtonAccessible* self = NULL;
120 nux::Object* nux_object = NULL;
121 Button* button = NULL;
122
123 ATK_OBJECT_CLASS(unity_session_button_accessible_parent_class)->initialize(accessible, data);
124 self = UNITY_SESSION_BUTTON_ACCESSIBLE(accessible);
125
126 accessible->role = ATK_ROLE_PUSH_BUTTON;
127
128 nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(accessible));
129
130 if (nux_object == NULL) /* defunct */
131 return;
132
133 button = dynamic_cast<Button*>(nux_object);
134
135 button->highlighted.changed.connect(sigc::bind(sigc::ptr_fun(on_focus_change_cb),
136 UNITY_SESSION_BUTTON_ACCESSIBLE(self)));
137}
138
139static const gchar*
140unity_session_button_accessible_get_name(AtkObject* obj)
141{
142 const gchar* name;
143
144 g_return_val_if_fail(UNITY_IS_SESSION_BUTTON_ACCESSIBLE(obj), NULL);
145
146 name = ATK_OBJECT_CLASS(unity_session_button_accessible_parent_class)->get_name(obj);
147 if (name == NULL)
148 {
149 Button* button = NULL;
150
151 button = dynamic_cast<Button*>(nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(obj)));
152
153 if (button == NULL) /* State is defunct */
154 name = NULL;
155 else
156 name = button->label().c_str();
157 }
158
159 return name;
160}
161
162static AtkStateSet*
163unity_session_button_accessible_ref_state_set(AtkObject* obj)
164{
165 AtkStateSet* state_set = NULL;
166 nux::Object* nux_object = NULL;
167 Button* button = NULL;
168
169 g_return_val_if_fail(UNITY_IS_SESSION_BUTTON_ACCESSIBLE(obj), NULL);
170
171 state_set = ATK_OBJECT_CLASS(unity_session_button_accessible_parent_class)->ref_state_set(obj);
172
173 nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(obj));
174
175 if (nux_object == NULL) /* defunct */
176 return state_set;
177
178 button = dynamic_cast<Button*>(nux_object);
179
180 atk_state_set_add_state(state_set, ATK_STATE_FOCUSABLE);
181 atk_state_set_add_state(state_set, ATK_STATE_ENABLED);
182 atk_state_set_add_state(state_set, ATK_STATE_SENSITIVE);
183 atk_state_set_add_state(state_set, ATK_STATE_VISIBLE);
184 atk_state_set_add_state(state_set, ATK_STATE_SHOWING);
185
186 if (button->highlighted)
187 {
188 atk_state_set_add_state(state_set, ATK_STATE_FOCUSED);
189 atk_state_set_add_state(state_set, ATK_STATE_SELECTED);
190 atk_state_set_add_state(state_set, ATK_STATE_ACTIVE);
191 }
192
193 return state_set;
194}
195
196/* private methods */
197static void
198on_focus_change_cb(bool const& value, UnitySessionButtonAccessible* accessible)
199{
200 nux::Object* nux_object = NULL;
201 Button* button = NULL;
202
203 nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(accessible));
204
205 if (nux_object == NULL) /* defunct */
206 return;
207
208 button = dynamic_cast<Button*>(nux_object);
209
210 atk_object_notify_state_change(ATK_OBJECT(accessible), ATK_STATE_FOCUSED, button->highlighted);
211 atk_object_notify_state_change(ATK_OBJECT(accessible), ATK_STATE_SELECTED, button->highlighted);
212 atk_object_notify_state_change(ATK_OBJECT(accessible), ATK_STATE_ACTIVE, button->highlighted);
213}
214
215/* AtkAction */
216static void
217atk_action_interface_init(AtkActionIface *iface)
218{
219 iface->do_action = unity_session_button_accessible_do_action;
220 iface->get_n_actions = unity_session_button_accessible_get_n_actions;
221 iface->get_name = unity_session_button_accessible_get_name;
222}
223
224static gboolean
225unity_session_button_accessible_do_action(AtkAction *action,
226 gint i)
227{
228 Button* button = NULL;
229 nux::Object* nux_object = NULL;
230
231 g_return_val_if_fail(UNITY_IS_SESSION_BUTTON_ACCESSIBLE(action), FALSE);
232
233 nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(action));
234 if (nux_object == NULL)
235 return FALSE;
236
237 button = dynamic_cast<Button*>(nux_object);
238
239 button->activated.emit();
240
241 return TRUE;
242}
243
244static gint
245unity_session_button_accessible_get_n_actions(AtkAction *action)
246{
247 g_return_val_if_fail(UNITY_IS_SESSION_BUTTON_ACCESSIBLE(action), 0);
248
249 return 1;
250}
251
252static const gchar*
253unity_session_button_accessible_get_name(AtkAction *action,
254 gint i)
255{
256 g_return_val_if_fail(UNITY_IS_SESSION_BUTTON_ACCESSIBLE(action), NULL);
257 g_return_val_if_fail(i == 0, NULL);
258
259 return "activate";
260}
0261
=== added file 'plugins/unityshell/src/unity-session-button-accessible.h'
--- plugins/unityshell/src/unity-session-button-accessible.h 1970-01-01 00:00:00 +0000
+++ plugins/unityshell/src/unity-session-button-accessible.h 2014-02-25 01:48:00 +0000
@@ -0,0 +1,53 @@
1/*
2 * Copyright (C) 2011 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
17 */
18
19#ifndef UNITY_SESSION_BUTTON_ACCESSIBLE_H
20#define UNITY_SESSION_BUTTON_ACCESSIBLE_H
21
22#include <atk/atk.h>
23
24#include "nux-object-accessible.h"
25
26G_BEGIN_DECLS
27
28#define UNITY_TYPE_SESSION_BUTTON_ACCESSIBLE (unity_session_button_accessible_get_type ())
29#define UNITY_SESSION_BUTTON_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_TYPE_SESSION_BUTTON_ACCESSIBLE, UnitySessionButtonAccessible))
30#define UNITY_SESSION_BUTTON_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_TYPE_SESSION_BUTTON_ACCESSIBLE, UnitySessionButtonAccessibleClass))
31#define UNITY_IS_SESSION_BUTTON_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_TYPE_SESSION_BUTTON_ACCESSIBLE))
32#define UNITY_IS_SESSION_BUTTON_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_TYPE_SESSION_BUTTON_ACCESSIBLE))
33#define UNITY_SESSION_BUTTON_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_TYPE_SESSION_BUTTON_ACCESSIBLE, UnitySessionButtonAccessibleClass))
34
35typedef struct _UnitySessionButtonAccessible UnitySessionButtonAccessible;
36typedef struct _UnitySessionButtonAccessibleClass UnitySessionButtonAccessibleClass;
37
38struct _UnitySessionButtonAccessible
39{
40 NuxObjectAccessible parent;
41};
42
43struct _UnitySessionButtonAccessibleClass
44{
45 NuxObjectAccessibleClass parent_class;
46};
47
48GType unity_session_button_accessible_get_type(void);
49AtkObject* unity_session_button_accessible_new(nux::Object* object);
50
51G_END_DECLS
52
53#endif /* __UNITY_SESSION_BUTTON_ACCESSIBLE_H__ */
054
=== modified file 'plugins/unityshell/src/unitya11y.cpp'
--- plugins/unityshell/src/unitya11y.cpp 2014-01-25 13:39:49 +0000
+++ plugins/unityshell/src/unitya11y.cpp 2014-02-25 01:48:00 +0000
@@ -42,6 +42,7 @@
42#include "QuicklistView.h"42#include "QuicklistView.h"
43#include "QuicklistMenuItem.h"43#include "QuicklistMenuItem.h"
44#include "SwitcherView.h"44#include "SwitcherView.h"
45#include "SessionButton.h"
45#include "unity-launcher-accessible.h"46#include "unity-launcher-accessible.h"
46#include "unity-launcher-icon-accessible.h"47#include "unity-launcher-icon-accessible.h"
47#include "unity-panel-view-accessible.h"48#include "unity-panel-view-accessible.h"
@@ -53,11 +54,13 @@
53#include "unity-quicklist-accessible.h"54#include "unity-quicklist-accessible.h"
54#include "unity-quicklist-menu-item-accessible.h"55#include "unity-quicklist-menu-item-accessible.h"
55#include "unity-switcher-accessible.h"56#include "unity-switcher-accessible.h"
57#include "unity-session-button-accessible.h"
5658
57using namespace unity;59using namespace unity;
58using namespace unity::dash;60using namespace unity::dash;
59using namespace unity::launcher;61using namespace unity::launcher;
60using namespace unity::panel;62using namespace unity::panel;
63using namespace unity::session;
6164
62static GHashTable* accessible_table = NULL;65static GHashTable* accessible_table = NULL;
63/* FIXME: remove accessible objects when not required anymore */66/* FIXME: remove accessible objects when not required anymore */
@@ -187,6 +190,9 @@
187 if (object->Type().IsDerivedFromType(unity::switcher::SwitcherView::StaticObjectType))190 if (object->Type().IsDerivedFromType(unity::switcher::SwitcherView::StaticObjectType))
188 return unity_switcher_accessible_new(object);191 return unity_switcher_accessible_new(object);
189192
193 if (object->Type().IsDerivedFromType(Button::StaticObjectType))
194 return unity_session_button_accessible_new(object);
195
190 /* NUX classes */196 /* NUX classes */
191 if (object->Type().IsDerivedFromType(nux::TextEntry::StaticObjectType))197 if (object->Type().IsDerivedFromType(nux::TextEntry::StaticObjectType))
192 return nux_text_entry_accessible_new(object);198 return nux_text_entry_accessible_new(object);