[gtk+] Drop gailtextutil from gtk/a11y
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Drop gailtextutil from gtk/a11y
- Date: Fri, 8 Jul 2011 22:41:48 +0000 (UTC)
commit db1eeb065182423d25b4799e132905b28b1d5aa2
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jul 8 18:38:05 2011 -0400
Drop gailtextutil from gtk/a11y
The last user was GailTextCell, and that can use gtk_pango
api instead.
gtk/a11y/Makefile.am | 2 -
gtk/a11y/gailtextcell.c | 151 ++++++----
gtk/a11y/gailtextcell.h | 2 -
gtk/a11y/gailtextutil.c | 786 -----------------------------------------------
gtk/a11y/gailtextutil.h | 87 ------
5 files changed, 87 insertions(+), 941 deletions(-)
---
diff --git a/gtk/a11y/Makefile.am b/gtk/a11y/Makefile.am
index 1842c73..1743fbb 100644
--- a/gtk/a11y/Makefile.am
+++ b/gtk/a11y/Makefile.am
@@ -45,7 +45,6 @@ gail_c_sources = \
gtksubmenuitemaccessible.c \
gtkswitchaccessible.c \
gailtextcell.c \
- gailtextutil.c \
gtktextviewaccessible.c \
gtktogglebuttonaccessible.c \
gailtoplevel.c \
@@ -98,7 +97,6 @@ gail_private_h_sources = \
gtksubmenuitemaccessible.h \
gtkswitchaccessible.h \
gailtextcell.h \
- gailtextutil.h \
gtktextviewaccessible.h \
gtktogglebuttonaccessible.h \
gailtoplevel.h \
diff --git a/gtk/a11y/gailtextcell.c b/gtk/a11y/gailtextcell.c
index ae88d3c..9a81046 100644
--- a/gtk/a11y/gailtextcell.c
+++ b/gtk/a11y/gailtextcell.c
@@ -20,10 +20,11 @@
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
+#include "../gtkpango.h"
#include "gailtextcell.h"
#include "gailcontainercell.h"
#include "gailcellparent.h"
-#include <libgail-util/gailmisc.h>
+#include "gailmisc.h"
static void gail_text_cell_class_init (GailTextCellClass *klass);
static void gail_text_cell_init (GailTextCell *text_cell);
@@ -78,8 +79,8 @@ static AtkAttributeSet* gail_text_cell_get_run_attributes
static AtkAttributeSet* gail_text_cell_get_default_attributes
(AtkText *text);
-static PangoLayout* create_pango_layout (GtkCellRendererText *gtk_renderer,
- GtkWidget *widget);
+static GtkWidget* get_widget (GailTextCell *cell);
+static PangoLayout* create_pango_layout (GailTextCell *cell);
static void add_attr (PangoAttrList *attr_list,
PangoAttribute *attr);
@@ -152,7 +153,6 @@ gail_text_cell_init (GailTextCell *text_cell)
text_cell->cell_text = NULL;
text_cell->caret_pos = 0;
text_cell->cell_length = 0;
- text_cell->textutil = gail_text_util_new ();
atk_state_set_add_state (GAIL_CELL (text_cell)->state_set,
ATK_STATE_SINGLE_LINE);
}
@@ -183,7 +183,6 @@ gail_text_cell_finalize (GObject *object)
{
GailTextCell *text_cell = GAIL_TEXT_CELL (object);
- g_object_unref (text_cell->textutil);
g_free (text_cell->cell_text);
G_OBJECT_CLASS (gail_text_cell_parent_class)->finalize (object);
@@ -255,8 +254,7 @@ gail_text_cell_update_cache (GailRendererCell *cell,
}
g_free (new_cache);
- gail_text_util_text_setup (text_cell->textutil, text_cell->cell_text);
-
+
if (rv)
{
if (emit_change_signal)
@@ -289,50 +287,68 @@ atk_text_interface_init (AtkTextIface *iface)
}
static gchar*
-gail_text_cell_get_text (AtkText *text,
+gail_text_cell_get_text (AtkText *atk_text,
gint start_pos,
gint end_pos)
{
- if (GAIL_TEXT_CELL (text)->cell_text)
- return gail_text_util_get_substring (GAIL_TEXT_CELL (text)->textutil,
- start_pos, end_pos);
+ gchar *text;
+
+ text = GAIL_TEXT_CELL (atk_text)->cell_text;
+ if (text)
+ return g_utf8_substring (text, start_pos, end_pos > -1 ? end_pos : g_utf8_strlen (text, -1));
else
return g_strdup ("");
}
static gchar*
-gail_text_cell_get_text_before_offset (AtkText *text,
+gail_text_cell_get_text_before_offset (AtkText *atk_text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset)
{
- return gail_text_util_get_text (GAIL_TEXT_CELL (text)->textutil,
- NULL, GAIL_BEFORE_OFFSET, boundary_type, offset, start_offset,
- end_offset);
+ PangoLayout *layout;
+ gchar *text;
+
+ layout = create_pango_layout (GAIL_TEXT_CELL (atk_text));
+ text = _gtk_pango_get_text_before (layout, boundary_type, offset, start_offset, end_offset);
+ g_object_unref (layout);
+
+ return text;
}
static gchar*
-gail_text_cell_get_text_at_offset (AtkText *text,
+gail_text_cell_get_text_at_offset (AtkText *atk_text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset)
{
- return gail_text_util_get_text (GAIL_TEXT_CELL (text)->textutil,
- NULL, GAIL_AT_OFFSET, boundary_type, offset, start_offset, end_offset);
+ PangoLayout *layout;
+ gchar *text;
+
+ layout = create_pango_layout (GAIL_TEXT_CELL (atk_text));
+ text = _gtk_pango_get_text_at (layout, boundary_type, offset, start_offset, end_offset);
+ g_object_unref (layout);
+
+ return text;
}
static gchar*
-gail_text_cell_get_text_after_offset (AtkText *text,
+gail_text_cell_get_text_after_offset (AtkText *atk_text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset)
{
- return gail_text_util_get_text (GAIL_TEXT_CELL (text)->textutil,
- NULL, GAIL_AFTER_OFFSET, boundary_type, offset, start_offset,
- end_offset);
+ PangoLayout *layout;
+ gchar *text;
+
+ layout = create_pango_layout (GAIL_TEXT_CELL (atk_text));
+ text = _gtk_pango_get_text_after (layout, boundary_type, offset, start_offset, end_offset);
+ g_object_unref (layout);
+
+ return text;
}
static gint
@@ -381,63 +397,66 @@ static AtkAttributeSet*
gail_text_cell_get_run_attributes (AtkText *text,
gint offset,
gint *start_offset,
- gint *end_offset)
+ gint *end_offset)
{
- GailRendererCell *gail_renderer;
- GtkCellRendererText *gtk_renderer;
AtkAttributeSet *attrib_set = NULL;
PangoLayout *layout;
- AtkObject *parent;
- GtkWidget *widget;
- gchar *renderer_text;
-
- gail_renderer = GAIL_RENDERER_CELL (text);
- gtk_renderer = GTK_CELL_RENDERER_TEXT (gail_renderer->renderer);
- parent = atk_object_get_parent (ATK_OBJECT (text));
- if (GAIL_IS_CONTAINER_CELL (parent))
- parent = atk_object_get_parent (parent);
- g_return_val_if_fail (GAIL_IS_CELL_PARENT (parent), NULL);
- widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (parent));
- layout = create_pango_layout (gtk_renderer, widget),
- g_object_get (gtk_renderer, "text", &renderer_text, NULL);
- attrib_set = gail_misc_layout_get_run_attributes (attrib_set,
- layout,
- renderer_text,
- offset,
- start_offset,
- end_offset);
- g_free (renderer_text);
+ layout = create_pango_layout (GAIL_TEXT_CELL (text));
+ attrib_set = _gtk_pango_get_run_attributes (NULL, layout, offset, start_offset, end_offset);
g_object_unref (G_OBJECT (layout));
-
+
return attrib_set;
}
+static AtkAttributeSet *
+add_attribute (AtkAttributeSet *attributes,
+ AtkTextAttribute attr,
+ const gchar *value)
+{
+ AtkAttribute *at;
+
+ at = g_new (AtkAttribute, 1);
+ at->name = g_strdup (atk_text_attribute_get_name (attr));
+ at->value = g_strdup (value);
+
+ return g_slist_prepend (attributes, at);
+}
+
static AtkAttributeSet*
gail_text_cell_get_default_attributes (AtkText *text)
{
- GailRendererCell *gail_renderer;
- GtkCellRendererText *gtk_renderer;
AtkAttributeSet *attrib_set = NULL;
PangoLayout *layout;
- AtkObject *parent;
GtkWidget *widget;
- gail_renderer = GAIL_RENDERER_CELL (text);
- gtk_renderer = GTK_CELL_RENDERER_TEXT (gail_renderer->renderer);
+ layout = create_pango_layout (GAIL_TEXT_CELL (text));
+ widget = get_widget (GAIL_TEXT_CELL (text));
+
+ attrib_set = add_attribute (attrib_set, ATK_TEXT_ATTR_DIRECTION,
+ atk_text_attribute_get_value (ATK_TEXT_ATTR_DIRECTION,
+ gtk_widget_get_direction (widget)));
+ attrib_set = _gtk_pango_get_default_attributes (NULL, layout);
+
+ attrib_set = _gtk_style_context_get_attributes (attrib_set,
+ gtk_widget_get_style_context (widget),
+ gtk_widget_get_state_flags (widget));
+
+ g_object_unref (G_OBJECT (layout));
+
+ return attrib_set;
+}
+
+GtkWidget *
+get_widget (GailTextCell *text)
+{
+ AtkObject *parent;
parent = atk_object_get_parent (ATK_OBJECT (text));
if (GAIL_IS_CONTAINER_CELL (parent))
parent = atk_object_get_parent (parent);
- g_return_val_if_fail (GAIL_IS_CELL_PARENT (parent), NULL);
- widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (parent));
- layout = create_pango_layout (gtk_renderer, widget),
- attrib_set = gail_misc_get_default_attributes (attrib_set,
- layout,
- widget);
- g_object_unref (G_OBJECT (layout));
- return attrib_set;
+ return gtk_accessible_get_widget (GTK_ACCESSIBLE (parent));
}
/*
@@ -447,8 +466,7 @@ gail_text_cell_get_default_attributes (AtkText *text)
* one using this function.
*/
static PangoLayout*
-create_pango_layout(GtkCellRendererText *gtk_renderer,
- GtkWidget *widget)
+create_pango_layout (GailTextCell *text)
{
GdkRGBA *foreground_rgba;
PangoAttrList *attr_list, *attributes;
@@ -461,6 +479,11 @@ create_pango_layout(GtkCellRendererText *gtk_renderer,
gchar *renderer_text;
gdouble scale;
gint rise;
+ GailRendererCell *gail_renderer;
+ GtkCellRendererText *gtk_renderer;
+
+ gail_renderer = GAIL_RENDERER_CELL (text);
+ gtk_renderer = GTK_CELL_RENDERER_TEXT (gail_renderer->renderer);
g_object_get (gtk_renderer,
"text", &renderer_text,
@@ -478,7 +501,7 @@ create_pango_layout(GtkCellRendererText *gtk_renderer,
"rise", &rise,
NULL);
- layout = gtk_widget_create_pango_layout (widget, renderer_text);
+ layout = gtk_widget_create_pango_layout (get_widget (text), renderer_text);
if (attributes)
attr_list = pango_attr_list_copy (attributes);
@@ -615,7 +638,7 @@ gail_text_cell_get_character_extents (AtkText *text,
x_offset = MAX (0, xalign * (rendered_rect.width - min_size.width));
y_offset = MAX (0, yalign * (rendered_rect.height - min_size.height));
- layout = create_pango_layout (gtk_renderer, widget);
+ layout = create_pango_layout (GAIL_TEXT_CELL (text));
index = g_utf8_offset_to_pointer (renderer_text, offset) - renderer_text;
pango_layout_index_to_pos (layout, index, &char_rect);
@@ -683,7 +706,7 @@ gail_text_cell_get_offset_at_point (AtkText *text,
x_offset = MAX (0, xalign * (rendered_rect.width - min_size.width));
y_offset = MAX (0, yalign * (rendered_rect.height - min_size.height));
- layout = create_pango_layout (gtk_renderer, widget);
+ layout = create_pango_layout (GAIL_TEXT_CELL (text));
gtk_cell_renderer_get_padding (gail_renderer->renderer, &xpad, &ypad);
index = gail_misc_get_index_at_point_in_layout (widget, layout,
diff --git a/gtk/a11y/gailtextcell.h b/gtk/a11y/gailtextcell.h
index b5f8adb..d91ec99 100644
--- a/gtk/a11y/gailtextcell.h
+++ b/gtk/a11y/gailtextcell.h
@@ -22,7 +22,6 @@
#include <atk/atk.h>
#include "gailrenderercell.h"
-#include "gailtextutil.h"
G_BEGIN_DECLS
@@ -39,7 +38,6 @@ typedef struct _GailTextCellClass GailTextCellClass;
struct _GailTextCell
{
GailRendererCell parent;
- GailTextUtil *textutil;
gchar *cell_text;
gint caret_pos;
gint cell_length;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]