[gtk+/drop-gail] Move GailProgressBar to GtkProgressBarAccessible



commit dcccc129a53505ff7353df81231ed0f2427f1954
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Feb 25 00:46:26 2011 -0500

    Move GailProgressBar to GtkProgressBarAccessible

 gtk/Makefile.am                |    1 +
 gtk/gtkprogressbar.c           |   89 ++++++++++++++++++++++++++++++++++++++++
 gtk/gtkprogressbaraccessible.h |   55 ++++++++++++++++++++++++
 modules/other/gail/gail.c      |    8 +++-
 4 files changed, 152 insertions(+), 1 deletions(-)
---
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index cfa8829..cf28ded 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -419,6 +419,7 @@ gtk_private_h_sources =		\
 	gtkprintoperation-private.h \
 	gtkprintutils.h		\
 	gtkprivate.h		\
+	gtkprogressbaraccessible.h \
 	gtkquery.h		\
 	gtkrbtree.h		\
 	gtkrecentchooserdefault.h \
diff --git a/gtk/gtkprogressbar.c b/gtk/gtkprogressbar.c
index d97a81c..2c33220 100644
--- a/gtk/gtkprogressbar.c
+++ b/gtk/gtkprogressbar.c
@@ -1361,3 +1361,92 @@ gtk_progress_bar_get_ellipsize (GtkProgressBar *pbar)
 
   return pbar->priv->ellipsize;
 }
