2012-10-30 14:21:44 +00:00
|
|
|
/* GTK+ - accessibility implementations
|
2007-12-18 13:51:12 +00:00
|
|
|
* Copyright 2001 Sun Microsystems Inc.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser 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
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2007-12-18 13:51:12 +00:00
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
2011-07-10 04:24:26 +00:00
|
|
|
|
2007-12-18 13:51:12 +00:00
|
|
|
#include <gtk/gtk.h>
|
2011-07-08 22:38:05 +00:00
|
|
|
#include "../gtkpango.h"
|
2011-07-10 03:26:59 +00:00
|
|
|
#include "gtktextcellaccessible.h"
|
2011-07-09 23:19:38 +00:00
|
|
|
#include "gtkcontainercellaccessible.h"
|
2011-07-10 03:56:42 +00:00
|
|
|
#include "gtkcellaccessibleparent.h"
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2012-10-15 01:21:34 +00:00
|
|
|
struct _GtkTextCellAccessiblePrivate
|
|
|
|
{
|
|
|
|
gchar *cell_text;
|
|
|
|
gint caret_pos;
|
|
|
|
gint cell_length;
|
|
|
|
};
|
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
static const gchar* gtk_text_cell_accessible_get_name (AtkObject *atk_obj);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* atktext.h */
|
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
static gchar* gtk_text_cell_accessible_get_text (AtkText *text,
|
|
|
|
gint start_pos,
|
|
|
|
gint end_pos);
|
|
|
|
static gunichar gtk_text_cell_accessible_get_character_at_offset (AtkText *text,
|
|
|
|
gint offset);
|
|
|
|
static gchar* gtk_text_cell_accessible_get_text_before_offset (AtkText *text,
|
|
|
|
gint offset,
|
|
|
|
AtkTextBoundary boundary_type,
|
|
|
|
gint *start_offset,
|
|
|
|
gint *end_offset);
|
|
|
|
static gchar* gtk_text_cell_accessible_get_text_at_offset (AtkText *text,
|
|
|
|
gint offset,
|
|
|
|
AtkTextBoundary boundary_type,
|
|
|
|
gint *start_offset,
|
|
|
|
gint *end_offset);
|
|
|
|
static gchar* gtk_text_cell_accessible_get_text_after_offset (AtkText *text,
|
|
|
|
gint offset,
|
|
|
|
AtkTextBoundary boundary_type,
|
|
|
|
gint *start_offset,
|
|
|
|
gint *end_offset);
|
|
|
|
static gint gtk_text_cell_accessible_get_character_count (AtkText *text);
|
|
|
|
static gint gtk_text_cell_accessible_get_caret_offset (AtkText *text);
|
|
|
|
static gboolean gtk_text_cell_accessible_set_caret_offset (AtkText *text,
|
|
|
|
gint offset);
|
|
|
|
static void gtk_text_cell_accessible_get_character_extents (AtkText *text,
|
|
|
|
gint offset,
|
|
|
|
gint *x,
|
|
|
|
gint *y,
|
|
|
|
gint *width,
|
|
|
|
gint *height,
|
|
|
|
AtkCoordType coords);
|
|
|
|
static gint gtk_text_cell_accessible_get_offset_at_point (AtkText *text,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
AtkCoordType coords);
|
|
|
|
static AtkAttributeSet* gtk_text_cell_accessible_get_run_attributes
|
|
|
|
(AtkText *text,
|
|
|
|
gint offset,
|
|
|
|
gint *start_offset,
|
|
|
|
gint *end_offset);
|
|
|
|
static AtkAttributeSet* gtk_text_cell_accessible_get_default_attributes
|
2007-12-18 13:51:12 +00:00
|
|
|
(AtkText *text);
|
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
static GtkWidget* get_widget (GtkTextCellAccessible *cell);
|
|
|
|
static PangoLayout* create_pango_layout (GtkTextCellAccessible *cell);
|
2007-12-18 13:51:12 +00:00
|
|
|
static void add_attr (PangoAttrList *attr_list,
|
|
|
|
PangoAttribute *attr);
|
|
|
|
|
|
|
|
/* Misc */
|
|
|
|
|
2011-12-15 23:07:46 +00:00
|
|
|
static void gtk_text_cell_accessible_update_cache (GtkCellAccessible *cell);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
static void atk_text_interface_init (AtkTextIface *iface);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2012-12-27 06:04:46 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkTextCellAccessible, gtk_text_cell_accessible, GTK_TYPE_RENDERER_CELL_ACCESSIBLE,
|
2013-06-24 18:13:44 +00:00
|
|
|
G_ADD_PRIVATE (GtkTextCellAccessible)
|
2011-07-10 03:26:59 +00:00
|
|
|
G_IMPLEMENT_INTERFACE (ATK_TYPE_TEXT, atk_text_interface_init))
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-11-24 00:59:18 +00:00
|
|
|
static AtkStateSet *
|
|
|
|
gtk_text_cell_accessible_ref_state_set (AtkObject *accessible)
|
|
|
|
{
|
|
|
|
AtkStateSet *state_set;
|
|
|
|
|
2012-12-27 06:04:46 +00:00
|
|
|
state_set = ATK_OBJECT_CLASS (gtk_text_cell_accessible_parent_class)->ref_state_set (accessible);
|
2011-11-24 00:59:18 +00:00
|
|
|
|
|
|
|
atk_state_set_add_state (state_set, ATK_STATE_SINGLE_LINE);
|
|
|
|
|
|
|
|
return state_set;
|
|
|
|
}
|
2007-12-18 13:51:12 +00:00
|
|
|
|
|
|
|
static void
|
2011-07-10 03:26:59 +00:00
|
|
|
gtk_text_cell_accessible_finalize (GObject *object)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-07-10 03:26:59 +00:00
|
|
|
GtkTextCellAccessible *text_cell = GTK_TEXT_CELL_ACCESSIBLE (object);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2012-10-15 01:21:34 +00:00
|
|
|
g_free (text_cell->priv->cell_text);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2012-12-27 06:04:46 +00:00
|
|
|
G_OBJECT_CLASS (gtk_text_cell_accessible_parent_class)->finalize (object);
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
static const gchar *
|
|
|
|
gtk_text_cell_accessible_get_name (AtkObject *atk_obj)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-07-10 03:26:59 +00:00
|
|
|
GtkTextCellAccessible *text_cell = GTK_TEXT_CELL_ACCESSIBLE (atk_obj);
|
|
|
|
|
2007-12-18 13:51:12 +00:00
|
|
|
if (atk_obj->name)
|
|
|
|
return atk_obj->name;
|
|
|
|
|
2012-10-15 01:21:34 +00:00
|
|
|
return text_cell->priv->cell_text;
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2011-12-15 22:51:57 +00:00
|
|
|
static void
|
2011-12-15 23:07:46 +00:00
|
|
|
gtk_text_cell_accessible_update_cache (GtkCellAccessible *cell)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-07-10 03:26:59 +00:00
|
|
|
GtkTextCellAccessible *text_cell = GTK_TEXT_CELL_ACCESSIBLE (cell);
|
2007-12-18 13:51:12 +00:00
|
|
|
AtkObject *obj = ATK_OBJECT (cell);
|
|
|
|
gboolean rv = FALSE;
|
|
|
|
gint temp_length;
|
2011-07-10 03:26:59 +00:00
|
|
|
gchar *text;
|
2012-10-15 01:07:46 +00:00
|
|
|
GtkCellRenderer *renderer;
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2012-10-15 01:07:46 +00:00
|
|
|
g_object_get (cell, "renderer", &renderer, NULL);
|
2012-10-15 01:21:34 +00:00
|
|
|
g_object_get (renderer, "text", &text, NULL);
|
2012-10-15 01:07:46 +00:00
|
|
|
g_object_unref (renderer);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2012-10-15 01:21:34 +00:00
|
|
|
if (text_cell->priv->cell_text)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2012-10-15 01:21:34 +00:00
|
|
|
if (text == NULL || g_strcmp0 (text_cell->priv->cell_text, text) != 0)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2012-10-15 01:21:34 +00:00
|
|
|
g_free (text_cell->priv->cell_text);
|
|
|
|
temp_length = text_cell->priv->cell_length;
|
|
|
|
text_cell->priv->cell_text = NULL;
|
|
|
|
text_cell->priv->cell_length = 0;
|
2011-12-15 22:51:57 +00:00
|
|
|
g_signal_emit_by_name (cell, "text-changed::delete", 0, temp_length);
|
|
|
|
if (obj->name == NULL)
|
|
|
|
g_object_notify (G_OBJECT (obj), "accessible-name");
|
2011-07-10 03:26:59 +00:00
|
|
|
if (text)
|
2007-12-18 13:51:12 +00:00
|
|
|
rv = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
rv = TRUE;
|
|
|
|
|
|
|
|
if (rv)
|
|
|
|
{
|
2011-07-10 03:26:59 +00:00
|
|
|
if (text == NULL)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2012-10-15 01:21:34 +00:00
|
|
|
text_cell->priv->cell_text = g_strdup ("");
|
|
|
|
text_cell->priv->cell_length = 0;
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-10-15 01:21:34 +00:00
|
|
|
text_cell->priv->cell_text = g_strdup (text);
|
|
|
|
text_cell->priv->cell_length = g_utf8_strlen (text, -1);
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
g_free (text);
|
2011-07-08 22:38:05 +00:00
|
|
|
|
2007-12-18 13:51:12 +00:00
|
|
|
if (rv)
|
|
|
|
{
|
2011-12-15 22:51:57 +00:00
|
|
|
g_signal_emit_by_name (cell, "text-changed::insert",
|
2012-10-15 01:21:34 +00:00
|
|
|
0, text_cell->priv->cell_length);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-12-15 22:51:57 +00:00
|
|
|
if (obj->name == NULL)
|
|
|
|
g_object_notify (G_OBJECT (obj), "accessible-name");
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-12-27 06:04:46 +00:00
|
|
|
gtk_text_cell_accessible_class_init (GtkTextCellAccessibleClass *klass)
|
2011-07-10 03:26:59 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
AtkObjectClass *atk_object_class = ATK_OBJECT_CLASS (klass);
|
2011-12-15 23:07:46 +00:00
|
|
|
GtkCellAccessibleClass *cell_class = GTK_CELL_ACCESSIBLE_CLASS (klass);
|
2011-07-10 03:26:59 +00:00
|
|
|
|
2011-12-15 23:07:46 +00:00
|
|
|
cell_class->update_cache = gtk_text_cell_accessible_update_cache;
|
2011-07-10 03:26:59 +00:00
|
|
|
|
|
|
|
atk_object_class->get_name = gtk_text_cell_accessible_get_name;
|
2011-11-24 00:59:18 +00:00
|
|
|
atk_object_class->ref_state_set = gtk_text_cell_accessible_ref_state_set;
|
2011-07-10 03:26:59 +00:00
|
|
|
|
|
|
|
gobject_class->finalize = gtk_text_cell_accessible_finalize;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-12-27 06:04:46 +00:00
|
|
|
gtk_text_cell_accessible_init (GtkTextCellAccessible *text_cell)
|
2011-07-10 03:26:59 +00:00
|
|
|
{
|
2013-06-24 18:13:44 +00:00
|
|
|
text_cell->priv = gtk_text_cell_accessible_get_instance_private (text_cell);
|
2011-07-10 03:26:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
|
|
|
gtk_text_cell_accessible_get_text (AtkText *atk_text,
|
|
|
|
gint start_pos,
|
|
|
|
gint end_pos)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-07-08 22:38:05 +00:00
|
|
|
gchar *text;
|
|
|
|
|
2012-10-15 01:21:34 +00:00
|
|
|
text = GTK_TEXT_CELL_ACCESSIBLE (atk_text)->priv->cell_text;
|
2011-07-08 22:38:05 +00:00
|
|
|
if (text)
|
|
|
|
return g_utf8_substring (text, start_pos, end_pos > -1 ? end_pos : g_utf8_strlen (text, -1));
|
2007-12-18 13:51:12 +00:00
|
|
|
else
|
|
|
|
return g_strdup ("");
|
|
|
|
}
|
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
static gchar *
|
|
|
|
gtk_text_cell_accessible_get_text_before_offset (AtkText *atk_text,
|
|
|
|
gint offset,
|
|
|
|
AtkTextBoundary boundary_type,
|
|
|
|
gint *start_offset,
|
|
|
|
gint *end_offset)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-07-08 22:38:05 +00:00
|
|
|
PangoLayout *layout;
|
|
|
|
gchar *text;
|
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
layout = create_pango_layout (GTK_TEXT_CELL_ACCESSIBLE (atk_text));
|
2011-07-08 22:38:05 +00:00
|
|
|
text = _gtk_pango_get_text_before (layout, boundary_type, offset, start_offset, end_offset);
|
|
|
|
g_object_unref (layout);
|
|
|
|
|
|
|
|
return text;
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
static gchar *
|
|
|
|
gtk_text_cell_accessible_get_text_at_offset (AtkText *atk_text,
|
|
|
|
gint offset,
|
|
|
|
AtkTextBoundary boundary_type,
|
|
|
|
gint *start_offset,
|
|
|
|
gint *end_offset)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-07-08 22:38:05 +00:00
|
|
|
PangoLayout *layout;
|
|
|
|
gchar *text;
|
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
layout = create_pango_layout (GTK_TEXT_CELL_ACCESSIBLE (atk_text));
|
2011-07-08 22:38:05 +00:00
|
|
|
text = _gtk_pango_get_text_at (layout, boundary_type, offset, start_offset, end_offset);
|
|
|
|
g_object_unref (layout);
|
|
|
|
|
|
|
|
return text;
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
static gchar *
|
|
|
|
gtk_text_cell_accessible_get_text_after_offset (AtkText *atk_text,
|
|
|
|
gint offset,
|
|
|
|
AtkTextBoundary boundary_type,
|
|
|
|
gint *start_offset,
|
|
|
|
gint *end_offset)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-07-08 22:38:05 +00:00
|
|
|
PangoLayout *layout;
|
|
|
|
gchar *text;
|
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
layout = create_pango_layout (GTK_TEXT_CELL_ACCESSIBLE (atk_text));
|
2011-07-08 22:38:05 +00:00
|
|
|
text = _gtk_pango_get_text_after (layout, boundary_type, offset, start_offset, end_offset);
|
|
|
|
g_object_unref (layout);
|
|
|
|
|
|
|
|
return text;
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
static gint
|
|
|
|
gtk_text_cell_accessible_get_character_count (AtkText *text)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2012-10-15 01:21:34 +00:00
|
|
|
if (GTK_TEXT_CELL_ACCESSIBLE (text)->priv->cell_text != NULL)
|
|
|
|
return GTK_TEXT_CELL_ACCESSIBLE (text)->priv->cell_length;
|
2007-12-18 13:51:12 +00:00
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
static gint
|
|
|
|
gtk_text_cell_accessible_get_caret_offset (AtkText *text)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2012-10-15 01:21:34 +00:00
|
|
|
return GTK_TEXT_CELL_ACCESSIBLE (text)->priv->caret_pos;
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
static gboolean
|
|
|
|
gtk_text_cell_accessible_set_caret_offset (AtkText *text,
|
|
|
|
gint offset)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-07-10 03:26:59 +00:00
|
|
|
GtkTextCellAccessible *text_cell = GTK_TEXT_CELL_ACCESSIBLE (text);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2012-10-15 01:21:34 +00:00
|
|
|
if (text_cell->priv->cell_text == NULL)
|
2007-12-18 13:51:12 +00:00
|
|
|
return FALSE;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Only set the caret within the bounds and if it is to a new position. */
|
2011-07-10 03:26:59 +00:00
|
|
|
if (offset >= 0 &&
|
2012-10-15 01:21:34 +00:00
|
|
|
offset <= text_cell->priv->cell_length &&
|
|
|
|
offset != text_cell->priv->caret_pos)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2012-10-15 01:21:34 +00:00
|
|
|
text_cell->priv->caret_pos = offset;
|
2007-12-18 13:51:12 +00:00
|
|
|
|
|
|
|
/* emit the signal */
|
2011-07-17 22:47:19 +00:00
|
|
|
g_signal_emit_by_name (text, "text-caret-moved", offset);
|
2007-12-18 13:51:12 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
static AtkAttributeSet *
|
|
|
|
gtk_text_cell_accessible_get_run_attributes (AtkText *text,
|
|
|
|
gint offset,
|
|
|
|
gint *start_offset,
|
|
|
|
gint *end_offset)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
AtkAttributeSet *attrib_set = NULL;
|
|
|
|
PangoLayout *layout;
|
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
layout = create_pango_layout (GTK_TEXT_CELL_ACCESSIBLE (text));
|
2011-07-08 22:38:05 +00:00
|
|
|
attrib_set = _gtk_pango_get_run_attributes (NULL, layout, offset, start_offset, end_offset);
|
2007-12-18 13:51:12 +00:00
|
|
|
g_object_unref (G_OBJECT (layout));
|
2011-07-08 22:38:05 +00:00
|
|
|
|
2007-12-18 13:51:12 +00:00
|
|
|
return attrib_set;
|
|
|
|
}
|
|
|
|
|
2011-07-08 22:38:05 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
static AtkAttributeSet *
|
|
|
|
gtk_text_cell_accessible_get_default_attributes (AtkText *text)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
AtkAttributeSet *attrib_set = NULL;
|
|
|
|
PangoLayout *layout;
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
layout = create_pango_layout (GTK_TEXT_CELL_ACCESSIBLE (text));
|
|
|
|
widget = get_widget (GTK_TEXT_CELL_ACCESSIBLE (text));
|
2011-07-08 22:38:05 +00:00
|
|
|
|
|
|
|
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 *
|
2011-07-10 03:26:59 +00:00
|
|
|
get_widget (GtkTextCellAccessible *text)
|
2011-07-08 22:38:05 +00:00
|
|
|
{
|
|
|
|
AtkObject *parent;
|
2007-12-18 13:51:12 +00:00
|
|
|
|
|
|
|
parent = atk_object_get_parent (ATK_OBJECT (text));
|
2011-07-09 23:19:38 +00:00
|
|
|
if (GTK_IS_CONTAINER_CELL_ACCESSIBLE (parent))
|
2007-12-18 13:51:12 +00:00
|
|
|
parent = atk_object_get_parent (parent);
|
|
|
|
|
2011-07-08 22:38:05 +00:00
|
|
|
return gtk_accessible_get_widget (GTK_ACCESSIBLE (parent));
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
/* This function is used by gtk_text_cell_accessible_get_offset_at_point()
|
|
|
|
* and gtk_text_cell_accessible_get_character_extents(). There is no
|
|
|
|
* cached PangoLayout so we must create a temporary one using this function.
|
|
|
|
*/
|
|
|
|
static PangoLayout *
|
|
|
|
create_pango_layout (GtkTextCellAccessible *text)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-06-06 15:47:10 +00:00
|
|
|
GdkRGBA *foreground_rgba;
|
2010-06-01 19:01:33 +00:00
|
|
|
PangoAttrList *attr_list, *attributes;
|
2007-12-18 13:51:12 +00:00
|
|
|
PangoLayout *layout;
|
2010-06-01 19:01:33 +00:00
|
|
|
PangoUnderline uline, underline;
|
2007-12-18 13:51:12 +00:00
|
|
|
PangoFontMask mask;
|
2010-06-01 19:01:33 +00:00
|
|
|
PangoFontDescription *font_desc;
|
|
|
|
gboolean foreground_set, strikethrough_set, strikethrough;
|
|
|
|
gboolean scale_set, underline_set, rise_set;
|
|
|
|
gchar *renderer_text;
|
|
|
|
gdouble scale;
|
|
|
|
gint rise;
|
2011-07-09 23:19:38 +00:00
|
|
|
GtkRendererCellAccessible *gail_renderer;
|
2011-07-08 22:38:05 +00:00
|
|
|
GtkCellRendererText *gtk_renderer;
|
|
|
|
|
2011-07-09 23:19:38 +00:00
|
|
|
gail_renderer = GTK_RENDERER_CELL_ACCESSIBLE (text);
|
2012-10-15 01:07:46 +00:00
|
|
|
g_object_get (gail_renderer, "renderer", >k_renderer, NULL);
|
2010-06-01 19:01:33 +00:00
|
|
|
|
|
|
|
g_object_get (gtk_renderer,
|
|
|
|
"text", &renderer_text,
|
|
|
|
"attributes", &attributes,
|
|
|
|
"foreground-set", &foreground_set,
|
2011-06-12 20:45:47 +00:00
|
|
|
"foreground-rgba", &foreground_rgba,
|
2010-06-01 19:01:33 +00:00
|
|
|
"strikethrough-set", &strikethrough_set,
|
|
|
|
"strikethrough", &strikethrough,
|
|
|
|
"font-desc", &font_desc,
|
|
|
|
"scale-set", &scale_set,
|
|
|
|
"scale", &scale,
|
|
|
|
"underline-set", &underline_set,
|
|
|
|
"underline", &underline,
|
|
|
|
"rise-set", &rise_set,
|
|
|
|
"rise", &rise,
|
|
|
|
NULL);
|
2012-10-15 01:07:46 +00:00
|
|
|
g_object_unref (gtk_renderer);
|
2010-06-01 19:01:33 +00:00
|
|
|
|
2011-07-08 22:38:05 +00:00
|
|
|
layout = gtk_widget_create_pango_layout (get_widget (text), renderer_text);
|
2010-06-01 19:01:33 +00:00
|
|
|
|
|
|
|
if (attributes)
|
|
|
|
attr_list = pango_attr_list_copy (attributes);
|
2007-12-18 13:51:12 +00:00
|
|
|
else
|
|
|
|
attr_list = pango_attr_list_new ();
|
|
|
|
|
2010-06-01 19:01:33 +00:00
|
|
|
if (foreground_set)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-06-06 15:47:10 +00:00
|
|
|
add_attr (attr_list, pango_attr_foreground_new (foreground_rgba->red * 65535,
|
|
|
|
foreground_rgba->green * 65535,
|
|
|
|
foreground_rgba->blue * 65535));
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2010-06-01 19:01:33 +00:00
|
|
|
if (strikethrough_set)
|
2007-12-18 13:51:12 +00:00
|
|
|
add_attr (attr_list,
|
2010-06-01 19:01:33 +00:00
|
|
|
pango_attr_strikethrough_new (strikethrough));
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2010-06-01 19:01:33 +00:00
|
|
|
mask = pango_font_description_get_set_fields (font_desc);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
|
|
|
if (mask & PANGO_FONT_MASK_FAMILY)
|
|
|
|
add_attr (attr_list,
|
2010-06-01 19:01:33 +00:00
|
|
|
pango_attr_family_new (pango_font_description_get_family (font_desc)));
|
2007-12-18 13:51:12 +00:00
|
|
|
|
|
|
|
if (mask & PANGO_FONT_MASK_STYLE)
|
2010-06-01 19:01:33 +00:00
|
|
|
add_attr (attr_list, pango_attr_style_new (pango_font_description_get_style (font_desc)));
|
2007-12-18 13:51:12 +00:00
|
|
|
|
|
|
|
if (mask & PANGO_FONT_MASK_VARIANT)
|
2010-06-01 19:01:33 +00:00
|
|
|
add_attr (attr_list, pango_attr_variant_new (pango_font_description_get_variant (font_desc)));
|
2007-12-18 13:51:12 +00:00
|
|
|
|
|
|
|
if (mask & PANGO_FONT_MASK_WEIGHT)
|
2010-06-01 19:01:33 +00:00
|
|
|
add_attr (attr_list, pango_attr_weight_new (pango_font_description_get_weight (font_desc)));
|
2007-12-18 13:51:12 +00:00
|
|
|
|
|
|
|
if (mask & PANGO_FONT_MASK_STRETCH)
|
2010-06-01 19:01:33 +00:00
|
|
|
add_attr (attr_list, pango_attr_stretch_new (pango_font_description_get_stretch (font_desc)));
|
2007-12-18 13:51:12 +00:00
|
|
|
|
|
|
|
if (mask & PANGO_FONT_MASK_SIZE)
|
2010-06-01 19:01:33 +00:00
|
|
|
add_attr (attr_list, pango_attr_size_new (pango_font_description_get_size (font_desc)));
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2010-06-01 19:01:33 +00:00
|
|
|
if (scale_set && scale != 1.0)
|
|
|
|
add_attr (attr_list, pango_attr_scale_new (scale));
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2010-06-01 19:01:33 +00:00
|
|
|
if (underline_set)
|
|
|
|
uline = underline;
|
2007-12-18 13:51:12 +00:00
|
|
|
else
|
|
|
|
uline = PANGO_UNDERLINE_NONE;
|
|
|
|
|
|
|
|
if (uline != PANGO_UNDERLINE_NONE)
|
|
|
|
add_attr (attr_list,
|
2010-06-01 19:01:33 +00:00
|
|
|
pango_attr_underline_new (underline));
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2010-06-01 19:01:33 +00:00
|
|
|
if (rise_set)
|
|
|
|
add_attr (attr_list, pango_attr_rise_new (rise));
|
2007-12-18 13:51:12 +00:00
|
|
|
|
|
|
|
pango_layout_set_attributes (layout, attr_list);
|
|
|
|
pango_layout_set_width (layout, -1);
|
|
|
|
pango_attr_list_unref (attr_list);
|
|
|
|
|
2010-06-01 19:01:33 +00:00
|
|
|
pango_font_description_free (font_desc);
|
|
|
|
pango_attr_list_unref (attributes);
|
|
|
|
g_free (renderer_text);
|
2011-06-06 15:47:10 +00:00
|
|
|
gdk_rgba_free (foreground_rgba);
|
2010-06-01 19:01:33 +00:00
|
|
|
|
2007-12-18 13:51:12 +00:00
|
|
|
return layout;
|
|
|
|
}
|
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
static void
|
|
|
|
add_attr (PangoAttrList *attr_list,
|
2007-12-18 13:51:12 +00:00
|
|
|
PangoAttribute *attr)
|
|
|
|
{
|
|
|
|
attr->start_index = 0;
|
|
|
|
attr->end_index = G_MAXINT;
|
|
|
|
pango_attr_list_insert (attr_list, attr);
|
|
|
|
}
|
|
|
|
|
2011-07-09 02:03:13 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
get_origins (GtkWidget *widget,
|
|
|
|
gint *x_window,
|
|
|
|
gint *y_window,
|
|
|
|
gint *x_toplevel,
|
|
|
|
gint *y_toplevel)
|
|
|
|
{
|
|
|
|
GdkWindow *window;
|
|
|
|
|
|
|
|
if (GTK_IS_TREE_VIEW (widget))
|
|
|
|
window = gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget));
|
|
|
|
else
|
|
|
|
window = gtk_widget_get_window (widget);
|
|
|
|
|
|
|
|
gdk_window_get_origin (window, x_window, y_window);
|
|
|
|
window = gdk_window_get_toplevel (gtk_widget_get_window (widget));
|
|
|
|
gdk_window_get_origin (window, x_toplevel, y_toplevel);
|
|
|
|
}
|
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
static void
|
|
|
|
gtk_text_cell_accessible_get_character_extents (AtkText *text,
|
|
|
|
gint offset,
|
|
|
|
gint *x,
|
|
|
|
gint *y,
|
|
|
|
gint *width,
|
|
|
|
gint *height,
|
|
|
|
AtkCoordType coords)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-07-10 03:26:59 +00:00
|
|
|
GtkRendererCellAccessible *gail_renderer;
|
2010-09-15 19:03:34 +00:00
|
|
|
GtkRequisition min_size;
|
2007-12-18 13:51:12 +00:00
|
|
|
GtkCellRendererText *gtk_renderer;
|
|
|
|
GdkRectangle rendered_rect;
|
|
|
|
GtkWidget *widget;
|
|
|
|
AtkObject *parent;
|
|
|
|
PangoRectangle char_rect;
|
|
|
|
PangoLayout *layout;
|
2010-06-01 19:01:33 +00:00
|
|
|
gchar *renderer_text;
|
2010-11-11 19:09:29 +00:00
|
|
|
gfloat xalign, yalign;
|
2010-09-15 19:03:34 +00:00
|
|
|
gint x_offset, y_offset, index;
|
2010-05-30 20:38:33 +00:00
|
|
|
gint xpad, ypad;
|
2011-07-09 02:03:13 +00:00
|
|
|
gint x_window, y_window, x_toplevel, y_toplevel;
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2012-10-15 01:21:34 +00:00
|
|
|
if (!GTK_TEXT_CELL_ACCESSIBLE (text)->priv->cell_text)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
*x = *y = *height = *width = 0;
|
|
|
|
return;
|
|
|
|
}
|
2012-10-15 01:21:34 +00:00
|
|
|
if (offset < 0 || offset >= GTK_TEXT_CELL_ACCESSIBLE (text)->priv->cell_length)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
*x = *y = *height = *width = 0;
|
|
|
|
return;
|
|
|
|
}
|
2011-07-09 23:19:38 +00:00
|
|
|
gail_renderer = GTK_RENDERER_CELL_ACCESSIBLE (text);
|
2012-10-15 01:07:46 +00:00
|
|
|
g_object_get (gail_renderer, "renderer", >k_renderer, NULL);
|
2010-06-01 19:01:33 +00:00
|
|
|
g_object_get (gtk_renderer, "text", &renderer_text, NULL);
|
2012-06-06 13:22:29 +00:00
|
|
|
if (renderer_text == NULL)
|
2012-10-15 01:07:46 +00:00
|
|
|
{
|
|
|
|
g_object_unref (gtk_renderer);
|
|
|
|
return;
|
|
|
|
}
|
2007-12-18 13:51:12 +00:00
|
|
|
|
|
|
|
parent = atk_object_get_parent (ATK_OBJECT (text));
|
2011-07-09 23:19:38 +00:00
|
|
|
if (GTK_IS_CONTAINER_CELL_ACCESSIBLE (parent))
|
2007-12-18 13:51:12 +00:00
|
|
|
parent = atk_object_get_parent (parent);
|
2010-05-22 23:55:33 +00:00
|
|
|
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (parent));
|
2011-07-10 03:56:42 +00:00
|
|
|
g_return_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent));
|
2012-12-27 06:04:46 +00:00
|
|
|
gtk_cell_accessible_parent_get_cell_area (GTK_CELL_ACCESSIBLE_PARENT (parent),
|
|
|
|
GTK_CELL_ACCESSIBLE (text),
|
|
|
|
&rendered_rect);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2010-09-21 14:52:59 +00:00
|
|
|
gtk_cell_renderer_get_preferred_size (GTK_CELL_RENDERER (gtk_renderer),
|
|
|
|
widget,
|
|
|
|
&min_size, NULL);
|
2010-09-15 19:03:34 +00:00
|
|
|
|
2010-11-11 19:09:29 +00:00
|
|
|
gtk_cell_renderer_get_alignment (GTK_CELL_RENDERER (gtk_renderer), &xalign, &yalign);
|
|
|
|
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
|
|
|
|
xalign = 1.0 - xalign;
|
|
|
|
x_offset = MAX (0, xalign * (rendered_rect.width - min_size.width));
|
|
|
|
y_offset = MAX (0, yalign * (rendered_rect.height - min_size.height));
|
2010-09-15 19:03:34 +00:00
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
layout = create_pango_layout (GTK_TEXT_CELL_ACCESSIBLE (text));
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2010-06-01 19:01:33 +00:00
|
|
|
index = g_utf8_offset_to_pointer (renderer_text, offset) - renderer_text;
|
2010-11-11 19:09:29 +00:00
|
|
|
pango_layout_index_to_pos (layout, index, &char_rect);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2012-10-15 01:07:46 +00:00
|
|
|
gtk_cell_renderer_get_padding (GTK_CELL_RENDERER (gtk_renderer), &xpad, &ypad);
|
2011-07-09 02:03:13 +00:00
|
|
|
|
|
|
|
get_origins (widget, &x_window, &y_window, &x_toplevel, &y_toplevel);
|
|
|
|
|
|
|
|
*x = (char_rect.x / PANGO_SCALE) + x_offset + rendered_rect.x + xpad + x_window;
|
|
|
|
*y = (char_rect.y / PANGO_SCALE) + y_offset + rendered_rect.y + ypad + y_window;
|
2011-07-10 03:26:59 +00:00
|
|
|
*height = char_rect.height / PANGO_SCALE;
|
|
|
|
*width = char_rect.width / PANGO_SCALE;
|
|
|
|
|
2011-07-09 02:03:13 +00:00
|
|
|
if (coords == ATK_XY_WINDOW)
|
|
|
|
{
|
|
|
|
*x -= x_toplevel;
|
|
|
|
*y -= y_toplevel;
|
|
|
|
}
|
|
|
|
else if (coords != ATK_XY_SCREEN)
|
|
|
|
{
|
|
|
|
*x = 0;
|
|
|
|
*y = 0;
|
|
|
|
*height = 0;
|
|
|
|
*width = 0;
|
|
|
|
}
|
2010-06-01 19:01:33 +00:00
|
|
|
|
|
|
|
g_free (renderer_text);
|
2007-12-18 13:51:12 +00:00
|
|
|
g_object_unref (layout);
|
2012-10-15 01:07:46 +00:00
|
|
|
g_object_unref (gtk_renderer);
|
2011-07-10 03:26:59 +00:00
|
|
|
}
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
static gint
|
|
|
|
gtk_text_cell_accessible_get_offset_at_point (AtkText *text,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
AtkCoordType coords)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
AtkObject *parent;
|
2011-07-10 03:26:59 +00:00
|
|
|
GtkRendererCellAccessible *gail_renderer;
|
2007-12-18 13:51:12 +00:00
|
|
|
GtkCellRendererText *gtk_renderer;
|
2010-09-15 19:03:34 +00:00
|
|
|
GtkRequisition min_size;
|
2007-12-18 13:51:12 +00:00
|
|
|
GtkWidget *widget;
|
|
|
|
GdkRectangle rendered_rect;
|
|
|
|
PangoLayout *layout;
|
2010-06-01 19:01:33 +00:00
|
|
|
gchar *renderer_text;
|
2010-11-09 13:15:06 +00:00
|
|
|
gfloat xalign, yalign;
|
2007-12-18 13:51:12 +00:00
|
|
|
gint x_offset, y_offset, index;
|
2010-05-30 20:38:33 +00:00
|
|
|
gint xpad, ypad;
|
2011-07-09 02:03:13 +00:00
|
|
|
gint x_window, y_window, x_toplevel, y_toplevel;
|
|
|
|
gint x_temp, y_temp;
|
|
|
|
gboolean ret;
|
|
|
|
|
2012-10-15 01:21:34 +00:00
|
|
|
if (!GTK_TEXT_CELL_ACCESSIBLE (text)->priv->cell_text)
|
2007-12-18 13:51:12 +00:00
|
|
|
return -1;
|
|
|
|
|
2011-07-09 23:19:38 +00:00
|
|
|
gail_renderer = GTK_RENDERER_CELL_ACCESSIBLE (text);
|
2012-10-15 01:07:46 +00:00
|
|
|
g_object_get (gail_renderer, "renderer", >k_renderer, NULL);
|
2007-12-18 13:51:12 +00:00
|
|
|
parent = atk_object_get_parent (ATK_OBJECT (text));
|
|
|
|
|
2010-06-01 19:01:33 +00:00
|
|
|
g_object_get (gtk_renderer, "text", &renderer_text, NULL);
|
|
|
|
if (text == NULL)
|
|
|
|
{
|
2012-10-15 01:07:46 +00:00
|
|
|
g_object_unref (gtk_renderer);
|
2010-06-01 19:01:33 +00:00
|
|
|
g_free (renderer_text);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-07-09 23:19:38 +00:00
|
|
|
if (GTK_IS_CONTAINER_CELL_ACCESSIBLE (parent))
|
2007-12-18 13:51:12 +00:00
|
|
|
parent = atk_object_get_parent (parent);
|
|
|
|
|
2010-05-22 23:55:33 +00:00
|
|
|
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (parent));
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-07-10 03:56:42 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent), -1);
|
2012-12-27 06:04:46 +00:00
|
|
|
gtk_cell_accessible_parent_get_cell_area (GTK_CELL_ACCESSIBLE_PARENT (parent),
|
|
|
|
GTK_CELL_ACCESSIBLE (text),
|
|
|
|
&rendered_rect);
|
2010-09-15 19:03:34 +00:00
|
|
|
|
2010-09-21 14:52:59 +00:00
|
|
|
gtk_cell_renderer_get_preferred_size (GTK_CELL_RENDERER (gtk_renderer),
|
|
|
|
widget,
|
|
|
|
&min_size, NULL);
|
2010-11-09 13:15:06 +00:00
|
|
|
gtk_cell_renderer_get_alignment (GTK_CELL_RENDERER (gtk_renderer), &xalign, &yalign);
|
|
|
|
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
|
|
|
|
xalign = 1.0 - xalign;
|
2010-11-11 19:09:29 +00:00
|
|
|
x_offset = MAX (0, xalign * (rendered_rect.width - min_size.width));
|
|
|
|
y_offset = MAX (0, yalign * (rendered_rect.height - min_size.height));
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
layout = create_pango_layout (GTK_TEXT_CELL_ACCESSIBLE (text));
|
2010-05-30 20:38:33 +00:00
|
|
|
|
2012-10-15 01:07:46 +00:00
|
|
|
gtk_cell_renderer_get_padding (GTK_CELL_RENDERER (gtk_renderer), &xpad, &ypad);
|
2011-07-09 02:03:13 +00:00
|
|
|
|
|
|
|
get_origins (widget, &x_window, &y_window, &x_toplevel, &y_toplevel);
|
|
|
|
|
|
|
|
x_temp = x - (x_offset + rendered_rect.x + xpad) - x_window;
|
|
|
|
y_temp = y - (y_offset + rendered_rect.y + ypad) - y_window;
|
|
|
|
if (coords == ATK_XY_WINDOW)
|
|
|
|
{
|
2011-07-10 03:26:59 +00:00
|
|
|
x_temp += x_toplevel;
|
2011-07-09 02:03:13 +00:00
|
|
|
y_temp += y_toplevel;
|
|
|
|
}
|
|
|
|
else if (coords != ATK_XY_SCREEN)
|
|
|
|
index = -1;
|
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
ret = pango_layout_xy_to_index (layout,
|
2011-07-09 02:03:13 +00:00
|
|
|
x_temp * PANGO_SCALE,
|
|
|
|
y_temp * PANGO_SCALE,
|
|
|
|
&index, NULL);
|
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
if (x_temp < 0 || y_temp < 0)
|
|
|
|
index = 0;
|
|
|
|
else
|
2011-07-10 03:26:59 +00:00
|
|
|
index = -1;
|
2011-07-09 02:03:13 +00:00
|
|
|
}
|
|
|
|
|
2007-12-18 13:51:12 +00:00
|
|
|
g_object_unref (layout);
|
2012-10-15 01:07:46 +00:00
|
|
|
g_object_unref (gtk_renderer);
|
|
|
|
|
2007-12-18 13:51:12 +00:00
|
|
|
if (index == -1)
|
|
|
|
{
|
|
|
|
if (coords == ATK_XY_WINDOW || coords == ATK_XY_SCREEN)
|
2010-06-01 19:01:33 +00:00
|
|
|
{
|
|
|
|
glong length;
|
|
|
|
|
|
|
|
length = g_utf8_strlen (renderer_text, -1);
|
|
|
|
g_free (renderer_text);
|
|
|
|
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (renderer_text);
|
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
return index;
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
else
|
2010-06-01 19:01:33 +00:00
|
|
|
{
|
|
|
|
glong offset;
|
|
|
|
|
|
|
|
offset = g_utf8_pointer_to_offset (renderer_text,
|
|
|
|
renderer_text + index);
|
|
|
|
g_free (renderer_text);
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
static gunichar
|
|
|
|
gtk_text_cell_accessible_get_character_at_offset (AtkText *text,
|
|
|
|
gint offset)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
|
|
|
gchar *index;
|
|
|
|
gchar *string;
|
|
|
|
|
2012-10-15 01:21:34 +00:00
|
|
|
string = GTK_TEXT_CELL_ACCESSIBLE(text)->priv->cell_text;
|
2007-12-18 13:51:12 +00:00
|
|
|
|
|
|
|
if (!string)
|
|
|
|
return '\0';
|
|
|
|
|
|
|
|
if (offset >= g_utf8_strlen (string, -1))
|
|
|
|
return '\0';
|
|
|
|
|
|
|
|
index = g_utf8_offset_to_pointer (string, offset);
|
|
|
|
|
|
|
|
return g_utf8_get_char (index);
|
|
|
|
}
|
|
|
|
|
2011-07-10 03:26:59 +00:00
|
|
|
static void
|
|
|
|
atk_text_interface_init (AtkTextIface *iface)
|
|
|
|
{
|
|
|
|
iface->get_text = gtk_text_cell_accessible_get_text;
|
|
|
|
iface->get_character_at_offset = gtk_text_cell_accessible_get_character_at_offset;
|
|
|
|
iface->get_text_before_offset = gtk_text_cell_accessible_get_text_before_offset;
|
|
|
|
iface->get_text_at_offset = gtk_text_cell_accessible_get_text_at_offset;
|
|
|
|
iface->get_text_after_offset = gtk_text_cell_accessible_get_text_after_offset;
|
|
|
|
iface->get_character_count = gtk_text_cell_accessible_get_character_count;
|
|
|
|
iface->get_caret_offset = gtk_text_cell_accessible_get_caret_offset;
|
|
|
|
iface->set_caret_offset = gtk_text_cell_accessible_set_caret_offset;
|
|
|
|
iface->get_run_attributes = gtk_text_cell_accessible_get_run_attributes;
|
|
|
|
iface->get_default_attributes = gtk_text_cell_accessible_get_default_attributes;
|
|
|
|
iface->get_character_extents = gtk_text_cell_accessible_get_character_extents;
|
|
|
|
iface->get_offset_at_point = gtk_text_cell_accessible_get_offset_at_point;
|
|
|
|
}
|