[Xfce4-commits] <xfce4-panel:andrzejr/deskbar-pager> pager: copied a11y implementation from libwnck
Andrzej
noreply at xfce.org
Thu Dec 22 14:56:01 CET 2011
Updating branch refs/heads/andrzejr/deskbar-pager
to e319360585143e4508cd3341f91f4293995e617d (commit)
from 11411a9a8919b17953d3a6be19e6ee6865bc39b1 (commit)
commit e319360585143e4508cd3341f91f4293995e617d
Author: Andrzej <ndrwrdck at gmail.com>
Date: Thu Dec 22 03:30:17 2011 +0900
pager: copied a11y implementation from libwnck
plugins/pager/pager-wnck-accessible-factory.c | 71 +++
plugins/pager/pager-wnck-accessible-factory.h | 59 +++
plugins/pager/pager-wnck-accessible.c | 487 ++++++++++++++++++++
plugins/pager/pager-wnck-accessible.h | 62 +++
.../pager-wnck-workspace-accessible-factory.c | 64 +++
.../pager-wnck-workspace-accessible-factory.h | 59 +++
plugins/pager/pager-wnck-workspace-accessible.c | 256 ++++++++++
plugins/pager/pager-wnck-workspace-accessible.h | 64 +++
8 files changed, 1122 insertions(+), 0 deletions(-)
diff --git a/plugins/pager/pager-wnck-accessible-factory.c b/plugins/pager/pager-wnck-accessible-factory.c
new file mode 100644
index 0000000..42cff8b
--- /dev/null
+++ b/plugins/pager/pager-wnck-accessible-factory.c
@@ -0,0 +1,71 @@
+/* vim: set sw=2 et: */
+/*
+ * Copyright 2002 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <gtk/gtk.h>
+#include "pager-accessible-factory.h"
+#include "pager-accessible.h"
+
+G_DEFINE_TYPE (WnckPagerAccessibleFactory,
+ wnck_pager_accessible_factory, ATK_TYPE_OBJECT_FACTORY);
+
+static AtkObject* wnck_pager_accessible_factory_create_accessible (GObject *obj);
+
+static GType wnck_pager_accessible_factory_get_accessible_type (void);
+
+static void
+wnck_pager_accessible_factory_class_init (WnckPagerAccessibleFactoryClass *klass)
+{
+ AtkObjectFactoryClass *class = ATK_OBJECT_FACTORY_CLASS (klass);
+
+ class->create_accessible = wnck_pager_accessible_factory_create_accessible;
+ class->get_accessible_type = wnck_pager_accessible_factory_get_accessible_type;
+}
+
+static void
+wnck_pager_accessible_factory_init (WnckPagerAccessibleFactory *factory)
+{
+}
+
+AtkObjectFactory*
+wnck_pager_accessible_factory_new (void)
+{
+ GObject *factory;
+
+ factory = g_object_new (WNCK_TYPE_PAGER_ACCESSIBLE_FACTORY, NULL);
+
+ return ATK_OBJECT_FACTORY (factory);
+}
+
+static AtkObject*
+wnck_pager_accessible_factory_create_accessible (GObject *obj)
+{
+ GtkWidget *widget;
+
+ g_return_val_if_fail (GTK_IS_WIDGET (obj), NULL);
+
+ widget = GTK_WIDGET (obj);
+ return wnck_pager_accessible_new (widget);
+}
+
+static GType
+wnck_pager_accessible_factory_get_accessible_type (void)
+{
+ return WNCK_PAGER_TYPE_ACCESSIBLE;
+}
diff --git a/plugins/pager/pager-wnck-accessible-factory.h b/plugins/pager/pager-wnck-accessible-factory.h
new file mode 100644
index 0000000..9dfef36
--- /dev/null
+++ b/plugins/pager/pager-wnck-accessible-factory.h
@@ -0,0 +1,59 @@
+/* vim: set sw=2 et: */
+/*
+ * Copyright 2002 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __WNCK_PAGER_ACCESSIBLE_FACTORY_H__
+#define __WBCK_PAGER_ACCESSIBLE_FACTORY_H__
+
+#include <atk/atk.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define WNCK_TYPE_PAGER_ACCESSIBLE_FACTORY (wnck_pager_accessible_factory_get_type())
+#define WNCK_PAGER_ACCESSIBLE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WNCK_TYPE_PAGER_ACCESSIBLE_FACTORY, WnckpagerAccessibleFactory))
+#define WNCK_PAGER_ACCESSIBLE_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WNCK_TYPE_PAGER_ACCESSIBLE_FACTORY, WnckPagerAccessibleFactoryClass))
+#define WNCK_IS_PAGER_ACCESSIBLE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WNCK_TYPE_PAGER_ACCESSIBLE_FACTORY))
+#define WNCK_IS_PAGER_ACCESSIBLE_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WNCK_TYPE_PAGER_ACCESSIBLE_FACTORY))
+#define WNCK_PAGER_ACCESSIBLE_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WNCK_TYPE_PAGER_ACCESSIBLE_FACTORY, WnckPagerAccessibleFactoryClass))
+
+typedef struct _WnckPagerAccessibleFactory WnckPagerAccessibleFactory;
+typedef struct _WnckPagerAccessibleFactoryClass WnckPagerAccessibleFactoryClass;
+
+struct _WnckPagerAccessibleFactory
+{
+ AtkObjectFactory parent;
+};
+
+struct _WnckPagerAccessibleFactoryClass
+{
+ AtkObjectFactoryClass parent_class;
+};
+
+GType wnck_pager_accessible_factory_get_type (void) G_GNUC_CONST;
+
+AtkObjectFactory* wnck_pager_accessible_factory_new (void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __WNCK_PAGER_ACCESSIBLE_FACTORY_H__ */
diff --git a/plugins/pager/pager-wnck-accessible.c b/plugins/pager/pager-wnck-accessible.c
new file mode 100644
index 0000000..ae6cb1b
--- /dev/null
+++ b/plugins/pager/pager-wnck-accessible.c
@@ -0,0 +1,487 @@
+/* vim: set sw=2 et: */
+/*
+ * Copyright 2002 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+
+#include <libwnck/libwnck.h>
+#include <glib/gi18n-lib.h>
+#include <gtk/gtk.h>
+#include <string.h>
+#include <atk/atk.h>
+#include "pager-accessible.h"
+#include "pager-accessible-factory.h"
+#include "workspace-accessible.h"
+#include "private.h"
+
+typedef struct _WnckPagerAccessiblePriv WnckPagerAccessiblePriv;
+struct _WnckPagerAccessiblePriv
+{
+ GSList *children;
+};
+
+static void wnck_pager_accessible_class_init (WnckPagerAccessibleClass *klass);
+static const char* wnck_pager_accessible_get_name (AtkObject *obj);
+static const char* wnck_pager_accessible_get_description (AtkObject *obj);
+static int wnck_pager_accessible_get_n_children (AtkObject *obj);
+static AtkObject* wnck_pager_accessible_ref_child (AtkObject *obj,
+ int i);
+static void atk_selection_interface_init (AtkSelectionIface *iface);
+static gboolean wnck_pager_add_selection (AtkSelection *selection,
+ int i);
+static gboolean wnck_pager_is_child_selected (AtkSelection *selection,
+ int i);
+static AtkObject* wnck_pager_ref_selection (AtkSelection *selection,
+ int i);
+static int wnck_pager_selection_count (AtkSelection *selection);
+static void wnck_pager_accessible_update_workspace (AtkObject *aobj_ws,
+ WnckPager *pager,
+ int i);
+static void wnck_pager_accessible_finalize (GObject *gobject);
+
+static WnckPagerAccessiblePriv* get_private_data (GObject *gobject);
+
+static void* parent_class;
+static GQuark quark_private_data = 0;
+
+GType
+wnck_pager_accessible_get_type (void)
+{
+ static GType type = 0;
+
+ if (!type)
+ {
+ GTypeInfo tinfo =
+ {
+ sizeof (WnckPagerAccessibleClass),
+ (GBaseInitFunc) NULL, /* base init */
+ (GBaseFinalizeFunc) NULL, /* base finalize */
+ (GClassInitFunc) wnck_pager_accessible_class_init, /* class init */
+ (GClassFinalizeFunc) NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof (WnckPagerAccessible), /* instance size */
+ 0, /* nb preallocs */
+ NULL, /* instance init */
+ NULL /* value table */
+ };
+
+ const GInterfaceInfo atk_selection_info =
+ {
+ (GInterfaceInitFunc) atk_selection_interface_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL
+ };
+
+ /*
+ * Figure out the size of the class and instance
+ * we are deriving from
+ */
+ AtkObjectFactory *factory;
+ GType derived_type;
+ GTypeQuery query;
+ GType derived_atk_type;
+
+ derived_type = g_type_parent (WNCK_TYPE_PAGER);
+
+ factory = atk_registry_get_factory (atk_get_default_registry (),
+ derived_type);
+ derived_atk_type = atk_object_factory_get_accessible_type (factory);
+ g_type_query (derived_atk_type, &query);
+ tinfo.class_size = query.class_size;
+ tinfo.instance_size = query.instance_size;
+
+ type = g_type_register_static (derived_atk_type,
+ "WnckPagerAccessible", &tinfo, 0);
+
+ g_type_add_interface_static (type, ATK_TYPE_SELECTION, &atk_selection_info);
+ }
+
+ return type;
+}
+
+static void
+atk_selection_interface_init (AtkSelectionIface *iface)
+{
+ g_return_if_fail (iface != NULL);
+
+ iface->add_selection = wnck_pager_add_selection;
+ iface->ref_selection = wnck_pager_ref_selection;
+ iface->get_selection_count = wnck_pager_selection_count;
+ iface->is_child_selected = wnck_pager_is_child_selected;
+}
+
+static void
+wnck_pager_accessible_class_init (WnckPagerAccessibleClass *klass)
+{
+ AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+ GObjectClass *obj_class = G_OBJECT_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ class->get_name = wnck_pager_accessible_get_name;
+ class->get_description = wnck_pager_accessible_get_description;
+ class->get_n_children = wnck_pager_accessible_get_n_children;
+ class->ref_child = wnck_pager_accessible_ref_child;
+
+ obj_class->finalize = wnck_pager_accessible_finalize;
+ quark_private_data = g_quark_from_static_string ("wnck-pager-accessible-private-data");
+}
+
+
+static gboolean
+wnck_pager_add_selection (AtkSelection *selection,
+ int i)
+{
+ WnckPager *pager;
+ WnckWorkspace *wspace;
+ GtkWidget *widget;
+ int n_spaces;
+
+#if GTK_CHECK_VERSION(2,21,0)
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
+#else
+ widget = GTK_ACCESSIBLE (selection)->widget;
+#endif
+
+ if (widget == NULL)
+ {
+ /*
+ *State is defunct
+ */
+ return FALSE;
+ }
+
+ pager = WNCK_PAGER (widget);
+ n_spaces = _wnck_pager_get_n_workspaces (pager);
+
+ if (i < 0 || i >= n_spaces)
+ return FALSE;
+
+ /*
+ * Activate the following worksapce as current workspace
+ */
+ wspace = _wnck_pager_get_workspace (pager, i);
+ /* FIXME: Is gtk_get_current_event_time() good enough here? I have no idea */
+ _wnck_pager_activate_workspace (wspace, gtk_get_current_event_time ());
+
+ return TRUE;
+}
+
+/*
+ * Returns the AtkObject of the selected WorkSpace
+ */
+static AtkObject*
+wnck_pager_ref_selection (AtkSelection *selection,
+ int i)
+{
+ WnckPager *pager;
+ GtkWidget *widget;
+ WnckWorkspace *active_wspace;
+ AtkObject *accessible;
+ int wsno;
+
+ g_return_val_if_fail (i == 0, NULL);
+
+#if GTK_CHECK_VERSION(2,21,0)
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
+#else
+ widget = GTK_ACCESSIBLE (selection)->widget;
+#endif
+ if (widget == NULL)
+ {
+ /*
+ * State is defunct
+ */
+ return NULL;
+ }
+ pager = WNCK_PAGER (widget);
+
+ active_wspace = WNCK_WORKSPACE (_wnck_pager_get_active_workspace (pager));
+ wsno = wnck_workspace_get_number (active_wspace);
+
+ accessible = ATK_OBJECT (wnck_pager_accessible_ref_child (ATK_OBJECT (selection), wsno));
+
+ return accessible;
+}
+
+/*
+ * Returns the no.of child selected, it should be either 1 or 0
+ * b'coz only one child can be selected at a time.
+ */
+static int
+wnck_pager_selection_count (AtkSelection *selection)
+{
+ GtkWidget *widget;
+
+#if GTK_CHECK_VERSION(2,21,0)
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
+#else
+ widget = GTK_ACCESSIBLE (selection)->widget;
+#endif
+ if (widget == NULL)
+ {
+ /*
+ * State is defunct
+ */
+ return 0;
+ }
+ else
+ {
+ return 1;
+ }
+}
+
+/*
+ *Checks whether the WorkSpace specified by i is selected,
+ *and returns TRUE on selection.
+ */
+static gboolean
+wnck_pager_is_child_selected (AtkSelection *selection,
+ int i)
+{
+ WnckPager *pager;
+ GtkWidget *widget;
+ WnckWorkspace *active_wspace;
+ int wsno;
+
+#if GTK_CHECK_VERSION(2,21,0)
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
+#else
+ widget = GTK_ACCESSIBLE (selection)->widget;
+#endif
+ if (widget == NULL)
+ {
+ /*
+ * State is defunct
+ */
+ return FALSE;
+ }
+
+ pager = WNCK_PAGER (widget);
+ active_wspace = _wnck_pager_get_active_workspace (pager);
+
+ wsno = wnck_workspace_get_number (active_wspace);
+
+ return (wsno == i);
+}
+
+AtkObject*
+wnck_pager_accessible_new (GtkWidget *widget)
+{
+ GObject *object;
+ AtkObject *aobj_pager;
+ GtkAccessible *gtk_accessible;
+
+ object = g_object_new (WNCK_PAGER_TYPE_ACCESSIBLE, NULL);
+
+ aobj_pager = ATK_OBJECT (object);
+
+ gtk_accessible = GTK_ACCESSIBLE (aobj_pager);
+#if GTK_CHECK_VERSION(2,21,3)
+ gtk_accessible_set_widget (gtk_accessible, widget);
+#else
+ gtk_accessible->widget = widget;
+#endif
+
+ atk_object_initialize (aobj_pager, widget);
+ aobj_pager->role = ATK_ROLE_PANEL;
+
+ return aobj_pager;
+}
+
+static void
+wnck_pager_accessible_finalize (GObject *gobject)
+{
+ WnckPagerAccessiblePriv *pager_accessible_priv;
+ GSList *children;
+
+ pager_accessible_priv = get_private_data (gobject);
+
+ if (pager_accessible_priv)
+ {
+ if (pager_accessible_priv->children)
+ {
+ children = pager_accessible_priv->children;
+ g_slist_foreach (children,
+ (GFunc) g_object_unref, NULL);
+
+ g_slist_free (children);
+ }
+
+ g_free (pager_accessible_priv);
+ g_object_set_qdata (gobject,
+ quark_private_data,
+ NULL);
+ }
+
+ G_OBJECT_CLASS (parent_class)->finalize (gobject);
+}
+
+static const char*
+wnck_pager_accessible_get_name (AtkObject *obj)
+{
+ g_return_val_if_fail (WNCK_PAGER_IS_ACCESSIBLE (obj), NULL);
+
+ if (obj->name == NULL)
+ obj->name = g_strdup (_("Workspace Switcher"));
+
+ return obj->name;
+}
+
+static const char*
+wnck_pager_accessible_get_description (AtkObject *obj)
+{
+ g_return_val_if_fail (WNCK_PAGER_IS_ACCESSIBLE (obj), NULL);
+
+ if (obj->description == NULL)
+ obj->description = g_strdup (_("Tool to switch between workspaces"));
+
+ return obj->description;
+}
+
+/*
+ * Number of workspaces is returned as n_children
+ */
+static int
+wnck_pager_accessible_get_n_children (AtkObject* obj)
+{
+ GtkAccessible *accessible;
+ GtkWidget *widget;
+ WnckPager *pager;
+
+ g_return_val_if_fail (WNCK_PAGER_IS_ACCESSIBLE (obj), 0);
+
+ accessible = GTK_ACCESSIBLE (obj);
+#if GTK_CHECK_VERSION(2,21,0)
+ widget = gtk_accessible_get_widget (accessible);
+#else
+ widget = accessible->widget;
+#endif
+
+ if (widget == NULL)
+ /* State is defunct */
+ return 0;
+
+ pager = WNCK_PAGER (widget);
+
+ return _wnck_pager_get_n_workspaces (pager);
+}
+
+/*
+ * Will return appropriate static AtkObject for the workspaces
+ */
+static AtkObject*
+wnck_pager_accessible_ref_child (AtkObject *obj,
+ int i)
+{
+ GtkAccessible *accessible;
+ GtkWidget *widget;
+ WnckPager *pager;
+ int n_spaces = 0;
+ int len;
+ WnckPagerAccessiblePriv *pager_accessible_priv;
+ AtkObject *ret;
+
+ g_return_val_if_fail (WNCK_PAGER_IS_ACCESSIBLE (obj), NULL);
+ g_return_val_if_fail (ATK_IS_OBJECT (obj), NULL);
+
+ accessible = GTK_ACCESSIBLE (obj);
+#if GTK_CHECK_VERSION(2,21,0)
+ widget = gtk_accessible_get_widget (accessible);
+#else
+ widget = accessible->widget;
+#endif
+
+ if (widget == NULL)
+ /* State is defunct */
+ return NULL;
+
+ pager = WNCK_PAGER (widget);
+ pager_accessible_priv = get_private_data (G_OBJECT (obj));
+
+ len = g_slist_length (pager_accessible_priv->children);
+ n_spaces = _wnck_pager_get_n_workspaces (pager);
+
+ if (i < 0 || i >= n_spaces)
+ return NULL;
+
+ /* We are really inefficient about this due to all the appending,
+ * and never shrink the list either.
+ */
+ while (n_spaces > len)
+ {
+ AtkRegistry *default_registry;
+ AtkObjectFactory *factory;
+ WnckWorkspace *wspace;
+ WnckWorkspaceAccessible *space_accessible;
+
+ default_registry = atk_get_default_registry ();
+ factory = atk_registry_get_factory (default_registry,
+ WNCK_TYPE_WORKSPACE);
+
+ wspace = _wnck_pager_get_workspace (pager, len);
+ space_accessible = WNCK_WORKSPACE_ACCESSIBLE (atk_object_factory_create_accessible (factory,
+ G_OBJECT (wspace)));
+ atk_object_set_parent (ATK_OBJECT (space_accessible), obj);
+
+ pager_accessible_priv->children = g_slist_append (pager_accessible_priv->children,
+ space_accessible);
+
+ ++len;
+ }
+
+ ret = g_slist_nth_data (pager_accessible_priv->children, i);
+ g_object_ref (G_OBJECT (ret));
+ wnck_pager_accessible_update_workspace (ret, pager, i);
+
+ return ret;
+}
+
+static void
+wnck_pager_accessible_update_workspace (AtkObject *aobj_ws,
+ WnckPager *pager,
+ int i)
+{
+ g_free (aobj_ws->name);
+ aobj_ws->name = g_strdup (_wnck_pager_get_workspace_name (pager, i));
+
+ g_free (aobj_ws->description);
+ aobj_ws->description = g_strdup_printf (_("Click this to switch to workspace %s"),
+ aobj_ws->name);
+ aobj_ws->role = ATK_ROLE_UNKNOWN;
+}
+
+static WnckPagerAccessiblePriv*
+get_private_data (GObject *gobject)
+{
+ WnckPagerAccessiblePriv *private_data;
+
+ private_data = g_object_get_qdata (gobject,
+ quark_private_data);
+ if (!private_data)
+ {
+ private_data = g_new0 (WnckPagerAccessiblePriv, 1);
+ g_object_set_qdata (gobject,
+ quark_private_data,
+ private_data);
+ }
+ return private_data;
+}
+
+
diff --git a/plugins/pager/pager-wnck-accessible.h b/plugins/pager/pager-wnck-accessible.h
new file mode 100644
index 0000000..ef0356a
--- /dev/null
+++ b/plugins/pager/pager-wnck-accessible.h
@@ -0,0 +1,62 @@
+/* vim: set sw=2 et: */
+/*
+ * Copyright 2002 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __WNCK_PAGER_ACCESSIBLE_H__
+#define __WNCK_PAGER_ACCESSIBLE_H__
+
+#include <gtk/gtk.h>
+#include <atk/atk.h>
+#include "pager.h"
+#include "screen.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define WNCK_PAGER_TYPE_ACCESSIBLE (wnck_pager_accessible_get_type ())
+#define WNCK_PAGER_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WNCK_PAGER_TYPE_ACCESSIBLE, WnckPagerAccessible))
+#define WNCK_PAGER_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WNCK_PAGER_TYPE_ACCESSIBLE, WnckPagerAccessibleClass))
+#define WNCK_PAGER_IS_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WNCK_PAGER_TYPE_ACCESSIBLE))
+#define WNCK_PAGER_IS_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WnckPagerAccessible))
+#define WNCK_PAGER_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WNCK_PAGER_TYPE_ACCESSIBLE, WnckPagerAccessibleClass))
+
+typedef struct _WnckPagerAccessible WnckPagerAccessible;
+typedef struct _WnckPagerAccessibleClass WnckPagerAccessibleClass;
+
+struct _WnckPagerAccessible
+{
+ GtkAccessible parent;
+};
+
+struct _WnckPagerAccessibleClass
+{
+ GtkAccessibleClass parent_class;
+};
+
+GType wnck_pager_accessible_get_type (void) G_GNUC_CONST;
+
+AtkObject* wnck_pager_accessible_new (GtkWidget *widget);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __WNCK_PAGER_ACCESSIBLE_H__ */
diff --git a/plugins/pager/pager-wnck-workspace-accessible-factory.c b/plugins/pager/pager-wnck-workspace-accessible-factory.c
new file mode 100644
index 0000000..8722558
--- /dev/null
+++ b/plugins/pager/pager-wnck-workspace-accessible-factory.c
@@ -0,0 +1,64 @@
+/* vim: set sw=2 et: */
+/*
+ * Copyright 2002 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <gtk/gtk.h>
+#include "workspace-accessible-factory.h"
+#include "workspace-accessible.h"
+
+G_DEFINE_TYPE (WnckWorkspaceAccessibleFactory,
+ wnck_workspace_accessible_factory, ATK_TYPE_OBJECT_FACTORY);
+
+static AtkObject* wnck_workspace_accessible_factory_create_accessible (GObject *obj);
+
+static GType wnck_workspace_accessible_factory_get_accessible_type (void);
+
+static void
+wnck_workspace_accessible_factory_class_init (WnckWorkspaceAccessibleFactoryClass *klass)
+{
+ AtkObjectFactoryClass *class = ATK_OBJECT_FACTORY_CLASS (klass);
+
+ class->create_accessible = wnck_workspace_accessible_factory_create_accessible;
+ class->get_accessible_type = wnck_workspace_accessible_factory_get_accessible_type;
+}
+
+static void
+wnck_workspace_accessible_factory_init (WnckWorkspaceAccessibleFactory *factory)
+{
+}
+
+AtkObjectFactory*
+wnck_workspace_accessible_factory_new (void)
+{
+ GObject *factory;
+ factory = g_object_new (WNCK_TYPE_WORKSPACE_ACCESSIBLE_FACTORY, NULL);
+ return ATK_OBJECT_FACTORY (factory);
+}
+
+static AtkObject*
+wnck_workspace_accessible_factory_create_accessible (GObject *obj)
+{
+ return wnck_workspace_accessible_new (obj);
+}
+
+static GType
+wnck_workspace_accessible_factory_get_accessible_type (void)
+{
+ return WNCK_WORKSPACE_TYPE_ACCESSIBLE;
+}
diff --git a/plugins/pager/pager-wnck-workspace-accessible-factory.h b/plugins/pager/pager-wnck-workspace-accessible-factory.h
new file mode 100644
index 0000000..c73f660
--- /dev/null
+++ b/plugins/pager/pager-wnck-workspace-accessible-factory.h
@@ -0,0 +1,59 @@
+/* vim: set sw=2 et: */
+/*
+ * Copyright 2002 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __WNCK_WORKSPACE_ACCESSIBLE_FACTORY_H__
+#define __WBCK_WORKSPACE_ACCESSIBLE_FACTORY_H__
+
+#include <atk/atk.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define WNCK_TYPE_WORKSPACE_ACCESSIBLE_FACTORY (wnck_workspace_accessible_factory_get_type())
+#define WNCK_WORKSPACE_ACCESSIBLE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WNCK_TYPE_WORKSPACE_ACCESSIBLE_FACTORY, WnckWorkspaceAccessibleFactory))
+#define WNCK_WORKSPACE_ACCESSIBLE_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WNCK_TYPE_WORKSPACE_ACCESSIBLE_FACTORY, WnckWorkspaceAccessibleFactoryClass))
+#define WNCK_IS_WORKSPACE_ACCESSIBLE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WNCK_TYPE_WORKSPACE_ACCESSIBLE_FACTORY))
+#define WNCK_IS_WORKSPACE_ACCESSIBLE_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WNCK_TYPE_WORKSPACE_ACCESSIBLE_FACTORY))
+#define WNCK_WORKSPACE_ACCESSIBLE_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WNCK_TYPE_WORKSPACE_ACCESSIBLE_FACTORY, WnckWorkspaceAccessibleFactoryClass))
+
+typedef struct _WnckWorkspaceAccessibleFactory WnckWorkspaceAccessibleFactory;
+typedef struct _WnckWorkspaceAccessibleFactoryClass WnckWorkspaceAccessibleFactoryClass;
+
+struct _WnckWorkspaceAccessibleFactory
+{
+ AtkObjectFactory parent;
+};
+
+struct _WnckWorkspaceAccessibleFactoryClass
+{
+ AtkObjectFactoryClass parent_class;
+};
+
+GType wnck_workspace_accessible_factory_get_type (void) G_GNUC_CONST;
+
+AtkObjectFactory* wnck_workspace_accessible_factory_new (void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __WNCK_WORKSPACE_ACCESSIBLE_FACTORY_H__ */
diff --git a/plugins/pager/pager-wnck-workspace-accessible.c b/plugins/pager/pager-wnck-workspace-accessible.c
new file mode 100644
index 0000000..8addbff
--- /dev/null
+++ b/plugins/pager/pager-wnck-workspace-accessible.c
@@ -0,0 +1,256 @@
+/* vim: set sw=2 et: */
+/*
+ * Copyright 2002 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <libwnck/libwnck.h>
+#include <gtk/gtk.h>
+#include <errno.h>
+#include <unistd.h>
+#include "workspace-accessible.h"
+#include "private.h"
+static void wnck_workspace_accessible_class_init (WnckWorkspaceAccessibleClass *klass);
+static const char* wnck_workspace_accessible_get_name (AtkObject *obj);
+static const char* wnck_workspace_accessible_get_description (AtkObject *obj);
+static int wnck_workspace_accessible_get_index_in_parent (AtkObject *obj);
+static void atk_component_interface_init (AtkComponentIface *iface);
+static void wnck_workspace_accessible_get_extents (AtkComponent *component,
+ int *x,
+ int *y,
+ int *width,
+ int *height,
+ AtkCoordType coords);
+static void wnck_workspace_accessible_get_position (AtkComponent *component,
+ int *x,
+ int *y,
+ AtkCoordType coords);
+static gboolean wnck_workspace_accessible_contains (AtkComponent *component,
+ int x,
+ int y,
+ AtkCoordType coords);
+static void wnck_workspace_accessible_get_size (AtkComponent *component,
+ int *width,
+ int *height);
+
+GType
+wnck_workspace_accessible_get_type (void)
+{
+ static GType type = 0;
+
+ if (!type)
+ {
+ const GTypeInfo tinfo =
+ {
+ sizeof (WnckWorkspaceAccessibleClass),
+ (GBaseInitFunc) NULL, /* base init */
+ (GBaseFinalizeFunc) NULL, /* base finalize */
+ (GClassInitFunc) wnck_workspace_accessible_class_init,
+ (GClassFinalizeFunc) NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof (WnckWorkspaceAccessible), /* instance size*/
+ 0, /* nb preallocs */
+ (GInstanceInitFunc) NULL, /* instance init */
+ NULL /* value table */
+ };
+
+ const GInterfaceInfo atk_component_info =
+ {
+ (GInterfaceInitFunc) atk_component_interface_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL
+ };
+
+ type = g_type_register_static (ATK_TYPE_GOBJECT_ACCESSIBLE, "WnckWorkspaceAccessible", &tinfo, 0);
+ g_type_add_interface_static (type, ATK_TYPE_COMPONENT, &atk_component_info);
+ }
+ return type;
+}
+
+static void
+atk_component_interface_init (AtkComponentIface *iface)
+{
+ g_return_if_fail (iface != NULL);
+
+ iface->get_extents = wnck_workspace_accessible_get_extents;
+ iface->get_size = wnck_workspace_accessible_get_size;
+ iface->get_position = wnck_workspace_accessible_get_position;
+ iface->contains = wnck_workspace_accessible_contains;
+}
+
+static void
+wnck_workspace_accessible_get_extents (AtkComponent *component,
+ int *x,
+ int *y,
+ int *width,
+ int *height,
+ AtkCoordType coords)
+{
+ AtkGObjectAccessible *atk_gobj;
+ WnckWorkspace *workspace;
+ WnckPager *pager;
+ GdkRectangle rect;
+ GtkWidget *widget;
+ AtkObject *parent;
+ GObject *g_obj;
+ int px, py;
+
+ g_return_if_fail (WNCK_IS_WORKSPACE_ACCESSIBLE (component));
+
+ atk_gobj = ATK_GOBJECT_ACCESSIBLE (component);
+ g_obj = atk_gobject_accessible_get_object (atk_gobj);
+ if (g_obj == NULL)
+ return;
+
+ g_return_if_fail (WNCK_IS_WORKSPACE (g_obj));
+ workspace = WNCK_WORKSPACE (g_obj);
+
+ parent = atk_object_get_parent (ATK_OBJECT(component));
+#if GTK_CHECK_VERSION(2,21,0)
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (parent));
+#else
+ widget = GTK_ACCESSIBLE (parent)->widget;
+#endif
+
+ if (widget == NULL)
+ {
+ /*
+ *State is defunct
+ */
+ return;
+ }
+
+ g_return_if_fail (WNCK_IS_PAGER (widget));
+ pager = WNCK_PAGER (widget);
+
+ g_return_if_fail (WNCK_IS_PAGER (pager));
+
+ atk_component_get_position (ATK_COMPONENT (parent), &px,&py, coords);
+
+ _wnck_pager_get_workspace_rect (pager, WNCK_WORKSPACE_ACCESSIBLE (component)->index, &rect);
+
+ *x = rect.x + px;
+ *y = rect.y + py;
+ *height = rect.height;
+ *width = rect.width;
+}
+
+static void
+wnck_workspace_accessible_get_size (AtkComponent *component,
+ int *width,
+ int *height)
+{
+ AtkCoordType coords = ATK_XY_SCREEN;
+ int x, y;
+
+ /* FIXME: Value for initialization of coords picked randomly to please gcc */
+
+ wnck_workspace_accessible_get_extents (component, &x, &y, width, height, coords);
+}
+
+static void
+wnck_workspace_accessible_get_position (AtkComponent *component,
+ int *x,
+ int *y,
+ AtkCoordType coords)
+{
+ int width, height;
+ wnck_workspace_accessible_get_extents (component, x, y, &width, &height, coords);
+}
+
+static gboolean
+wnck_workspace_accessible_contains (AtkComponent *component,
+ int x,
+ int y,
+ AtkCoordType coords)
+{
+ int lx, ly, width, height;
+
+ wnck_workspace_accessible_get_extents (component, &lx, &ly, &width, &height, coords);
+
+ /*
+ * Check if the specified co-ordinates fall within the workspace.
+ */
+ if ( (x > lx) && ((lx + width) >= x) && (y > ly) && ((ly + height) >= ly) )
+ return TRUE;
+ else
+ return FALSE;
+}
+
+static void
+wnck_workspace_accessible_class_init (WnckWorkspaceAccessibleClass *klass)
+{
+ AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+
+ class->get_name = wnck_workspace_accessible_get_name;
+ class->get_description = wnck_workspace_accessible_get_description;
+ class->get_index_in_parent = wnck_workspace_accessible_get_index_in_parent;
+}
+
+AtkObject*
+wnck_workspace_accessible_new (GObject *obj)
+{
+ GObject *object;
+ AtkObject *atk_object;
+
+ g_return_val_if_fail (WNCK_IS_WORKSPACE (obj), NULL);
+
+ object = g_object_new (WNCK_WORKSPACE_TYPE_ACCESSIBLE, NULL);
+ atk_object = ATK_OBJECT (object);
+ atk_object_initialize (atk_object, obj);
+
+ g_return_val_if_fail (ATK_IS_OBJECT (atk_object), NULL);
+
+ WNCK_WORKSPACE_ACCESSIBLE (atk_object)->index =
+ wnck_workspace_get_number (WNCK_WORKSPACE (obj));
+
+ return atk_object;
+}
+
+static const char*
+wnck_workspace_accessible_get_name (AtkObject *obj)
+{
+ g_return_val_if_fail (WNCK_IS_WORKSPACE_ACCESSIBLE (obj), NULL);
+
+ if (obj->name != NULL)
+ {
+ return obj->name;
+ }
+ else
+ return NULL;
+}
+
+static const char*
+wnck_workspace_accessible_get_description (AtkObject *obj)
+{
+ g_return_val_if_fail (WNCK_IS_WORKSPACE_ACCESSIBLE (obj), NULL);
+
+ if (obj->description != NULL)
+ {
+ return obj->description;
+ }
+ else
+ return NULL;
+}
+
+static gint
+wnck_workspace_accessible_get_index_in_parent (AtkObject *obj)
+{
+ g_return_val_if_fail (WNCK_IS_WORKSPACE_ACCESSIBLE (obj), -1);
+
+ return WNCK_WORKSPACE_ACCESSIBLE (obj)->index;
+}
diff --git a/plugins/pager/pager-wnck-workspace-accessible.h b/plugins/pager/pager-wnck-workspace-accessible.h
new file mode 100644
index 0000000..6aaa6e5
--- /dev/null
+++ b/plugins/pager/pager-wnck-workspace-accessible.h
@@ -0,0 +1,64 @@
+/* vim: set sw=2 et: */
+/*
+ * Copyright 2002 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __WNCK_WORKSPACE_ACCESSIBLE_H__
+#define __WNCK_WORKSPACE_ACCESSIBLE_H__
+
+#include <gtk/gtk.h>
+#include <atk/atk.h>
+#include "workspace.h"
+#include "pager-accessible.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define WNCK_WORKSPACE_TYPE_ACCESSIBLE (wnck_workspace_accessible_get_type ())
+#define WNCK_WORKSPACE_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WNCK_WORKSPACE_TYPE_ACCESSIBLE, WnckWorkspaceAccessible))
+#define WNCK_WORKSPACE_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WNCK_WORKSPACE_TYPE_ACCESSIBLE, WnckWorkspaceAccessibleClass))
+#define WNCK_IS_WORKSPACE_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WNCK_WORKSPACE_TYPE_ACCESSIBLE))
+#define WNCK_IS_WORKSPACE_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WnckWorkspaceAccessible))
+#define WNCK_WORKSPACE_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WNCK_WORKSPACE_TYPE_ACCESSIBLE, WnckWorkspaceAccessibleClass))
+
+typedef struct _WnckWorkspaceAccessible WnckWorkspaceAccessible;
+typedef struct _WnckWorkspaceAccessibleClass WnckWorkspaceAccessibleClass;
+
+struct _WnckWorkspaceAccessible
+{
+ AtkGObjectAccessible parent;
+
+ int index;
+};
+
+struct _WnckWorkspaceAccessibleClass
+{
+ AtkGObjectAccessibleClass parent_class;
+};
+
+GType wnck_workspace_accessible_get_type (void) G_GNUC_CONST;
+
+AtkObject* wnck_workspace_accessible_new (GObject *obj);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __WNCK_WORKSPACE_ACCESSIBLE_H__ */
More information about the Xfce4-commits
mailing list