diff options
| -rw-r--r-- | dash/ScopeBar.cpp | 2 | ||||
| -rw-r--r-- | dash/ScopeBarIcon.cpp | 3 | ||||
| -rw-r--r-- | dash/ScopeBarIcon.h | 3 | ||||
| -rw-r--r-- | plugins/unityshell/src/unity-scope-bar-icon-accessible.cpp | 191 | ||||
| -rw-r--r-- | plugins/unityshell/src/unity-scope-bar-icon-accessible.h | 57 | ||||
| -rw-r--r-- | plugins/unityshell/src/unitya11y.cpp | 4 | ||||
| -rw-r--r-- | po/POTFILES.in | 1 | 
7 files changed, 258 insertions, 3 deletions
diff --git a/dash/ScopeBar.cpp b/dash/ScopeBar.cpp index f7ed43189..027675c5a 100644 --- a/dash/ScopeBar.cpp +++ b/dash/ScopeBar.cpp @@ -85,7 +85,7 @@ void ScopeBar::SetupLayout()  void ScopeBar::AddScope(Scope::Ptr const& scope)  { - ScopeBarIcon* icon = new ScopeBarIcon(scope->id, scope->icon_hint); + ScopeBarIcon* icon = new ScopeBarIcon(scope->id, scope->icon_hint, scope->name);  icon->SetVisible(scope->visible);  icon->scale = scale(); diff --git a/dash/ScopeBarIcon.cpp b/dash/ScopeBarIcon.cpp index 165d691bf..f2146578b 100644 --- a/dash/ScopeBarIcon.cpp +++ b/dash/ScopeBarIcon.cpp @@ -37,9 +37,10 @@ double const DEFAULT_SCALE = 1.0;  NUX_IMPLEMENT_OBJECT_TYPE(ScopeBarIcon); -ScopeBarIcon::ScopeBarIcon(std::string id_, std::string icon_hint) +ScopeBarIcon::ScopeBarIcon(std::string id_, std::string icon_hint, std::string name_)  : IconTexture(icon_hint, TEXTURE_SIZE)  , id(id_) + , name(name_)  , active(false)  , scale(DEFAULT_SCALE)  , inactive_opacity_(0.4f) diff --git a/dash/ScopeBarIcon.h b/dash/ScopeBarIcon.h index a9825d168..4276b5534 100644 --- a/dash/ScopeBarIcon.h +++ b/dash/ScopeBarIcon.h @@ -37,9 +37,10 @@ class ScopeBarIcon : public IconTexture  {  NUX_DECLARE_OBJECT_TYPE(ScopeBarIcon, IconTexture);  public: - ScopeBarIcon(std::string id, std::string icon_hint); + ScopeBarIcon(std::string id, std::string icon_hint, std::string name);  nux::Property<std::string> id; + nux::Property<std::string> name;  nux::Property<bool> active;  nux::Property<double> scale; diff --git a/plugins/unityshell/src/unity-scope-bar-icon-accessible.cpp b/plugins/unityshell/src/unity-scope-bar-icon-accessible.cpp new file mode 100644 index 000000000..997e9364d --- /dev/null +++ b/plugins/unityshell/src/unity-scope-bar-icon-accessible.cpp @@ -0,0 +1,191 @@ +/* + * Copyright (C) 2011 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by: Luke Yelavich <luke.yelavich@canonical.com> + */ + +/** + * SECTION:unity-scope_bar_icon-accessible + * @Title: UnityScopeBarIconAccessible + * @short_description: Implementation of the ATK interfaces for #ScopeBarIcon + * @see_also: ScopeBarIcon + * + * #UnityScopeBarIconAccessible implements the required ATK interfaces for + * #ScopeBarIcon, mainly exposing the text as his name, as this + * #object is mainly used as a label + * + */ + +#include <glib/gi18n.h> + +#include "unity-scope-bar-icon-accessible.h" + +#include "unitya11y.h" +#include "ScopeBarIcon.h" + +using namespace unity::dash; + +/* GObject */ +static void unity_scope_bar_icon_accessible_class_init(UnityScopeBarIconAccessibleClass* klass); +static void unity_scope_bar_icon_accessible_init(UnityScopeBarIconAccessible* self); +static void unity_scope_bar_icon_accessible_dispose(GObject* object); + +/* AtkObject.h */ +static void unity_scope_bar_icon_accessible_initialize(AtkObject* accessible, + gpointer data); +static const gchar* unity_scope_bar_icon_accessible_get_name(AtkObject* obj); +static void on_focus_changed_cb(nux::Area* area, + bool has_focus, + nux::KeyNavDirection direction, + AtkObject* accessible); +static void on_active_changed_cb(bool is_active, + AtkObject* accessible); + +G_DEFINE_TYPE(UnityScopeBarIconAccessible, unity_scope_bar_icon_accessible, NUX_TYPE_VIEW_ACCESSIBLE); + +#define UNITY_SCOPE_BAR_ICON_ACCESSIBLE_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), UNITY_TYPE_SCOPE_BAR_ICON_ACCESSIBLE, \ + UnityScopeBarIconAccessiblePrivate)) + +struct _UnityScopeBarIconAccessiblePrivate +{ + gchar* name; +}; + +static void +unity_scope_bar_icon_accessible_class_init(UnityScopeBarIconAccessibleClass* klass) +{ + AtkObjectClass* atk_class = ATK_OBJECT_CLASS(klass); + GObjectClass* gobject_class = G_OBJECT_CLASS(klass); + + gobject_class->dispose = unity_scope_bar_icon_accessible_dispose; + + /* AtkObject */ + atk_class->get_name = unity_scope_bar_icon_accessible_get_name; + atk_class->initialize = unity_scope_bar_icon_accessible_initialize; + + g_type_class_add_private(gobject_class, sizeof(UnityScopeBarIconAccessiblePrivate)); +} + +static void +unity_scope_bar_icon_accessible_init(UnityScopeBarIconAccessible* self) +{ + UnityScopeBarIconAccessiblePrivate* priv = + UNITY_SCOPE_BAR_ICON_ACCESSIBLE_GET_PRIVATE(self); + + self->priv = priv; + self->priv->name = NULL; +} + +static void +unity_scope_bar_icon_accessible_dispose(GObject* object) +{ + UnityScopeBarIconAccessible* self = UNITY_SCOPE_BAR_ICON_ACCESSIBLE(object); + + if (self->priv->name != NULL) + { + g_free(self->priv->name); + self->priv->name = NULL; + } + + G_OBJECT_CLASS(unity_scope_bar_icon_accessible_parent_class)->dispose(object); +} + +AtkObject* +unity_scope_bar_icon_accessible_new(nux::Object* object) +{ + AtkObject* accessible = NULL; + + g_return_val_if_fail(dynamic_cast<ScopeBarIcon*>(object), NULL); + + accessible = ATK_OBJECT(g_object_new(UNITY_TYPE_SCOPE_BAR_ICON_ACCESSIBLE, NULL)); + + atk_object_initialize(accessible, object); + + return accessible; +} + +/* AtkObject.h */ +static void +unity_scope_bar_icon_accessible_initialize(AtkObject* accessible, + gpointer data) +{ + nux::Object* nux_object = NULL; + ScopeBarIcon* icon = NULL; + + ATK_OBJECT_CLASS(unity_scope_bar_icon_accessible_parent_class)->initialize(accessible, data); + + nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(accessible)); + icon = dynamic_cast<ScopeBarIcon*>(nux_object); + + if (icon == NULL) + return; + + icon->key_nav_focus_change.connect(sigc::bind(sigc::ptr_fun(on_focus_changed_cb), accessible)); + + icon->active.changed.connect(sigc::bind(sigc::ptr_fun(on_active_changed_cb), accessible)); + + atk_object_set_role(accessible, ATK_ROLE_PUSH_BUTTON); +} + +static const gchar* +unity_scope_bar_icon_accessible_get_name(AtkObject* obj) +{ + g_return_val_if_fail(UNITY_IS_SCOPE_BAR_ICON_ACCESSIBLE(obj), NULL); + UnityScopeBarIconAccessible* self = UNITY_SCOPE_BAR_ICON_ACCESSIBLE(obj); + + if (self->priv->name) + { + g_free(self->priv->name); + self->priv->name = NULL; + } + + self->priv->name = g_strdup(ATK_OBJECT_CLASS(unity_scope_bar_icon_accessible_parent_class)->get_name(obj)); + if (self->priv->name == NULL) + { + ScopeBarIcon* icon = NULL; + + icon = dynamic_cast<ScopeBarIcon*>(nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(obj))); + if (icon != NULL) + { + if (icon->active()) + self->priv->name = g_strdup_printf(_("%s: selected"), icon->name().c_str()); + else + self->priv->name = g_strdup(icon->name().c_str()); + } + } + + return self->priv->name; +} + +static void +on_focus_changed_cb(nux::Area* area, + bool has_focus, + nux::KeyNavDirection direction, + AtkObject* accessible) +{ + g_return_if_fail(UNITY_IS_SCOPE_BAR_ICON_ACCESSIBLE(accessible)); + + g_signal_emit_by_name(accessible, "focus-event", has_focus); +} + +static void +on_active_changed_cb(bool is_active, + AtkObject* accessible) +{ + g_return_if_fail(UNITY_IS_SCOPE_BAR_ICON_ACCESSIBLE(accessible)); + + g_object_notify(G_OBJECT(accessible), "accessible-name"); +} diff --git a/plugins/unityshell/src/unity-scope-bar-icon-accessible.h b/plugins/unityshell/src/unity-scope-bar-icon-accessible.h new file mode 100644 index 000000000..6fa67f160 --- /dev/null +++ b/plugins/unityshell/src/unity-scope-bar-icon-accessible.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2015 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by: Luke Yelavich <luke.yelavich@canonical.com> + */ + +#ifndef UNITY_SCOPE_BAR_ICON_ACCESSIBLE_H +#define UNITY_SCOPE_BAR_ICON_ACCESSIBLE_H + +#include <atk/atk.h> + +#include "nux-view-accessible.h" + +G_BEGIN_DECLS + +#define UNITY_TYPE_SCOPE_BAR_ICON_ACCESSIBLE (unity_scope_bar_icon_accessible_get_type ()) +#define UNITY_SCOPE_BAR_ICON_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_TYPE_SCOPE_BAR_ICON_ACCESSIBLE, UnityScopeBarIconAccessible)) +#define UNITY_SCOPE_BAR_ICON_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_TYPE_SCOPE_BAR_ICON_ACCESSIBLE, UnityScopeBarIconAccessibleClass)) +#define UNITY_IS_SCOPE_BAR_ICON_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_TYPE_SCOPE_BAR_ICON_ACCESSIBLE)) +#define UNITY_IS_SCOPE_BAR_ICON_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_TYPE_SCOPE_BAR_ICON_ACCESSIBLE)) +#define UNITY_SCOPE_BAR_ICON_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_TYPE_SCOPE_BAR_ICON_ACCESSIBLE, UnityScopeBarIconAccessibleClass)) + +typedef struct _UnityScopeBarIconAccessible UnityScopeBarIconAccessible; +typedef struct _UnityScopeBarIconAccessibleClass UnityScopeBarIconAccessibleClass; +typedef struct _UnityScopeBarIconAccessiblePrivate UnityScopeBarIconAccessiblePrivate; + +struct _UnityScopeBarIconAccessible +{ + NuxViewAccessible parent; + + /*< private >*/ + UnityScopeBarIconAccessiblePrivate* priv; +}; + +struct _UnityScopeBarIconAccessibleClass +{ + NuxViewAccessibleClass parent_class; +}; + +GType unity_scope_bar_icon_accessible_get_type(void); +AtkObject* unity_scope_bar_icon_accessible_new(nux::Object* object); + +G_END_DECLS + +#endif /* __UNITY_SCOPE_BAR_ICON_ACCESSIBLE_H__ */ diff --git a/plugins/unityshell/src/unitya11y.cpp b/plugins/unityshell/src/unitya11y.cpp index 346c915ae..1d84ce647 100644 --- a/plugins/unityshell/src/unitya11y.cpp +++ b/plugins/unityshell/src/unitya11y.cpp @@ -48,6 +48,7 @@  #include "unity-launcher-icon-accessible.h"  #include "unity-panel-view-accessible.h"  #include "unity-dash-view-accessible.h" +#include "unity-scope-bar-icon-accessible.h"  #include "unity-search-bar-accessible.h"  #include "unity-sctext-accessible.h"  #include "unity-rvgrid-accessible.h" @@ -171,6 +172,9 @@ unity_a11y_create_accessible(nux::Object* object)  if (object->Type().IsDerivedFromType(DashView::StaticObjectType))  return unity_dash_view_accessible_new(object); + if (object->Type().IsDerivedFromType(ScopeBarIcon::StaticObjectType)) + return unity_scope_bar_icon_accessible_new(object); +  if (object->Type().IsDerivedFromType(PlacesGroup::StaticObjectType))  return unity_places_group_accessible_new(object); diff --git a/po/POTFILES.in b/po/POTFILES.in index 0bfb7082f..66c7663f6 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -33,6 +33,7 @@ plugins/unityshell/src/unity-dash-view-accessible.cpp  plugins/unityshell/src/unity-launcher-accessible.cpp  plugins/unityshell/src/unity-launcher-icon-accessible.cpp  plugins/unityshell/src/unity-quicklist-menu-accessible.cpp +plugins/unityshell/src/unity-scope-bar-icon-accessible.cpp  plugins/unityshell/src/unity-search-bar-accessible.cpp  plugins/unityshell/src/unity-switcher-accessible.cpp  plugins/unityshell/src/unityshell.cpp  | 
