Merge lp:~themuso/unity/add-scope-bar-accessibility into lp:unity

Proposed by Luke Yelavich
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 3971
Proposed branch: lp:~themuso/unity/add-scope-bar-accessibility
Merge into: lp:unity
Diff against target: 336 lines (+258/-3)
7 files modified
dash/ScopeBar.cpp (+1/-1)
dash/ScopeBarIcon.cpp (+2/-1)
dash/ScopeBarIcon.h (+2/-1)
plugins/unityshell/src/unity-scope-bar-icon-accessible.cpp (+191/-0)
plugins/unityshell/src/unity-scope-bar-icon-accessible.h (+57/-0)
plugins/unityshell/src/unitya11y.cpp (+4/-0)
po/POTFILES.in (+1/-0)
To merge this branch: bzr merge lp:~themuso/unity/add-scope-bar-accessibility
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+258221@code.launchpad.net

Commit message

Implement scope bar icon accessibility

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 :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dash/ScopeBar.cpp'
2--- dash/ScopeBar.cpp 2014-07-30 00:49:35 +0000
3+++ dash/ScopeBar.cpp 2015-05-05 02:16:57 +0000
4@@ -85,7 +85,7 @@
5
6 void ScopeBar::AddScope(Scope::Ptr const& scope)
7 {
8- ScopeBarIcon* icon = new ScopeBarIcon(scope->id, scope->icon_hint);
9+ ScopeBarIcon* icon = new ScopeBarIcon(scope->id, scope->icon_hint, scope->name);
10
11 icon->SetVisible(scope->visible);
12 icon->scale = scale();
13
14=== modified file 'dash/ScopeBarIcon.cpp'
15--- dash/ScopeBarIcon.cpp 2014-07-09 11:17:35 +0000
16+++ dash/ScopeBarIcon.cpp 2015-05-05 02:16:57 +0000
17@@ -37,9 +37,10 @@
18
19 NUX_IMPLEMENT_OBJECT_TYPE(ScopeBarIcon);
20
21-ScopeBarIcon::ScopeBarIcon(std::string id_, std::string icon_hint)
22+ScopeBarIcon::ScopeBarIcon(std::string id_, std::string icon_hint, std::string name_)
23 : IconTexture(icon_hint, TEXTURE_SIZE)
24 , id(id_)
25+ , name(name_)
26 , active(false)
27 , scale(DEFAULT_SCALE)
28 , inactive_opacity_(0.4f)
29
30=== modified file 'dash/ScopeBarIcon.h'
31--- dash/ScopeBarIcon.h 2014-03-20 04:05:39 +0000
32+++ dash/ScopeBarIcon.h 2015-05-05 02:16:57 +0000
33@@ -37,9 +37,10 @@
34 {
35 NUX_DECLARE_OBJECT_TYPE(ScopeBarIcon, IconTexture);
36 public:
37- ScopeBarIcon(std::string id, std::string icon_hint);
38+ ScopeBarIcon(std::string id, std::string icon_hint, std::string name);
39
40 nux::Property<std::string> id;
41+ nux::Property<std::string> name;
42 nux::Property<bool> active;
43 nux::Property<double> scale;
44
45
46=== added file 'plugins/unityshell/src/unity-scope-bar-icon-accessible.cpp'
47--- plugins/unityshell/src/unity-scope-bar-icon-accessible.cpp 1970-01-01 00:00:00 +0000
48+++ plugins/unityshell/src/unity-scope-bar-icon-accessible.cpp 2015-05-05 02:16:57 +0000
49@@ -0,0 +1,191 @@
50+/*
51+ * Copyright (C) 2011 Canonical Ltd
52+ *
53+ * This program is free software: you can redistribute it and/or modify
54+ * it under the terms of the GNU General Public License version 3 as
55+ * published by the Free Software Foundation.
56+ *
57+ * This program is distributed in the hope that it will be useful,
58+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
59+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
60+ * GNU General Public License for more details.
61+ *
62+ * You should have received a copy of the GNU General Public License
63+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
64+ *
65+ * Authored by: Luke Yelavich <luke.yelavich@canonical.com>
66+ */
67+
68+/**
69+ * SECTION:unity-scope_bar_icon-accessible
70+ * @Title: UnityScopeBarIconAccessible
71+ * @short_description: Implementation of the ATK interfaces for #ScopeBarIcon
72+ * @see_also: ScopeBarIcon
73+ *
74+ * #UnityScopeBarIconAccessible implements the required ATK interfaces for
75+ * #ScopeBarIcon, mainly exposing the text as his name, as this
76+ * #object is mainly used as a label
77+ *
78+ */
79+
80+#include <glib/gi18n.h>
81+
82+#include "unity-scope-bar-icon-accessible.h"
83+
84+#include "unitya11y.h"
85+#include "ScopeBarIcon.h"
86+
87+using namespace unity::dash;
88+
89+/* GObject */
90+static void unity_scope_bar_icon_accessible_class_init(UnityScopeBarIconAccessibleClass* klass);
91+static void unity_scope_bar_icon_accessible_init(UnityScopeBarIconAccessible* self);
92+static void unity_scope_bar_icon_accessible_dispose(GObject* object);
93+
94+/* AtkObject.h */
95+static void unity_scope_bar_icon_accessible_initialize(AtkObject* accessible,
96+ gpointer data);
97+static const gchar* unity_scope_bar_icon_accessible_get_name(AtkObject* obj);
98+static void on_focus_changed_cb(nux::Area* area,
99+ bool has_focus,
100+ nux::KeyNavDirection direction,
101+ AtkObject* accessible);
102+static void on_active_changed_cb(bool is_active,
103+ AtkObject* accessible);
104+
105+G_DEFINE_TYPE(UnityScopeBarIconAccessible, unity_scope_bar_icon_accessible, NUX_TYPE_VIEW_ACCESSIBLE);
106+
107+#define UNITY_SCOPE_BAR_ICON_ACCESSIBLE_GET_PRIVATE(obj) \
108+ (G_TYPE_INSTANCE_GET_PRIVATE ((obj), UNITY_TYPE_SCOPE_BAR_ICON_ACCESSIBLE, \
109+ UnityScopeBarIconAccessiblePrivate))
110+
111+struct _UnityScopeBarIconAccessiblePrivate
112+{
113+ gchar* name;
114+};
115+
116+static void
117+unity_scope_bar_icon_accessible_class_init(UnityScopeBarIconAccessibleClass* klass)
118+{
119+ AtkObjectClass* atk_class = ATK_OBJECT_CLASS(klass);
120+ GObjectClass* gobject_class = G_OBJECT_CLASS(klass);
121+
122+ gobject_class->dispose = unity_scope_bar_icon_accessible_dispose;
123+
124+ /* AtkObject */
125+ atk_class->get_name = unity_scope_bar_icon_accessible_get_name;
126+ atk_class->initialize = unity_scope_bar_icon_accessible_initialize;
127+
128+ g_type_class_add_private(gobject_class, sizeof(UnityScopeBarIconAccessiblePrivate));
129+}
130+
131+static void
132+unity_scope_bar_icon_accessible_init(UnityScopeBarIconAccessible* self)
133+{
134+ UnityScopeBarIconAccessiblePrivate* priv =
135+ UNITY_SCOPE_BAR_ICON_ACCESSIBLE_GET_PRIVATE(self);
136+
137+ self->priv = priv;
138+ self->priv->name = NULL;
139+}
140+
141+static void
142+unity_scope_bar_icon_accessible_dispose(GObject* object)
143+{
144+ UnityScopeBarIconAccessible* self = UNITY_SCOPE_BAR_ICON_ACCESSIBLE(object);
145+
146+ if (self->priv->name != NULL)
147+ {
148+ g_free(self->priv->name);
149+ self->priv->name = NULL;
150+ }
151+
152+ G_OBJECT_CLASS(unity_scope_bar_icon_accessible_parent_class)->dispose(object);
153+}
154+
155+AtkObject*
156+unity_scope_bar_icon_accessible_new(nux::Object* object)
157+{
158+ AtkObject* accessible = NULL;
159+
160+ g_return_val_if_fail(dynamic_cast<ScopeBarIcon*>(object), NULL);
161+
162+ accessible = ATK_OBJECT(g_object_new(UNITY_TYPE_SCOPE_BAR_ICON_ACCESSIBLE, NULL));
163+
164+ atk_object_initialize(accessible, object);
165+
166+ return accessible;
167+}
168+
169+/* AtkObject.h */
170+static void
171+unity_scope_bar_icon_accessible_initialize(AtkObject* accessible,
172+ gpointer data)
173+{
174+ nux::Object* nux_object = NULL;
175+ ScopeBarIcon* icon = NULL;
176+
177+ ATK_OBJECT_CLASS(unity_scope_bar_icon_accessible_parent_class)->initialize(accessible, data);
178+
179+ nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(accessible));
180+ icon = dynamic_cast<ScopeBarIcon*>(nux_object);
181+
182+ if (icon == NULL)
183+ return;
184+
185+ icon->key_nav_focus_change.connect(sigc::bind(sigc::ptr_fun(on_focus_changed_cb), accessible));
186+
187+ icon->active.changed.connect(sigc::bind(sigc::ptr_fun(on_active_changed_cb), accessible));
188+
189+ atk_object_set_role(accessible, ATK_ROLE_PUSH_BUTTON);
190+}
191+
192+static const gchar*
193+unity_scope_bar_icon_accessible_get_name(AtkObject* obj)
194+{
195+ g_return_val_if_fail(UNITY_IS_SCOPE_BAR_ICON_ACCESSIBLE(obj), NULL);
196+ UnityScopeBarIconAccessible* self = UNITY_SCOPE_BAR_ICON_ACCESSIBLE(obj);
197+
198+ if (self->priv->name)
199+ {
200+ g_free(self->priv->name);
201+ self->priv->name = NULL;
202+ }
203+
204+ self->priv->name = g_strdup(ATK_OBJECT_CLASS(unity_scope_bar_icon_accessible_parent_class)->get_name(obj));
205+ if (self->priv->name == NULL)
206+ {
207+ ScopeBarIcon* icon = NULL;
208+
209+ icon = dynamic_cast<ScopeBarIcon*>(nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(obj)));
210+ if (icon != NULL)
211+ {
212+ if (icon->active())
213+ self->priv->name = g_strdup_printf(_("%s: selected"), icon->name().c_str());
214+ else
215+ self->priv->name = g_strdup(icon->name().c_str());
216+ }
217+ }
218+
219+ return self->priv->name;
220+}
221+
222+static void
223+on_focus_changed_cb(nux::Area* area,
224+ bool has_focus,
225+ nux::KeyNavDirection direction,
226+ AtkObject* accessible)
227+{
228+ g_return_if_fail(UNITY_IS_SCOPE_BAR_ICON_ACCESSIBLE(accessible));
229+
230+ g_signal_emit_by_name(accessible, "focus-event", has_focus);
231+}
232+
233+static void
234+on_active_changed_cb(bool is_active,
235+ AtkObject* accessible)
236+{
237+ g_return_if_fail(UNITY_IS_SCOPE_BAR_ICON_ACCESSIBLE(accessible));
238+
239+ g_object_notify(G_OBJECT(accessible), "accessible-name");
240+}
241
242=== added file 'plugins/unityshell/src/unity-scope-bar-icon-accessible.h'
243--- plugins/unityshell/src/unity-scope-bar-icon-accessible.h 1970-01-01 00:00:00 +0000
244+++ plugins/unityshell/src/unity-scope-bar-icon-accessible.h 2015-05-05 02:16:57 +0000
245@@ -0,0 +1,57 @@
246+/*
247+ * Copyright (C) 2015 Canonical Ltd
248+ *
249+ * This program is free software: you can redistribute it and/or modify
250+ * it under the terms of the GNU General Public License version 3 as
251+ * published by the Free Software Foundation.
252+ *
253+ * This program is distributed in the hope that it will be useful,
254+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
255+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
256+ * GNU General Public License for more details.
257+ *
258+ * You should have received a copy of the GNU General Public License
259+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
260+ *
261+ * Authored by: Luke Yelavich <luke.yelavich@canonical.com>
262+ */
263+
264+#ifndef UNITY_SCOPE_BAR_ICON_ACCESSIBLE_H
265+#define UNITY_SCOPE_BAR_ICON_ACCESSIBLE_H
266+
267+#include <atk/atk.h>
268+
269+#include "nux-view-accessible.h"
270+
271+G_BEGIN_DECLS
272+
273+#define UNITY_TYPE_SCOPE_BAR_ICON_ACCESSIBLE (unity_scope_bar_icon_accessible_get_type ())
274+#define UNITY_SCOPE_BAR_ICON_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_TYPE_SCOPE_BAR_ICON_ACCESSIBLE, UnityScopeBarIconAccessible))
275+#define UNITY_SCOPE_BAR_ICON_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_TYPE_SCOPE_BAR_ICON_ACCESSIBLE, UnityScopeBarIconAccessibleClass))
276+#define UNITY_IS_SCOPE_BAR_ICON_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_TYPE_SCOPE_BAR_ICON_ACCESSIBLE))
277+#define UNITY_IS_SCOPE_BAR_ICON_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_TYPE_SCOPE_BAR_ICON_ACCESSIBLE))
278+#define UNITY_SCOPE_BAR_ICON_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_TYPE_SCOPE_BAR_ICON_ACCESSIBLE, UnityScopeBarIconAccessibleClass))
279+
280+typedef struct _UnityScopeBarIconAccessible UnityScopeBarIconAccessible;
281+typedef struct _UnityScopeBarIconAccessibleClass UnityScopeBarIconAccessibleClass;
282+typedef struct _UnityScopeBarIconAccessiblePrivate UnityScopeBarIconAccessiblePrivate;
283+
284+struct _UnityScopeBarIconAccessible
285+{
286+ NuxViewAccessible parent;
287+
288+ /*< private >*/
289+ UnityScopeBarIconAccessiblePrivate* priv;
290+};
291+
292+struct _UnityScopeBarIconAccessibleClass
293+{
294+ NuxViewAccessibleClass parent_class;
295+};
296+
297+GType unity_scope_bar_icon_accessible_get_type(void);
298+AtkObject* unity_scope_bar_icon_accessible_new(nux::Object* object);
299+
300+G_END_DECLS
301+
302+#endif /* __UNITY_SCOPE_BAR_ICON_ACCESSIBLE_H__ */
303
304=== modified file 'plugins/unityshell/src/unitya11y.cpp'
305--- plugins/unityshell/src/unitya11y.cpp 2014-03-06 16:13:58 +0000
306+++ plugins/unityshell/src/unitya11y.cpp 2015-05-05 02:16:57 +0000
307@@ -48,6 +48,7 @@
308 #include "unity-launcher-icon-accessible.h"
309 #include "unity-panel-view-accessible.h"
310 #include "unity-dash-view-accessible.h"
311+#include "unity-scope-bar-icon-accessible.h"
312 #include "unity-search-bar-accessible.h"
313 #include "unity-sctext-accessible.h"
314 #include "unity-rvgrid-accessible.h"
315@@ -171,6 +172,9 @@
316 if (object->Type().IsDerivedFromType(DashView::StaticObjectType))
317 return unity_dash_view_accessible_new(object);
318
319+ if (object->Type().IsDerivedFromType(ScopeBarIcon::StaticObjectType))
320+ return unity_scope_bar_icon_accessible_new(object);
321+
322 if (object->Type().IsDerivedFromType(PlacesGroup::StaticObjectType))
323 return unity_places_group_accessible_new(object);
324
325
326=== modified file 'po/POTFILES.in'
327--- po/POTFILES.in 2015-02-05 14:07:05 +0000
328+++ po/POTFILES.in 2015-05-05 02:16:57 +0000
329@@ -33,6 +33,7 @@
330 plugins/unityshell/src/unity-launcher-accessible.cpp
331 plugins/unityshell/src/unity-launcher-icon-accessible.cpp
332 plugins/unityshell/src/unity-quicklist-menu-accessible.cpp
333+plugins/unityshell/src/unity-scope-bar-icon-accessible.cpp
334 plugins/unityshell/src/unity-search-bar-accessible.cpp
335 plugins/unityshell/src/unity-switcher-accessible.cpp
336 plugins/unityshell/src/unityshell.cpp