[at-spi2-core/gi] Add selection interface
- From: Mike Gorse <mgorse src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [at-spi2-core/gi] Add selection interface
- Date: Fri, 19 Nov 2010 19:25:13 +0000 (UTC)
commit 9264c1189ac000516b8d494bd4f75c9d2da86600
Author: Mike Gorse <mgorse novell com>
Date: Fri Nov 19 14:27:13 2010 -0500
Add selection interface
atspi/Makefile.am | 2 +
atspi/atspi-accessible.c | 14 ++-
atspi/atspi-accessible.h | 2 +
atspi/atspi-selection.c | 259 ++++++++++++++++++++++++++++++++++++++++++++++
atspi/atspi-selection.h | 64 +++++++++++
atspi/atspi-types.h | 2 +-
atspi/atspi.h | 1 +
7 files changed, 340 insertions(+), 4 deletions(-)
---
diff --git a/atspi/Makefile.am b/atspi/Makefile.am
index 327a623..4da8fa0 100644
--- a/atspi/Makefile.am
+++ b/atspi/Makefile.am
@@ -33,6 +33,8 @@ libatspi_la_SOURCES = \
atspi-private.h \
atspi-registry.c \
atspi-registry.h \
+ atspi-selection.c \
+ atspi-selection.h \
atspi-stateset.c \
atspi-stateset.h \
atspi-table.c \
diff --git a/atspi/atspi-accessible.c b/atspi/atspi-accessible.c
index 43da7dd..a413f65 100644
--- a/atspi/atspi-accessible.c
+++ b/atspi/atspi-accessible.c
@@ -30,6 +30,11 @@ atspi_component_interface_init (AtspiComponent *component)
}
static void
+atspi_selection_interface_init (AtspiSelection *selection)
+{
+}
+
+static void
atspi_table_interface_init (AtspiTable *table)
{
}
@@ -41,6 +46,7 @@ atspi_text_interface_init (AtspiText *text)
G_DEFINE_TYPE_WITH_CODE (AtspiAccessible, atspi_accessible, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (ATSPI_TYPE_COMPONENT, atspi_component_interface_init)
+ G_IMPLEMENT_INTERFACE (ATSPI_TYPE_SELECTION, atspi_selection_interface_init)
G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TABLE, atspi_table_interface_init)
G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TEXT, atspi_text_interface_init))
@@ -893,6 +899,7 @@ atspi_accessible_get_image (AtspiAccessible *accessible)
return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
accessible : NULL);
}
+#endif
/**
* atspi_accessible_get_selection:
@@ -900,16 +907,17 @@ atspi_accessible_get_image (AtspiAccessible *accessible)
*
* Get the #AtspiSelection interface for an #AtspiAccessible.
*
- * Returns: a pointer to an #AtspiSelection interface instance, or
- * NULL if @obj does not implement #AtspiSelection.
+ * Returns: (transfer full): a pointer to an #AtspiSelection interface
+ * instance, or NULL if @obj does not implement #AtspiSelection.
**/
AtspiSelection *
atspi_accessible_get_selection (AtspiAccessible *accessible)
{
return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
- accessible : NULL);
+ g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
}
+#if 0
/**
* atspi_accessible_get_streamable_content:
* @obj: a pointer to the #AtspiAccessible instance to query.
diff --git a/atspi/atspi-accessible.h b/atspi/atspi-accessible.h
index de37bf8..4c0f939 100644
--- a/atspi/atspi-accessible.h
+++ b/atspi/atspi-accessible.h
@@ -97,6 +97,8 @@ AtspiAccessible * atspi_accessible_get_host_application (AtspiAccessible *obj, G
AtspiComponent * atspi_accessible_get_component (AtspiAccessible *obj);
+AtspiSelection * atspi_accessible_get_selection (AtspiAccessible *obj);
+
AtspiTable * atspi_accessible_get_table (AtspiAccessible *obj);
AtspiText * atspi_accessible_get_text (AtspiAccessible *obj);
diff --git a/atspi/atspi-selection.c b/atspi/atspi-selection.c
new file mode 100644
index 0000000..4e76a3c
--- /dev/null
+++ b/atspi/atspi-selection.c
@@ -0,0 +1,259 @@
+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * Copyright 2001, 2002 Sun Microsystems Inc.,
+ * Copyright 2001, 2002 Ximian, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library 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 "atspi-private.h"
+
+/**
+ * atspi_selection_get_n_selected_children:
+ * @obj: a pointer to the #AtspiSelection implementor on which to operate.
+ *
+ * Get the number of children of an #AtspiSelection implementor which are
+ * currently selected.
+ *
+ * Returns: a #gint indicating the number of #Accessible children
+ * of the #AtspiSelection implementor which are currently selected.
+ *
+ **/
+gint
+atspi_selection_get_n_selected_children (AtspiSelection *obj, GError **error)
+{
+ dbus_int32_t retval = -1;
+
+ g_return_val_if_fail (obj != NULL, -1);
+
+ _atspi_dbus_get_property (obj, atspi_interface_selection, "nSelectedChildren", error, "i", &retval);
+
+ return retval;
+}
+
+/**
+ * atspi_selection_get_selected_child:
+ * @obj: a pointer to the #AtspiSelection on which to operate.
+ * @selected_child_index: a #gint indicating which of the selected
+ * children is specified.
+ *
+ * Get the i-th selected #AtspiAccessible child of an #AtspiSelection.
+ * Note that @child_index refers to the index in the list of 'selected'
+ * children and generally differs from that used in
+ * #atspi_accessible_get_child_at_index() or returned by
+ * #atspi_accessible_get_index_in_parent(). @selected_child_index must lie between 0
+ * and #Atspi_selection_get_n_selected_children()-1, inclusive.
+ *
+ * Returns: (transfer full): a pointer to a selected #AtspiAccessible child
+ * object, specified by @child_index.
+ *
+ **/
+AtspiAccessible *
+atspi_selection_get_selected_child (AtspiSelection *obj,
+ gint selected_child_index, GError **error)
+{
+ dbus_int32_t d_selected_child_index = selected_child_index;
+ AtspiAccessible *child = NULL;
+
+ g_return_val_if_fail (obj != NULL, NULL);
+
+ _atspi_dbus_call (obj, atspi_interface_selection, "GetSelectedChild", error, "i=>(so)", &d_selected_child_index, &child);
+
+ return child;
+}
+
+/**
+ * atspi_selection_select_child:
+ * @obj: a pointer to the #AtspiSelection on which to operate.
+ * @child_index: a #gint indicating which child of the #Accessible
+ * is to be selected.
+ *
+ * Add a child to the selected children list of an #AtspiSelection.
+ * For #AtspiSelection implementors that only allow
+ * single selections, this may replace the (single) current
+ * selection.
+ *
+ * Returns: #TRUE if the child was successfully selected, #FALSE otherwise.
+ **/
+gboolean
+atspi_selection_select_child (AtspiSelection *obj,
+ gint child_index,
+ GError **error)
+{
+ dbus_int32_t d_child_index = child_index;
+ dbus_bool_t retval = FALSE;
+
+ g_return_val_if_fail (obj != NULL, FALSE);
+
+ _atspi_dbus_call (obj, atspi_interface_selection, "SelectChild", error, "i=>b", &d_child_index, &retval);
+
+ return retval;
+}
+
+/**
+ * atspi_selection_deselect_selected_child:
+ * @obj: a pointer to the #AtspiSelection on which to operate.
+ * @selected_child_index: a #gint indicating which of the selected children
+ * of the #Accessible is to be selected.
+ *
+ * Remove a child to the selected children list of an #AtspiSelection.
+ * Note that @child_index is the index in the selected-children list,
+ * not the index in the parent container. @selectedChildIndex in this
+ * method, and @child_index in #atspi_selection_select_child
+ * are asymmettric.
+ *
+ * Returns: #TRUE if the child was successfully deselected, #FALSE otherwise.
+ **/
+gboolean
+atspi_selection_deselect_selected_child (AtspiSelection *obj,
+ gint selected_child_index,
+ GError **error)
+{
+ dbus_int32_t d_selected_child_index = selected_child_index;
+ dbus_bool_t retval = FALSE;
+
+ g_return_val_if_fail (obj != NULL, FALSE);
+
+ _atspi_dbus_call (obj, atspi_interface_selection, "DeselectSelectedChild", error, "i=>b", d_selected_child_index, &retval);
+
+ return retval;
+}
+
+/**
+ * atspi_selection_deselect_child:
+ * @obj: a pointer to the #AtspiSelection on which to operate.
+ * @child_index: a #gint indicating which of the children
+ * of the #AtspiAccessible is to be de-selected.
+ *
+ * Deselect a specific child of an #AtspiSelection.
+ * Note that @child_index is the index of the child
+ * in the parent container.
+ *
+ * See #atspi_selection_deselect_selected_child
+ *
+ * Returns: #TRUE if the child was successfully deselected, #FALSE otherwise.
+ **/
+gboolean
+atspi_selection_deselect_child (AtspiSelection *obj,
+ gint child_index,
+ GError **error)
+{
+ dbus_int32_t d_child_index = child_index;
+ dbus_bool_t retval = FALSE;
+
+ g_return_val_if_fail (obj != NULL, FALSE);
+
+ _atspi_dbus_call (obj, atspi_interface_selection, "DeselectChild", error, "i=>b", &d_child_index, &retval);
+
+ return retval;
+}
+
+/**
+ * atspi_selection_is_child_selected:
+ * @obj: a pointer to the #AtspiSelection implementor on which to operate.
+ * @child_index: an index into the #AtspiSelection's list of children.
+ *
+ * Determine whether a particular child of an #AtspiSelection implementor
+ * is currently selected. Note that @child_index is the index into the
+ * standard #Accessible container's list of children.
+ *
+ * Returns: #TRUE if the specified child is currently selected,
+ * #FALSE otherwise.
+ **/
+gboolean
+atspi_selection_is_child_selected (AtspiSelection *obj,
+ gint child_index,
+ GError **error)
+{
+ dbus_int32_t d_child_index = child_index;
+ dbus_bool_t retval = FALSE;
+
+ g_return_val_if_fail (obj != NULL, FALSE);
+
+ _atspi_dbus_call (obj, atspi_interface_selection, "IsChildSelected", error, "i=>b", &d_child_index, &retval);
+
+ return retval;
+}
+
+/**
+ * atspi_selection_select_all:
+ * @obj: a pointer to the #AtspiSelection implementor on which to operate.
+ *
+ * Attempt to select all of the children of an #AtspiSelection implementor.
+ * Not all #AtspiSelection implementors support this operation.
+ *
+ * Returns: #TRUE if successful, #FALSE otherwise.
+ *
+ **/
+gboolean
+atspi_selection_select_all (AtspiSelection *obj, GError **error)
+{
+ dbus_bool_t retval = FALSE;
+
+ g_return_val_if_fail (obj != NULL, FALSE);
+
+ _atspi_dbus_call (obj, atspi_interface_selection, "SelectAll", error, "=>b", &retval);
+
+ return retval;
+}
+
+/**
+ * atspi_selection_clear_selection:
+ * @obj: a pointer to the #AtspiSelection implementor on which to operate.
+ *
+ * Clear the current selection, removing all selected children from the
+ * specified #AtspiSelection implementor's selection list.
+ *
+ * Returns: #TRUE if successful, #FALSE otherwise.
+ *
+ **/
+gboolean
+atspi_selection_clear_selection (AtspiSelection *obj, GError **error)
+{
+ dbus_bool_t retval = FALSE;
+
+ g_return_val_if_fail (obj != NULL, FALSE);
+
+ _atspi_dbus_call (obj, atspi_interface_selection, "ClearSelection", error, "=>b", &retval);
+
+ return retval;
+}
+
+static void
+atspi_selection_base_init (AtspiSelection *klass)
+{
+}
+
+GType
+atspi_selection_get_type (void)
+{
+ static GType type = 0;
+
+ if (!type) {
+ static const GTypeInfo tinfo =
+ {
+ sizeof (AtspiSelection),
+ (GBaseInitFunc) atspi_selection_base_init,
+ (GBaseFinalizeFunc) NULL,
+ };
+
+ type = g_type_register_static (G_TYPE_INTERFACE, "AtspiSelection", &tinfo, 0);
+
+ }
+ return type;
+}
diff --git a/atspi/atspi-selection.h b/atspi/atspi-selection.h
new file mode 100644
index 0000000..09dd6d1
--- /dev/null
+++ b/atspi/atspi-selection.h
@@ -0,0 +1,64 @@
+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * Copyright 2002 Ximian, Inc.
+ * 2002 Sun Microsystems Inc.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library 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 _ATSPI_SELECTION_H_
+#define _ATSPI_SELECTION_H_
+
+#include "glib-object.h"
+
+#include "atspi-constants.h"
+
+#include "atspi-types.h"
+
+#define ATSPI_TYPE_SELECTION (atspi_selection_get_type ())
+#define ATSPI_IS_SELECTION(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATSPI_TYPE_SELECTION)
+#define ATSPI_SELECTION(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATSPI_TYPE_SELECTION, AtspiSelection)
+#define ATSPI_SELECTION_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATSPI_TYPE_SELECTION, AtspiSelection))
+
+GType atspi_selection_get_type ();
+
+struct _AtspiSelection
+{
+ GTypeInterface parent;
+};
+
+gint atspi_selection_get_n_selected_children (AtspiSelection *obj, GError **error);
+
+AtspiAccessible * atspi_selection_get_selected_child (AtspiSelection *obj, gint selected_child_index, GError **error);
+
+gboolean atspi_selection_select_child (AtspiSelection *obj, gint child_index, GError **error);
+
+gboolean atspi_selection_deselect_selected_child (AtspiSelection *obj, gint selected_child_index, GError **error);
+
+gboolean atspi_selection_deselect_child (AtspiSelection *obj, gint child_index, GError **error);
+
+gboolean
+atspi_selection_is_child_selected (AtspiSelection *obj,
+ gint child_index, GError **error);
+
+gboolean atspi_selection_select_all (AtspiSelection *obj, GError **error);
+
+gboolean atspi_selection_clear_selection (AtspiSelection *obj, GError **error);
+
+#endif /* _ATSPI_SELECTION_H_ */
diff --git a/atspi/atspi-types.h b/atspi/atspi-types.h
index 40eaa47..eb7c7a3 100644
--- a/atspi/atspi-types.h
+++ b/atspi/atspi-types.h
@@ -36,7 +36,7 @@ typedef struct _AtspiComponent AtspiComponent;
typedef struct _AtspiAccessible AtspiDocument;
typedef struct _AtspiAccessible AtspiEditableText;
typedef struct _AtspiAccessible AtspiHypertext;
-typedef struct _AtspiAccessible AtspiSelection;
+typedef struct _AtspiSelection AtspiSelection;
typedef struct _AtspiTable AtspiTable;
typedef struct _AtspiText AtspiText;
typedef struct _AtspiAccessible AtspiValue;
diff --git a/atspi/atspi.h b/atspi/atspi.h
index aa341ff..ff4ba06 100644
--- a/atspi/atspi.h
+++ b/atspi/atspi.h
@@ -34,6 +34,7 @@
#include "atspi-event-listener.h"
#include "atspi-misc.h"
#include "atspi-registry.h"
+#include "atspi-selection.h"
#include "atspi-table.h"
#include "atspi-text.h"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]