summaryrefslogtreecommitdiff
path: root/plugins
diff options
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2014-03-06 17:17:34 +0100
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2014-03-06 17:17:34 +0100
commit61e2c0fc40dcb12288bcdd6fea5d7046c304b953 (patch)
tree812df8ce9318c04b50f9b94635f9bedd6a02b17e /plugins
parent0470b22d9d23976d2cf36c99bab0ab11619cbe20 (diff)
parent45d874ce6b8f380015836b264ebe0ac9906dfe48 (diff)
Merging with lp:~andyrock/unity/lockscreen
(bzr r3695.5.1)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/unityshell/src/nux-layout-accessible.cpp5
-rw-r--r--plugins/unityshell/src/unity-session-button-accessible.cpp260
-rw-r--r--plugins/unityshell/src/unity-session-button-accessible.h53
-rw-r--r--plugins/unityshell/src/unitya11y.cpp6
-rw-r--r--plugins/unityshell/src/unityshell.cpp20
5 files changed, 336 insertions, 8 deletions
diff --git a/plugins/unityshell/src/nux-layout-accessible.cpp b/plugins/unityshell/src/nux-layout-accessible.cpp
index b706df620..22ef5b22e 100644
--- a/plugins/unityshell/src/nux-layout-accessible.cpp
+++ b/plugins/unityshell/src/nux-layout-accessible.cpp
@@ -137,6 +137,7 @@ nux_layout_accessible_ref_child(AtkObject* obj,
std::list<nux::Area*> element_list;
gint num = 0;
std::list<nux::Area*>::iterator it;
+ AtkObject* parent = NULL;
g_return_val_if_fail(NUX_IS_LAYOUT_ACCESSIBLE(obj), 0);
num = atk_object_get_n_accessible_children(obj);
@@ -156,6 +157,10 @@ nux_layout_accessible_ref_child(AtkObject* obj,
child = dynamic_cast<nux::Object*>(*it);
child_accessible = unity_a11y_get_accessible(child);
+ parent = atk_object_get_parent(child_accessible);
+ if (parent != obj)
+ atk_object_set_parent(child_accessible, obj);
+
g_object_ref(child_accessible);
return child_accessible;
diff --git a/plugins/unityshell/src/unity-session-button-accessible.cpp b/plugins/unityshell/src/unity-session-button-accessible.cpp
new file mode 100644
index 000000000..40f56522c
--- /dev/null
+++ b/plugins/unityshell/src/unity-session-button-accessible.cpp
@@ -0,0 +1,260 @@
+/*
+ * 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-session_button_accessible
+ * @Title: UnitySessionButtonAccessible
+ * @short_description: Implementation of the ATK interfaces for #unity::session::Button
+ *
+ * #UnitySessionButtonAccessible implements the required ATK interfaces of
+ * unity::Button, exposing the common elements on each basic individual
+ * element (position, extents, etc)
+ *
+ */
+
+#include "unity-session-button-accessible.h"
+#include "SessionButton.h"
+
+#include "unitya11y.h"
+
+using namespace unity::session;
+
+/* GObject */
+static void unity_session_button_accessible_class_init(UnitySessionButtonAccessibleClass* klass);
+static void unity_session_button_accessible_init(UnitySessionButtonAccessible* session_button_accessible);
+static void unity_session_button_accessible_dispose(GObject* object);
+static void unity_session_button_accessible_finalize(GObject* object);
+
+
+/* AtkObject.h */
+static void unity_session_button_accessible_initialize(AtkObject* accessible,
+ gpointer data);
+static AtkStateSet* unity_session_button_accessible_ref_state_set(AtkObject* obj);
+static const gchar* unity_session_button_accessible_get_name(AtkObject* obj);
+
+
+/* AtkAction */
+static void atk_action_interface_init(AtkActionIface *iface);
+static gboolean unity_session_button_accessible_do_action(AtkAction *action,
+ gint i);
+static gint unity_session_button_accessible_get_n_actions(AtkAction *action);
+static const gchar* unity_session_button_accessible_get_name(AtkAction *action,
+ gint i);
+
+/* private/utility methods*/
+static void on_focus_change_cb(bool const& value, UnitySessionButtonAccessible* accessible);
+
+G_DEFINE_TYPE_WITH_CODE(UnitySessionButtonAccessible,
+ unity_session_button_accessible,
+ NUX_TYPE_OBJECT_ACCESSIBLE,
+ G_IMPLEMENT_INTERFACE(ATK_TYPE_ACTION,
+ atk_action_interface_init))
+
+static void
+unity_session_button_accessible_class_init(UnitySessionButtonAccessibleClass* klass)
+{
+ GObjectClass* gobject_class = G_OBJECT_CLASS(klass);
+ AtkObjectClass* atk_class = ATK_OBJECT_CLASS(klass);
+
+ gobject_class->dispose = unity_session_button_accessible_dispose;
+ gobject_class->finalize = unity_session_button_accessible_finalize;
+
+ /* AtkObject */
+ atk_class->initialize = unity_session_button_accessible_initialize;
+ atk_class->get_name = unity_session_button_accessible_get_name;
+ atk_class->ref_state_set = unity_session_button_accessible_ref_state_set;
+}
+
+static void
+unity_session_button_accessible_init(UnitySessionButtonAccessible* session_button_accessible)
+{
+}
+
+static void
+unity_session_button_accessible_dispose(GObject* object)
+{
+ G_OBJECT_CLASS(unity_session_button_accessible_parent_class)->dispose(object);
+}
+
+static void
+unity_session_button_accessible_finalize(GObject* object)
+{
+ G_OBJECT_CLASS(unity_session_button_accessible_parent_class)->finalize(object);
+}
+
+AtkObject*
+unity_session_button_accessible_new(nux::Object* object)
+{
+ AtkObject* accessible = NULL;
+
+ g_return_val_if_fail(dynamic_cast<Button*>(object), NULL);
+
+ accessible = ATK_OBJECT(g_object_new(UNITY_TYPE_SESSION_BUTTON_ACCESSIBLE, NULL));
+
+ atk_object_initialize(accessible, object);
+
+ return accessible;
+}
+
+/* AtkObject.h */
+static void
+unity_session_button_accessible_initialize(AtkObject* accessible,
+ gpointer data)
+{
+ UnitySessionButtonAccessible* self = NULL;
+ nux::Object* nux_object = NULL;
+ Button* button = NULL;
+
+ ATK_OBJECT_CLASS(unity_session_button_accessible_parent_class)->initialize(accessible, data);
+ self = UNITY_SESSION_BUTTON_ACCESSIBLE(accessible);
+
+ accessible->role = ATK_ROLE_PUSH_BUTTON;
+
+ nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(accessible));
+
+ if (nux_object == NULL) /* defunct */
+ return;
+
+ button = dynamic_cast<Button*>(nux_object);
+
+ button->highlighted.changed.connect(sigc::bind(sigc::ptr_fun(on_focus_change_cb),
+ UNITY_SESSION_BUTTON_ACCESSIBLE(self)));
+}
+
+static const gchar*
+unity_session_button_accessible_get_name(AtkObject* obj)
+{
+ const gchar* name;
+
+ g_return_val_if_fail(UNITY_IS_SESSION_BUTTON_ACCESSIBLE(obj), NULL);
+
+ name = ATK_OBJECT_CLASS(unity_session_button_accessible_parent_class)->get_name(obj);
+ if (name == NULL)
+ {
+ Button* button = NULL;
+
+ button = dynamic_cast<Button*>(nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(obj)));
+
+ if (button == NULL) /* State is defunct */
+ name = NULL;
+ else
+ name = button->label().c_str();
+ }
+
+ return name;
+}
+
+static AtkStateSet*
+unity_session_button_accessible_ref_state_set(AtkObject* obj)
+{
+ AtkStateSet* state_set = NULL;
+ nux::Object* nux_object = NULL;
+ Button* button = NULL;
+
+ g_return_val_if_fail(UNITY_IS_SESSION_BUTTON_ACCESSIBLE(obj), NULL);
+
+ state_set = ATK_OBJECT_CLASS(unity_session_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<Button*>(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->highlighted)
+ {
+ 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);
+ }
+
+ return state_set;
+}
+
+/* private methods */
+static void
+on_focus_change_cb(bool const& value, UnitySessionButtonAccessible* accessible)
+{
+ nux::Object* nux_object = NULL;
+ Button* button = NULL;
+
+ nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(accessible));
+
+ if (nux_object == NULL) /* defunct */
+ return;
+
+ button = dynamic_cast<Button*>(nux_object);
+
+ atk_object_notify_state_change(ATK_OBJECT(accessible), ATK_STATE_FOCUSED, button->highlighted);
+ atk_object_notify_state_change(ATK_OBJECT(accessible), ATK_STATE_SELECTED, button->highlighted);
+ atk_object_notify_state_change(ATK_OBJECT(accessible), ATK_STATE_ACTIVE, button->highlighted);
+}
+
+/* AtkAction */
+static void
+atk_action_interface_init(AtkActionIface *iface)
+{
+ iface->do_action = unity_session_button_accessible_do_action;
+ iface->get_n_actions = unity_session_button_accessible_get_n_actions;
+ iface->get_name = unity_session_button_accessible_get_name;
+}
+
+static gboolean
+unity_session_button_accessible_do_action(AtkAction *action,
+ gint i)
+{
+ Button* button = NULL;
+ nux::Object* nux_object = NULL;
+
+ g_return_val_if_fail(UNITY_IS_SESSION_BUTTON_ACCESSIBLE(action), FALSE);
+
+ nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(action));
+ if (nux_object == NULL)
+ return FALSE;
+
+ button = dynamic_cast<Button*>(nux_object);
+
+ button->activated.emit();
+
+ return TRUE;
+}
+
+static gint
+unity_session_button_accessible_get_n_actions(AtkAction *action)
+{
+ g_return_val_if_fail(UNITY_IS_SESSION_BUTTON_ACCESSIBLE(action), 0);
+
+ return 1;
+}
+
+static const gchar*
+unity_session_button_accessible_get_name(AtkAction *action,
+ gint i)
+{
+ g_return_val_if_fail(UNITY_IS_SESSION_BUTTON_ACCESSIBLE(action), NULL);
+ g_return_val_if_fail(i == 0, NULL);
+
+ return "activate";
+}
diff --git a/plugins/unityshell/src/unity-session-button-accessible.h b/plugins/unityshell/src/unity-session-button-accessible.h
new file mode 100644
index 000000000..9653c843e
--- /dev/null
+++ b/plugins/unityshell/src/unity-session-button-accessible.h
@@ -0,0 +1,53 @@
+/*
+ * 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: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
+ */
+
+#ifndef UNITY_SESSION_BUTTON_ACCESSIBLE_H
+#define UNITY_SESSION_BUTTON_ACCESSIBLE_H
+
+#include <atk/atk.h>
+
+#include "nux-object-accessible.h"
+
+G_BEGIN_DECLS
+
+#define UNITY_TYPE_SESSION_BUTTON_ACCESSIBLE (unity_session_button_accessible_get_type ())
+#define UNITY_SESSION_BUTTON_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_TYPE_SESSION_BUTTON_ACCESSIBLE, UnitySessionButtonAccessible))
+#define UNITY_SESSION_BUTTON_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_TYPE_SESSION_BUTTON_ACCESSIBLE, UnitySessionButtonAccessibleClass))
+#define UNITY_IS_SESSION_BUTTON_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_TYPE_SESSION_BUTTON_ACCESSIBLE))
+#define UNITY_IS_SESSION_BUTTON_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_TYPE_SESSION_BUTTON_ACCESSIBLE))
+#define UNITY_SESSION_BUTTON_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_TYPE_SESSION_BUTTON_ACCESSIBLE, UnitySessionButtonAccessibleClass))
+
+typedef struct _UnitySessionButtonAccessible UnitySessionButtonAccessible;
+typedef struct _UnitySessionButtonAccessibleClass UnitySessionButtonAccessibleClass;
+
+struct _UnitySessionButtonAccessible
+{
+ NuxObjectAccessible parent;
+};
+
+struct _UnitySessionButtonAccessibleClass
+{
+ NuxObjectAccessibleClass parent_class;
+};
+
+GType unity_session_button_accessible_get_type(void);
+AtkObject* unity_session_button_accessible_new(nux::Object* object);
+
+G_END_DECLS
+
+#endif /* __UNITY_SESSION_BUTTON_ACCESSIBLE_H__ */
diff --git a/plugins/unityshell/src/unitya11y.cpp b/plugins/unityshell/src/unitya11y.cpp
index 159938451..346c915ae 100644
--- a/plugins/unityshell/src/unitya11y.cpp
+++ b/plugins/unityshell/src/unitya11y.cpp
@@ -43,6 +43,7 @@
#include "QuicklistMenuItem.h"
#include "SwitcherView.h"
#include "TextInput.h"
+#include "SessionButton.h"
#include "unity-launcher-accessible.h"
#include "unity-launcher-icon-accessible.h"
#include "unity-panel-view-accessible.h"
@@ -55,11 +56,13 @@
#include "unity-quicklist-menu-item-accessible.h"
#include "unity-switcher-accessible.h"
#include "unity-text-input-accessible.h"
+#include "unity-session-button-accessible.h"
using namespace unity;
using namespace unity::dash;
using namespace unity::launcher;
using namespace unity::panel;
+using namespace unity::session;
static GHashTable* accessible_table = NULL;
/* FIXME: remove accessible objects when not required anymore */
@@ -192,6 +195,9 @@ unity_a11y_create_accessible(nux::Object* object)
if (object->Type().IsDerivedFromType(unity::switcher::SwitcherView::StaticObjectType))
return unity_switcher_accessible_new(object);
+ if (object->Type().IsDerivedFromType(Button::StaticObjectType))
+ return unity_session_button_accessible_new(object);
+
/* NUX classes */
if (object->Type().IsDerivedFromType(nux::TextEntry::StaticObjectType))
return nux_text_entry_accessible_new(object);
diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp
index 29cf6515c..91abfe0bf 100644
--- a/plugins/unityshell/src/unityshell.cpp
+++ b/plugins/unityshell/src/unityshell.cpp
@@ -3650,14 +3650,15 @@ void UnityScreen::initLauncher()
// Setup Lockscreen Controller
lockscreen_controller_ = std::make_shared<lockscreen::Controller>(manager);
- auto on_launcher_size_changed = [this] (nux::Area*, int w, int h) {
+ auto on_launcher_size_changed = [this] (nux::Area* area, int w, int h) {
/* The launcher geometry includes 1px used to draw the right margin
* that must not be considered when drawing an overlay */
+
int launcher_width = w - 1;
- hud_controller_->launcher_width = launcher_width;
- dash_controller_->launcher_width = launcher_width;
- panel_controller_->launcher_width = launcher_width;
- shortcut_controller_->SetAdjustment(launcher_width, panel_style_.PanelHeight());
+ Launcher const* const launcher = static_cast<Launcher*>(area);
+
+ unity::Settings::Instance().SetLauncherWidth(launcher_width, launcher->monitor);
+ shortcut_controller_->SetAdjustment(launcher_width, panel_style_.PanelHeight(launcher->monitor));
CompOption::Value v(launcher_width);
screen->setOptionForPlugin("expo", "x_offset", v);
@@ -3665,10 +3666,13 @@ void UnityScreen::initLauncher()
if (launcher_controller_->options()->hide_mode != LAUNCHER_HIDE_NEVER)
screen->setOptionForPlugin("scale", "x_offset", v);
};
- launcher_controller_->launcher().size_changed.connect(on_launcher_size_changed);
- auto* l = &launcher_controller_->launcher();
- on_launcher_size_changed(l, l->GetWidth(), l->GetHeight());
+ for (auto const& launcher : launcher_controller_->launchers())
+ {
+ launcher->size_changed.connect(on_launcher_size_changed);
+
+ on_launcher_size_changed(launcher.GetPointer(), launcher->GetWidth(), launcher->GetHeight());
+ }
ScheduleRelayout(0);
}