]> Pileus Git - ~andy/gtk/commitdiff
GtkEntryAccessible: add a private struct
authorMatthias Clasen <mclasen@redhat.com>
Sun, 14 Oct 2012 19:59:58 +0000 (15:59 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 14 Oct 2012 19:59:58 +0000 (15:59 -0400)
Move instance fields to a private struct, in preparation
for installing a11y headers.

gtk/a11y/gtkentryaccessible.c
gtk/a11y/gtkentryaccessible.h

index d5339e2750acce09419923fb7d7d4cec755c85be..bac2b02b526ddebb6686453e9a7c057c86de6342 100644 (file)
 #include "gtkentryprivate.h"
 #include "gtkcomboboxaccessible.h"
 
+struct _GtkEntryAccessiblePrivate
+{
+  gint cursor_position;
+  gint selection_bound;
+};
+
 /* Callbacks */
 
 static void     insert_text_cb             (GtkEditable        *editable,
@@ -109,10 +115,9 @@ gtk_entry_accessible_initialize (AtkObject *obj,
   gtk_entry_accessible = GTK_ENTRY_ACCESSIBLE (obj);
 
   entry = GTK_ENTRY (data);
-  gtk_editable_get_selection_bounds (GTK_EDITABLE (entry),
-                                     &start_pos, &end_pos);
-  gtk_entry_accessible->cursor_position = end_pos;
-  gtk_entry_accessible->selection_bound = start_pos;
+  gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start_pos, &end_pos);
+  gtk_entry_accessible->priv->cursor_position = end_pos;
+  gtk_entry_accessible->priv->selection_bound = start_pos;
 
   /* Set up signal callbacks */
   g_signal_connect (entry, "insert-text", G_CALLBACK (insert_text_cb), NULL);
@@ -146,7 +151,7 @@ gtk_entry_accessible_notify_gtk (GObject    *obj,
        * The entry cursor position has moved so generate the signal.
        */
       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)
     {
@@ -199,13 +204,18 @@ _gtk_entry_accessible_class_init (GtkEntryAccessibleClass *klass)
   class->get_attributes = gtk_entry_accessible_get_attributes;
 
   widget_class->notify_gtk = gtk_entry_accessible_notify_gtk;
+
+  g_type_class_add_private (klass, sizeof (GtkEntryAccessiblePrivate));
 }
 
 static void
 _gtk_entry_accessible_init (GtkEntryAccessible *entry)
 {
-  entry->cursor_position = 0;
-  entry->selection_bound = 0;
+  entry->priv = G_TYPE_INSTANCE_GET_PRIVATE (entry,
+                                             GTK_TYPE_ENTRY_ACCESSIBLE,
+                                             GtkEntryAccessiblePrivate);
+  entry->priv->cursor_position = 0;
+  entry->priv->selection_bound = 0;
 }
 
 static gchar *
@@ -889,8 +899,8 @@ check_for_selection_change (GtkEntryAccessible *accessible,
 
   if (gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start, &end))
     {
-      if (end != accessible->cursor_position ||
-          start != accessible->selection_bound)
+      if (end != accessible->priv->cursor_position ||
+          start != accessible->priv->selection_bound)
         /*
          * This check is here as this function can be called
          * for notification of selection_bound and current_pos.
@@ -903,11 +913,11 @@ check_for_selection_change (GtkEntryAccessible *accessible,
   else
     {
       /* 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->selection_bound = start;
+  accessible->priv->cursor_position = end;
+  accessible->priv->selection_bound = start;
 
   return ret_val;
 }
index ec9dbc71a6bdc7320608c496bc1a910f3aa181a5..1883cc5a9c5eeb89aab47fad4981555ab4b55e82 100644 (file)
@@ -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_ENTRY_ACCESSIBLE_GET_CLASS(obj)            (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ENTRY_ACCESSIBLE, GtkEntryAccessibleClass))
 
-typedef struct _GtkEntryAccessible      GtkEntryAccessible;
-typedef struct _GtkEntryAccessibleClass GtkEntryAccessibleClass;
+typedef struct _GtkEntryAccessible        GtkEntryAccessible;
+typedef struct _GtkEntryAccessibleClass   GtkEntryAccessibleClass;
+typedef struct _GtkEntryAccessiblePrivate GtkEntryAccessiblePrivate;
 
 struct _GtkEntryAccessible
 {
   GtkWidgetAccessible parent;
 
-  gint cursor_position;
-  gint selection_bound;
+  GtkEntryAccessiblePrivate *priv;
 };
 
 struct _GtkEntryAccessibleClass