Merge lp:~apinheiro/unity/a11y-quicklist into lp:unity
- a11y-quicklist
- Merge into trunk
Proposed by
Alejandro Piñeiro
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Alex Launi | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 1737 | ||||
Proposed branch: | lp:~apinheiro/unity/a11y-quicklist | ||||
Merge into: | lp:unity | ||||
Prerequisite: | lp:~apinheiro/unity/a11y-internal-dash | ||||
Diff against target: |
1193 lines (+1049/-2) 11 files modified
plugins/unityshell/src/QuicklistMenuItem.cpp (+2/-2) plugins/unityshell/src/QuicklistView.cpp (+13/-0) plugins/unityshell/src/QuicklistView.h (+4/-0) plugins/unityshell/src/unity-launcher-accessible.cpp (+1/-0) plugins/unityshell/src/unity-quicklist-accessible.cpp (+182/-0) plugins/unityshell/src/unity-quicklist-accessible.h (+57/-0) plugins/unityshell/src/unity-quicklist-menu-accessible.cpp (+367/-0) plugins/unityshell/src/unity-quicklist-menu-accessible.h (+57/-0) plugins/unityshell/src/unity-quicklist-menu-item-accessible.cpp (+299/-0) plugins/unityshell/src/unity-quicklist-menu-item-accessible.h (+57/-0) plugins/unityshell/src/unitya11y.cpp (+10/-0) |
||||
To merge this branch: | bzr merge lp:~apinheiro/unity/a11y-quicklist | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alex Launi (community) | Approve | ||
Neil J. Patel | Pending | ||
Review via email: mp+79289@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Alejandro Piñeiro (apinheiro) wrote : | # |
Revision history for this message
Alex Launi (alexlauni) wrote : | # |
+1 this looks good
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'plugins/unityshell/src/QuicklistMenuItem.cpp' |
2 | --- plugins/unityshell/src/QuicklistMenuItem.cpp 2011-10-11 18:18:13 +0000 |
3 | +++ plugins/unityshell/src/QuicklistMenuItem.cpp 2011-11-07 19:26:37 +0000 |
4 | @@ -28,6 +28,8 @@ |
5 | |
6 | #include <X11/Xlib.h> |
7 | |
8 | +NUX_IMPLEMENT_OBJECT_TYPE(QuicklistMenuItem); |
9 | + |
10 | static void |
11 | OnPropertyChanged(gchar* property, |
12 | GValue* value, |
13 | @@ -37,8 +39,6 @@ |
14 | OnItemActivated(guint timestamp, |
15 | QuicklistMenuItem* self); |
16 | |
17 | -NUX_IMPLEMENT_OBJECT_TYPE(QuicklistMenuItem); |
18 | - |
19 | QuicklistMenuItem::QuicklistMenuItem(DbusmenuMenuitem* item, |
20 | NUX_FILE_LINE_DECL) : |
21 | View(NUX_FILE_LINE_PARAM) |
22 | |
23 | === modified file 'plugins/unityshell/src/QuicklistView.cpp' |
24 | --- plugins/unityshell/src/QuicklistView.cpp 2011-10-11 18:18:13 +0000 |
25 | +++ plugins/unityshell/src/QuicklistView.cpp 2011-11-07 19:26:37 +0000 |
26 | @@ -181,6 +181,8 @@ |
27 | while (IsMenuItemSeperator(_current_item_index)) |
28 | _current_item_index--; |
29 | |
30 | + selection_change.emit(); |
31 | + |
32 | GetNthItems(_current_item_index)->_prelight = true; |
33 | QueueDraw(); |
34 | } |
35 | @@ -201,6 +203,8 @@ |
36 | while (IsMenuItemSeperator(_current_item_index)) |
37 | _current_item_index++; |
38 | |
39 | + selection_change.emit(); |
40 | + |
41 | GetNthItems(_current_item_index)->_prelight = true; |
42 | QueueDraw(); |
43 | } |
44 | @@ -210,6 +214,7 @@ |
45 | case NUX_VK_LEFT: |
46 | case NUX_KP_LEFT: |
47 | _current_item_index = 0; |
48 | + selection_change.emit(); |
49 | GetNthItems(_current_item_index)->_prelight = true; |
50 | Hide(); |
51 | // inform Launcher we switch back to Launcher key-nav |
52 | @@ -221,12 +226,14 @@ |
53 | // esc (close quicklist, exit key-nav) |
54 | case NUX_VK_ESCAPE: |
55 | _current_item_index = 0; |
56 | + selection_change.emit(); |
57 | GetNthItems(_current_item_index)->_prelight = true; |
58 | Hide(); |
59 | // inform UnityScreen we leave key-nav completely |
60 | ubus_server_send_message(ubus_server_get_default(), |
61 | UBUS_LAUNCHER_END_KEY_NAV, |
62 | NULL); |
63 | + selection_change.emit(); |
64 | break; |
65 | |
66 | // <SPACE>, <RETURN> (activate selected menu-item) |
67 | @@ -242,6 +249,7 @@ |
68 | NULL, |
69 | 0); |
70 | _current_item_index = 0; |
71 | + selection_change.emit(); |
72 | GetNthItems(_current_item_index)->_prelight = true; |
73 | Hide(); |
74 | } |
75 | @@ -1507,3 +1515,8 @@ |
76 | return true; |
77 | } |
78 | |
79 | +QuicklistMenuItem* |
80 | +QuicklistView::GetSelectedMenuItem() |
81 | +{ |
82 | + return GetNthItems(_current_item_index); |
83 | +} |
84 | |
85 | === modified file 'plugins/unityshell/src/QuicklistView.h' |
86 | --- plugins/unityshell/src/QuicklistView.h 2011-10-11 18:18:13 +0000 |
87 | +++ plugins/unityshell/src/QuicklistView.h 2011-11-07 19:26:37 +0000 |
88 | @@ -97,6 +97,10 @@ |
89 | unsigned int keysym, |
90 | const char* character); |
91 | |
92 | + //Required for a11y |
93 | + QuicklistMenuItem* GetSelectedMenuItem(); |
94 | + sigc::signal<void> selection_change; |
95 | + |
96 | private: |
97 | void RecvCairoTextChanged(QuicklistMenuItem* item); |
98 | void RecvCairoTextColorChanged(QuicklistMenuItem* item); |
99 | |
100 | === modified file 'plugins/unityshell/src/unity-launcher-accessible.cpp' |
101 | --- plugins/unityshell/src/unity-launcher-accessible.cpp 2011-10-06 04:18:36 +0000 |
102 | +++ plugins/unityshell/src/unity-launcher-accessible.cpp 2011-11-07 19:26:37 +0000 |
103 | @@ -36,6 +36,7 @@ |
104 | #include "unitya11y.h" |
105 | #include "Launcher.h" |
106 | #include "LauncherModel.h" |
107 | +#include "QuicklistView.h" |
108 | |
109 | using unity::launcher::Launcher; |
110 | using unity::launcher::LauncherIcon; |
111 | |
112 | === added file 'plugins/unityshell/src/unity-quicklist-accessible.cpp' |
113 | --- plugins/unityshell/src/unity-quicklist-accessible.cpp 1970-01-01 00:00:00 +0000 |
114 | +++ plugins/unityshell/src/unity-quicklist-accessible.cpp 2011-11-07 19:26:37 +0000 |
115 | @@ -0,0 +1,182 @@ |
116 | +/* |
117 | + * Copyright (C) 2011 Canonical Ltd |
118 | + * |
119 | + * This program is free software: you can redistribute it and/or modify |
120 | + * it under the terms of the GNU General Public License version 3 as |
121 | + * published by the Free Software Foundation. |
122 | + * |
123 | + * This program is distributed in the hope that it will be useful, |
124 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
125 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
126 | + * GNU General Public License for more details. |
127 | + * |
128 | + * You should have received a copy of the GNU General Public License |
129 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
130 | + * |
131 | + * Authored by: Alejandro Piñeiro Iglesias <apinheiro@igalia.com> |
132 | + */ |
133 | + |
134 | +/** |
135 | + * SECTION:unity-quicklist-accessible |
136 | + * @Title: UnityQuicklistAccessible |
137 | + * @short_description: Implementation of the ATK interfaces for #QuicklistView |
138 | + * @see_also: QuicklistView |
139 | + * |
140 | + * #UnityQuicklistAccessible implements the required ATK interfaces for |
141 | + * #QuicklistView. |
142 | + * |
143 | + * IMPLEMENTATION NOTES: |
144 | + * |
145 | + * The desired accessible object hierarchy is the following one: |
146 | + * Role:menu |
147 | + * Role:menu-item |
148 | + * Role:menu-item. |
149 | + * |
150 | + * But this quicklist is also a base window, so we can't set a role |
151 | + * menu, and then keeping it sending window messages. |
152 | + * |
153 | + * So a new object, with role menu will be added to the hierarchy: |
154 | + * QuicklistMenu. It also hide the intermediate container objects. |
155 | + * |
156 | + * So we will have: |
157 | + * Role:window (the quicklist itself) |
158 | + * Role:menu (a dummy object having the role menu) |
159 | + * Role:menuitem (From QuicklistView->GetChildren) |
160 | + * Role:menuitem |
161 | + * |
162 | + */ |
163 | + |
164 | +#include <glib/gi18n.h> |
165 | + |
166 | +#include "unity-quicklist-accessible.h" |
167 | +#include "unity-quicklist-menu-accessible.h" |
168 | + |
169 | +#include "unitya11y.h" |
170 | +#include "Launcher.h" /*without this I get a error with the following include*/ |
171 | +#include "QuicklistView.h" |
172 | + |
173 | +/* GObject */ |
174 | +static void unity_quicklist_accessible_class_init(UnityQuicklistAccessibleClass* klass); |
175 | +static void unity_quicklist_accessible_init(UnityQuicklistAccessible* self); |
176 | + |
177 | +/* AtkObject.h */ |
178 | +static void unity_quicklist_accessible_initialize(AtkObject* accessible, |
179 | + gpointer data); |
180 | +static gint unity_quicklist_accessible_get_n_children(AtkObject* obj); |
181 | +static AtkObject* unity_quicklist_accessible_ref_child(AtkObject* obj, |
182 | + gint i); |
183 | + |
184 | +G_DEFINE_TYPE(UnityQuicklistAccessible, unity_quicklist_accessible, NUX_TYPE_BASE_WINDOW_ACCESSIBLE); |
185 | + |
186 | + |
187 | +#define UNITY_QUICKLIST_ACCESSIBLE_GET_PRIVATE(obj) \ |
188 | + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), UNITY_TYPE_QUICKLIST_ACCESSIBLE, \ |
189 | + UnityQuicklistAccessiblePrivate)) |
190 | + |
191 | +struct _UnityQuicklistAccessiblePrivate |
192 | +{ |
193 | + AtkObject* menu_accessible; |
194 | +}; |
195 | + |
196 | + |
197 | +static void |
198 | +unity_quicklist_accessible_class_init(UnityQuicklistAccessibleClass* klass) |
199 | +{ |
200 | + GObjectClass* gobject_class = G_OBJECT_CLASS(klass); |
201 | + AtkObjectClass* atk_class = ATK_OBJECT_CLASS(klass); |
202 | + |
203 | + /* AtkObject */ |
204 | + atk_class->initialize = unity_quicklist_accessible_initialize; |
205 | + atk_class->get_n_children = unity_quicklist_accessible_get_n_children; |
206 | + atk_class->ref_child = unity_quicklist_accessible_ref_child; |
207 | + |
208 | + g_type_class_add_private(gobject_class, sizeof(UnityQuicklistAccessiblePrivate)); |
209 | +} |
210 | + |
211 | +static void |
212 | +unity_quicklist_accessible_init(UnityQuicklistAccessible* self) |
213 | +{ |
214 | + UnityQuicklistAccessiblePrivate* priv = |
215 | + UNITY_QUICKLIST_ACCESSIBLE_GET_PRIVATE(self); |
216 | + |
217 | + self->priv = priv; |
218 | + priv->menu_accessible = NULL; |
219 | +} |
220 | + |
221 | +AtkObject* |
222 | +unity_quicklist_accessible_new(nux::Object* object) |
223 | +{ |
224 | + AtkObject* accessible = NULL; |
225 | + |
226 | + g_return_val_if_fail(dynamic_cast<QuicklistView*>(object), NULL); |
227 | + |
228 | + accessible = ATK_OBJECT(g_object_new(UNITY_TYPE_QUICKLIST_ACCESSIBLE, NULL)); |
229 | + |
230 | + atk_object_initialize(accessible, object); |
231 | + |
232 | + return accessible; |
233 | +} |
234 | + |
235 | +/* AtkObject.h */ |
236 | +static void |
237 | +unity_quicklist_accessible_initialize(AtkObject* accessible, |
238 | + gpointer data) |
239 | +{ |
240 | + nux::Object* nux_object = NULL; |
241 | + QuicklistView* quicklist = NULL; |
242 | + |
243 | + ATK_OBJECT_CLASS(unity_quicklist_accessible_parent_class)->initialize(accessible, data); |
244 | + |
245 | + nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(accessible)); |
246 | + quicklist = dynamic_cast<QuicklistView*>(nux_object); |
247 | + |
248 | + if (quicklist == NULL) /* status defunct */ |
249 | + return; |
250 | + |
251 | + atk_object_set_name(accessible, "Quicklist"); |
252 | + |
253 | +} |
254 | + |
255 | +static gint |
256 | +unity_quicklist_accessible_get_n_children(AtkObject* obj) |
257 | +{ |
258 | + QuicklistView* quicklist = NULL; |
259 | + nux::Object* nux_object = NULL; |
260 | + |
261 | + g_return_val_if_fail(UNITY_IS_QUICKLIST_ACCESSIBLE(obj), 0); |
262 | + |
263 | + nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(obj)); |
264 | + quicklist = dynamic_cast<QuicklistView*>(nux_object); |
265 | + |
266 | + if (quicklist == NULL) |
267 | + return 0; |
268 | + else |
269 | + return 1; |
270 | +} |
271 | + |
272 | +static AtkObject* |
273 | +unity_quicklist_accessible_ref_child(AtkObject* obj, |
274 | + gint i) |
275 | +{ |
276 | + UnityQuicklistAccessible* self = NULL; |
277 | + QuicklistView* quicklist = NULL; |
278 | + nux::Object* nux_object = NULL; |
279 | + |
280 | + g_return_val_if_fail(UNITY_IS_QUICKLIST_ACCESSIBLE(obj), NULL); |
281 | + self = UNITY_QUICKLIST_ACCESSIBLE(obj); |
282 | + |
283 | + nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(obj)); |
284 | + quicklist = dynamic_cast<QuicklistView*>(nux_object); |
285 | + if (quicklist == NULL) |
286 | + return NULL; |
287 | + |
288 | + if (self->priv->menu_accessible == NULL) |
289 | + { |
290 | + self->priv->menu_accessible = unity_quicklist_menu_accessible_new(quicklist); |
291 | + atk_object_set_parent(self->priv->menu_accessible, ATK_OBJECT(self)); |
292 | + } |
293 | + |
294 | + g_object_ref(self->priv->menu_accessible); |
295 | + |
296 | + return self->priv->menu_accessible; |
297 | +} |
298 | |
299 | === added file 'plugins/unityshell/src/unity-quicklist-accessible.h' |
300 | --- plugins/unityshell/src/unity-quicklist-accessible.h 1970-01-01 00:00:00 +0000 |
301 | +++ plugins/unityshell/src/unity-quicklist-accessible.h 2011-11-07 19:26:37 +0000 |
302 | @@ -0,0 +1,57 @@ |
303 | +/* |
304 | + * Copyright (C) 2011 Canonical Ltd |
305 | + * |
306 | + * This program is free software: you can redistribute it and/or modify |
307 | + * it under the terms of the GNU General Public License version 3 as |
308 | + * published by the Free Software Foundation. |
309 | + * |
310 | + * This program is distributed in the hope that it will be useful, |
311 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
312 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
313 | + * GNU General Public License for more details. |
314 | + * |
315 | + * You should have received a copy of the GNU General Public License |
316 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
317 | + * |
318 | + * Authored by: Alejandro Piñeiro Iglesias <apinheiro@igalia.com> |
319 | + */ |
320 | + |
321 | +#ifndef UNITY_QUICKLIST_ACCESSIBLE_H |
322 | +#define UNITY_QUICKLIST_ACCESSIBLE_H |
323 | + |
324 | +#include <atk/atk.h> |
325 | + |
326 | +#include "nux-base-window-accessible.h" |
327 | + |
328 | +G_BEGIN_DECLS |
329 | + |
330 | +#define UNITY_TYPE_QUICKLIST_ACCESSIBLE (unity_quicklist_accessible_get_type ()) |
331 | +#define UNITY_QUICKLIST_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_TYPE_QUICKLIST_ACCESSIBLE, UnityQuicklistAccessible)) |
332 | +#define UNITY_QUICKLIST_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_TYPE_QUICKLIST_ACCESSIBLE, UnityQuicklistAccessibleClass)) |
333 | +#define UNITY_IS_QUICKLIST_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_TYPE_QUICKLIST_ACCESSIBLE)) |
334 | +#define UNITY_IS_QUICKLIST_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_TYPE_QUICKLIST_ACCESSIBLE)) |
335 | +#define UNITY_QUICKLIST_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_TYPE_QUICKLIST_ACCESSIBLE, UnityQuicklistAccessibleClass)) |
336 | + |
337 | +typedef struct _UnityQuicklistAccessible UnityQuicklistAccessible; |
338 | +typedef struct _UnityQuicklistAccessibleClass UnityQuicklistAccessibleClass; |
339 | +typedef struct _UnityQuicklistAccessiblePrivate UnityQuicklistAccessiblePrivate; |
340 | + |
341 | +struct _UnityQuicklistAccessible |
342 | +{ |
343 | + NuxBaseWindowAccessible parent; |
344 | + |
345 | + /*< private >*/ |
346 | + UnityQuicklistAccessiblePrivate* priv; |
347 | +}; |
348 | + |
349 | +struct _UnityQuicklistAccessibleClass |
350 | +{ |
351 | + NuxViewAccessibleClass parent_class; |
352 | +}; |
353 | + |
354 | +GType unity_quicklist_accessible_get_type(void); |
355 | +AtkObject* unity_quicklist_accessible_new(nux::Object* object); |
356 | + |
357 | +G_END_DECLS |
358 | + |
359 | +#endif /* __UNITY_QUICKLIST_ACCESSIBLE_H__ */ |
360 | |
361 | === added file 'plugins/unityshell/src/unity-quicklist-menu-accessible.cpp' |
362 | --- plugins/unityshell/src/unity-quicklist-menu-accessible.cpp 1970-01-01 00:00:00 +0000 |
363 | +++ plugins/unityshell/src/unity-quicklist-menu-accessible.cpp 2011-11-07 19:26:37 +0000 |
364 | @@ -0,0 +1,367 @@ |
365 | +/* |
366 | + * Copyright (C) 2011 Canonical Ltd |
367 | + * |
368 | + * This program is free software: you can redistribute it and/or modify |
369 | + * it under the terms of the GNU General Public License version 3 as |
370 | + * published by the Free Software Foundation. |
371 | + * |
372 | + * This program is distributed in the hope that it will be useful, |
373 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
374 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
375 | + * GNU General Public License for more details. |
376 | + * |
377 | + * You should have received a copy of the GNU General Public License |
378 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
379 | + * |
380 | + * Authored by: Alejandro Piñeiro Iglesias <apinheiro@igalia.com> |
381 | + */ |
382 | + |
383 | +/** |
384 | + * SECTION:unity-quicklist-accessible |
385 | + * @Title: UnityQuicklistMenuAccessible |
386 | + * @short_description: Implementation of the ATK interfaces for #QuicklistView as a menu |
387 | + * @see_also: QuicklistView |
388 | + * |
389 | + * #UnityQuicklistAccessible implements the required ATK interfaces for |
390 | + * #QuicklistView, exposing himself as a menu. |
391 | + * |
392 | + * Note that this object is a QuicklistAccessible delegated object. If |
393 | + * you call unitya11y->get_accessible with a Quicklist it will return |
394 | + * a QuicklistAccessible. QuicklistMenuAccessible should only be |
395 | + * instantiated by QuicklistAccessible |
396 | + * |
397 | + * IMPLEMENTATION NOTES: |
398 | + * |
399 | + * The desired accessible object hierarchy is the following one: |
400 | + * Role:menu |
401 | + * Role:menu-item |
402 | + * Role:menu-item. |
403 | + * |
404 | + * But this quicklist is also a base window, so we can't set a role |
405 | + * menu, and then keeping it sending window messages. |
406 | + * |
407 | + * So a new object, with role menu will be added to the hierarchy: |
408 | + * QuicklistMenu. It also hide the intermediate container objects. |
409 | + * |
410 | + * So we will have: |
411 | + * Role:window (the quicklist itself) |
412 | + * Role:menu (a dummy object having the role menu) |
413 | + * Role:menuitem (From QuicklistView->GetChildren) |
414 | + * Role:menuitem |
415 | + * |
416 | + */ |
417 | + |
418 | +#include <glib/gi18n.h> |
419 | + |
420 | +#include "unity-quicklist-menu-accessible.h" |
421 | + |
422 | +#include "unitya11y.h" |
423 | +#include "Launcher.h" /*without this I get a error with the following include*/ |
424 | +#include "QuicklistView.h" |
425 | + |
426 | +/* GObject */ |
427 | +static void unity_quicklist_menu_accessible_class_init(UnityQuicklistMenuAccessibleClass* klass); |
428 | +static void unity_quicklist_menu_accessible_init(UnityQuicklistMenuAccessible* self); |
429 | +static void unity_quicklist_menu_accessible_finalize(GObject* object); |
430 | + |
431 | +/* AtkObject.h */ |
432 | +static void unity_quicklist_menu_accessible_initialize(AtkObject* accessible, |
433 | + gpointer data); |
434 | +static gint unity_quicklist_menu_accessible_get_n_children(AtkObject* obj); |
435 | +static AtkObject* unity_quicklist_menu_accessible_ref_child(AtkObject* obj, |
436 | + gint i); |
437 | + |
438 | +/* AtkSelection */ |
439 | +static void atk_selection_interface_init(AtkSelectionIface* iface); |
440 | +static AtkObject* unity_quicklist_menu_accessible_ref_selection(AtkSelection* selection, |
441 | + gint i); |
442 | +static gint unity_quicklist_menu_accessible_get_selection_count(AtkSelection* selection); |
443 | +static gboolean unity_quicklist_menu_accessible_is_child_selected(AtkSelection* selection, |
444 | + gint i); |
445 | +/* private */ |
446 | +static void on_selection_change_cb(UnityQuicklistMenuAccessible* self); |
447 | +static void on_parent_activate_change_cb(AtkObject* parent_window, |
448 | + UnityQuicklistMenuAccessible* self); |
449 | +static void on_parent_change_cb(gchar* property, |
450 | + GValue* value, |
451 | + gpointer data); |
452 | + |
453 | +G_DEFINE_TYPE_WITH_CODE(UnityQuicklistMenuAccessible, |
454 | + unity_quicklist_menu_accessible, NUX_TYPE_OBJECT_ACCESSIBLE, |
455 | + G_IMPLEMENT_INTERFACE(ATK_TYPE_SELECTION, atk_selection_interface_init)); |
456 | + |
457 | + |
458 | +#define UNITY_QUICKLIST_MENU_ACCESSIBLE_GET_PRIVATE(obj) \ |
459 | + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), UNITY_TYPE_QUICKLIST_MENU_ACCESSIBLE, \ |
460 | + UnityQuicklistMenuAccessiblePrivate)) |
461 | + |
462 | +struct _UnityQuicklistMenuAccessiblePrivate |
463 | +{ |
464 | + sigc::connection on_selection_change_connection; |
465 | + guint on_parent_change_id; |
466 | + guint on_parent_activate_change_id; |
467 | +}; |
468 | + |
469 | + |
470 | +static void |
471 | +unity_quicklist_menu_accessible_class_init(UnityQuicklistMenuAccessibleClass* klass) |
472 | +{ |
473 | + GObjectClass* gobject_class = G_OBJECT_CLASS(klass); |
474 | + AtkObjectClass* atk_class = ATK_OBJECT_CLASS(klass); |
475 | + |
476 | + gobject_class->finalize = unity_quicklist_menu_accessible_finalize; |
477 | + |
478 | + /* AtkObject */ |
479 | + atk_class->initialize = unity_quicklist_menu_accessible_initialize; |
480 | + atk_class->get_n_children = unity_quicklist_menu_accessible_get_n_children; |
481 | + atk_class->ref_child = unity_quicklist_menu_accessible_ref_child; |
482 | + |
483 | + g_type_class_add_private(gobject_class, sizeof(UnityQuicklistMenuAccessiblePrivate)); |
484 | +} |
485 | + |
486 | +static void |
487 | +unity_quicklist_menu_accessible_init(UnityQuicklistMenuAccessible* self) |
488 | +{ |
489 | + UnityQuicklistMenuAccessiblePrivate* priv = |
490 | + UNITY_QUICKLIST_MENU_ACCESSIBLE_GET_PRIVATE(self); |
491 | + |
492 | + self->priv = priv; |
493 | +} |
494 | + |
495 | +static void |
496 | +unity_quicklist_menu_accessible_finalize(GObject* object) |
497 | +{ |
498 | + UnityQuicklistMenuAccessible* self = UNITY_QUICKLIST_MENU_ACCESSIBLE(object); |
499 | + |
500 | + self->priv->on_selection_change_connection.disconnect(); |
501 | + |
502 | + if (self->priv->on_parent_change_id != 0) |
503 | + g_signal_handler_disconnect(object, self->priv->on_parent_change_id); |
504 | + |
505 | + G_OBJECT_CLASS(unity_quicklist_menu_accessible_parent_class)->finalize(object); |
506 | +} |
507 | + |
508 | +AtkObject* |
509 | +unity_quicklist_menu_accessible_new(nux::Object* object) |
510 | +{ |
511 | + AtkObject* accessible = NULL; |
512 | + |
513 | + g_return_val_if_fail(dynamic_cast<QuicklistView*>(object), NULL); |
514 | + |
515 | + accessible = ATK_OBJECT(g_object_new(UNITY_TYPE_QUICKLIST_MENU_ACCESSIBLE, NULL)); |
516 | + |
517 | + atk_object_initialize(accessible, object); |
518 | + |
519 | + return accessible; |
520 | +} |
521 | + |
522 | +/* AtkObject.h */ |
523 | +static void |
524 | +unity_quicklist_menu_accessible_initialize(AtkObject* accessible, |
525 | + gpointer data) |
526 | +{ |
527 | + nux::Object* nux_object = NULL; |
528 | + QuicklistView* quicklist = NULL; |
529 | + UnityQuicklistMenuAccessible* self = NULL; |
530 | + |
531 | + ATK_OBJECT_CLASS(unity_quicklist_menu_accessible_parent_class)->initialize(accessible, data); |
532 | + self = UNITY_QUICKLIST_MENU_ACCESSIBLE(accessible); |
533 | + |
534 | + nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(accessible)); |
535 | + quicklist = dynamic_cast<QuicklistView*>(nux_object); |
536 | + |
537 | + if (quicklist == NULL) /* status defunct */ |
538 | + return; |
539 | + |
540 | + atk_object_set_role(accessible, ATK_ROLE_MENU); |
541 | + atk_object_set_name(accessible, "QuicklistMenu"); |
542 | + |
543 | + self->priv->on_selection_change_connection = |
544 | + quicklist->selection_change.connect(sigc::bind(sigc::ptr_fun(on_selection_change_cb), self)); |
545 | + |
546 | + self->priv->on_parent_change_id = |
547 | + g_signal_connect(accessible, "notify::accessible-parent", |
548 | + G_CALLBACK(on_parent_change_cb), self); |
549 | +} |
550 | + |
551 | +static gint |
552 | +unity_quicklist_menu_accessible_get_n_children(AtkObject* obj) |
553 | +{ |
554 | + QuicklistView* quicklist = NULL; |
555 | + nux::Object* nux_object = NULL; |
556 | + |
557 | + g_return_val_if_fail(UNITY_IS_QUICKLIST_MENU_ACCESSIBLE(obj), 0); |
558 | + |
559 | + nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(obj)); |
560 | + quicklist = dynamic_cast<QuicklistView*>(nux_object); |
561 | + |
562 | + if (quicklist == NULL) |
563 | + return 0; |
564 | + |
565 | + return quicklist->GetNumItems(); |
566 | +} |
567 | + |
568 | +static AtkObject* |
569 | +unity_quicklist_menu_accessible_ref_child(AtkObject* obj, |
570 | + gint i) |
571 | +{ |
572 | + QuicklistView* quicklist = NULL; |
573 | + QuicklistMenuItem* child = NULL; |
574 | + AtkObject* child_accessible = NULL; |
575 | + AtkObject* parent = NULL; |
576 | + nux::Object* nux_object = NULL; |
577 | + |
578 | + g_return_val_if_fail(UNITY_IS_QUICKLIST_MENU_ACCESSIBLE(obj), NULL); |
579 | + |
580 | + nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(obj)); |
581 | + quicklist = dynamic_cast<QuicklistView*>(nux_object); |
582 | + |
583 | + if (quicklist == NULL) |
584 | + return NULL; |
585 | + |
586 | + child = quicklist->GetNthItems(i); |
587 | + child_accessible = unity_a11y_get_accessible(child); |
588 | + |
589 | + if (child_accessible != NULL) |
590 | + { |
591 | + g_object_ref(child_accessible); |
592 | + parent = atk_object_get_parent(child_accessible); |
593 | + if (parent != obj) |
594 | + atk_object_set_parent(child_accessible, obj); |
595 | + } |
596 | + |
597 | + return child_accessible; |
598 | +} |
599 | + |
600 | +/* AtkSelection */ |
601 | +static void |
602 | +atk_selection_interface_init(AtkSelectionIface* iface) |
603 | +{ |
604 | + iface->ref_selection = unity_quicklist_menu_accessible_ref_selection; |
605 | + iface->get_selection_count = unity_quicklist_menu_accessible_get_selection_count; |
606 | + iface->is_child_selected = unity_quicklist_menu_accessible_is_child_selected; |
607 | + |
608 | + /* NOTE: for the moment we don't provide the implementation for the |
609 | + "interactable" methods, it is, the methods that allow to change |
610 | + the selected icon. The QuicklistView doesn't provide that API, and |
611 | + right now we are focusing on a normal user input.*/ |
612 | +} |
613 | + |
614 | +static AtkObject* |
615 | +unity_quicklist_menu_accessible_ref_selection(AtkSelection* selection, |
616 | + gint i) |
617 | +{ |
618 | + QuicklistView* quicklist = NULL; |
619 | + QuicklistMenuItem* child = NULL; |
620 | + AtkObject* child_accessible = NULL; |
621 | + nux::Object* nux_object = NULL; |
622 | + |
623 | + g_return_val_if_fail(UNITY_IS_QUICKLIST_MENU_ACCESSIBLE(selection), NULL); |
624 | + /* there can be only one item selected */ |
625 | + g_return_val_if_fail(i == 0, NULL); |
626 | + |
627 | + nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(selection)); |
628 | + quicklist = dynamic_cast<QuicklistView*>(nux_object); |
629 | + |
630 | + if (quicklist == NULL) /*state is defunct */ |
631 | + return NULL; |
632 | + |
633 | + child = quicklist->GetSelectedMenuItem(); |
634 | + child_accessible = unity_a11y_get_accessible(child); |
635 | + |
636 | + if (child_accessible != NULL) |
637 | + g_object_ref(child_accessible); |
638 | + |
639 | + return child_accessible; |
640 | +} |
641 | + |
642 | +static gint |
643 | +unity_quicklist_menu_accessible_get_selection_count(AtkSelection* selection) |
644 | +{ |
645 | + QuicklistView* quicklist = NULL; |
646 | + nux::Object* nux_object = NULL; |
647 | + |
648 | + g_return_val_if_fail(UNITY_IS_QUICKLIST_MENU_ACCESSIBLE(selection), 0); |
649 | + |
650 | + /* |
651 | + * Looking at QuicklistView code, there is always one item selected, |
652 | + * anyway we check that there is at least one item |
653 | + */ |
654 | + nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(selection)); |
655 | + quicklist = dynamic_cast<QuicklistView*>(nux_object); |
656 | + |
657 | + if (quicklist == NULL) /*state is defunct */ |
658 | + return 0; |
659 | + |
660 | + if (quicklist->GetNumItems() > 0) |
661 | + return 1; |
662 | + else |
663 | + return 0; |
664 | +} |
665 | + |
666 | +static gboolean |
667 | +unity_quicklist_menu_accessible_is_child_selected(AtkSelection* selection, |
668 | + gint i) |
669 | +{ |
670 | + QuicklistView* quicklist = NULL; |
671 | + QuicklistMenuItem* selected = NULL; |
672 | + QuicklistMenuItem* ith_item = NULL; |
673 | + nux::Object* nux_object = NULL; |
674 | + |
675 | + g_return_val_if_fail(UNITY_IS_QUICKLIST_MENU_ACCESSIBLE(selection), FALSE); |
676 | + |
677 | + nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(selection)); |
678 | + quicklist = dynamic_cast<QuicklistView*>(nux_object); |
679 | + |
680 | + if (quicklist == NULL) /*state is defunct */ |
681 | + return FALSE; |
682 | + |
683 | + selected = quicklist->GetSelectedMenuItem(); |
684 | + ith_item = quicklist->GetNthItems(i); |
685 | + |
686 | + if (selected == ith_item) |
687 | + return TRUE; |
688 | + else |
689 | + return FALSE; |
690 | +} |
691 | + |
692 | +/* private */ |
693 | +static void |
694 | +on_selection_change_cb(UnityQuicklistMenuAccessible* self) |
695 | +{ |
696 | + g_signal_emit_by_name(ATK_OBJECT(self), "selection-changed"); |
697 | +} |
698 | + |
699 | +static void |
700 | +on_parent_activate_change_cb(AtkObject* parent_window, |
701 | + UnityQuicklistMenuAccessible* self) |
702 | +{ |
703 | + /* We consider that when our parent window is activated, the focus |
704 | + should be on the menu, specifically on one of the menu-item. So |
705 | + we emit a selection-change in order to notify that a selection |
706 | + was made */ |
707 | + g_signal_emit_by_name(ATK_OBJECT(self), "selection-changed"); |
708 | +} |
709 | + |
710 | + |
711 | +static void |
712 | +on_parent_change_cb(gchar* property, |
713 | + GValue* value, |
714 | + gpointer data) |
715 | +{ |
716 | + AtkObject* parent = NULL; |
717 | + UnityQuicklistMenuAccessible* self = NULL; |
718 | + |
719 | + g_return_if_fail(UNITY_IS_QUICKLIST_MENU_ACCESSIBLE(data)); |
720 | + self = UNITY_QUICKLIST_MENU_ACCESSIBLE(data); |
721 | + |
722 | + parent = atk_object_get_parent(ATK_OBJECT(self)); |
723 | + |
724 | + if (parent == NULL) |
725 | + return; |
726 | + |
727 | + self->priv->on_parent_activate_change_id = |
728 | + g_signal_connect(parent, "activate", |
729 | + G_CALLBACK(on_parent_activate_change_cb), self); |
730 | +} |
731 | + |
732 | |
733 | === added file 'plugins/unityshell/src/unity-quicklist-menu-accessible.h' |
734 | --- plugins/unityshell/src/unity-quicklist-menu-accessible.h 1970-01-01 00:00:00 +0000 |
735 | +++ plugins/unityshell/src/unity-quicklist-menu-accessible.h 2011-11-07 19:26:37 +0000 |
736 | @@ -0,0 +1,57 @@ |
737 | +/* |
738 | + * Copyright (C) 2011 Canonical Ltd |
739 | + * |
740 | + * This program is free software: you can redistribute it and/or modify |
741 | + * it under the terms of the GNU General Public License version 3 as |
742 | + * published by the Free Software Foundation. |
743 | + * |
744 | + * This program is distributed in the hope that it will be useful, |
745 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
746 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
747 | + * GNU General Public License for more details. |
748 | + * |
749 | + * You should have received a copy of the GNU General Public License |
750 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
751 | + * |
752 | + * Authored by: Alejandro Piñeiro Iglesias <apinheiro@igalia.com> |
753 | + */ |
754 | + |
755 | +#ifndef UNITY_QUICKLIST_MENU_ACCESSIBLE_H |
756 | +#define UNITY_QUICKLIST_MENU_ACCESSIBLE_H |
757 | + |
758 | +#include <atk/atk.h> |
759 | + |
760 | +#include "nux-base-window-accessible.h" |
761 | + |
762 | +G_BEGIN_DECLS |
763 | + |
764 | +#define UNITY_TYPE_QUICKLIST_MENU_ACCESSIBLE (unity_quicklist_menu_accessible_get_type ()) |
765 | +#define UNITY_QUICKLIST_MENU_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_TYPE_QUICKLIST_MENU_ACCESSIBLE, UnityQuicklistMenuAccessible)) |
766 | +#define UNITY_QUICKLIST_MENU_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_TYPE_QUICKLIST_MENU_ACCESSIBLE, UnityQuicklistMenuAccessibleClass)) |
767 | +#define UNITY_IS_QUICKLIST_MENU_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_TYPE_QUICKLIST_MENU_ACCESSIBLE)) |
768 | +#define UNITY_IS_QUICKLIST_MENU_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_TYPE_QUICKLIST_MENU_ACCESSIBLE)) |
769 | +#define UNITY_QUICKLIST_MENU_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_TYPE_QUICKLIST_MENU_ACCESSIBLE, UnityQuicklistMenuAccessibleClass)) |
770 | + |
771 | +typedef struct _UnityQuicklistMenuAccessible UnityQuicklistMenuAccessible; |
772 | +typedef struct _UnityQuicklistMenuAccessibleClass UnityQuicklistMenuAccessibleClass; |
773 | +typedef struct _UnityQuicklistMenuAccessiblePrivate UnityQuicklistMenuAccessiblePrivate; |
774 | + |
775 | +struct _UnityQuicklistMenuAccessible |
776 | +{ |
777 | + NuxObjectAccessible parent; |
778 | + |
779 | + /*< private >*/ |
780 | + UnityQuicklistMenuAccessiblePrivate* priv; |
781 | +}; |
782 | + |
783 | +struct _UnityQuicklistMenuAccessibleClass |
784 | +{ |
785 | + NuxViewAccessibleClass parent_class; |
786 | +}; |
787 | + |
788 | +GType unity_quicklist_menu_accessible_get_type(void); |
789 | +AtkObject* unity_quicklist_menu_accessible_new(nux::Object* object); |
790 | + |
791 | +G_END_DECLS |
792 | + |
793 | +#endif /* __UNITY_QUICKLIST_MENU_ACCESSIBLE_H__ */ |
794 | |
795 | === added file 'plugins/unityshell/src/unity-quicklist-menu-item-accessible.cpp' |
796 | --- plugins/unityshell/src/unity-quicklist-menu-item-accessible.cpp 1970-01-01 00:00:00 +0000 |
797 | +++ plugins/unityshell/src/unity-quicklist-menu-item-accessible.cpp 2011-11-07 19:26:37 +0000 |
798 | @@ -0,0 +1,299 @@ |
799 | +/* |
800 | + * Copyright (C) 2011 Canonical Ltd |
801 | + * |
802 | + * This program is free software: you can redistribute it and/or modify |
803 | + * it under the terms of the GNU General Public License version 3 as |
804 | + * published by the Free Software Foundation. |
805 | + * |
806 | + * This program is distributed in the hope that it will be useful, |
807 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
808 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
809 | + * GNU General Public License for more details. |
810 | + * |
811 | + * You should have received a copy of the GNU General Public License |
812 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
813 | + * |
814 | + * Authored by: Alejandro Piñeiro Iglesias <apinheiro@igalia.com> |
815 | + */ |
816 | + |
817 | +/** |
818 | + * SECTION:unity-quicklist_menu_item-accessible |
819 | + * @Title: UnityQuicklistMenuItemAccessible |
820 | + * @short_description: Implementation of the ATK interfaces for #QuicklistMenuItem |
821 | + * @see_also: QuicklistMenuItem |
822 | + * |
823 | + * #UnityQuicklistMenuItemAccessible implements the required ATK interfaces for |
824 | + * #QuicklistMenuItem, mainly exposing the text as his name, as this |
825 | + * #object is mainly used as a label |
826 | + * |
827 | + */ |
828 | + |
829 | +#include <glib/gi18n.h> |
830 | + |
831 | +#include "unity-quicklist-menu-item-accessible.h" |
832 | + |
833 | +#include "unitya11y.h" |
834 | +#include "QuicklistMenuItem.h" |
835 | +#include "QuicklistMenuItemLabel.h" |
836 | +#include "QuicklistMenuItemSeparator.h" |
837 | + |
838 | +/* GObject */ |
839 | +static void unity_quicklist_menu_item_accessible_class_init(UnityQuicklistMenuItemAccessibleClass* klass); |
840 | +static void unity_quicklist_menu_item_accessible_init(UnityQuicklistMenuItemAccessible* self); |
841 | +static void unity_quicklist_menu_item_accessible_dispose(GObject* object); |
842 | + |
843 | +/* AtkObject.h */ |
844 | +static void unity_quicklist_menu_item_accessible_initialize(AtkObject* accessible, |
845 | + gpointer data); |
846 | +static const gchar* unity_quicklist_menu_item_accessible_get_name(AtkObject* obj); |
847 | +static AtkStateSet* unity_quicklist_menu_item_accessible_ref_state_set(AtkObject* obj); |
848 | + |
849 | +/* private */ |
850 | +static void on_parent_selection_change_cb(AtkSelection* selection, |
851 | + gpointer data); |
852 | + |
853 | +G_DEFINE_TYPE(UnityQuicklistMenuItemAccessible, unity_quicklist_menu_item_accessible, NUX_TYPE_VIEW_ACCESSIBLE); |
854 | + |
855 | + |
856 | +#define UNITY_QUICKLIST_MENU_ITEM_ACCESSIBLE_GET_PRIVATE(obj) \ |
857 | + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), UNITY_TYPE_QUICKLIST_MENU_ITEM_ACCESSIBLE, \ |
858 | + UnityQuicklistMenuItemAccessiblePrivate)) |
859 | + |
860 | +struct _UnityQuicklistMenuItemAccessiblePrivate |
861 | +{ |
862 | + gboolean selected; |
863 | + |
864 | + guint on_parent_selection_change_id; |
865 | + guint on_parent_change_id; |
866 | +}; |
867 | + |
868 | + |
869 | +static void |
870 | +unity_quicklist_menu_item_accessible_class_init(UnityQuicklistMenuItemAccessibleClass* klass) |
871 | +{ |
872 | + GObjectClass* gobject_class = G_OBJECT_CLASS(klass); |
873 | + AtkObjectClass* atk_class = ATK_OBJECT_CLASS(klass); |
874 | + |
875 | + gobject_class->dispose = unity_quicklist_menu_item_accessible_dispose; |
876 | + |
877 | + /* AtkObject */ |
878 | + atk_class->get_name = unity_quicklist_menu_item_accessible_get_name; |
879 | + atk_class->initialize = unity_quicklist_menu_item_accessible_initialize; |
880 | + atk_class->ref_state_set = unity_quicklist_menu_item_accessible_ref_state_set; |
881 | + |
882 | + g_type_class_add_private(gobject_class, sizeof(UnityQuicklistMenuItemAccessiblePrivate)); |
883 | +} |
884 | + |
885 | +static void |
886 | +unity_quicklist_menu_item_accessible_init(UnityQuicklistMenuItemAccessible* self) |
887 | +{ |
888 | + UnityQuicklistMenuItemAccessiblePrivate* priv = |
889 | + UNITY_QUICKLIST_MENU_ITEM_ACCESSIBLE_GET_PRIVATE(self); |
890 | + |
891 | + self->priv = priv; |
892 | +} |
893 | + |
894 | +static void |
895 | +unity_quicklist_menu_item_accessible_dispose(GObject* object) |
896 | +{ |
897 | + UnityQuicklistMenuItemAccessible* self = UNITY_QUICKLIST_MENU_ITEM_ACCESSIBLE(object); |
898 | + AtkObject* parent = NULL; |
899 | + |
900 | + parent = atk_object_get_parent(ATK_OBJECT(object)); |
901 | + |
902 | + if (UNITY_IS_QUICKLIST_MENU_ITEM_ACCESSIBLE(parent)) |
903 | + { |
904 | + if (self->priv->on_parent_selection_change_id != 0) |
905 | + g_signal_handler_disconnect(parent, self->priv->on_parent_selection_change_id); |
906 | + } |
907 | + |
908 | + if (self->priv->on_parent_change_id != 0) |
909 | + g_signal_handler_disconnect(object, self->priv->on_parent_change_id); |
910 | + |
911 | + G_OBJECT_CLASS(unity_quicklist_menu_item_accessible_parent_class)->dispose(object); |
912 | +} |
913 | + |
914 | +AtkObject* |
915 | +unity_quicklist_menu_item_accessible_new(nux::Object* object) |
916 | +{ |
917 | + AtkObject* accessible = NULL; |
918 | + |
919 | + g_return_val_if_fail(dynamic_cast<QuicklistMenuItem*>(object), NULL); |
920 | + |
921 | + accessible = ATK_OBJECT(g_object_new(UNITY_TYPE_QUICKLIST_MENU_ITEM_ACCESSIBLE, NULL)); |
922 | + |
923 | + atk_object_initialize(accessible, object); |
924 | + |
925 | + return accessible; |
926 | +} |
927 | + |
928 | +/* AtkObject.h */ |
929 | +static gboolean |
930 | +menu_item_is_a_separator(QuicklistMenuItem* menu_item) |
931 | +{ |
932 | + QuicklistMenuItemSeparator* separator = NULL; |
933 | + |
934 | + separator = dynamic_cast<QuicklistMenuItemSeparator*>(menu_item); |
935 | + |
936 | + if (separator != NULL) |
937 | + return TRUE; |
938 | + else |
939 | + return FALSE; |
940 | +} |
941 | + |
942 | +static void |
943 | +on_parent_change_cb(gchar* property, |
944 | + GValue* value, |
945 | + gpointer data) |
946 | +{ |
947 | + AtkObject* parent = NULL; |
948 | + UnityQuicklistMenuItemAccessible* self = NULL; |
949 | + |
950 | + g_return_if_fail(UNITY_IS_QUICKLIST_MENU_ITEM_ACCESSIBLE(data)); |
951 | + self = UNITY_QUICKLIST_MENU_ITEM_ACCESSIBLE(data); |
952 | + |
953 | + parent = atk_object_get_parent(ATK_OBJECT(self)); |
954 | + |
955 | + if (parent == NULL) |
956 | + return; |
957 | + |
958 | + self->priv->on_parent_selection_change_id = |
959 | + g_signal_connect(parent, "selection-changed", |
960 | + G_CALLBACK(on_parent_selection_change_cb), self); |
961 | +} |
962 | + |
963 | +static void |
964 | +unity_quicklist_menu_item_accessible_initialize(AtkObject* accessible, |
965 | + gpointer data) |
966 | +{ |
967 | + nux::Object* nux_object = NULL; |
968 | + QuicklistMenuItem* menu_item = NULL; |
969 | + UnityQuicklistMenuItemAccessible* self = NULL; |
970 | + |
971 | + ATK_OBJECT_CLASS(unity_quicklist_menu_item_accessible_parent_class)->initialize(accessible, data); |
972 | + self = UNITY_QUICKLIST_MENU_ITEM_ACCESSIBLE(accessible); |
973 | + |
974 | + nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(accessible)); |
975 | + menu_item = dynamic_cast<QuicklistMenuItem*>(nux_object); |
976 | + |
977 | + if (menu_item == NULL) |
978 | + return; |
979 | + |
980 | + if (menu_item_is_a_separator(menu_item)) |
981 | + atk_object_set_role(accessible, ATK_ROLE_SEPARATOR); |
982 | + else |
983 | + atk_object_set_role(accessible, ATK_ROLE_MENU_ITEM); |
984 | + |
985 | + /* we could do that by redefining ->set_parent */ |
986 | + self->priv->on_parent_change_id = |
987 | + g_signal_connect(accessible, "notify::accessible-parent", |
988 | + G_CALLBACK(on_parent_change_cb), self); |
989 | +} |
990 | + |
991 | + |
992 | + |
993 | +static const gchar* |
994 | +unity_quicklist_menu_item_accessible_get_name(AtkObject* obj) |
995 | +{ |
996 | + const gchar* name = NULL; |
997 | + |
998 | + g_return_val_if_fail(UNITY_IS_QUICKLIST_MENU_ITEM_ACCESSIBLE(obj), NULL); |
999 | + |
1000 | + name = ATK_OBJECT_CLASS(unity_quicklist_menu_item_accessible_parent_class)->get_name(obj); |
1001 | + if (name == NULL) |
1002 | + { |
1003 | + QuicklistMenuItem* menu_item = NULL; |
1004 | + |
1005 | + menu_item = dynamic_cast<QuicklistMenuItem*>(nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(obj))); |
1006 | + if (menu_item != NULL) |
1007 | + { |
1008 | + name = menu_item->GetLabel(); |
1009 | + } |
1010 | + } |
1011 | + |
1012 | + return name; |
1013 | +} |
1014 | + |
1015 | +static AtkStateSet* |
1016 | +unity_quicklist_menu_item_accessible_ref_state_set(AtkObject* obj) |
1017 | +{ |
1018 | + AtkStateSet* state_set = NULL; |
1019 | + UnityQuicklistMenuItemAccessible* self = NULL; |
1020 | + nux::Object* nux_object = NULL; |
1021 | + |
1022 | + g_return_val_if_fail(UNITY_IS_QUICKLIST_MENU_ITEM_ACCESSIBLE(obj), NULL); |
1023 | + self = UNITY_QUICKLIST_MENU_ITEM_ACCESSIBLE(obj); |
1024 | + |
1025 | + state_set = ATK_OBJECT_CLASS(unity_quicklist_menu_item_accessible_parent_class)->ref_state_set(obj); |
1026 | + |
1027 | + nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(obj)); |
1028 | + |
1029 | + if (nux_object == NULL) /* defunct */ |
1030 | + return state_set; |
1031 | + |
1032 | + /* by default */ |
1033 | + atk_state_set_add_state(state_set, ATK_STATE_FOCUSABLE); |
1034 | + atk_state_set_add_state(state_set, ATK_STATE_ENABLED); |
1035 | + atk_state_set_add_state(state_set, ATK_STATE_SENSITIVE); |
1036 | + |
1037 | + if (self->priv->selected) |
1038 | + { |
1039 | + atk_state_set_add_state(state_set, ATK_STATE_FOCUSED); |
1040 | + atk_state_set_add_state(state_set, ATK_STATE_SELECTED); |
1041 | + atk_state_set_add_state(state_set, ATK_STATE_ACTIVE); |
1042 | + } |
1043 | + else |
1044 | + { |
1045 | + /* we clean the states that could come from NuxAreaAccessible */ |
1046 | + atk_state_set_remove_state(state_set, ATK_STATE_FOCUSED); |
1047 | + } |
1048 | + |
1049 | + return state_set; |
1050 | +} |
1051 | + |
1052 | +/* private */ |
1053 | +static void |
1054 | +check_selected(UnityQuicklistMenuItemAccessible* self) |
1055 | +{ |
1056 | + AtkObject* selected_item = NULL; |
1057 | + AtkObject* parent = NULL; |
1058 | + nux::Object* nux_object = NULL; |
1059 | + gboolean found = FALSE; |
1060 | + |
1061 | + nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(self)); |
1062 | + if (nux_object == NULL) /* state is defunct */ |
1063 | + return; |
1064 | + |
1065 | + parent = atk_object_get_parent(ATK_OBJECT(self)); |
1066 | + if (parent == NULL) |
1067 | + return; |
1068 | + |
1069 | + selected_item = atk_selection_ref_selection(ATK_SELECTION(parent), 0); |
1070 | + |
1071 | + if (ATK_OBJECT(self) == selected_item) |
1072 | + found = TRUE; |
1073 | + |
1074 | + if (found != self->priv->selected) |
1075 | + { |
1076 | + gboolean return_val = FALSE; |
1077 | + |
1078 | + self->priv->selected = found; |
1079 | + atk_object_notify_state_change(ATK_OBJECT(self), |
1080 | + ATK_STATE_SELECTED, |
1081 | + found); |
1082 | + atk_object_notify_state_change(ATK_OBJECT(self), |
1083 | + ATK_STATE_ACTIVE, |
1084 | + found); |
1085 | + |
1086 | + g_signal_emit_by_name(self, "focus-event", self->priv->selected, &return_val); |
1087 | + } |
1088 | +} |
1089 | + |
1090 | +static void |
1091 | +on_parent_selection_change_cb(AtkSelection* selection, |
1092 | + gpointer data) |
1093 | +{ |
1094 | + g_return_if_fail(UNITY_IS_QUICKLIST_MENU_ITEM_ACCESSIBLE(data)); |
1095 | + |
1096 | + check_selected(UNITY_QUICKLIST_MENU_ITEM_ACCESSIBLE(data)); |
1097 | +} |
1098 | |
1099 | === added file 'plugins/unityshell/src/unity-quicklist-menu-item-accessible.h' |
1100 | --- plugins/unityshell/src/unity-quicklist-menu-item-accessible.h 1970-01-01 00:00:00 +0000 |
1101 | +++ plugins/unityshell/src/unity-quicklist-menu-item-accessible.h 2011-11-07 19:26:37 +0000 |
1102 | @@ -0,0 +1,57 @@ |
1103 | +/* |
1104 | + * Copyright (C) 2011 Canonical Ltd |
1105 | + * |
1106 | + * This program is free software: you can redistribute it and/or modify |
1107 | + * it under the terms of the GNU General Public License version 3 as |
1108 | + * published by the Free Software Foundation. |
1109 | + * |
1110 | + * This program is distributed in the hope that it will be useful, |
1111 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1112 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1113 | + * GNU General Public License for more details. |
1114 | + * |
1115 | + * You should have received a copy of the GNU General Public License |
1116 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1117 | + * |
1118 | + * Authored by: Alejandro Piñeiro Iglesias <apinheiro@igalia.com> |
1119 | + */ |
1120 | + |
1121 | +#ifndef UNITY_QUICKLIST_MENU_ITEM_ACCESSIBLE_H |
1122 | +#define UNITY_QUICKLIST_MENU_ITEM_ACCESSIBLE_H |
1123 | + |
1124 | +#include <atk/atk.h> |
1125 | + |
1126 | +#include "nux-view-accessible.h" |
1127 | + |
1128 | +G_BEGIN_DECLS |
1129 | + |
1130 | +#define UNITY_TYPE_QUICKLIST_MENU_ITEM_ACCESSIBLE (unity_quicklist_menu_item_accessible_get_type ()) |
1131 | +#define UNITY_QUICKLIST_MENU_ITEM_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_TYPE_QUICKLIST_MENU_ITEM_ACCESSIBLE, UnityQuicklistMenuItemAccessible)) |
1132 | +#define UNITY_QUICKLIST_MENU_ITEM_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_TYPE_QUICKLIST_MENU_ITEM_ACCESSIBLE, UnityQuicklistMenuItemAccessibleClass)) |
1133 | +#define UNITY_IS_QUICKLIST_MENU_ITEM_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_TYPE_QUICKLIST_MENU_ITEM_ACCESSIBLE)) |
1134 | +#define UNITY_IS_QUICKLIST_MENU_ITEM_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_TYPE_QUICKLIST_MENU_ITEM_ACCESSIBLE)) |
1135 | +#define UNITY_QUICKLIST_MENU_ITEM_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_TYPE_QUICKLIST_MENU_ITEM_ACCESSIBLE, UnityQuicklistMenuItemAccessibleClass)) |
1136 | + |
1137 | +typedef struct _UnityQuicklistMenuItemAccessible UnityQuicklistMenuItemAccessible; |
1138 | +typedef struct _UnityQuicklistMenuItemAccessibleClass UnityQuicklistMenuItemAccessibleClass; |
1139 | +typedef struct _UnityQuicklistMenuItemAccessiblePrivate UnityQuicklistMenuItemAccessiblePrivate; |
1140 | + |
1141 | +struct _UnityQuicklistMenuItemAccessible |
1142 | +{ |
1143 | + NuxViewAccessible parent; |
1144 | + |
1145 | + /*< private >*/ |
1146 | + UnityQuicklistMenuItemAccessiblePrivate* priv; |
1147 | +}; |
1148 | + |
1149 | +struct _UnityQuicklistMenuItemAccessibleClass |
1150 | +{ |
1151 | + NuxViewAccessibleClass parent_class; |
1152 | +}; |
1153 | + |
1154 | +GType unity_quicklist_menu_item_accessible_get_type(void); |
1155 | +AtkObject* unity_quicklist_menu_item_accessible_new(nux::Object* object); |
1156 | + |
1157 | +G_END_DECLS |
1158 | + |
1159 | +#endif /* __UNITY_QUICKLIST_MENU_ITEM_ACCESSIBLE_H__ */ |
1160 | |
1161 | === modified file 'plugins/unityshell/src/unitya11y.cpp' |
1162 | --- plugins/unityshell/src/unitya11y.cpp 2011-11-07 19:26:36 +0000 |
1163 | +++ plugins/unityshell/src/unitya11y.cpp 2011-11-07 19:26:37 +0000 |
1164 | @@ -39,6 +39,8 @@ |
1165 | #include "DashView.h" |
1166 | #include "PlacesSimpleTile.h" |
1167 | #include "PlacesGroup.h" |
1168 | +#include "QuicklistView.h" |
1169 | +#include "QuicklistMenuItem.h" |
1170 | #include "unity-launcher-accessible.h" |
1171 | #include "unity-launcher-icon-accessible.h" |
1172 | #include "unity-panel-view-accessible.h" |
1173 | @@ -48,6 +50,8 @@ |
1174 | #include "unity-rvgrid-accessible.h" |
1175 | #include "unity-places-simple-tile-accessible.h" |
1176 | #include "unity-places-group-accessible.h" |
1177 | +#include "unity-quicklist-accessible.h" |
1178 | +#include "unity-quicklist-menu-item-accessible.h" |
1179 | |
1180 | using namespace unity; |
1181 | using namespace unity::dash; |
1182 | @@ -281,6 +285,12 @@ |
1183 | if (object->Type().IsDerivedFromType(PlacesGroup::StaticObjectType)) |
1184 | return unity_places_group_accessible_new(object); |
1185 | |
1186 | + if (object->Type().IsDerivedFromType(QuicklistView::StaticObjectType)) |
1187 | + return unity_quicklist_accessible_new(object); |
1188 | + |
1189 | + if (object->Type().IsDerivedFromType(QuicklistMenuItem::StaticObjectType)) |
1190 | + return unity_quicklist_menu_item_accessible_new(object); |
1191 | + |
1192 | if (object->Type().IsDerivedFromType(nux::StaticCairoText::StaticObjectType)) |
1193 | return unity_sctext_accessible_new(object); |
1194 |
BTW, this branch is already being tested by the users, as it is included on this branch:
https:/ /launchpad. net/~apinheiro/ +archive/ unity-extra- a11y
I already received some positive feedback from ubuntu- accessibility mailing list