]> Pileus Git - ~andy/gtk/commitdiff
Convert GailRadioButton to GtkRadioButtonAccessible
authorMatthias Clasen <mclasen@redhat.com>
Tue, 28 Jun 2011 03:24:22 +0000 (23:24 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 5 Jul 2011 20:08:54 +0000 (16:08 -0400)
gtk/a11y/Makefile.am
gtk/a11y/gail.c
gtk/a11y/gailradiobutton.c [deleted file]
gtk/a11y/gailradiobutton.h [deleted file]
gtk/a11y/gtkradiobuttonaccessible.c [new file with mode: 0644]
gtk/a11y/gtkradiobuttonaccessible.h [new file with mode: 0644]
gtk/gtkradiobutton.c

index 1756bef44928b2b45dbd5882043bb93e96eb8278..71defa0786a5f0ee0f8c3f418d9681c27530754a 100644 (file)
@@ -31,7 +31,7 @@ gail_c_sources =                      \
        gailnotebookpage.c              \
        gtkpanedaccessible.c            \
        gtkprogressbaraccessible.c      \
-       gailradiobutton.c               \
+       gtkradiobuttonaccessible.c      \
        gailradiomenuitem.c             \
        gailradiosubmenuitem.c          \
        gtkrangeaccessible.c            \
@@ -83,7 +83,7 @@ gail_private_h_sources =              \
        gailnotebookpage.h              \
        gtkpanedaccessible.h            \
        gtkprogressbaraccessible.h      \
-       gailradiobutton.h               \
+       gtkradiobuttonaccessible.h      \
        gailradiomenuitem.h             \
        gailradiosubmenuitem.h          \
        gtkrangeaccessible.h            \
index 3c4e13bc195ceb42b207c63ec583e67b9fa0cd9d..fcc27dc4ff08711e01182e1e84c026f695ec6110 100644 (file)
@@ -37,7 +37,6 @@
 #include "gailmenushell.h"
 #include "gailmenuitem.h"
 #include "gailnotebook.h"
-#include "gailradiobutton.h"
 #include "gailradiomenuitem.h"
 #include "gailrenderercell.h"
 #include "gailscalebutton.h"
@@ -110,7 +109,6 @@ GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_SCALE_BUTTON, GailScaleButton, gail_scale_butt
 GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_STATUSBAR, GailStatusbar, gail_statusbar, GTK_TYPE_STATUSBAR)
 GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_NOTEBOOK, GailNotebook, gail_notebook, GTK_TYPE_NOTEBOOK)
 GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_TREE_VIEW, GailTreeView, gail_tree_view, GTK_TYPE_TREE_VIEW)
-GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_RADIO_BUTTON, GailRadioButton, gail_radio_button, GTK_TYPE_RADIO_BUTTON)
 GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_SCROLLED_WINDOW, GailScrolledWindow, gail_scrolled_window, GTK_TYPE_SCROLLED_WINDOW)
 GAIL_IMPLEMENT_FACTORY_WITH_FUNC (GAIL_TYPE_CHECK_MENU_ITEM, GailCheckMenuItem, gail_check_menu_item, gail_check_menu_item_new)
 GAIL_IMPLEMENT_FACTORY_WITH_FUNC (GAIL_TYPE_RADIO_MENU_ITEM, GailRadioMenuItem, gail_radio_menu_item, gail_radio_menu_item_new)
