Commit 1dc4d2c6 authored by Matthias Clasen's avatar Matthias Clasen

GtkComboBoxAccessible: add a private struct

Move instance fields to a private struct, in preparation
for installing a11y headers.
parent 5226327e
...@@ -20,6 +20,12 @@ ...@@ -20,6 +20,12 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "gtkcomboboxaccessible.h" #include "gtkcomboboxaccessible.h"
struct _GtkComboBoxAccessiblePrivate
{
gchar *name;
gint old_selection;
gboolean popup_set;
};
static void atk_action_interface_init (AtkActionIface *iface); static void atk_action_interface_init (AtkActionIface *iface);
static void atk_selection_interface_init (AtkSelectionIface *iface); static void atk_selection_interface_init (AtkSelectionIface *iface);
...@@ -41,9 +47,9 @@ changed_cb (GtkWidget *widget) ...@@ -41,9 +47,9 @@ changed_cb (GtkWidget *widget)
index = gtk_combo_box_get_active (combo_box); index = gtk_combo_box_get_active (combo_box);
obj = gtk_widget_get_accessible (widget); obj = gtk_widget_get_accessible (widget);
accessible = GTK_COMBO_BOX_ACCESSIBLE (obj); accessible = GTK_COMBO_BOX_ACCESSIBLE (obj);
if (accessible->old_selection != index) if (accessible->priv->old_selection != index)
{ {
accessible->old_selection = index; accessible->priv->old_selection = index;
g_object_notify (G_OBJECT (obj), "accessible-name"); g_object_notify (G_OBJECT (obj), "accessible-name");
g_signal_emit_by_name (obj, "selection-changed"); g_signal_emit_by_name (obj, "selection-changed");
} }
...@@ -63,13 +69,13 @@ gtk_combo_box_accessible_initialize (AtkObject *obj, ...@@ -63,13 +69,13 @@ gtk_combo_box_accessible_initialize (AtkObject *obj,
accessible = GTK_COMBO_BOX_ACCESSIBLE (obj); accessible = GTK_COMBO_BOX_ACCESSIBLE (obj);
g_signal_connect (combo_box, "changed", G_CALLBACK (changed_cb), NULL); g_signal_connect (combo_box, "changed", G_CALLBACK (changed_cb), NULL);
accessible->old_selection = gtk_combo_box_get_active (combo_box); accessible->priv->old_selection = gtk_combo_box_get_active (combo_box);
popup = gtk_combo_box_get_popup_accessible (combo_box); popup = gtk_combo_box_get_popup_accessible (combo_box);
if (popup) if (popup)
{ {
atk_object_set_parent (popup, obj); atk_object_set_parent (popup, obj);
accessible->popup_set = TRUE; accessible->priv->popup_set = TRUE;
} }
if (gtk_combo_box_get_has_entry (combo_box)) if (gtk_combo_box_get_has_entry (combo_box))
atk_object_set_parent (gtk_widget_get_accessible (gtk_bin_get_child (GTK_BIN (combo_box))), obj); atk_object_set_parent (gtk_widget_get_accessible (gtk_bin_get_child (GTK_BIN (combo_box))), obj);
...@@ -82,7 +88,7 @@ gtk_combo_box_accessible_finalize (GObject *object) ...@@ -82,7 +88,7 @@ gtk_combo_box_accessible_finalize (GObject *object)
{ {
GtkComboBoxAccessible *combo_box = GTK_COMBO_BOX_ACCESSIBLE (object); GtkComboBoxAccessible *combo_box = GTK_COMBO_BOX_ACCESSIBLE (object);
g_free (combo_box->name); g_free (combo_box->priv->name);
G_OBJECT_CLASS (_gtk_combo_box_accessible_parent_class)->finalize (object); G_OBJECT_CLASS (_gtk_combo_box_accessible_parent_class)->finalize (object);
} }
...@@ -120,8 +126,8 @@ gtk_combo_box_accessible_get_name (AtkObject *obj) ...@@ -120,8 +126,8 @@ gtk_combo_box_accessible_get_name (AtkObject *obj)
gtk_tree_model_get_value (model, &iter, i, &value); gtk_tree_model_get_value (model, &iter, i, &value);
if (G_VALUE_HOLDS_STRING (&value)) if (G_VALUE_HOLDS_STRING (&value))
{ {
g_free (accessible->name); g_free (accessible->priv->name);
accessible->name = g_strdup (g_value_get_string (&value)); accessible->priv->name = g_strdup (g_value_get_string (&value));
g_value_unset (&value); g_value_unset (&value);
break; break;
} }
...@@ -129,7 +135,7 @@ gtk_combo_box_accessible_get_name (AtkObject *obj) ...@@ -129,7 +135,7 @@ gtk_combo_box_accessible_get_name (AtkObject *obj)
g_value_unset (&value); g_value_unset (&value);
} }
} }
return accessible->name; return accessible->priv->name;
} }
static gint static gint
...@@ -165,10 +171,10 @@ gtk_combo_box_accessible_ref_child (AtkObject *obj, ...@@ -165,10 +171,10 @@ gtk_combo_box_accessible_ref_child (AtkObject *obj,
{ {
child = gtk_combo_box_get_popup_accessible (GTK_COMBO_BOX (widget)); child = gtk_combo_box_get_popup_accessible (GTK_COMBO_BOX (widget));
box = GTK_COMBO_BOX_ACCESSIBLE (obj); box = GTK_COMBO_BOX_ACCESSIBLE (obj);
if (box->popup_set == FALSE) if (!box->priv->popup_set)
{ {
atk_object_set_parent (child, obj); atk_object_set_parent (child, obj);
box->popup_set = TRUE; box->priv->popup_set = TRUE;
} }
} }
else if (i == 1 && gtk_combo_box_get_has_entry (GTK_COMBO_BOX (widget))) else if (i == 1 && gtk_combo_box_get_has_entry (GTK_COMBO_BOX (widget)))
...@@ -195,14 +201,19 @@ _gtk_combo_box_accessible_class_init (GtkComboBoxAccessibleClass *klass) ...@@ -195,14 +201,19 @@ _gtk_combo_box_accessible_class_init (GtkComboBoxAccessibleClass *klass)
class->get_n_children = gtk_combo_box_accessible_get_n_children; class->get_n_children = gtk_combo_box_accessible_get_n_children;
class->ref_child = gtk_combo_box_accessible_ref_child; class->ref_child = gtk_combo_box_accessible_ref_child;
class->initialize = gtk_combo_box_accessible_initialize; class->initialize = gtk_combo_box_accessible_initialize;
g_type_class_add_private (klass, sizeof (GtkComboBoxAccessiblePrivate));
} }
static void static void
_gtk_combo_box_accessible_init (GtkComboBoxAccessible *combo_box) _gtk_combo_box_accessible_init (GtkComboBoxAccessible *combo_box)
{ {
combo_box->old_selection = -1; combo_box->priv = G_TYPE_INSTANCE_GET_PRIVATE (combo_box,
combo_box->name = NULL; GTK_TYPE_COMBO_BOX_ACCESSIBLE,
combo_box->popup_set = FALSE; GtkComboBoxAccessiblePrivate);
combo_box->priv->old_selection = -1;
combo_box->priv->name = NULL;
combo_box->priv->popup_set = FALSE;
} }
static gboolean static gboolean
......
...@@ -29,16 +29,15 @@ G_BEGIN_DECLS ...@@ -29,16 +29,15 @@ G_BEGIN_DECLS
#define GTK_IS_COMBO_BOX_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_COMBO_BOX_ACCESSIBLE)) #define GTK_IS_COMBO_BOX_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_COMBO_BOX_ACCESSIBLE))
#define GTK_COMBO_BOX_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_COMBO_BOX_ACCESSIBLE, GtkComboBoxAccessibleClass)) #define GTK_COMBO_BOX_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_COMBO_BOX_ACCESSIBLE, GtkComboBoxAccessibleClass))
typedef struct _GtkComboBoxAccessible GtkComboBoxAccessible; typedef struct _GtkComboBoxAccessible GtkComboBoxAccessible;
typedef struct _GtkComboBoxAccessibleClass GtkComboBoxAccessibleClass; typedef struct _GtkComboBoxAccessibleClass GtkComboBoxAccessibleClass;
typedef struct _GtkComboBoxAccessiblePrivate GtkComboBoxAccessiblePrivate;
struct _GtkComboBoxAccessible struct _GtkComboBoxAccessible
{ {
GtkContainerAccessible parent; GtkContainerAccessible parent;
gchar *name; GtkComboBoxAccessiblePrivate *priv;
gint old_selection;
gboolean popup_set;
}; };
struct _GtkComboBoxAccessibleClass struct _GtkComboBoxAccessibleClass
......
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