summaryrefslogtreecommitdiff
path: root/gtk/gtkswitch.c
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@linux.intel.com>2010-11-29 13:43:53 +0000
committerEmmanuele Bassi <ebassi@linux.intel.com>2010-11-29 14:06:02 +0000
commit1f71d641e8c4a0e8315e8ff7105769b9a4d20ded (patch)
tree1f939a384a291abfc538ed68840361147585dabf /gtk/gtkswitch.c
parent9ad31a5a2117f8fb0c24b0ff4afc41a1daf26118 (diff)
downloadgtk+-1f71d641e8c4a0e8315e8ff7105769b9a4d20ded.tar.gz
switch: Use ATK macros to reduce the amount of code
And the insanity. Reviewed-by: Christian Persch <chpe@gnome.org>
Diffstat (limited to 'gtk/gtkswitch.c')
-rw-r--r--gtk/gtkswitch.c60
1 files changed, 14 insertions, 46 deletions
diff --git a/gtk/gtkswitch.c b/gtk/gtkswitch.c
index a73e25bd9e..58e1f4ffec 100644
--- a/gtk/gtkswitch.c
+++ b/gtk/gtkswitch.c
@@ -904,7 +904,11 @@ gtk_switch_activatable_interface_init (GtkActivatableIface *iface)
/* accessibility: object */
-static AtkObjectClass *a11y_parent_class = NULL;
+/* dummy typedefs */
+typedef struct _GtkSwitchAccessible GtkSwitchAccessible;
+typedef struct _GtkSwitchAccessibleClass GtkSwitchAccessibleClass;
+
+ATK_DEFINE_TYPE (GtkSwitchAccessible, gtk_switch_accessible, GTK_TYPE_WIDGET);
static AtkStateSet *
gtk_switch_accessible_ref_state_set (AtkObject *accessible)
@@ -912,7 +916,7 @@ gtk_switch_accessible_ref_state_set (AtkObject *accessible)
AtkStateSet *state_set;
GtkWidget *widget;
- state_set = a11y_parent_class->ref_state_set (accessible);
+ state_set = ATK_OBJECT_CLASS (gtk_switch_accessible_parent_class)->ref_state_set (accessible);
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
if (widget == NULL)
@@ -928,7 +932,7 @@ static void
gtk_switch_accessible_initialize (AtkObject *accessible,
gpointer widget)
{
- a11y_parent_class->initialize (accessible, widget);
+ ATK_OBJECT_CLASS (gtk_switch_accessible_parent_class)->initialize (accessible, widget);
atk_object_set_role (accessible, ATK_ROLE_TOGGLE_BUTTON);
atk_object_set_name (accessible, C_("light switch widget", "Switch"));
@@ -936,55 +940,19 @@ gtk_switch_accessible_initialize (AtkObject *accessible,
}
static void
-gtk_switch_accessible_class_init (AtkObjectClass *klass)
+gtk_switch_accessible_class_init (GtkSwitchAccessibleClass *klass)
{
- a11y_parent_class = g_type_class_peek_parent (klass);
+ AtkObjectClass *atk_class = ATK_OBJECT_CLASS (klass);
- klass->initialize = gtk_switch_accessible_initialize;
- klass->ref_state_set = gtk_switch_accessible_ref_state_set;
+ atk_class->initialize = gtk_switch_accessible_initialize;
+ atk_class->ref_state_set = gtk_switch_accessible_ref_state_set;
}
-static GType
-gtk_switch_accessible_get_type (void)
+static void
+gtk_switch_accessible_init (GtkSwitchAccessible *self)
{
- static GType type = 0;
-
- /* Action interface
- Name etc. ... */
- if (G_UNLIKELY (type == 0))
- {
- GType parent_atk_type;
- GTypeInfo tinfo = { 0 };
- GTypeQuery query;
- AtkObjectFactory *factory;
-
- if ((type = g_type_from_name ("GtkSwitchAccessible")) != G_TYPE_INVALID)
- return type;
-
- /* we inherit from the same ATK factory that provides support
- * for GtkWidget; if Gail is being used then this means GailWidget.
- */
- factory = atk_registry_get_factory (atk_get_default_registry (), GTK_TYPE_WIDGET);
- if (factory == NULL)
- return G_TYPE_INVALID;
-
- parent_atk_type = atk_object_factory_get_accessible_type (factory);
- if (parent_atk_type == G_TYPE_INVALID)
- return G_TYPE_INVALID;
-
- g_type_query (parent_atk_type, &query);
-
- tinfo.class_init = (GClassInitFunc) gtk_switch_accessible_class_init;
- tinfo.class_size = query.class_size;
- tinfo.instance_size = query.instance_size;
-
- type = g_type_register_static (parent_atk_type,
- I_("GtkSwitchAccessible"),
- &tinfo, 0);
- }
-
- return type;
}
+
/* accessibility: factory */
typedef AtkObjectFactoryClass GtkSwitchAccessibleFactoryClass;