Commit d13b70f7 authored by Matthias Clasen's avatar Matthias Clasen

GtkTextCellAccessible: add a private struct

Move instance fields to a private struct, in preparation
for installing a11y headers.
parent 8b667e00
......@@ -23,6 +23,13 @@
#include "gtkcontainercellaccessible.h"
#include "gtkcellaccessibleparent.h"
struct _GtkTextCellAccessiblePrivate
{
gchar *cell_text;
gint caret_pos;
gint cell_length;
};
static const gchar* gtk_text_cell_accessible_get_name (AtkObject *atk_obj);
......@@ -102,7 +109,7 @@ gtk_text_cell_accessible_finalize (GObject *object)
{
GtkTextCellAccessible *text_cell = GTK_TEXT_CELL_ACCESSIBLE (object);
g_free (text_cell->cell_text);
g_free (text_cell->priv->cell_text);
G_OBJECT_CLASS (_gtk_text_cell_accessible_parent_class)->finalize (object);
}
......@@ -115,7 +122,7 @@ gtk_text_cell_accessible_get_name (AtkObject *atk_obj)
if (atk_obj->name)
return atk_obj->name;
return text_cell->cell_text;
return text_cell->priv->cell_text;
}
static void
......@@ -129,19 +136,17 @@ gtk_text_cell_accessible_update_cache (GtkCellAccessible *cell)
GtkCellRenderer *renderer;
g_object_get (cell, "renderer", &renderer, NULL);
g_object_get (renderer,
"text", &text,
NULL);
g_object_get (renderer, "text", &text, NULL);
g_object_unref (renderer);
if (text_cell->cell_text)
if (text_cell->priv->cell_text)
{
if (text == NULL || g_strcmp0 (text_cell->cell_text, text) != 0)
if (text == NULL || g_strcmp0 (text_cell->priv->cell_text, text) != 0)
{
g_free (text_cell->cell_text);
temp_length = text_cell->cell_length;
text_cell->cell_text = NULL;
text_cell->cell_length = 0;
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;
g_signal_emit_by_name (cell, "text-changed::delete", 0, temp_length);
if (obj->name == NULL)
g_object_notify (G_OBJECT (obj), "accessible-name");
......@@ -156,13 +161,13 @@ gtk_text_cell_accessible_update_cache (GtkCellAccessible *cell)
{
if (text == NULL)
{
text_cell->cell_text = g_strdup ("");
text_cell->cell_length = 0;
text_cell->priv->cell_text = g_strdup ("");
text_cell->priv->cell_length = 0;
}
else
{
text_cell->cell_text = g_strdup (text);
text_cell->cell_length = g_utf8_strlen (text, -1);
text_cell->priv->cell_text = g_strdup (text);
text_cell->priv->cell_length = g_utf8_strlen (text, -1);
}
}
......@@ -171,7 +176,7 @@ gtk_text_cell_accessible_update_cache (GtkCellAccessible *cell)
if (rv)
{
g_signal_emit_by_name (cell, "text-changed::insert",
0, text_cell->cell_length);
0, text_cell->priv->cell_length);
if (obj->name == NULL)
g_object_notify (G_OBJECT (obj), "accessible-name");
......@@ -191,14 +196,16 @@ _gtk_text_cell_accessible_class_init (GtkTextCellAccessibleClass *klass)
atk_object_class->ref_state_set = gtk_text_cell_accessible_ref_state_set;
gobject_class->finalize = gtk_text_cell_accessible_finalize;
g_type_class_add_private (klass, sizeof (GtkTextCellAccessiblePrivate));
}
static void
_gtk_text_cell_accessible_init (GtkTextCellAccessible *text_cell)
{
text_cell->cell_text = NULL;
text_cell->caret_pos = 0;
text_cell->cell_length = 0;
text_cell->priv = G_TYPE_INSTANCE_GET_PRIVATE (text_cell,
GTK_TYPE_TEXT_CELL_ACCESSIBLE,
GtkTextCellAccessiblePrivate);
}
static gchar *
......@@ -208,7 +215,7 @@ gtk_text_cell_accessible_get_text (AtkText *atk_text,
{
gchar *text;
text = GTK_TEXT_CELL_ACCESSIBLE (atk_text)->cell_text;
text = GTK_TEXT_CELL_ACCESSIBLE (atk_text)->priv->cell_text;
if (text)
return g_utf8_substring (text, start_pos, end_pos > -1 ? end_pos : g_utf8_strlen (text, -1));
else
......@@ -269,8 +276,8 @@ gtk_text_cell_accessible_get_text_after_offset (AtkText *atk_text,
static gint
gtk_text_cell_accessible_get_character_count (AtkText *text)
{
if (GTK_TEXT_CELL_ACCESSIBLE (text)->cell_text != NULL)
return GTK_TEXT_CELL_ACCESSIBLE (text)->cell_length;
if (GTK_TEXT_CELL_ACCESSIBLE (text)->priv->cell_text != NULL)
return GTK_TEXT_CELL_ACCESSIBLE (text)->priv->cell_length;
else
return 0;
}
......@@ -278,7 +285,7 @@ gtk_text_cell_accessible_get_character_count (AtkText *text)
static gint
gtk_text_cell_accessible_get_caret_offset (AtkText *text)
{
return GTK_TEXT_CELL_ACCESSIBLE (text)->caret_pos;
return GTK_TEXT_CELL_ACCESSIBLE (text)->priv->caret_pos;
}
static gboolean
......@@ -287,16 +294,16 @@ gtk_text_cell_accessible_set_caret_offset (AtkText *text,
{
GtkTextCellAccessible *text_cell = GTK_TEXT_CELL_ACCESSIBLE (text);
if (text_cell->cell_text == NULL)
if (text_cell->priv->cell_text == NULL)
return FALSE;
else
{
/* Only set the caret within the bounds and if it is to a new position. */
if (offset >= 0 &&
offset <= text_cell->cell_length &&
offset != text_cell->caret_pos)
offset <= text_cell->priv->cell_length &&
offset != text_cell->priv->caret_pos)
{
text_cell->caret_pos = offset;
text_cell->priv->caret_pos = offset;
/* emit the signal */
g_signal_emit_by_name (text, "text-caret-moved", offset);
......@@ -532,12 +539,12 @@ gtk_text_cell_accessible_get_character_extents (AtkText *text,
gint xpad, ypad;
gint x_window, y_window, x_toplevel, y_toplevel;
if (!GTK_TEXT_CELL_ACCESSIBLE (text)->cell_text)
if (!GTK_TEXT_CELL_ACCESSIBLE (text)->priv->cell_text)
{
*x = *y = *height = *width = 0;
return;
}
if (offset < 0 || offset >= GTK_TEXT_CELL_ACCESSIBLE (text)->cell_length)
if (offset < 0 || offset >= GTK_TEXT_CELL_ACCESSIBLE (text)->priv->cell_length)
{
*x = *y = *height = *width = 0;
return;
......@@ -624,7 +631,7 @@ gtk_text_cell_accessible_get_offset_at_point (AtkText *text,
gint x_temp, y_temp;
gboolean ret;
if (!GTK_TEXT_CELL_ACCESSIBLE (text)->cell_text)
if (!GTK_TEXT_CELL_ACCESSIBLE (text)->priv->cell_text)
return -1;
gail_renderer = GTK_RENDERER_CELL_ACCESSIBLE (text);
......@@ -724,7 +731,7 @@ gtk_text_cell_accessible_get_character_at_offset (AtkText *text,
gchar *index;
gchar *string;
string = GTK_TEXT_CELL_ACCESSIBLE(text)->cell_text;
string = GTK_TEXT_CELL_ACCESSIBLE(text)->priv->cell_text;
if (!string)
return '\0';
......
......@@ -30,15 +30,15 @@ G_BEGIN_DECLS
#define GTK_IS_TEXT_CELL_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEXT_CELL_ACCESSIBLE))
#define GTK_TEXT_CELL_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TEXT_CELL_ACCESSIBLE, GtkTextCellAccessibleClass))
typedef struct _GtkTextCellAccessible GtkTextCellAccessible;
typedef struct _GtkTextCellAccessibleClass GtkTextCellAccessibleClass;
typedef struct _GtkTextCellAccessible GtkTextCellAccessible;
typedef struct _GtkTextCellAccessibleClass GtkTextCellAccessibleClass;
typedef struct _GtkTextCellAccessiblePrivate GtkTextCellAccessiblePrivate;
struct _GtkTextCellAccessible
{
GtkRendererCellAccessible parent;
gchar *cell_text;
gint caret_pos;
gint cell_length;
GtkTextCellAccessiblePrivate *priv;
};
struct _GtkTextCellAccessibleClass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment