summaryrefslogtreecommitdiff
path: root/eel
diff options
context:
space:
mode:
authorLuke Yelavich <[email protected]>2016-10-08 12:22:45 +1100
committerLuke Yelavich <[email protected]>2016-10-11 19:36:03 +1100
commit99a9c6e7c6a67484c029518bdb31160469627701 (patch)
tree2d7268eb3491d3a642f2cc26654445c2df5b7343 /eel
parent6e142d59d7408e53ab1e579dba62517b6f59e307 (diff)
downloadcaja-99a9c6e7c6a67484c029518bdb31160469627701.tar.bz2
caja-99a9c6e7c6a67484c029518bdb31160469627701.tar.xz
Fix accessible object inherritance when used with GTK 3
Also disable eel accessibility code that is not needed. Fixes https://github.com/mate-desktop/caja/issues/590
Diffstat (limited to 'eel')
-rw-r--r--eel/eel-accessibility.c5
-rw-r--r--eel/eel-accessibility.h2
-rw-r--r--eel/eel-canvas.c84
-rw-r--r--eel/eel-canvas.h20
-rw-r--r--eel/eel-editable-label.c55
-rw-r--r--eel/eel-labeled-image.c77
6 files changed, 238 insertions, 5 deletions
diff --git a/eel/eel-accessibility.c b/eel/eel-accessibility.c
index 707756d1..da586ddc 100644
--- a/eel/eel-accessibility.c
+++ b/eel/eel-accessibility.c
@@ -63,6 +63,7 @@ eel_accessibility_set_up_label_widget_relation (GtkWidget *label, GtkWidget *wid
*
* Return value: the registered type, or 0 on failure.
**/
+#if !GTK_CHECK_VERSION(3, 0, 0)
GType
eel_accessibility_create_derived_type (const char *type_name,
GType existing_gobject_with_proxy,
@@ -113,7 +114,7 @@ eel_accessibility_create_derived_type (const char *type_name,
return type;
}
-
+#endif
static GQuark
get_quark_accessible (void)
@@ -207,6 +208,7 @@ eel_accessibility_destroy (gpointer data,
*
* Return value: @atk_object.
**/
+#if !GTK_CHECK_VERSION(3, 0, 0)
AtkObject *
eel_accessibility_set_atk_object_return (gpointer object,
AtkObject *atk_object)
@@ -224,6 +226,7 @@ eel_accessibility_set_atk_object_return (gpointer object,
return atk_object;
}
+#endif
static GailTextUtil *
get_simple_text (gpointer object)
diff --git a/eel/eel-accessibility.h b/eel/eel-accessibility.h
index 45514c91..a1f68d56 100644
--- a/eel/eel-accessibility.h
+++ b/eel/eel-accessibility.h
@@ -38,11 +38,13 @@ typedef void (*EelAccessibilityClassInitFn) (AtkObjectClass *klass);
AtkObject *eel_accessibility_get_atk_object (gpointer object);
AtkObject *eel_accessibility_for_object (gpointer object);
gpointer eel_accessibility_get_gobject (AtkObject *object);
+#if !GTK_CHECK_VERSION(3, 0, 0)
AtkObject *eel_accessibility_set_atk_object_return (gpointer object,
AtkObject *atk_object);
GType eel_accessibility_create_derived_type (const char *type_name,
GType existing_gobject_with_proxy,
EelAccessibilityClassInitFn class_init);
+#endif
void eel_accessibility_set_name (gpointer object,
const char *name);
void eel_accessibility_set_description (gpointer object,
diff --git a/eel/eel-canvas.c b/eel/eel-canvas.c
index ae4faaa7..74132149 100644
--- a/eel/eel-canvas.c
+++ b/eel/eel-canvas.c
@@ -68,6 +68,9 @@
#include <stdio.h>
#include <gdk/gdkprivate.h>
#include <gtk/gtk.h>
+#if GTK_CHECK_VERSION(3,2,0)
+#include <gtk/gtk-a11y.h>
+#endif
#include <glib/gi18n-lib.h>
#if GTK_CHECK_VERSION(3,0,0)
# include <cairo/cairo-gobject.h>
@@ -2158,6 +2161,25 @@ eel_canvas_accessible_ref_child (AtkObject *obj,
return atk_object;
}
+#if GTK_CHECK_VERSION(3, 0, 0)
+G_DEFINE_TYPE (EelCanvasAccessible, eel_canvas_accessible, GTK_TYPE_CONTAINER_ACCESSIBLE)
+
+static void
+eel_canvas_accessible_class_init (EelCanvasAccessibleClass *klass)
+{
+ AtkObjectClass *atk_class = ATK_OBJECT_CLASS (klass);
+ accessible_parent_class = g_type_class_peek_parent (atk_class);
+
+ atk_class->initialize = eel_canvas_accessible_initialize;
+ atk_class->get_n_children = eel_canvas_accessible_get_n_children;
+ atk_class->ref_child = eel_canvas_accessible_ref_child;
+}
+
+static void
+eel_canvas_accessible_init (EelCanvasAccessible *accessible)
+{
+}
+#else
static void
eel_canvas_accessible_class_init (AtkObjectClass *klass)
{
@@ -2275,7 +2297,7 @@ eel_canvas_accessible_factory_get_type (void)
return type;
}
-
+#endif
/* Class initialization function for EelCanvasClass */
static void
@@ -2336,9 +2358,13 @@ eel_canvas_class_init (EelCanvasClass *klass)
G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT);
#endif
+#if GTK_CHECK_VERSION(3, 0, 0)
+ gtk_widget_class_set_accessible_type (widget_class, eel_canvas_accessible_get_type ());
+#else
atk_registry_set_factory_type (atk_get_default_registry (),
EEL_TYPE_CANVAS,
eel_canvas_accessible_factory_get_type ());
+#endif
}
/* Callback used when the root item of a canvas is destroyed. The user should
@@ -3424,7 +3450,7 @@ idle_handler (gpointer data)
{
EelCanvas *canvas;
-#if !GTK_CHECK_VERSION (3, 0, 0)
+#if !GTK_CHECK_VERSION(3, 0, 0)
GDK_THREADS_ENTER ();
#endif
@@ -4270,6 +4296,43 @@ eel_canvas_item_accessible_ref_state_set (AtkObject *accessible)
return state_set;
}
+#if GTK_CHECK_VERSION(3, 0, 0)
+static GType eel_canvas_item_accessible_get_type (void);
+
+typedef struct _EelCanvasItemAccessible EelCanvasItemAccessible;
+typedef struct _EelCanvasItemAccessibleClass EelCanvasItemAccessibleClass;
+
+struct _EelCanvasItemAccessible
+{
+ GtkAccessible parent;
+};
+
+struct _EelCanvasItemAccessibleClass
+{
+ GtkAccessibleClass parent_class;
+};
+
+G_DEFINE_TYPE_WITH_CODE (EelCanvasItemAccessible,
+ eel_canvas_item_accessible,
+ ATK_TYPE_GOBJECT_ACCESSIBLE,
+ G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT,
+ eel_canvas_item_accessible_component_interface_init));
+
+static void
+eel_canvas_item_accessible_class_init (EelCanvasItemAccessibleClass *klass)
+{
+ AtkObjectClass *atk_class = ATK_OBJECT_CLASS (klass);
+ accessible_item_parent_class = g_type_class_peek_parent (atk_class);
+
+ atk_class->initialize = eel_canvas_item_accessible_initialize;
+ atk_class->ref_state_set = eel_canvas_item_accessible_ref_state_set;
+}
+
+static void
+eel_canvas_item_accessible_init (EelCanvasItemAccessible *accessible)
+{
+}
+#else
static void
eel_canvas_item_accessible_class_init (AtkObjectClass *klass)
{
@@ -4323,7 +4386,7 @@ eel_canvas_item_accessible_get_type (void)
return type;
}
-
+#endif
static AtkObject *
eel_canvas_item_accessible_create (GObject *for_object)
{
@@ -4370,6 +4433,20 @@ eel_canvas_item_accessible_factory_class_init (AtkObjectFactoryClass *klass)
klass->get_accessible_type = eel_canvas_item_accessible_factory_get_accessible_type;
}
+#if GTK_CHECK_VERSION(3, 0, 0)
+static GType eel_canvas_item_accessible_factory_get_type (void);
+
+typedef AtkObjectFactory EelCanvasItemAccessibleFactory;
+typedef AtkObjectFactoryClass EelCanvasItemAccessibleFactoryClass;
+G_DEFINE_TYPE (EelCanvasItemAccessibleFactory, eel_canvas_item_accessible_factory,
+ ATK_TYPE_OBJECT_FACTORY)
+
+static void
+eel_canvas_item_accessible_factory_init (EelCanvasItemAccessibleFactory *accessible)
+{
+}
+
+#else
static GType
eel_canvas_item_accessible_factory_get_type (void)
{
@@ -4396,6 +4473,7 @@ eel_canvas_item_accessible_factory_get_type (void)
return type;
}
+#endif
/* Class initialization function for EelCanvasItemClass */
static void
diff --git a/eel/eel-canvas.h b/eel/eel-canvas.h
index fcb4cb3d..b168aed8 100644
--- a/eel/eel-canvas.h
+++ b/eel/eel-canvas.h
@@ -38,6 +38,9 @@
#define EEL_CANVAS_H
#include <gtk/gtk.h>
+#if GTK_CHECK_VERSION(3, 0, 0)
+#include <gtk/gtk-a11y.h>
+#endif
#include <gdk/gdk.h>
#include <stdarg.h>
@@ -555,6 +558,23 @@ extern "C" {
void eel_canvas_world_to_window (EelCanvas *canvas,
double worldx, double worldy, double *winx, double *winy);
+#if GTK_CHECK_VERSION(3, 0, 0)
+ GType eel_canvas_accessible_get_type (void);
+
+ typedef struct _EelCanvasAccessible EelCanvasAccessible;
+ typedef struct _EelCanvasAccessibleClass EelCanvasAccessibleClass;
+
+ struct _EelCanvasAccessible
+ {
+ GtkContainerAccessible parent;
+ };
+
+ struct _EelCanvasAccessibleClass
+ {
+ GtkContainerAccessibleClass parent_class;
+ };
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/eel/eel-editable-label.c b/eel/eel-editable-label.c
index be172a75..37564275 100644
--- a/eel/eel-editable-label.c
+++ b/eel/eel-editable-label.c
@@ -35,6 +35,9 @@
#include <glib/gi18n-lib.h>
#include <pango/pango.h>
#include <gtk/gtk.h>
+#if GTK_CHECK_VERSION(3, 0, 0)
+#include <gtk/gtk-a11y.h>
+#endif
#include <gdk/gdkkeysyms.h>
/* Some compatibility defines to let us build on both Gtk2 and Gtk3 */
@@ -137,7 +140,11 @@ static gint eel_editable_label_focus_in (GtkWidget
GdkEventFocus *event);
static gint eel_editable_label_focus_out (GtkWidget *widget,
GdkEventFocus *event);
+#if GTK_CHECK_VERSION(3, 0, 0)
+static GType eel_editable_label_accessible_get_type (void);
+#else
static AtkObject *eel_editable_label_get_accessible (GtkWidget *widget);
+#endif
static void eel_editable_label_commit_cb (GtkIMContext *context,
const gchar *str,
EelEditableLabel *label);
@@ -282,7 +289,11 @@ eel_editable_label_class_init (EelEditableLabelClass *class)
widget_class->key_release_event = eel_editable_label_key_release;
widget_class->focus_in_event = eel_editable_label_focus_in;
widget_class->focus_out_event = eel_editable_label_focus_out;
+#if GTK_CHECK_VERSION(3, 0, 0)
+ gtk_widget_class_set_accessible_type (widget_class, eel_editable_label_accessible_get_type ());
+#else
widget_class->get_accessible = eel_editable_label_get_accessible;
+#endif
class->move_cursor = eel_editable_label_move_cursor;
class->delete_from_cursor = eel_editable_label_delete_from_cursor;
@@ -3765,6 +3776,20 @@ typedef struct
gint position;
} EelEditableLabelAccessiblePaste;
+#if GTK_CHECK_VERSION(3, 0, 0)
+typedef struct _EelEditableLabelAccessible EelEditableLabelAccessible;
+typedef struct _EelEditableLabelAccessibleClass EelEditableLabelAccessibleClass;
+
+struct _EelEditableLabelAccessible
+{
+ GtkWidgetAccessible parent;
+};
+
+struct _EelEditableLabelAccessibleClass
+{
+ GtkWidgetAccessibleClass parent_class;
+};
+#endif
static gchar*
eel_editable_label_accessible_get_text (AtkText *text,
@@ -4619,6 +4644,34 @@ eel_editable_label_accessible_finalize (GObject *object)
G_OBJECT_CLASS (a11y_parent_class)->finalize (object);
}
+#if GTK_CHECK_VERSION(3, 0, 0)
+static void
+eel_editable_label_accessible_class_init (EelEditableLabelAccessibleClass *klass)
+{
+ AtkObjectClass *atk_class = ATK_OBJECT_CLASS (klass);
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+ a11y_parent_class = g_type_class_peek_parent (klass);
+
+ atk_class->initialize = eel_editable_label_accessible_initialize;
+ atk_class->get_name = eel_editable_label_accessible_get_name;
+ atk_class->ref_state_set = eel_editable_label_accessible_ref_state_set;
+ gobject_class->finalize = eel_editable_label_accessible_finalize;
+}
+
+static void
+eel_editable_label_accessible_init (EelEditableLabelAccessible *accessible)
+{
+}
+
+G_DEFINE_TYPE_WITH_CODE (EelEditableLabelAccessible,
+ eel_editable_label_accessible,
+ GTK_TYPE_WIDGET_ACCESSIBLE,
+ G_IMPLEMENT_INTERFACE (ATK_TYPE_EDITABLE_TEXT,
+ atk_editable_text_interface_init)
+ G_IMPLEMENT_INTERFACE (ATK_TYPE_TEXT,
+ atk_text_interface_init));
+#else
static void
eel_editable_label_accessible_class_init (AtkObjectClass *klass)
{
@@ -4671,4 +4724,4 @@ eel_editable_label_get_accessible (GtkWidget *widget)
return eel_accessibility_set_atk_object_return (widget, accessible);
}
-
+#endif
diff --git a/eel/eel-labeled-image.c b/eel/eel-labeled-image.c
index 02b28bdc..27f13d25 100644
--- a/eel/eel-labeled-image.c
+++ b/eel/eel-labeled-image.c
@@ -31,6 +31,9 @@
#include "eel-gtk-extensions.h"
#include "eel-accessibility.h"
#include <gtk/gtk.h>
+#if GTK_CHECK_VERSION(3, 0, 0)
+#include <gtk/gtk-a11y.h>
+#endif
#include <gdk/gdkkeysyms.h>
#include <atk/atkimage.h>
@@ -92,7 +95,11 @@ static GType eel_labeled_image_radio_button_get_type (void);
static GType eel_labeled_image_toggle_button_get_type (void);
/* GtkWidgetClass methods */
+#if GTK_CHECK_VERSION(3, 0, 0)
+static GType eel_labeled_image_accessible_get_type (void);
+#else
static AtkObject *eel_labeled_image_get_accessible (GtkWidget *widget);
+#endif
/* Private EelLabeledImage methods */
static EelDimensions labeled_image_get_image_dimensions (const EelLabeledImage *labeled_image);
@@ -634,7 +641,11 @@ eel_labeled_image_class_init (EelLabeledImageClass *labeled_image_class)
#endif
widget_class->map = eel_labeled_image_map;
widget_class->unmap = eel_labeled_image_unmap;
+#if GTK_CHECK_VERSION(3, 0, 0)
+ gtk_widget_class_set_accessible_type (widget_class, eel_labeled_image_accessible_get_type ());
+#else
widget_class->get_accessible = eel_labeled_image_get_accessible;
+#endif
/* GtkContainerClass */
container_class->add = eel_labeled_image_add;
@@ -2312,7 +2323,32 @@ static void
eel_labeled_image_accessible_initialize (AtkObject *accessible,
gpointer widget)
{
+#if GTK_CHECK_VERSION(3, 0, 0)
+ a11y_parent_class->initialize (accessible, widget);
+
+ if (GTK_IS_CHECK_BUTTON (widget))
+ {
+ atk_object_set_role (accessible, ATK_ROLE_CHECK_BOX);
+ }
+ else if (GTK_IS_RADIO_BUTTON (widget))
+ {
+ atk_object_set_role (accessible, ATK_ROLE_RADIO_BUTTON);
+ }
+ else if (GTK_IS_TOGGLE_BUTTON (widget))
+ {
+ atk_object_set_role (accessible, ATK_ROLE_TOGGLE_BUTTON);
+ }
+ else if (GTK_IS_BUTTON (widget))
+ {
+ atk_object_set_role (accessible, ATK_ROLE_PUSH_BUTTON);
+ }
+ else
+ {
+ atk_object_set_role (accessible, ATK_ROLE_IMAGE);
+ }
+#else
a11y_parent_class->initialize (accessible, widget);
+#endif
}
static EelLabeledImage *
@@ -2374,6 +2410,40 @@ eel_labeled_image_accessible_image_interface_init (AtkImageIface *iface)
iface->get_image_size = eel_labeled_image_accessible_image_get_size;
}
+#if GTK_CHECK_VERSION(3, 0, 0)
+typedef struct _EelLabeledImageAccessible EelLabeledImageAccessible;
+typedef struct _EelLabeledImageAccessibleClass EelLabeledImageAccessibleClass;
+
+struct _EelLabeledImageAccessible
+{
+ GtkContainerAccessible parent;
+};
+
+struct _EelLabeledImageAccessibleClass
+{
+ GtkContainerAccessibleClass parent_class;
+};
+
+G_DEFINE_TYPE_WITH_CODE (EelLabeledImageAccessible,
+ eel_labeled_image_accessible,
+ GTK_TYPE_CONTAINER_ACCESSIBLE,
+ G_IMPLEMENT_INTERFACE (ATK_TYPE_IMAGE,
+ eel_labeled_image_accessible_image_interface_init));
+static void
+eel_labeled_image_accessible_class_init (EelLabeledImageAccessibleClass *klass)
+{
+ AtkObjectClass *atk_class = ATK_OBJECT_CLASS (klass);
+ a11y_parent_class = g_type_class_peek_parent (klass);
+
+ atk_class->get_name = eel_labeled_image_accessible_get_name;
+ atk_class->initialize = eel_labeled_image_accessible_initialize;
+}
+
+static void
+eel_labeled_image_accessible_init (EelLabeledImageAccessible *accessible)
+{
+}
+#else
static void
eel_labeled_image_accessible_class_init (AtkObjectClass *klass)
{
@@ -2465,11 +2535,18 @@ eel_labeled_image_get_accessible (GtkWidget *widget)
return eel_accessibility_set_atk_object_return (widget, accessible);
}
+#endif
static void
eel_labeled_image_button_class_init (GtkWidgetClass *klass)
{
+#if GTK_CHECK_VERSION(3, 0, 0)
+ gtk_widget_class_set_accessible_type (GTK_WIDGET_CLASS (klass),
+ eel_labeled_image_accessible_get_type ());
+
+#else
klass->get_accessible = eel_labeled_image_get_accessible;
+#endif
}
static GType