@@ -876,7 +874,6 @@ gail_accessibility_module_init (void)
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CELL_RENDERER_TOGGLE, gail_boolean_cell);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CELL_RENDERER_PIXBUF, gail_image_cell);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CELL_RENDERER, gail_renderer_cell);
-  GAIL_WIDGET_SET_FACTORY (GTK_TYPE_RADIO_BUTTON, gail_radio_button);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_SCROLLED_WINDOW, gail_scrolled_window);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CHECK_MENU_ITEM, gail_check_menu_item);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_RADIO_MENU_ITEM, gail_radio_menu_item);
diff --git a/gtk/a11y/gailradiobutton.c b/gtk/a11y/gailradiobutton.c
deleted file mode 100644 (file)
index 46b85a0..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-/* GAIL - The GNOME Accessibility Implementation Library
- * Copyright 2001 Sun Microsystems Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include "config.h"
-
-#include <gtk/gtk.h>
-#include "gailradiobutton.h"
-
-static void      gail_radio_button_class_init        (GailRadioButtonClass *klass);
-static void      gail_radio_button_init              (GailRadioButton      *radio_button);
-static void      gail_radio_button_initialize        (AtkObject            *accessible,
-                                                      gpointer              data);
-
-static AtkRelationSet* gail_radio_button_ref_relation_set (AtkObject       *obj);
-
-G_DEFINE_TYPE (GailRadioButton, gail_radio_button, GAIL_TYPE_TOGGLE_BUTTON)
-
-static void
-gail_radio_button_class_init (GailRadioButtonClass *klass)
-{
-  AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
-
-  class->initialize = gail_radio_button_initialize;
-  class->ref_relation_set = gail_radio_button_ref_relation_set;
-}
-
-static void
-gail_radio_button_init (GailRadioButton *radio_button)
-{
-  radio_button->old_group = NULL;
-}
-
-static void
-gail_radio_button_initialize (AtkObject *accessible,
-                              gpointer  data)
-{
-  ATK_OBJECT_CLASS (gail_radio_button_parent_class)->initialize (accessible, data);
-
-  accessible->role = ATK_ROLE_RADIO_BUTTON;
-}
-
-AtkRelationSet*
-gail_radio_button_ref_relation_set (AtkObject *obj)
-{
-  GtkWidget *widget;
-  AtkRelationSet *relation_set;
-  GSList *list;
-  GailRadioButton *radio_button;
-
-  g_return_val_if_fail (GAIL_IS_RADIO_BUTTON (obj), NULL);
-
-  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
-  if (widget == NULL)
-  {
-    /*
-     * State is defunct
-     */
-    return NULL;
-  }
-  radio_button = GAIL_RADIO_BUTTON (obj);
-
-  relation_set = ATK_OBJECT_CLASS (gail_radio_button_parent_class)->ref_relation_set (obj);
-
-  /*
-   * If the radio button'group has changed remove the relation
-   */
-  list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
-  
-  if (radio_button->old_group != list)
-    {
-      AtkRelation *relation;
-
-      relation = atk_relation_set_get_relation_by_type (relation_set, ATK_RELATION_MEMBER_OF);
-      atk_relation_set_remove (relation_set, relation);
-    }
-
-  if (!atk_relation_set_contains (relation_set, ATK_RELATION_MEMBER_OF))
-  {
-    /*
-     * Get the members of the button group
-     */
-
-    radio_button->old_group = list;
-    if (list)
-    {
-      AtkObject **accessible_array;
-      guint list_length;
-      AtkRelation* relation;
-      gint i = 0;
-
-      list_length = g_slist_length (list);
-      accessible_array = (AtkObject**) g_malloc (sizeof (AtkObject *) * 
-                          list_length);
-      while (list != NULL)
-      {
-        GtkWidget* list_item = list->data;
-
-        accessible_array[i++] = gtk_widget_get_accessible (list_item);
-
-        list = list->next;
-      }
-      relation = atk_relation_new (accessible_array, list_length,
-                                   ATK_RELATION_MEMBER_OF);
-      g_free (accessible_array);
-
-      atk_relation_set_add (relation_set, relation);
-      /*
-       * Unref the relation so that it is not leaked.
-       */
-      g_object_unref (relation);
-    }
-  }
-  return relation_set;
-}
diff --git a/gtk/a11y/gailradiobutton.h b/gtk/a11y/gailradiobutton.h
deleted file mode 100644 (file)
index 1615e44..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/* GAIL - The GNOME Accessibility Implementation Library
- * Copyright 2001 Sun Microsystems Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __GAIL_RADIO_BUTTON_H__
-#define __GAIL_RADIO_BUTTON_H__
-
-#include "gailtogglebutton.h"
-
-G_BEGIN_DECLS
-
-#define GAIL_TYPE_RADIO_BUTTON               (gail_radio_button_get_type ())
-#define GAIL_RADIO_BUTTON(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_RADIO_BUTTON, GailRadioButton))
-#define GAIL_RADIO_BUTTON_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_RADIO_BUTTON, GailRadioButtonClass))
-#define GAIL_IS_RADIO_BUTTON(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_RADIO_BUTTON))
-#define GAIL_IS_RADIO_BUTTON_CLASS(klass)    (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_RADIO_BUTTON))
-#define GAIL_RADIO_BUTTON_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_RADIO_BUTTON, GailRadioButtonClass))
-
-typedef struct _GailRadioButton              GailRadioButton;
-typedef struct _GailRadioButtonClass         GailRadioButtonClass;
-
-struct _GailRadioButton
-{
-  GailToggleButton parent;
-
-  GSList *old_group;
-};
-
-GType gail_radio_button_get_type (void);
-
-struct _GailRadioButtonClass
-{
-  GailToggleButtonClass parent_class;
-};
-
-G_END_DECLS
-
-#endif /* __GAIL_RADIO_BUTTON_H__ */
diff --git a/gtk/a11y/gtkradiobuttonaccessible.c b/gtk/a11y/gtkradiobuttonaccessible.c
new file mode 100644 (file)
index 0000000..50e99b3
--- /dev/null
@@ -0,0 +1,116 @@
+/* GAIL - The GNOME Accessibility Implementation Library
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+#include "gtkradiobuttonaccessible.h"
+
+
+G_DEFINE_TYPE (GtkRadioButtonAccessible, gtk_radio_button_accessible, GAIL_TYPE_TOGGLE_BUTTON)
+
+static void
+gtk_radio_button_accessible_initialize (AtkObject *accessible,
+                                        gpointer   data)
+{
+  ATK_OBJECT_CLASS (gtk_radio_button_accessible_parent_class)->initialize (accessible, data);
+
+  accessible->role = ATK_ROLE_RADIO_BUTTON;
+}
+
+static AtkRelationSet *
+gtk_radio_button_accessible_ref_relation_set (AtkObject *obj)
+{
+  GtkWidget *widget;
+  AtkRelationSet *relation_set;
+  GSList *list;
+  GtkRadioButtonAccessible *radio_button;
+
+  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
+  if (widget == NULL)
+    return NULL;
+
+  radio_button = GTK_RADIO_BUTTON_ACCESSIBLE (obj);
+
+  relation_set = ATK_OBJECT_CLASS (gtk_radio_button_accessible_parent_class)->ref_relation_set (obj);
+
+  /* If the radio button'group has changed remove the relation */
+  list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
+
+  if (radio_button->old_group != list)
+    {
+      AtkRelation *relation;
+
+      relation = atk_relation_set_get_relation_by_type (relation_set, ATK_RELATION_MEMBER_OF);
+      atk_relation_set_remove (relation_set, relation);
+    }
+
+  if (!atk_relation_set_contains (relation_set, ATK_RELATION_MEMBER_OF))
+  {
+    /*
+     * Get the members of the button group
+     */
+    radio_button->old_group = list;
+    if (list)
+      {
+        AtkObject **accessible_array;
+        guint list_length;
+        AtkRelation* relation;
+        gint i = 0;
+
+        list_length = g_slist_length (list);
+        accessible_array = g_new (AtkObject *, list_length);
+        while (list != NULL)
+          {
+            GtkWidget* list_item = list->data;
+
+            accessible_array[i++] = gtk_widget_get_accessible (list_item);
+
+            list = list->next;
+          }
+        relation = atk_relation_new (accessible_array, list_length,
+                                     ATK_RELATION_MEMBER_OF);
+        g_free (accessible_array);
+
+        atk_relation_set_add (relation_set, relation);
+        /*
+         * Unref the relation so that it is not leaked.
+         */
+        g_object_unref (relation);
+      }
+    }
+
+  return relation_set;
+}
+
+static void
+gtk_radio_button_accessible_class_init (GtkRadioButtonAccessibleClass *klass)
+{
+  AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+
+  class->initialize = gtk_radio_button_accessible_initialize;
+  class->ref_relation_set = gtk_radio_button_accessible_ref_relation_set;
+}
+
+static void
+gtk_radio_button_accessible_init (GtkRadioButtonAccessible *radio_button)
+{
+  radio_button->old_group = NULL;
+}
+
diff --git a/gtk/a11y/gtkradiobuttonaccessible.h b/gtk/a11y/gtkradiobuttonaccessible.h
new file mode 100644 (file)
index 0000000..44f47c5
--- /dev/null
@@ -0,0 +1,53 @@
+/* GAIL - The GNOME Accessibility Implementation Library
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GTK_RADIO_BUTTON_ACCESSIBLE_H__
+#define __GTK_RADIO_BUTTON_ACCESSIBLE_H__
+
+#include "gailtogglebutton.h"
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_RADIO_BUTTON_ACCESSIBLE               (gtk_radio_button_accessible_get_type ())
+#define GTK_RADIO_BUTTON_ACCESSIBLE(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_RADIO_BUTTON_ACCESSIBLE, GtkRadioButtonAccessible))
+#define GTK_RADIO_BUTTON_ACCESSIBLE_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_RADIO_BUTTON_ACCESSIBLE, GtkRadioButtonAccessibleClass))
+#define GTK_IS_RADIO_BUTTON_ACCESSIBLE(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_RADIO_BUTTON_ACCESSIBLE))
+#define GTK_IS_RADIO_BUTTON_ACCESSIBLE_CLASS(klass)    (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_RADIO_BUTTON_ACCESSIBLE))
+#define GTK_RADIO_BUTTON_ACCESSIBLE_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RADIO_BUTTON_ACCESSIBLE, GtkRadioButtonAccessibleClass))
+
+typedef struct _GtkRadioButtonAccessible      GtkRadioButtonAccessible;
+typedef struct _GtkRadioButtonAccessibleClass GtkRadioButtonAccessibleClass;
+
+struct _GtkRadioButtonAccessible
+{
+  GailToggleButton parent;
+
+  GSList *old_group;
+};
+
+struct _GtkRadioButtonAccessibleClass
+{
+  GailToggleButtonClass parent_class;
+};
+
+GType gtk_radio_button_accessible_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GTK_RADIO_BUTTON_ACCESSIBLE_H__ */
index b080dc29f9ade42794f34a477644a31f0ae080d5..cb1ba20d55f142a5a22096ab8dedeef987954073 100644 (file)
@@ -33,6 +33,7 @@
 #include "gtkmarshalers.h"
 #include "gtkprivate.h"
 #include "gtkintl.h"
+#include "a11y/gtkradiobuttonaccessible.h"
 
 /**
  * SECTION:gtkradiobutton
@@ -195,6 +196,8 @@ gtk_radio_button_class_init (GtkRadioButtonClass *class)
                                       G_TYPE_NONE, 0);
 
   g_type_class_add_private (class, sizeof (GtkRadioButtonPrivate));
+
+  gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_RADIO_BUTTON_ACCESSIBLE);
 }
 
 static void