[gtk+/drop-gail: 10/24] Move GailArrow to GtkArrowAccessible.



commit 4d5d6c1409829bab7de016e63ef7d0c87a560671
Author: Li Yuan <li yuan sun com>
Date:   Wed Feb 23 14:32:45 2011 +0800

    Move GailArrow to GtkArrowAccessible.

 gtk/gtkarrow.c            |   78 +++++++++++++++++++++++++++++++++++++++++++++
 gtk/gtkarrowaccessible.h  |   55 +++++++++++++++++++++++++++++++
 modules/other/gail/gail.c |    5 ++-
 3 files changed, 137 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkarrow.c b/gtk/gtkarrow.c
index b8744e7..42f8de8 100644
--- a/gtk/gtkarrow.c
+++ b/gtk/gtkarrow.c
@@ -375,3 +375,81 @@ gtk_arrow_draw (GtkWidget *widget,
 
   return FALSE;
 }
+
+/* --- Accessibility --- */
+#include "gtkaccessibility.h"
+#include "gtkarrowaccessible.h"
+
+static void  atk_image_interface_init   (AtkImageIface  *iface);
+
+G_DEFINE_TYPE_WITH_CODE (GtkArrowAccessible, gtk_arrow_accessible, GTK_TYPE_WIDGET_ACCESSIBLE,
+                         G_IMPLEMENT_INTERFACE (ATK_TYPE_IMAGE, atk_image_interface_init))
+
+static void
+gtk_arrow_accessible_initialize (AtkObject *accessible,
+                       gpointer data)
+{
+  ATK_OBJECT_CLASS (gtk_arrow_accessible_parent_class)->initialize (accessible, data);
+
+  atk_object_set_role (accessible, ATK_ROLE_ICON);
+}
+
+static void
+gtk_arrow_accessible_finalize (GObject      *object)
+{
+  GtkArrowAccessible *accessible = GTK_ARROW_ACCESSIBLE (object);
+
+  g_free (accessible->image_description);
+  G_OBJECT_CLASS (gtk_arrow_accessible_parent_class)->finalize (object);
+}
+
+static void
+gtk_arrow_accessible_class_init (GtkArrowAccessibleClass *klass)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+  AtkObjectClass *atk_object_class = ATK_OBJECT_CLASS (klass);
+
+  atk_object_class->initialize = gtk_arrow_accessible_initialize;
+
+  gobject_class->finalize = gtk_arrow_accessible_finalize;
+}
+
+static void
+gtk_arrow_accessible_init (GtkArrowAccessible *arrow)
+{
+}
+
+
+static G_CONST_RETURN gchar*
+gtk_arrow_accessible_get_image_description (AtkImage       *image)
+{
+  GtkArrowAccessible* accessible;
+
+  accessible = GTK_ARROW_ACCESSIBLE (image);
+
+  return accessible->image_description;
+}
+
+static gboolean
+gtk_arrow_accessible_set_image_description (AtkImage       *image,
+                                            const gchar    *description)
+{
+  GtkArrowAccessible *accessible;
+
+  accessible = GTK_ARROW_ACCESSIBLE (image);
+  g_free (accessible->image_description);
+
+  accessible->image_description = g_strdup (description);
+
+  return TRUE;
+
+}
+
+static void
+atk_image_interface_init (AtkImageIface *iface)
+{
+  iface->get_image_description = gtk_arrow_accessible_get_image_description;
+  iface->set_image_description = gtk_arrow_accessible_set_image_description;
+}
+
+GTK_ACCESSIBLE_FACTORY(GTK_TYPE_ARROW_ACCESSIBLE, gtk_arrow_accessible)
diff --git a/gtk/gtkarrowaccessible.h b/gtk/gtkarrowaccessible.h
new file mode 100644
index 0000000..36e335b
--- /dev/null
+++ b/gtk/gtkarrowaccessible.h
@@ -0,0 +1,55 @@
+/* GTK - The GIMP Toolkit
+ * Copyright 2011 Oracle Corporation
+ *
+ * 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.
+ */
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#ifndef __GTK_ARROW_ACCESSIBLE_H__
+#define __GTK_ARROW_ACCESSIBLE_H__
+
+#include <gtk/gtkwidgetaccessible.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_ARROW_ACCESSIBLE            (gtk_arrow_accessible_get_type ())
+#define GTK_ARROW_ACCESSIBLE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ARROW_ACCESSIBLE, GtkArrowAccessible))
+#define GTK_ARROW_ACCESSIBLE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ARROW_ACCESSIBLE, GtkArrowAccessibleClass))
+
+typedef struct _GtkArrowAccessible GtkArrowAccessible;
+typedef struct _GtkArrowAccessibleClass GtkArrowAccessibleClass;
+
+struct _GtkArrowAccessible
+{
+  GtkWidgetAccessible parent;
+
+  gchar*     image_description;
+};
+
+struct _GtkArrowAccessibleClass
+{
+  GtkWidgetAccessibleClass parent_class;
+};
+
+GType gtk_arrow_accessible_get_type (void) G_GNUC_CONST;
+GType gtk_arrow_accessible_factory_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* __GTK_ARROW_ACCESSIBLE_H__ */
diff --git a/modules/other/gail/gail.c b/modules/other/gail/gail.c
index efef87e..e3be7ca 100644
--- a/modules/other/gail/gail.c
+++ b/modules/other/gail/gail.c
@@ -862,6 +862,7 @@ extern void gnome_accessibility_module_shutdown (void);
 extern GType gtk_widget_accessible_factory_get_type (void);
 extern GType gtk_container_accessible_factory_get_type (void);
 extern GType gtk_image_accessible_factory_get_type (void);
+extern GType gtk_arrow_accessible_factory_get_type (void);
 
 static int gail_initialized = FALSE;
 
@@ -894,6 +895,9 @@ gail_accessibility_module_init (void)
   atk_registry_set_factory_type (atk_get_default_registry (),
                                  GTK_TYPE_IMAGE,
                                  gtk_image_accessible_factory_get_type ());
+  atk_registry_set_factory_type (atk_get_default_registry (),
+                                 GTK_TYPE_ARROW,
+                                 gtk_arrow_accessible_factory_get_type ());
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_BUTTON, gail_button);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_LINK_BUTTON, gail_link_button);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_MENU_ITEM, gail_menu_item);
@@ -920,7 +924,6 @@ gail_accessibility_module_init (void)
   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_ARROW, gail_arrow);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_SEPARATOR, gail_separator);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_BOX, gail_box);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_SCROLLED_WINDOW, gail_scrolled_window);



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