[nautilus/wip/ernestask/gtk4: 6/19] eel: Remove a11y utilities
- From: Carlos Soriano <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/ernestask/gtk4: 6/19] eel: Remove a11y utilities
- Date: Tue, 22 May 2018 13:52:26 +0000 (UTC)
commit 979e5f5e090a70e9bcc20ebd77425eb10224a6c5
Author: Ernestas Kulik <ernestask gnome org>
Date: Mon May 14 09:46:43 2018 +0300
eel: Remove a11y utilities
In theory, it would be possible to just drop the GAIL code and keep the
header, but, given that NautilusCanvasItem is the only remaining
consumer, the needed bits can be moved over.
.gitlab-ci.yml | 2 +-
eel/eel-accessibility.c | 183 ---------------------------------------
eel/eel-accessibility.h | 76 ----------------
eel/meson.build | 3 -
meson.build | 1 -
src/nautilus-canvas-container.c | 1 -
src/nautilus-canvas-item.c | 94 +++++++++++---------
src/nautilus-properties-window.c | 14 ++-
8 files changed, 67 insertions(+), 307 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index af5f5c5c3..72fd1dee0 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -94,7 +94,7 @@ ubuntu:devel:
libgnome-autoar-0-dev
gobject-introspection libxml2-dev
libtracker-control-2.0-dev desktop-file-utils libgexiv2-dev
- libgail-3-dev libtracker-sparql-2.0-dev
+ libtracker-sparql-2.0-dev
libgirepository1.0-dev
<<: *distro_test
only:
diff --git a/eel/meson.build b/eel/meson.build
index ba06203d4..5437bdc4c 100644
--- a/eel/meson.build
+++ b/eel/meson.build
@@ -1,6 +1,4 @@
libeel_2_sources = [
- 'eel-accessibility.h',
- 'eel-accessibility.c',
'eel-art-extensions.h',
'eel-art-extensions.c',
'eel-canvas.h',
@@ -27,7 +25,6 @@ libeel_2_sources = [
libeel_2_deps = [
config_h,
- gail,
glib,
gtk,
libm,
diff --git a/meson.build b/meson.build
index b68cf04ac..50f8134ca 100644
--- a/meson.build
+++ b/meson.build
@@ -69,7 +69,6 @@ libgd_dep = libgd.get_variable('libgd_dep')
libm = cc.find_library('m')
-gail = dependency('gail-3.0')
if get_option('extensions')
gexiv = dependency('gexiv2', version: '>= 0.10.0')
endif
diff --git a/src/nautilus-canvas-container.c b/src/nautilus-canvas-container.c
index 3cb4b9b07..ea212c5a0 100644
--- a/src/nautilus-canvas-container.c
+++ b/src/nautilus-canvas-container.c
@@ -25,7 +25,6 @@
#include "nautilus-canvas-container.h"
#include <atk/atkaction.h>
-#include <eel/eel-accessibility.h>
#include <eel/eel-art-extensions.h>
#include <eel/eel-gtk-extensions.h>
#include <eel/eel-vfs-extensions.h>
diff --git a/src/nautilus-canvas-item.c b/src/nautilus-canvas-item.c
index 7f90d1cb3..ba0d5e793 100644
--- a/src/nautilus-canvas-item.c
+++ b/src/nautilus-canvas-item.c
@@ -31,7 +31,6 @@
#include <eel/eel-glib-extensions.h>
#include <eel/eel-graphic-effects.h>
#include <eel/eel-string.h>
-#include <eel/eel-accessibility.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
@@ -131,8 +130,7 @@ struct NautilusCanvasItemDetails
GdkWindow *cursor_window;
- /* Accessibility bits */
- GailTextUtil *text_util;
+ GString *text;
};
/* Object argument IDs. */
@@ -155,12 +153,9 @@ typedef enum
TOP_SIDE
} RectangleSide;
-static void nautilus_canvas_item_text_interface_init (EelAccessibleTextIface *iface);
static GType nautilus_canvas_item_accessible_factory_get_type (void);
-G_DEFINE_TYPE_WITH_CODE (NautilusCanvasItem, nautilus_canvas_item, EEL_TYPE_CANVAS_ITEM,
- G_IMPLEMENT_INTERFACE (EEL_TYPE_ACCESSIBLE_TEXT,
- nautilus_canvas_item_text_interface_init));
+G_DEFINE_TYPE (NautilusCanvasItem, nautilus_canvas_item, EEL_TYPE_CANVAS_ITEM)
/* private */
static void get_icon_rectangle (NautilusCanvasItem *item,
@@ -199,9 +194,10 @@ nautilus_canvas_item_finalize (GObject *object)
g_object_unref (details->pixbuf);
}
- if (details->text_util != NULL)
+ if (details->text != NULL)
{
- g_object_unref (details->text_util);
+ g_string_free (details->text, TRUE);
+ details->text = NULL;
}
g_free (details->editable_text);
@@ -295,10 +291,10 @@ nautilus_canvas_item_set_property (GObject *object,
is_rename = details->editable_text != NULL;
g_free (details->editable_text);
details->editable_text = g_strdup (g_value_get_string (value));
- if (details->text_util)
+ if (details->text)
{
- gail_text_util_text_setup (details->text_util,
- details->editable_text);
+ details->text = g_string_assign (details->text, details->editable_text);
+
if (is_rename)
g_object_notify (G_OBJECT (accessible), "accessible-name");
}
@@ -1901,18 +1897,6 @@ nautilus_canvas_item_class_init (NautilusCanvasItemClass *class)
g_type_class_add_private (class, sizeof (NautilusCanvasItemDetails));
}
-static GailTextUtil *
-nautilus_canvas_item_get_text (GObject *text)
-{
- return NAUTILUS_CANVAS_ITEM (text)->details->text_util;
-}
-
-static void
-nautilus_canvas_item_text_interface_init (EelAccessibleTextIface *iface)
-{
- iface->get_text = nautilus_canvas_item_get_text;
-}
-
/* ============================= a11y interfaces =========================== */
static const char *nautilus_canvas_item_accessible_action_names[] =
@@ -2549,15 +2533,53 @@ nautilus_canvas_item_accessible_get_character_extents (AtkText *text,
*height = PANGO_PIXELS (rect.height);
}
+static char *
+nautilus_canvas_item_accessible_text_get_text (AtkText *text,
+ gint start_pos,
+ gint end_pos)
+{
+ GObject *object;
+ NautilusCanvasItem *item;
+
+ object = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (text));
+ item = NAUTILUS_CANVAS_ITEM (object);
+
+ return g_utf8_substring (item->details->text->str, start_pos, end_pos);
+}
+
+static gunichar
+nautilus_canvas_item_accessible_text_get_character_at_offset (AtkText *text,
+ gint offset)
+{
+ GObject *object;
+ NautilusCanvasItem *item;
+ gchar *pointer;
+
+ object = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (text));
+ item = NAUTILUS_CANVAS_ITEM (object);
+ pointer = g_utf8_offset_to_pointer (item->details->text->str, offset);
+
+ return g_utf8_get_char (pointer);
+}
+
+static gint
+nautilus_canvas_item_accessible_text_get_character_count (AtkText *text)
+{
+ GObject *object;
+ NautilusCanvasItem *item;
+
+ object = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (text));
+ item = NAUTILUS_CANVAS_ITEM (object);
+
+ return g_utf8_strlen (item->details->text->str, -1);
+}
+
static void
nautilus_canvas_item_accessible_text_interface_init (AtkTextIface *iface)
{
- iface->get_text = eel_accessibility_text_get_text;
- iface->get_character_at_offset = eel_accessibility_text_get_character_at_offset;
- iface->get_text_before_offset = eel_accessibility_text_get_text_before_offset;
- iface->get_text_at_offset = eel_accessibility_text_get_text_at_offset;
- iface->get_text_after_offset = eel_accessibility_text_get_text_after_offset;
- iface->get_character_count = eel_accessibility_text_get_character_count;
+ iface->get_text = nautilus_canvas_item_accessible_text_get_text;
+ iface->get_character_at_offset = nautilus_canvas_item_accessible_text_get_character_at_offset;
+ iface->get_character_count = nautilus_canvas_item_accessible_text_get_character_count;
iface->get_character_extents = nautilus_canvas_item_accessible_get_character_extents;
iface->get_offset_at_point = nautilus_canvas_item_accessible_get_offset_at_point;
}
@@ -2678,26 +2700,20 @@ nautilus_canvas_item_accessible_factory_create_accessible (GObject *for_object)
{
AtkObject *accessible;
NautilusCanvasItem *item;
- GString *item_text;
item = NAUTILUS_CANVAS_ITEM (for_object);
g_assert (item != NULL);
- item_text = g_string_new (NULL);
+ item->details->text = g_string_new (NULL);
if (item->details->editable_text)
{
- g_string_append (item_text, item->details->editable_text);
+ g_string_append (item->details->text, item->details->editable_text);
}
if (item->details->additional_text)
{
- g_string_append (item_text, item->details->additional_text);
+ g_string_append (item->details->text, item->details->additional_text);
}
- item->details->text_util = gail_text_util_new ();
- gail_text_util_text_setup (item->details->text_util,
- item_text->str);
- g_string_free (item_text, TRUE);
-
accessible = g_object_new (nautilus_canvas_item_accessible_get_type (), NULL);
atk_object_initialize (accessible, for_object);
diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c
index d239263e2..906e69af0 100644
--- a/src/nautilus-properties-window.c
+++ b/src/nautilus-properties-window.c
@@ -22,7 +22,6 @@
#include "nautilus-properties-window.h"
#include <cairo.h>
-#include <eel/eel-accessibility.h>
#include <eel/eel-gtk-extensions.h>
#include <eel/eel-stock-dialogs.h>
#include <eel/eel-string.h>
@@ -3714,8 +3713,17 @@ add_execute_checkbox_with_label (NautilusPropertiesWindow *window,
a11y_enabled = GTK_IS_ACCESSIBLE (gtk_widget_get_accessible (check_button));
if (a11y_enabled && label_for != NULL)
{
- eel_accessibility_set_up_label_widget_relation (GTK_WIDGET (label_for),
- check_button);
+ AtkObject *atk_widget;
+ AtkObject *atk_label;
+
+ atk_label = gtk_widget_get_accessible (GTK_WIDGET (label_for));
+ atk_widget = gtk_widget_get_accessible (check_button);
+
+ /* Create the label -> widget relation */
+ atk_object_add_relationship (atk_label, ATK_RELATION_LABEL_FOR, atk_widget);
+
+ /* Create the widget -> label relation */
+ atk_object_add_relationship (atk_widget, ATK_RELATION_LABELLED_BY, atk_label);
}
return check_button;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]