Compare commits

...

3 Commits

Author SHA1 Message Date
Emmanuele Bassi
48ea50510f inspector: Remove the GtkAtSpiContext use
There is generic API to access the D-Bus object path of the
accessibility context object.
2023-02-04 12:17:47 +01:00
Emmanuele Bassi
d31450929f a11y: Implement get_dbus_object_path() for AT-SPI context
Implement the vfunc from the parent GtkATContextClass vtable.
2023-02-04 12:16:59 +01:00
Emmanuele Bassi
1b4adc4ed8 a11y: Add accessor for D-Bus object path
ATContext instances that use D-Bus have an object path that is usable to
access the accessible object on the accessibility bus. This allows
constructing bridges between processes for complex scenarios, like
having a split UI and document rendering processes.
2023-02-04 12:14:14 +01:00
5 changed files with 55 additions and 8 deletions

View File

@@ -1394,6 +1394,14 @@ gtk_at_spi_context_unrealize (GtkATContext *context)
g_clear_object (&self->root);
}
static const char *
gtk_at_spi_context_get_dbus_object_path (GtkATContext *context)
{
GtkAtSpiContext *self = GTK_AT_SPI_CONTEXT (context);
return self->context_path;
}
static void
gtk_at_spi_context_class_init (GtkAtSpiContextClass *klass)
{
@@ -1409,6 +1417,7 @@ gtk_at_spi_context_class_init (GtkAtSpiContextClass *klass)
context_class->platform_change = gtk_at_spi_context_platform_change;
context_class->bounds_change = gtk_at_spi_context_bounds_change;
context_class->child_change = gtk_at_spi_context_child_change;
context_class->get_dbus_object_path = gtk_at_spi_context_get_dbus_object_path;
}
static void

View File

@@ -1152,3 +1152,37 @@ gtk_at_context_child_changed (GtkATContext *self,
GTK_AT_CONTEXT_GET_CLASS (self)->child_change (self, change, child);
}
/**
* gtk_at_context_get_dbus_object_path:
* @self: an accessibility context
*
* Returns the D-Bus object path of the accessibility context.
*
* If the accessibility context uses a D-Bus transport, the return value is
* the path at which you will be able to find the object.
*
* This function returns `NULL` if the accessibility context is unrealized,
* or it does not use D-Bus, or if the accessibility support has been
* disabled.
*
* Returns: (nullable) (transfer none): the D-Bus object path of the
* accessibility context
*
* Since: 4.10
*/
const char *
gtk_at_context_get_dbus_object_path (GtkATContext *self)
{
g_return_val_if_fail (GTK_IS_AT_CONTEXT (self), NULL);
if (!self->realized)
return FALSE;
GtkATContextClass *klass = GTK_AT_CONTEXT_GET_CLASS (self);
if (klass->get_dbus_object_path != NULL)
return klass->get_dbus_object_path (self);
else
return NULL;
}

View File

@@ -45,4 +45,7 @@ GtkATContext * gtk_at_context_create (GtkAccessibleRo
GtkAccessible *accessible,
GdkDisplay *display);
GDK_AVAILABLE_IN_4_10
const char * gtk_at_context_get_dbus_object_path (GtkATContext *self);
G_END_DECLS

View File

@@ -124,6 +124,8 @@ struct _GtkATContextClass
void (* realize) (GtkATContext *self);
void (* unrealize) (GtkATContext *self);
const char * (* get_dbus_object_path) (GtkATContext *self);
};
GtkATContext * gtk_at_context_clone (GtkATContext *self,

View File

@@ -34,9 +34,6 @@
#include "gtknoselection.h"
#include "gtkfilterlistmodel.h"
#include "gtkboolfilter.h"
#ifdef G_OS_UNIX
#include "a11y/gtkatspicontextprivate.h"
#endif
typedef enum {
STATE,
@@ -233,17 +230,19 @@ update_path (GtkInspectorA11y *sl)
const char *path = "";
#ifdef G_OS_UNIX
GtkATContext *context;
const char *context_path;
context = gtk_accessible_get_at_context (GTK_ACCESSIBLE (sl->object));
if (GTK_IS_AT_SPI_CONTEXT (context))
context_path = gtk_at_context_get_dbus_object_path (context);
if (context_path == NULL)
{
if (gtk_at_context_is_realized (context))
path = gtk_at_spi_context_get_context_path (GTK_AT_SPI_CONTEXT (context));
else
if (!gtk_at_context_is_realized (context))
path = "not realized";
else
path = "not available on accessibility bus";
}
else
path = "not on bus";
path = context_path;
#endif
gtk_label_set_label (GTK_LABEL (sl->path), path);