Commit 4745adae authored by Matthias Clasen's avatar Matthias Clasen

GtkEntryAccessible: add a private struct

Move instance fields to a private struct, in preparation
for installing a11y headers.
parent 0ad37970
...@@ -23,6 +23,12 @@ ...@@ -23,6 +23,12 @@
#include "gtkentryprivate.h" #include "gtkentryprivate.h"
#include "gtkcomboboxaccessible.h" #include "gtkcomboboxaccessible.h"
struct _GtkEntryAccessiblePrivate
{
gint cursor_position;
gint selection_bound;
};
/* Callbacks */ /* Callbacks */
static void insert_text_cb (GtkEditable *editable, static void insert_text_cb (GtkEditable *editable,
...@@ -109,10 +115,9 @@ gtk_entry_accessible_initialize (AtkObject *obj, ...@@ -109,10 +115,9 @@ gtk_entry_accessible_initialize (AtkObject *obj,
gtk_entry_accessible = GTK_ENTRY_ACCESSIBLE (obj); gtk_entry_accessible = GTK_ENTRY_ACCESSIBLE (obj);
entry = GTK_ENTRY (data); entry = GTK_ENTRY (data);
gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start_pos, &end_pos);
&start_pos, &end_pos); gtk_entry_accessible->priv->cursor_position = end_pos;
gtk_entry_accessible->cursor_position = end_pos; gtk_entry_accessible->priv->selection_bound = start_pos;
gtk_entry_accessible->selection_bound = start_pos;
/* Set up signal callbacks */ /* Set up signal callbacks */
g_signal_connect (entry, "insert-text", G_CALLBACK (insert_text_cb), NULL); g_signal_connect (entry, "insert-text", G_CALLBACK (insert_text_cb), NULL);
...@@ -146,7 +151,7 @@ gtk_entry_accessible_notify_gtk (GObject *obj, ...@@ -146,7 +151,7 @@ gtk_entry_accessible_notify_gtk (GObject *obj,
* The entry cursor position has moved so generate the signal. * The entry cursor position has moved so generate the signal.
*/ */
g_signal_emit_by_name (atk_obj, "text-caret-moved", g_signal_emit_by_name (atk_obj, "text-caret-moved",
entry->cursor_position); entry->priv->cursor_position);
} }
else if (g_strcmp0 (pspec->name, "selection-bound") == 0) else if (g_strcmp0 (pspec->name, "selection-bound") == 0)
{ {
...@@ -199,13 +204,18 @@ _gtk_entry_accessible_class_init (GtkEntryAccessibleClass *klass) ...@@ -199,13 +204,18 @@ _gtk_entry_accessible_class_init (GtkEntryAccessibleClass *klass)
class->get_attributes = gtk_entry_accessible_get_attributes; class->get_attributes = gtk_entry_accessible_get_attributes;
widget_class->notify_gtk = gtk_entry_accessible_notify_gtk; widget_class->notify_gtk = gtk_entry_accessible_notify_gtk;
g_type_class_add_private (klass, sizeof (GtkEntryAccessiblePrivate));
} }
static void static void
_gtk_entry_accessible_init (GtkEntryAccessible *entry) _gtk_entry_accessible_init (GtkEntryAccessible *entry)
{ {
entry->cursor_position = 0; entry->priv = G_TYPE_INSTANCE_GET_PRIVATE (entry,
entry->selection_bound = 0; GTK_TYPE_ENTRY_ACCESSIBLE,
GtkEntryAccessiblePrivate);
entry->priv->cursor_position = 0;
entry->priv->selection_bound = 0;
} }
static gchar * static gchar *
...@@ -889,8 +899,8 @@ check_for_selection_change (GtkEntryAccessible *accessible, ...@@ -889,8 +899,8 @@ check_for_selection_change (GtkEntryAccessible *accessible,
if (gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start, &end)) if (gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start, &end))
{ {
if (end != accessible->cursor_position || if (end != accessible->priv->cursor_position ||
start != accessible->selection_bound) start != accessible->priv->selection_bound)
/* /*
* This check is here as this function can be called * This check is here as this function can be called
* for notification of selection_bound and current_pos. * for notification of selection_bound and current_pos.
...@@ -903,11 +913,11 @@ check_for_selection_change (GtkEntryAccessible *accessible, ...@@ -903,11 +913,11 @@ check_for_selection_change (GtkEntryAccessible *accessible,
else else
{ {
/* We had a selection */ /* We had a selection */
ret_val = (accessible->cursor_position != accessible->selection_bound); ret_val = (accessible->priv->cursor_position != accessible->priv->selection_bound);
} }
accessible->cursor_position = end; accessible->priv->cursor_position = end;
accessible->selection_bound = start; accessible->priv->selection_bound = start;
return ret_val; return ret_val;
} }
......
...@@ -29,15 +29,15 @@ G_BEGIN_DECLS ...@@ -29,15 +29,15 @@ G_BEGIN_DECLS
#define GTK_IS_ENTRY_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ENTRY_ACCESSIBLE)) #define GTK_IS_ENTRY_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ENTRY_ACCESSIBLE))
#define GTK_ENTRY_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ENTRY_ACCESSIBLE, GtkEntryAccessibleClass)) #define GTK_ENTRY_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ENTRY_ACCESSIBLE, GtkEntryAccessibleClass))
typedef struct _GtkEntryAccessible GtkEntryAccessible; typedef struct _GtkEntryAccessible GtkEntryAccessible;
typedef struct _GtkEntryAccessibleClass GtkEntryAccessibleClass; typedef struct _GtkEntryAccessibleClass GtkEntryAccessibleClass;
typedef struct _GtkEntryAccessiblePrivate GtkEntryAccessiblePrivate;
struct _GtkEntryAccessible struct _GtkEntryAccessible
{ {
GtkWidgetAccessible parent; GtkWidgetAccessible parent;
gint cursor_position; GtkEntryAccessiblePrivate *priv;
gint selection_bound;
}; };
struct _GtkEntryAccessibleClass struct _GtkEntryAccessibleClass
......
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