atspi.h \
atspi-accessible.c \
atspi-accessible.h \
+ atspi-application.c \
+ atspi-application.h \
atspi-constants.h \
atspi-event-types.h \
atspi-listener.c \
}
static void
+atspi_accessible_finalize (AtspiAccessible *accessible)
+{
+ if (accessible->app)
+ g_object_unref (accessible->app);
+
+ g_free (accessible->path);
+}
+
+static void
atspi_accessible_class_init (AtspiAccessibleClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = atspi_accessible_finalize;
}
/* TODO: Generate following from spec? */
static const char *role_names [] =
*
* Get the #AtspiAccessible child of an #AtspiAccessible object at a given index.
*
- * Returns: a pointer to the #AtspiAccessible child object at index
- * @child_index. or NULL on exception
+ * Returns: (transfer full): a pointer to the #AtspiAccessible child object at
+ * index @child_index. or NULL on exception
**/
AtspiAccessible *
atspi_accessible_get_child_at_index (AtspiAccessible *obj,
* For typographic, textual, or textually-semantic attributes, see
* atspi_text_get_attributes instead.
*
- * Returns: The name-value-pair attributes assigned to this object.
+ * Returns: (transfer full): The name-value-pair attributes assigned to this
+ * object.
*/
GHashTable *
atspi_accessible_get_attributes (AtspiAccessible *obj, GError **error)
e.type = "object:state-change:defunct";
e.source = accessible;
e.detail1 = 1;
+#if 0
+ g_warning ("atspi: TODO: Finish events");
atspi_dispatch_event (&e);
+#endif
g_free (accessible->path);
}
AtspiAccessible *
-atspi_accessible_new ()
+atspi_accessible_new (AtspiApplication *app, const gchar *path)
{
AtspiAccessible *accessible;
accessible = g_object_new (ATSPI_TYPE_ACCESSIBLE, NULL);
g_return_val_if_fail (accessible != NULL, NULL);
+ accessible->app = g_object_ref (app);
+ accessible->path = g_strdup (path);
+
return accessible;
}
#include "glib-object.h"
+#include "atspi-application.h"
#include "atspi-constants.h"
#include "atspi-stateset.h"
#define ATSPI_IS_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATSPI_TYPE_ACCESSIBLE))
#define ATSPI_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATSPI_TYPE_ACCESSIBLE, AtspiAccessibleClass))
-typedef struct _AtspiApplication AtspiApplication;
-struct _AtspiApplication
-{
- GHashTable *hash;
- char *bus_name;
- struct _AtspiAccessible *root;
-};
-
typedef struct _AtspiAccessible AtspiAccessible;
struct _AtspiAccessible
{
GType atspi_accessible_get_type (void);
AtspiAccessible *
-atspi_accessible_new ();
+atspi_accessible_new (AtspiApplication *app, const gchar *path);
gchar * atspi_role_get_name (AtspiRole role);
--- /dev/null
+/*
+ * 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"
+
+G_DEFINE_TYPE (AtspiApplication, atspi_application, G_TYPE_OBJECT)
+
+static void
+atspi_application_init (AtspiApplication *application)
+{
+}
+
+static void
+atspi_application_finalize (AtspiApplication *application)
+{
+ if (application->bus_name)
+ g_free (application->bus_name);
+}
+
+static void
+atspi_application_class_init (AtspiApplicationClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = atspi_application_finalize;
+}
+
+AtspiApplication *
+_atspi_application_new (const gchar *bus_name)
+{
+ AtspiApplication *application;
+
+ application = g_object_new (ATSPI_TYPE_APPLICATION, NULL);
+ if (application)
+ application->bus_name = g_strdup (bus_name);
+ return application;
+}
--- /dev/null
+/*
+ * 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_APPLICATION_H_
+#define _ATSPI_APPLICATION_H_
+
+#include "glib-object.h"
+
+#include "atspi-accessible.h"
+
+#define ATSPI_TYPE_APPLICATION (atspi_application_get_type ())
+#define ATSPI_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATSPI_TYPE_APPLICATION, AtspiAccessible))
+#define ATSPI_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATSPI_TYPE_APPLICATION, AtspiAccessibleClass))
+#define ATSPI_IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATSPI_TYPE_APPLICATION))
+#define ATSPI_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATSPI_TYPE_APPLICATION))
+#define ATSPI_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATSPI_TYPE_APPLICATION, AtspiAccessibleClass))
+
+typedef struct _AtspiApplication AtspiApplication;
+struct _AtspiApplication
+{
+ GObject parent;
+ GHashTable *hash;
+ char *bus_name;
+ struct _AtspiAccessible *root;
+};
+
+typedef struct _AtspiApplicationClass AtspiApplicationClass;
+struct _AtspiApplicationClass
+{
+ GObjectClass parent_class;
+};
+
+AtspiApplication *
+_atspi_application_new (const char *bus_name);
+
+#endif /* _ATSPI_APPLICATION_H_ */
return live_refs;
}
+/* TODO: Add an application parameter */
DBusConnection *
_atspi_bus ()
{
+ if (!bus)
+ atspi_init ();
return bus;
}
bus_name_dup = g_strdup (bus_name);
if (!bus_name_dup) return NULL;
// TODO: change below to something that will send state-change:defunct notification if necessary */
- app = g_new (AtspiApplication, 1);
+ app = _atspi_application_new (bus_name);
if (!app) return NULL;
app->bus_name = bus_name_dup;
if (APP_IS_REGISTRY (app))
static AtspiAccessible *
ref_accessible (const char *app_name, const char *path)
{
- int id;
- guint *id_val;
AtspiApplication *app = get_application (app_name);
AtspiAccessible *a;
if (!strcmp (path, "/org/a11y/atspi/accessible/root"))
- return g_object_ref (app->root);
-
- if (sscanf (path, "/org/a11y/atspi/accessible/%d", &id) != 1)
{
- return NULL;
+ if (!app->root)
+ {
+ app->root = atspi_accessible_new (app, atspi_path_root);
+ app->root->accessible_parent = atspi_get_desktop (0);
+ }
+ return g_object_ref (app->root);
}
- a = g_hash_table_lookup (app->hash, &id);
+ a = g_hash_table_lookup (app->hash, path);
if (a)
{
g_object_ref (a);
return a;
}
- id_val = g_new (guint, 1);
- if (!id_val) return NULL;
- *id_val = id;
- a = atspi_accessible_new ();
+ a = atspi_accessible_new (app, path);
if (!a)
- {
- g_free (id_val);
return NULL;
- }
- a->app = app;
- a->path = g_strdup_printf ("/org/a11y/atspi/accessible/%d", id);
- g_hash_table_insert (app->hash, id_val, a);
+ g_hash_table_insert (app->hash, a->path, a);
g_object_ref (a); /* for the hash */
return a;
}
a->accessible_parent->children = g_list_remove (a->accessible_parent->children, a);
g_object_unref (a);
}
- if (sscanf (a->path, "/org/a11y/atspi/accessible/%d", &id) == 1)
- {
- g_warning("atspi: FIX HASH REMOVE");
- g_hash_table_remove (app->hash, id);
- }
- else
- g_warning ("libspi: Strange path %s\n", a->path);
+ g_hash_table_remove (app->hash, app->bus_name);
g_object_unref (a); /* unref our own ref */
return DBUS_HANDLER_RESULT_HANDLED;
}
e.type = (add? "object:children-changed:add": "object:children-changed:remove");
e.source = parent;
e.detail1 = g_list_index (parent->children, child);
+#if 0
+ g_warning ("atspi: TODO: Finish events");
atspi_dispatch_event (&e);
+#endif
}
static void
{
unref_object_and_descendants (l->data);
}
- g_object_unref_internal (obj, TRUE);
+ g_object_unref (obj);
}
static gboolean
DBusMessageIter iter_struct;
dbus_message_iter_recurse (iter, &iter_struct);
- dbus_message_iter_get_basic (&iter_struct, &app_name);
- dbus_message_iter_get_basic (&iter_struct, &path);
+ dbus_message_iter_get_basic (&iter_struct, app_name);
+ dbus_message_iter_next (&iter_struct);
+ dbus_message_iter_get_basic (&iter_struct, path);
dbus_message_iter_next (iter);
}
get_reference_from_iter (&iter_struct, &app_name, &path);
accessible = ref_accessible (app_name, path);
+ /* Get application: TODO */
+ dbus_message_iter_next (&iter_struct);
+
/* get parent */
get_reference_from_iter (&iter_struct, &app_name, &path);
accessible->accessible_parent = ref_accessible (app_name, path);
g_warning ("Unknown interface %s", iface);
}
else accessible->interfaces |= (1 << n);
+ dbus_message_iter_next (&iter_array);
}
dbus_message_iter_next (&iter_struct);
AtspiApplication *app = get_application (app_name);
/* TODO: Move this functionality into app initializer? */
dbus_error_init (&error);
- message = dbus_message_new_method_call (app_name, "/org/a11y/atspi/accessible/cache", atspi_interface_cache, "GetItems");
+ message = dbus_message_new_method_call (app_name, "/org/a11y/atspi/cache", atspi_interface_cache, "GetItems");
reply = _atspi_dbus_send_with_reply_and_block (message);
- if (!reply || strcmp (dbus_message_get_signature (reply), "a((so)(so)a(so)assusau)") != 0)
+ if (!reply || strcmp (dbus_message_get_signature (reply), "a((so)(so)(so)a(so)assusau)") != 0)
{
g_warning ("at-spi: Error in GetItems");
return;
g_object_ref (desktop);
return desktop;
}
- desktop = atspi_accessible_new ();
+ desktop = atspi_accessible_new (app, atspi_path_root);
if (!desktop)
{
return NULL;
}
- g_hash_table_insert (app->hash, 0, desktop);
- desktop->app = app;
+ g_hash_table_insert (app->hash, desktop->path, desktop);
g_object_ref (desktop); /* for the hash */
desktop->name = g_strdup ("main");
dbus_error_init (&error);
if (!message)
return;
reply = _atspi_dbus_send_with_reply_and_block (message);
- if (!reply || strcmp (dbus_message_get_signature (reply), "a(so") != 0)
+ if (!reply || strcmp (dbus_message_get_signature (reply), "a(so)") != 0)
{
g_error ("Couldn't get application list: %s", error.message);
if (reply)
* Get the virtual desktop indicated by index @i.
* NOTE: currently multiple virtual desktops are not implemented.
*
- * Returns: a pointer to the 'i-th' virtual desktop's #AtspiAccessible
- * representation.
+ * Returns: (transfer full): a pointer to the 'i-th' virtual desktop's
+ * #AtspiAccessible representation.
**/
AtspiAccessible*
atspi_get_desktop (gint i)
/**
* atspi_get_desktop_list:
- * @desktop_list: a pointer to an array of #Accessible references.
*
* Get the list of virtual desktops. On return, @list will point
* to a newly-created, NULL terminated array of virtual desktop
* Not Yet Implemented : this implementation always returns a single
* #Accessible desktop.
*
- * Returns: an integer indicating how many virtual desktops have been
- * placed in the list pointed to by parameter @list.
+ * Returns: (transfer full): a #GArray of desktops.
**/
-/* TODO: Make this a garray */
GArray *
atspi_get_desktop_list ()
{