[gtk+/quartz-integration: 466/563] Convert GailRadioButton to GtkRadioButtonAccessible



commit ea536db7388be940b7f87ac76ef181498f47dd36
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Jun 27 23:24:22 2011 -0400

    Convert GailRadioButton to GtkRadioButtonAccessible

 gtk/a11y/Makefile.am                |    4 +-
 gtk/a11y/gail.c                     |    3 -
 gtk/a11y/gailradiobutton.c          |  130 -----------------------------------
 gtk/a11y/gailradiobutton.h          |   53 --------------
 gtk/a11y/gtkradiobuttonaccessible.c |  116 +++++++++++++++++++++++++++++++
 gtk/a11y/gtkradiobuttonaccessible.h |   53 ++++++++++++++
 gtk/gtkradiobutton.c                |    3 +
 7 files changed, 174 insertions(+), 188 deletions(-)
---
diff --git a/gtk/a11y/Makefile.am b/gtk/a11y/Makefile.am
index 1756bef..71defa0 100644
--- a/gtk/a11y/Makefile.am
+++ b/gtk/a11y/Makefile.am
@@ -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		\
diff --git a/gtk/a11y/gail.c b/gtk/a11y/gail.c
index 3c4e13b..fcc27dc 100644
--- a/gtk/a11y/gail.c
+++ b/gtk/a11y/gail.c
@@ -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/gtkradiobuttonaccessible.c b/gtk/a11y/gtkradiobuttonaccessible.c
new file mode 100644
index 0000000..50e99b3
--- /dev/null
+++ b/gtk/a11y/gtkradiobuttonaccessible.c
@@ -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
index 0000000..44f47c5
--- /dev/null
+++ b/gtk/a11y/gtkradiobuttonaccessible.h
@@ -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__ */
diff --git a/gtk/gtkradiobutton.c b/gtk/gtkradiobutton.c
index b080dc2..cb1ba20 100644
--- a/gtk/gtkradiobutton.c
+++ b/gtk/gtkradiobutton.c
@@ -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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]