summaryrefslogtreecommitdiff
diff options
-rw-r--r--dash/FilterBasicButton.cpp5
-rw-r--r--dash/FilterBasicButton.h2
-rw-r--r--dash/FilterExpanderLabel.cpp38
-rw-r--r--dash/FilterExpanderLabel.h5
-rw-r--r--plugins/unityshell/src/unity-expander-view-accessible.cpp207
-rw-r--r--plugins/unityshell/src/unity-expander-view-accessible.h60
-rw-r--r--plugins/unityshell/src/unity-filter-basic-button-accessible.cpp285
-rw-r--r--plugins/unityshell/src/unity-filter-basic-button-accessible.h53
-rw-r--r--plugins/unityshell/src/unitya11y.cpp10
-rw-r--r--unity-shared/CMakeLists.txt1
-rw-r--r--unity-shared/ExpanderView.cpp64
-rw-r--r--unity-shared/ExpanderView.h48
-rw-r--r--unity-shared/SearchBar.cpp43
-rw-r--r--unity-shared/SearchBar.h3
14 files changed, 748 insertions, 76 deletions
diff --git a/dash/FilterBasicButton.cpp b/dash/FilterBasicButton.cpp
index d66980663..1cdb1ce1c 100644
--- a/dash/FilterBasicButton.cpp
+++ b/dash/FilterBasicButton.cpp
@@ -188,5 +188,10 @@ void FilterBasicButton::Draw(nux::GraphicsEngine& graphics_engine, bool force_dr
graphics_engine.PopClippingRectangle();
}
+std::string FilterBasicButton::GetLabel()
+{
+ return label_;
+}
+
} // namespace dash
} // namespace unity
diff --git a/dash/FilterBasicButton.h b/dash/FilterBasicButton.h
index bb5d79cb9..a963002c2 100644
--- a/dash/FilterBasicButton.h
+++ b/dash/FilterBasicButton.h
@@ -42,6 +42,8 @@ public:
nux::Property<double> scale;
+ std::string GetLabel();
+
protected:
virtual long ComputeContentSize();
virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
diff --git a/dash/FilterExpanderLabel.cpp b/dash/FilterExpanderLabel.cpp
index da683c054..f2f59faa2 100644
--- a/dash/FilterExpanderLabel.cpp
+++ b/dash/FilterExpanderLabel.cpp
@@ -40,40 +40,6 @@ const RawPixel ARROW_BOTTOM_PADDING = 9_em;
// font
const char* const FONT_EXPANDER_LABEL = "Ubuntu 13"; // 17px = 13
-class ExpanderView : public nux::View
-{
-public:
- ExpanderView(NUX_FILE_LINE_DECL)
- : nux::View(NUX_FILE_LINE_PARAM)
- {
- SetAcceptKeyNavFocusOnMouseDown(false);
- SetAcceptKeyNavFocusOnMouseEnter(true);
- }
-
-protected:
- void Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)
- {};
-
- void DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw)
- {
- if (GetLayout())
- GetLayout()->ProcessDraw(graphics_engine, force_draw);
- }
-
- bool AcceptKeyNavFocus()
- {
- return true;
- }
-
- nux::Area* FindAreaUnderMouse(const nux::Point& mouse_position, nux::NuxEventType event_type)
- {
- if (event_type != nux::EVENT_MOUSE_WHEEL && TestMousePointerInclusion(mouse_position, event_type))
- return this;
- else
- return nullptr;
- }
-};
-
}
NUX_IMPLEMENT_OBJECT_TYPE(FilterExpanderLabel);
@@ -97,6 +63,7 @@ FilterExpanderLabel::FilterExpanderLabel(std::string const& label, NUX_FILE_LINE
void FilterExpanderLabel::SetLabel(std::string const& label)
{
cairo_label_->SetText(label);
+ expander_view_->label = label;
}
void FilterExpanderLabel::UpdateScale(double scale)
@@ -139,6 +106,7 @@ void FilterExpanderLabel::BuildLayout()
expander_layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
expander_view_ = new ExpanderView(NUX_TRACKER_LOCATION);
+ expander_view_->expanded.Set(expanded);
expander_view_->SetLayout(expander_layout_);
top_bar_layout_->AddView(expander_view_, 1);
@@ -168,6 +136,7 @@ void FilterExpanderLabel::BuildLayout()
auto mouse_expand = [this](int x, int y, unsigned long b, unsigned long k)
{
expanded = !expanded;
+ expander_view_->expanded.Set(expanded);
};
auto key_redraw = [this](nux::Area*, bool, nux::KeyNavDirection)
@@ -178,6 +147,7 @@ void FilterExpanderLabel::BuildLayout()
auto key_expand = [this](nux::Area*)
{
expanded = !expanded;
+ expander_view_->expanded.Set(expanded);
};
// Signals
diff --git a/dash/FilterExpanderLabel.h b/dash/FilterExpanderLabel.h
index f107d6803..52f672788 100644
--- a/dash/FilterExpanderLabel.h
+++ b/dash/FilterExpanderLabel.h
@@ -35,6 +35,7 @@
#include "unity-shared/IconTexture.h"
#include "unity-shared/Introspectable.h"
#include "unity-shared/StaticCairoText.h"
+#include "unity-shared/ExpanderView.h"
namespace nux
{
@@ -62,7 +63,7 @@ public:
virtual void SetFilter(Filter::Ptr const& filter) = 0;
virtual std::string GetFilterType() = 0;
- nux::View* expander_view() const { return expander_view_; }
+ ExpanderView* expander_view() const { return expander_view_; }
nux::Property<double> scale;
nux::Property<bool> expanded;
@@ -87,7 +88,7 @@ private:
nux::VLayout* layout_;
nux::LinearLayout* top_bar_layout_;
- nux::View* expander_view_;
+ ExpanderView* expander_view_;
nux::LinearLayout* expander_layout_;
nux::View* right_hand_contents_;
StaticCairoText* cairo_label_;
diff --git a/plugins/unityshell/src/unity-expander-view-accessible.cpp b/plugins/unityshell/src/unity-expander-view-accessible.cpp
new file mode 100644
index 000000000..ba03d3f05
--- /dev/null
+++ b/plugins/unityshell/src/unity-expander-view-accessible.cpp
@@ -0,0 +1,207 @@
+/*
+ * 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>
+ */
+
+/**
+ * SECTION:unity-expander-view-accessible
+ * @Title: UnityExpanderViewAccessible
+ * @short_description: Implementation of the ATK interfaces for #ExpanderView
+ * @see_also: ExpanderView
+ *
+ * #UnityExpanderViewAccessible implements the required ATK interfaces for
+ * #ExpanderView, mainly exposing the text as his name, as this
+ * #object is mainly used as a label
+ *
+ */
+
+#include <NuxCore/Logger.h>
+#include <glib/gi18n.h>
+
+#include "unity-expander-view-accessible.h"
+
+#include "ExpanderView.h"
+#include "StaticCairoText.h"
+
+DECLARE_LOGGER(logger, "unity.a11y.ExpanderView");
+
+using namespace unity;
+
+/* GObject */
+static void unity_expander_view_accessible_class_init(UnityExpanderViewAccessibleClass* klass);
+static void unity_expander_view_accessible_init(UnityExpanderViewAccessible* self);
+static void unity_expander_view_accessible_dispose(GObject* object);
+
+/* AtkObject.h */
+static void unity_expander_view_accessible_initialize(AtkObject* accessible,
+ gpointer data);
+static const gchar* unity_expander_view_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_expanded_changed_cb(bool is_expanded,
+ AtkObject* accessible);
+static void on_name_changed_cb(std::string name,
+ AtkObject* accessible);
+
+G_DEFINE_TYPE(UnityExpanderViewAccessible, unity_expander_view_accessible, NUX_TYPE_VIEW_ACCESSIBLE);
+
+
+#define UNITY_EXPANDER_VIEW_ACCESSIBLE_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((obj), UNITY_TYPE_EXPANDER_VIEW_ACCESSIBLE, \
+ UnityExpanderViewAccessiblePrivate))
+
+struct _UnityExpanderViewAccessiblePrivate
+{
+ gchar* name;
+};
+
+
+static void
+unity_expander_view_accessible_class_init(UnityExpanderViewAccessibleClass* klass)
+{
+ GObjectClass* gobject_class = G_OBJECT_CLASS(klass);
+ AtkObjectClass* atk_class = ATK_OBJECT_CLASS(klass);
+
+ gobject_class->dispose = unity_expander_view_accessible_dispose;
+
+ /* AtkObject */
+ atk_class->initialize = unity_expander_view_accessible_initialize;
+ atk_class->get_name = unity_expander_view_accessible_get_name;
+
+ g_type_class_add_private(gobject_class, sizeof(UnityExpanderViewAccessiblePrivate));
+}
+
+static void
+unity_expander_view_accessible_init(UnityExpanderViewAccessible* self)
+{
+ UnityExpanderViewAccessiblePrivate* priv =
+ UNITY_EXPANDER_VIEW_ACCESSIBLE_GET_PRIVATE(self);
+
+ self->priv = priv;
+ self->priv->name = NULL;
+}
+
+static void
+unity_expander_view_accessible_dispose(GObject* object)
+{
+ UnityExpanderViewAccessible* self = UNITY_EXPANDER_VIEW_ACCESSIBLE(object);
+
+ if (self->priv->name != NULL)
+ {
+ g_free(self->priv->name);
+ self->priv->name = NULL;
+ }
+
+ G_OBJECT_CLASS(unity_expander_view_accessible_parent_class)->dispose(object);
+}
+
+AtkObject*
+unity_expander_view_accessible_new(nux::Object* object)
+{
+ AtkObject* accessible = NULL;
+
+ g_return_val_if_fail(dynamic_cast<ExpanderView*>(object), NULL);
+
+ accessible = ATK_OBJECT(g_object_new(UNITY_TYPE_EXPANDER_VIEW_ACCESSIBLE, NULL));
+
+ atk_object_initialize(accessible, object);
+
+ return accessible;
+}
+
+/* AtkObject.h */
+static void
+unity_expander_view_accessible_initialize(AtkObject* accessible,
+ gpointer data)
+{
+ nux::Object* object = NULL;
+ ExpanderView* view = NULL;
+
+ ATK_OBJECT_CLASS(unity_expander_view_accessible_parent_class)->initialize(accessible, data);
+
+ object = (nux::Object*)data;
+ view = dynamic_cast<ExpanderView*>(object);
+
+ view->key_nav_focus_change.connect(sigc::bind(sigc::ptr_fun(on_focus_changed_cb), accessible));
+
+ view->expanded.changed.connect(sigc::bind(sigc::ptr_fun(on_expanded_changed_cb), accessible));
+ view->label.changed.connect(sigc::bind(sigc::ptr_fun(on_name_changed_cb), accessible));
+
+ atk_object_set_role(accessible, ATK_ROLE_PANEL);
+}
+
+static const gchar*
+unity_expander_view_accessible_get_name(AtkObject* obj)
+{
+ g_return_val_if_fail(UNITY_IS_EXPANDER_VIEW_ACCESSIBLE(obj), NULL);
+ UnityExpanderViewAccessible* self = UNITY_EXPANDER_VIEW_ACCESSIBLE(obj);
+
+ if (self->priv->name != NULL)
+ {
+ g_free(self->priv->name);
+ self->priv->name = NULL;
+ }
+
+ self->priv->name = g_strdup(ATK_OBJECT_CLASS(unity_expander_view_accessible_parent_class)->get_name(obj));
+ if (self->priv->name == NULL)
+ {
+ ExpanderView* view = NULL;
+
+ view = dynamic_cast<ExpanderView*>(nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(obj)));
+
+ if (view == NULL) /* state is defunct */
+ return NULL;
+
+ if (view->expanded)
+ self->priv->name = g_strdup_printf(_("%s: expanded"), view->label().c_str());
+ else
+ self->priv->name = g_strdup_printf(_("%s: collapsed"), view->label().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_EXPANDER_VIEW_ACCESSIBLE(accessible));
+
+ LOG_WARN(logger) << "has_focus = " << has_focus;
+ g_signal_emit_by_name(accessible, "focus-event", has_focus);
+}
+
+static void
+on_expanded_changed_cb(bool is_expanded,
+ AtkObject* accessible)
+{
+ g_return_if_fail(UNITY_IS_EXPANDER_VIEW_ACCESSIBLE(accessible));
+
+ g_object_notify(G_OBJECT(accessible), "accessible-name");
+}
+
+static void
+on_name_changed_cb(std::string name,
+ AtkObject* accessible)
+{
+ g_return_if_fail(UNITY_IS_EXPANDER_VIEW_ACCESSIBLE(accessible));
+
+ g_object_notify(G_OBJECT(accessible), "accessible-name");
+}
diff --git a/plugins/unityshell/src/unity-expander-view-accessible.h b/plugins/unityshell/src/unity-expander-view-accessible.h
new file mode 100644
index 000000000..0c9855d79
--- /dev/null
+++ b/plugins/unityshell/src/unity-expander-view-accessible.h
@@ -0,0 +1,60 @@
+/*
+ * 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_EXPANDER_VIEW_ACCESSIBLE_H
+#define UNITY_EXPANDER_VIEW_ACCESSIBLE_H
+
+#include <atk/atk.h>
+
+#include <Nux/Nux.h>
+#include <Nux/Layout.h>
+
+#include "nux-view-accessible.h"
+
+G_BEGIN_DECLS
+
+#define UNITY_TYPE_EXPANDER_VIEW_ACCESSIBLE (unity_expander_view_accessible_get_type ())
+#define UNITY_EXPANDER_VIEW_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_TYPE_EXPANDER_VIEW_ACCESSIBLE, UnityExpanderViewAccessible))
+#define UNITY_EXPANDER_VIEW_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_TYPE_EXPANDER_VIEW_ACCESSIBLE, UnityExpanderViewAccessibleClass))
+#define UNITY_IS_EXPANDER_VIEW_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_TYPE_EXPANDER_VIEW_ACCESSIBLE))
+#define UNITY_IS_EXPANDER_VIEW_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_TYPE_EXPANDER_VIEW_ACCESSIBLE))
+#define UNITY_EXPANDER_VIEW_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_TYPE_EXPANDER_VIEW_ACCESSIBLE, UnityExpanderViewAccessibleClass))
+
+typedef struct _UnityExpanderViewAccessible UnityExpanderViewAccessible;
+typedef struct _UnityExpanderViewAccessibleClass UnityExpanderViewAccessibleClass;
+typedef struct _UnityExpanderViewAccessiblePrivate UnityExpanderViewAccessiblePrivate;
+
+struct _UnityExpanderViewAccessible
+{
+ NuxViewAccessible parent;
+
+ /*< private >*/
+ UnityExpanderViewAccessiblePrivate* priv;
+};
+
+struct _UnityExpanderViewAccessibleClass
+{
+ NuxViewAccessibleClass parent_class;
+};
+
+GType unity_expander_view_accessible_get_type(void);
+AtkObject* unity_expander_view_accessible_new(nux::Object* object);
+
+G_END_DECLS
+
+#endif /* __UNITY_EXPANDER_VIEW_ACCESSIBLE_H__ */
diff --git a/plugins/unityshell/src/unity-filter-basic-button-accessible.cpp b/plugins/unityshell/src/unity-filter-basic-button-accessible.cpp
new file mode 100644
index 000000000..652706488
--- /dev/null
+++ b/plugins/unityshell/src/unity-filter-basic-button-accessible.cpp
@@ -0,0 +1,285 @@
+/*
+ * 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>
+ */
+
+/**
+ * SECTION:unity-filter-basic-button_accessible
+ * @Title: UnityFilterBasicButtonAccessible
+ * @short_description: Implementation of the ATK interfaces for #unity::dash::FilterBasicButton
+ *
+ * #UnityFilterBasicButtonAccessible implements the required ATK interfaces of
+ * unity::dash::FilterBasicButton, exposing the common elements on each basic individual
+ * element (position, extents, etc)
+ *
+ */
+
+#include <NuxCore/Logger.h>
+#include "unity-filter-basic-button-accessible.h"
+#include "FilterBasicButton.h"
+
+#include "unitya11y.h"
+
+DECLARE_LOGGER(logger, "unity.a11y.UnityFilterBasicButtonAccessible");
+
+using namespace unity::dash;
+
+/* GObject */
+static void unity_filter_basic_button_accessible_class_init(UnityFilterBasicButtonAccessibleClass* klass);
+static void unity_filter_basic_button_accessible_init(UnityFilterBasicButtonAccessible* session_button_accessible);
+static void unity_filter_basic_button_accessible_dispose(GObject* object);
+static void unity_filter_basic_button_accessible_finalize(GObject* object);
+
+
+/* AtkObject.h */
+static void unity_filter_basic_button_accessible_initialize(AtkObject* accessible,
+ gpointer data);
+static AtkStateSet* unity_filter_basic_button_accessible_ref_state_set(AtkObject* obj);
+static const gchar* unity_filter_basic_button_accessible_get_name(AtkObject* obj);
+
+
+/* AtkAction */
+static void atk_action_interface_init(AtkActionIface *iface);
+static gboolean unity_filter_basic_button_accessible_do_action(AtkAction *action,
+ gint i);
+static gint unity_filter_basic_button_accessible_get_n_actions(AtkAction *action);
+static const gchar* unity_filter_basic_button_accessible_get_action_name(AtkAction *action,
+ gint i);
+static void on_layout_changed_cb(nux::View* view,
+ nux::Layout* layout,
+ AtkObject* accessible,
+ gboolean is_add);
+static void on_focus_changed_cb(nux::Area* area,
+ bool has_focus,
+ nux::KeyNavDirection direction,
+ AtkObject* accessible);
+
+G_DEFINE_TYPE_WITH_CODE(UnityFilterBasicButtonAccessible,
+ unity_filter_basic_button_accessible,
+ NUX_TYPE_VIEW_ACCESSIBLE,
+ G_IMPLEMENT_INTERFACE(ATK_TYPE_ACTION,
+ atk_action_interface_init))
+
+static void
+unity_filter_basic_button_accessible_class_init(UnityFilterBasicButtonAccessibleClass* klass)
+{
+ GObjectClass* gobject_class = G_OBJECT_CLASS(klass);
+ AtkObjectClass* atk_class = ATK_OBJECT_CLASS(klass);
+
+ gobject_class->dispose = unity_filter_basic_button_accessible_dispose;
+ gobject_class->finalize = unity_filter_basic_button_accessible_finalize;
+
+ /* AtkObject */
+ atk_class->initialize = unity_filter_basic_button_accessible_initialize;
+ atk_class->get_name = unity_filter_basic_button_accessible_get_name;
+ atk_class->ref_state_set = unity_filter_basic_button_accessible_ref_state_set;
+}
+
+static void
+unity_filter_basic_button_accessible_init(UnityFilterBasicButtonAccessible* session_button_accessible)
+{
+}
+
+static void
+unity_filter_basic_button_accessible_dispose(GObject* object)
+{
+ G_OBJECT_CLASS(unity_filter_basic_button_accessible_parent_class)->dispose(object);
+}
+
+static void
+unity_filter_basic_button_accessible_finalize(GObject* object)
+{
+ G_OBJECT_CLASS(unity_filter_basic_button_accessible_parent_class)->finalize(object);
+}
+
+AtkObject*
+unity_filter_basic_button_accessible_new(nux::Object* object)
+{
+ AtkObject* accessible = NULL;
+
+ g_return_val_if_fail(dynamic_cast<FilterBasicButton*>(object), NULL);
+
+ accessible = ATK_OBJECT(g_object_new(UNITY_TYPE_FILTER_BASIC_BUTTON_ACCESSIBLE, NULL));
+
+ atk_object_initialize(accessible, object);
+
+ return accessible;
+}
+
+/* AtkObject.h */
+static void
+unity_filter_basic_button_accessible_initialize(AtkObject* accessible,
+ gpointer data)
+{
+ nux::Object* nux_object = NULL;
+ FilterBasicButton* button = NULL;
+
+ ATK_OBJECT_CLASS(unity_filter_basic_button_accessible_parent_class)->initialize(accessible, data);
+
+ accessible->role = ATK_ROLE_TOGGLE_BUTTON;
+
+ nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(accessible));
+
+ if (nux_object == NULL) /* defunct */
+ return;
+
+ button = dynamic_cast<FilterBasicButton*>(nux_object);
+
+ if (button == NULL) /* defunct */
+ return;
+
+ button->LayoutAdded.connect(sigc::bind(sigc::ptr_fun(on_layout_changed_cb),
+ accessible, TRUE));
+
+ button->key_nav_focus_change.connect(sigc::bind(sigc::ptr_fun(on_focus_changed_cb), accessible));
+}
+
+static const gchar*
+unity_filter_basic_button_accessible_get_name(AtkObject* obj)
+{
+ const gchar* name;
+
+ g_return_val_if_fail(UNITY_IS_FILTER_BASIC_BUTTON_ACCESSIBLE(obj), NULL);
+
+ name = ATK_OBJECT_CLASS(unity_filter_basic_button_accessible_parent_class)->get_name(obj);
+ if (name == NULL)
+ {
+ FilterBasicButton* button = NULL;
+
+ button = dynamic_cast<FilterBasicButton*>(nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(obj)));
+
+ if (button == NULL) /* State is defunct */
+ name = NULL;
+ else
+ name = button->GetLabel().c_str();
+ }
+
+ if (name == NULL)
+ {
+ LOG_WARN(logger) << "Name == NULL";
+ }
+
+ return name;
+}
+
+static AtkStateSet*
+unity_filter_basic_button_accessible_ref_state_set(AtkObject* obj)
+{
+ AtkStateSet* state_set = NULL;
+ nux::Object* nux_object = NULL;
+ FilterBasicButton* button = NULL;
+
+ g_return_val_if_fail(UNITY_IS_FILTER_BASIC_BUTTON_ACCESSIBLE(obj), NULL);
+
+ state_set = ATK_OBJECT_CLASS(unity_filter_basic_button_accessible_parent_class)->ref_state_set(obj);
+
+ nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(obj));
+
+ if (nux_object == NULL) /* defunct */
+ return state_set;
+
+ button = dynamic_cast<FilterBasicButton*>(nux_object);
+
+ atk_state_set_add_state(state_set, ATK_STATE_FOCUSABLE);
+ atk_state_set_add_state(state_set, ATK_STATE_ENABLED);
+ atk_state_set_add_state(state_set, ATK_STATE_SENSITIVE);
+ atk_state_set_add_state(state_set, ATK_STATE_VISIBLE);
+ atk_state_set_add_state(state_set, ATK_STATE_SHOWING);
+
+ if (button->GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)
+ {
+ atk_state_set_add_state(state_set, ATK_STATE_FOCUSED);
+ atk_state_set_add_state(state_set, ATK_STATE_SELECTED);
+ atk_state_set_add_state(state_set, ATK_STATE_ACTIVE);
+ }
+
+// if (button->GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRESSED)
+// atk_state_set_add_state(state_set, ATK_STATE_ARMED);
+
+ if (button->Active())
+ atk_state_set_add_state(state_set, ATK_STATE_CHECKED);
+
+ return state_set;
+}
+
+/* AtkAction */
+static void
+atk_action_interface_init(AtkActionIface *iface)
+{
+ iface->do_action = unity_filter_basic_button_accessible_do_action;
+ iface->get_n_actions = unity_filter_basic_button_accessible_get_n_actions;
+ iface->get_name = unity_filter_basic_button_accessible_get_action_name;
+}
+
+static gboolean
+unity_filter_basic_button_accessible_do_action(AtkAction *action,
+ gint i)
+{
+ FilterBasicButton* button = NULL;
+ nux::Object* nux_object = NULL;
+
+ g_return_val_if_fail(UNITY_IS_FILTER_BASIC_BUTTON_ACCESSIBLE(action), FALSE);
+
+ nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(action));
+ if (nux_object == NULL)
+ return FALSE;
+
+ button = dynamic_cast<FilterBasicButton*>(nux_object);
+
+ button->Activate();
+
+ return TRUE;
+}
+
+static gint
+unity_filter_basic_button_accessible_get_n_actions(AtkAction *action)
+{
+ g_return_val_if_fail(UNITY_IS_FILTER_BASIC_BUTTON_ACCESSIBLE(action), 0);
+
+ return 1;
+}
+
+static const gchar*
+unity_filter_basic_button_accessible_get_action_name(AtkAction *action,
+ gint i)
+{
+ g_return_val_if_fail(UNITY_IS_FILTER_BASIC_BUTTON_ACCESSIBLE(action), NULL);
+ g_return_val_if_fail(i == 0, NULL);
+
+ return "activate";
+}
+
+static void
+on_layout_changed_cb(nux::View* view,
+ nux::Layout* layout,
+ AtkObject* accessible,
+ gboolean is_add)
+{
+ g_return_if_fail(UNITY_IS_FILTER_BASIC_BUTTON_ACCESSIBLE(accessible));
+
+ g_object_notify(G_OBJECT(accessible), "accessible-name");
+}
+
+static void
+on_focus_changed_cb(nux::Area* area,
+ bool has_focus,
+ nux::KeyNavDirection direction,
+ AtkObject* accessible)
+{
+ g_return_if_fail(UNITY_IS_FILTER_BASIC_BUTTON_ACCESSIBLE(accessible));
+
+ g_signal_emit_by_name(accessible, "focus-event", has_focus);
+}
diff --git a/plugins/unityshell/src/unity-filter-basic-button-accessible.h b/plugins/unityshell/src/unity-filter-basic-button-accessible.h
new file mode 100644
index 000000000..a5eed8df0
--- /dev/null
+++ b/plugins/unityshell/src/unity-filter-basic-button-accessible.h
@@ -0,0 +1,53 @@
+/*
+ * 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_FILTER_BASIC_BUTTON_ACCESSIBLE_H
+#define UNITY_FILTER_BASIC_BUTTON_ACCESSIBLE_H
+
+#include <atk/atk.h>
+
+#include "nux-view-accessible.h"
+
+G_BEGIN_DECLS
+
+#define UNITY_TYPE_FILTER_BASIC_BUTTON_ACCESSIBLE (unity_filter_basic_button_accessible_get_type ())
+#define UNITY_FILTER_BASIC_BUTTON_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_TYPE_FILTER_BASIC_BUTTON_ACCESSIBLE, UnityFilterBasicButtonAccessible))
+#define UNITY_FILTER_BASIC_BUTTON_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_TYPE_FILTER_BASIC_BUTTON_ACCESSIBLE, UnityFilterBasicButtonAccessibleClass))
+#define UNITY_IS_FILTER_BASIC_BUTTON_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_TYPE_FILTER_BASIC_BUTTON_ACCESSIBLE))
+#define UNITY_IS_FILTER_BASIC_BUTTON_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_TYPE_FILTER_BASIC_BUTTON_ACCESSIBLE))
+#define UNITY_FILTER_BASIC_BUTTON_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_TYPE_FILTER_BASIC_BUTTON_ACCESSIBLE, UnityFilterBasicButtonAccessibleClass))
+
+typedef struct _UnityFilterBasicButtonAccessible UnityFilterBasicButtonAccessible;
+typedef struct _UnityFilterBasicButtonAccessibleClass UnityFilterBasicButtonAccessibleClass;
+
+struct _UnityFilterBasicButtonAccessible
+{
+ NuxViewAccessible parent;
+};
+
+struct _UnityFilterBasicButtonAccessibleClass
+{
+ NuxViewAccessibleClass parent_class;
+};
+
+GType unity_filter_basic_button_accessible_get_type(void);
+AtkObject* unity_filter_basic_button_accessible_new(nux::Object* object);
+
+G_END_DECLS
+
+#endif /* __UNITY_FILTER_BASIC_BUTTON_ACCESSIBLE_H__ */
diff --git a/plugins/unityshell/src/unitya11y.cpp b/plugins/unityshell/src/unitya11y.cpp
index 346c915ae..f4ce5e57f 100644
--- a/plugins/unityshell/src/unitya11y.cpp
+++ b/plugins/unityshell/src/unitya11y.cpp
@@ -39,11 +39,13 @@
#include "PanelView.h"
#include "DashView.h"
#include "PlacesGroup.h"
+#include "ExpanderView.h"
#include "QuicklistView.h"
#include "QuicklistMenuItem.h"
#include "SwitcherView.h"
#include "TextInput.h"
#include "SessionButton.h"
+#include "FilterBasicButton.h"
#include "unity-launcher-accessible.h"
#include "unity-launcher-icon-accessible.h"
#include "unity-panel-view-accessible.h"
@@ -52,11 +54,13 @@
#include "unity-sctext-accessible.h"
#include "unity-rvgrid-accessible.h"
#include "unity-places-group-accessible.h"
+#include "unity-expander-view-accessible.h"
#include "unity-quicklist-accessible.h"
#include "unity-quicklist-menu-item-accessible.h"
#include "unity-switcher-accessible.h"
#include "unity-text-input-accessible.h"
#include "unity-session-button-accessible.h"
+#include "unity-filter-basic-button-accessible.h"
using namespace unity;
using namespace unity::dash;
@@ -174,6 +178,12 @@ unity_a11y_create_accessible(nux::Object* object)
if (object->Type().IsDerivedFromType(PlacesGroup::StaticObjectType))
return unity_places_group_accessible_new(object);
+ if (object->Type().IsDerivedFromType(ExpanderView::StaticObjectType))
+ return unity_expander_view_accessible_new(object);
+
+ if (object->Type().IsDerivedFromType(FilterBasicButton::StaticObjectType))
+ return unity_filter_basic_button_accessible_new(object);
+
if (object->Type().IsDerivedFromType(QuicklistView::StaticObjectType))
return unity_quicklist_accessible_new(object);
diff --git a/unity-shared/CMakeLists.txt b/unity-shared/CMakeLists.txt
index ed39e5809..e37edb074 100644
--- a/unity-shared/CMakeLists.txt
+++ b/unity-shared/CMakeLists.txt
@@ -28,6 +28,7 @@ set (UNITY_SHARED_SOURCES
DeltaRestrainment.cpp
DesktopApplicationManager.cpp
EMConverter.cpp
+ ExpanderView.cpp
GnomeFileManager.cpp
FontSettings.cpp
GraphicsUtils.cpp
diff --git a/unity-shared/ExpanderView.cpp b/unity-shared/ExpanderView.cpp
new file mode 100644
index 000000000..ca206e533
--- /dev/null
+++ b/unity-shared/ExpanderView.cpp
@@ -0,0 +1,64 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+ * 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>
+ */
+
+#include <Nux/Layout.h>
+
+#include "ExpanderView.h"
+
+namespace unity
+{
+// namespace dash
+// {
+
+NUX_IMPLEMENT_OBJECT_TYPE(ExpanderView);
+
+ExpanderView::ExpanderView(NUX_FILE_LINE_DECL)
+ : nux::View(NUX_FILE_LINE_PARAM)
+{
+ SetAcceptKeyNavFocusOnMouseDown(false);
+ SetAcceptKeyNavFocusOnMouseEnter(true);
+}
+
+void ExpanderView::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)
+{
+}
+
+void ExpanderView::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw)
+{
+ if (GetLayout())
+ GetLayout()->ProcessDraw(graphics_engine, force_draw);
+}
+
+bool ExpanderView::AcceptKeyNavFocus()
+{
+ return true;
+}
+
+nux::Area* ExpanderView::FindAreaUnderMouse(const nux::Point& mouse_position, nux::NuxEventType event_type)
+{
+ bool mouse_inside = TestMousePointerInclusionFilterMouseWheel(mouse_position, event_type);
+
+ if (mouse_inside == false)
+ return nullptr;
+
+ return this;
+}
+
+// ] // namespace dash
+} // namespace unity
diff --git a/unity-shared/ExpanderView.h b/unity-shared/ExpanderView.h
new file mode 100644
index 000000000..8f7e6bbd4
--- /dev/null
+++ b/unity-shared/ExpanderView.h
@@ -0,0 +1,48 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+ * 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 EXPANDERVIEW_H
+#define EXPANDERVIEW_H
+
+#include <Nux/Nux.h>
+
+namespace unity
+{
+// namespace dash
+// {
+
+class ExpanderView : public nux::View
+{
+ NUX_DECLARE_OBJECT_TYPE(ExpanderView, nux::View);
+public:
+ ExpanderView(NUX_FILE_LINE_PROTO);
+
+protected:
+ void Draw(nux::GraphicsEngine& graphics_engine, bool force_draw);
+ void DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw);
+
+ bool AcceptKeyNavFocus();
+
+ nux::Area* FindAreaUnderMouse(const nux::Point& mouse_position, nux::NuxEventType event_type);
+};
+
+// }
+}
+
+#endif
diff --git a/unity-shared/SearchBar.cpp b/unity-shared/SearchBar.cpp
index b9bf13452..369f2d366 100644
--- a/unity-shared/SearchBar.cpp
+++ b/unity-shared/SearchBar.cpp
@@ -88,45 +88,6 @@ const std::string SHOW_FILTERS_LABEL_DEFAULT_FONT = "Ubuntu " + SHOW_FILTERS_LAB
}
DECLARE_LOGGER(logger, "unity.dash.searchbar");
-namespace
-{
-class ExpanderView : public nux::View
-{
-public:
- ExpanderView(NUX_FILE_LINE_DECL)
- : nux::View(NUX_FILE_LINE_PARAM)
- {
- SetAcceptKeyNavFocusOnMouseDown(false);
- SetAcceptKeyNavFocusOnMouseEnter(true);
- }
-
-protected:
- void Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)
- {}
-
- void DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw)
- {
- if (GetLayout())
- GetLayout()->ProcessDraw(graphics_engine, force_draw);
- }
-
- bool AcceptKeyNavFocus()
- {
- return true;
- }
-
- nux::Area* FindAreaUnderMouse(const nux::Point& mouse_position, nux::NuxEventType event_type)
- {
- bool mouse_inside = TestMousePointerInclusionFilterMouseWheel(mouse_position, event_type);
-
- if (mouse_inside == false)
- return nullptr;
-
- return this;
- }
-};
-
-}
namespace unity
{
@@ -231,6 +192,8 @@ SearchBar::SearchBar(bool show_filter_hint, NUX_FILE_LINE_DECL)
filter_layout_->AddView(arrow_layout_, 0, nux::MINOR_POSITION_CENTER);
expander_view_ = new ExpanderView(NUX_TRACKER_LOCATION);
+ expander_view_->label = filter_str;
+ expander_view_->expanded.Set(showing_filters);
expander_view_->SetVisible(false);
expander_view_->SetLayout(filter_layout_);
layout_->AddView(expander_view_, 0, nux::MINOR_POSITION_END, nux::MINOR_SIZE_FULL);
@@ -239,6 +202,7 @@ SearchBar::SearchBar(bool show_filter_hint, NUX_FILE_LINE_DECL)
auto mouse_expand = [this](int, int, unsigned long, unsigned long)
{
showing_filters = !showing_filters;
+ expander_view_->expanded.Set(showing_filters);
};
auto key_redraw = [this](nux::Area*, bool, nux::KeyNavDirection)
@@ -249,6 +213,7 @@ SearchBar::SearchBar(bool show_filter_hint, NUX_FILE_LINE_DECL)
auto key_expand = [this](nux::Area*)
{
showing_filters = !showing_filters;
+ expander_view_->expanded.Set(showing_filters);
};
// Signals
diff --git a/unity-shared/SearchBar.h b/unity-shared/SearchBar.h
index 9cc6440b6..a04bf2ae9 100644
--- a/unity-shared/SearchBar.h
+++ b/unity-shared/SearchBar.h
@@ -26,6 +26,7 @@
#include <UnityCore/GLibSource.h>
#include "unity-shared/Introspectable.h"
+#include "unity-shared/ExpanderView.h"
namespace nux
{
@@ -110,7 +111,7 @@ private:
StaticCairoText* hint_;
nux::LinearLayout* expander_layout_;
IMTextEntry* pango_entry_;
- nux::View* expander_view_;
+ ExpanderView* expander_view_;
nux::HLayout* filter_layout_;
StaticCairoText* show_filters_;
nux::VLayout* arrow_layout_;