+
+/* --- Accessibility --- */
+
+#include "gtkaccessibility.h"
+#include "gtkprogressbaraccessible.h"
+
+static void atk_value_interface_init (AtkValueIface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (GtkProgressBarAccessible, gtk_progress_bar_accessible, GTK_TYPE_WIDGET_ACCESSIBLE,
+                         G_IMPLEMENT_INTERFACE (ATK_TYPE_VALUE, atk_value_interface_init))
+
+static void
+gtk_progress_bar_accessible_notify_gtk (GObject    *obj,
+                                        GParamSpec *pspec)
+{
+  GtkWidget *widget = GTK_WIDGET (obj);
+  GtkProgressBarAccessible *bar = GTK_PROGRESS_BAR_ACCESSIBLE (gtk_widget_get_accessible (widget));
+
+  if (strcmp (pspec->name, "fraction") == 0)
+    g_object_notify (G_OBJECT (bar), "accessible-value");
+  else
+    GTK_WIDGET_ACCESSIBLE_CLASS (gtk_progress_bar_accessible_parent_class)->notify_gtk (obj, pspec);
+}
+
+static void
+gtk_progress_bar_accessible_initialize (AtkObject *obj,
+                                        gpointer  data)
+{
+  ATK_OBJECT_CLASS (gtk_progress_bar_accessible_parent_class)->initialize (obj, data);
+
+  atk_object_set_role (obj, ATK_ROLE_PROGRESS_BAR);
+}
+
+static void
+gtk_progress_bar_accessible_class_init (GtkProgressBarAccessibleClass *klass)
+{
+  AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+  GtkWidgetAccessibleClass *widget_class = GTK_WIDGET_ACCESSIBLE_CLASS (klass);
+
+  widget_class->notify_gtk = gtk_progress_bar_accessible_notify_gtk;
+
+  class->initialize = gtk_progress_bar_accessible_initialize;
+}
+
+static void
+gtk_progress_bar_accessible_init (GtkProgressBarAccessible *bar)
+{
+}
+
+static void
+gtk_progress_bar_accessible_get_current_value (AtkValue *obj,
+                                               GValue   *value)
+{
+  GtkWidget *widget;
+
+  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
+
+  memset (value, 0, sizeof (GValue));
+  g_value_init (value, G_TYPE_DOUBLE);
+  g_value_set_double (value, gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (widget)));
+}
+
+static void
+gtk_progress_bar_accessible_get_maximum_value (AtkValue *obj,
+                                               GValue   *value)
+{
+  memset (value, 0, sizeof (GValue));
+  g_value_init (value, G_TYPE_DOUBLE);
+  g_value_set_double (value, 1.0);
+}
+
+static void
+gtk_progress_bar_accessible_get_minimum_value (AtkValue *obj,
+                                               GValue   *value)
+{
+  memset (value, 0, sizeof (GValue));
+  g_value_init (value, G_TYPE_DOUBLE);
+  g_value_set_double (value, 0.0);
+}
+
+static void
+atk_value_interface_init (AtkValueIface *iface)
+{
+  iface->get_current_value = gtk_progress_bar_accessible_get_current_value;
+  iface->get_maximum_value = gtk_progress_bar_accessible_get_maximum_value;
+  iface->get_minimum_value = gtk_progress_bar_accessible_get_minimum_value;
+}
+
+GTK_ACCESSIBLE_FACTORY(GTK_TYPE_PROGRESS_BAR_ACCESSIBLE, gtk_progress_bar_accessible)
diff --git a/gtk/gtkprogressbaraccessible.h b/gtk/gtkprogressbaraccessible.h
new file mode 100644
index 0000000..89e0b7b
--- /dev/null
+++ b/gtk/gtkprogressbaraccessible.h
@@ -0,0 +1,55 @@
+/* GTK - The GIMP Toolkit
+ * Copyright 2011 Red Hat, 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.
+ */
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#ifndef __GTK_PROGRESS_BAR_ACCESSIBLE_H__
+#define __GTK_PROGRESS_BAR_ACCESSIBLE_H__
+
+#include <gtk/gtkwidgetaccessible.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_PROGRESS_BAR_ACCESSIBLE (gtk_progress_bar_accessible_get_type ())
+#define GTK_PROGRESS_BAR_ACCESSIBLE(obj)(G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PROGRESS_BAR_ACCESSIBLE, GtkProgressBarAccessible))
+#define GTK_PROGRESS_BAR_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PROGRESS_BAR_ACCESSIBLE, GtkProgressBarAccessibleClass))
+
+typedef struct _GtkProgressBarAccessible GtkProgressBarAccessible;
+typedef struct _GtkProgressBarAccessibleClass GtkProgressBarAccessibleClass;
+
+struct _GtkProgressBarAccessible
+{
+  GtkWidgetAccessible parent;
+};
+
+struct _GtkProgressBarAccessibleClass
+{
+  GtkWidgetAccessibleClass parent_class;
+};
+
+
+GType gtk_progress_bar_accessible_get_type (void) G_GNUC_CONST;
+GType gtk_progress_bar_accessible_factory_get_type (void) G_GNUC_CONST;
+
+
+G_END_DECLS
+
+#endif  /* __GTK_PROGRESS_BAR_ACCESSIBLE_H__ */
diff --git a/modules/other/gail/gail.c b/modules/other/gail/gail.c
index b6a29bc..04c3e7a 100644
--- a/modules/other/gail/gail.c
+++ b/modules/other/gail/gail.c
@@ -26,6 +26,7 @@
 #include <gtk/gtkcalendaraccessible.h>
 #include <gtk/gtkcontaineraccessible.h>
 #include <gtk/gtkimageaccessible.h>
+#include <gtk/gtkprogressbaraccessible.h>
 #include <gtk/gtkwidgetaccessible.h>
 
 #include "gail.h"
@@ -898,6 +899,12 @@ gail_accessibility_module_init (void)
   atk_registry_set_factory_type (atk_get_default_registry (),
                                  GTK_TYPE_CALENDAR,
                                  gtk_calendar_accessible_factory_get_type ());
+  atk_registry_set_factory_type (atk_get_default_registry (),
+                                 GTK_TYPE_ARROW,
+                                 gtk_calendar_accessible_factory_get_type ());
+  atk_registry_set_factory_type (atk_get_default_registry (),
+                                 GTK_TYPE_PROGRESS_BAR,
+                                 gtk_progress_bar_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);
@@ -914,7 +921,6 @@ gail_accessibility_module_init (void)
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_LABEL, gail_label);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_STATUSBAR, gail_statusbar);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_NOTEBOOK, gail_notebook);
-  GAIL_WIDGET_SET_FACTORY (GTK_TYPE_PROGRESS_BAR, gail_progress_bar);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_SPIN_BUTTON, gail_spin_button);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_TREE_VIEW, gail_tree_view);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_FRAME, gail_frame);



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