[gtk+/drop-gail: 17/24] Move GailAdjustment to GtkAdjustmentAccessible



commit c68f3f7bb76c376112893190c14bc274a68ea2ae
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Feb 24 23:11:21 2011 -0500

    Move GailAdjustment to GtkAdjustmentAccessible

 gtk/Makefile.am               |    1 +
 gtk/gtkadjustment.c           |  153 +++++++++++++++++++++++++++++++++++++++++
 gtk/gtkadjustmentaccessible.h |   59 ++++++++++++++++
 3 files changed, 213 insertions(+), 0 deletions(-)
---
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 031bc66..71cb7b7 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -379,6 +379,7 @@ gtk_private_h_sources =		\
 	gtkaccelgroupprivate.h	\
 	gtkaccessibility.h	\
 	gtkaccessibleprivate.h	\
+	gtkadjustmentaccessible.h \
 	gtkanimationdescription.h \
 	gtkappchooserprivate.h	\
 	gtkappchoosermodule.h	\
diff --git a/gtk/gtkadjustment.c b/gtk/gtkadjustment.c
index 40329a4..4eeadfc 100644
--- a/gtk/gtkadjustment.c
+++ b/gtk/gtkadjustment.c
@@ -809,3 +809,156 @@ gtk_adjustment_clamp_page (GtkAdjustment *adjustment,
   if (need_emission)
     gtk_adjustment_value_changed (adjustment);
 }
+
+/* --- Accessibility --- */
+
+#include "gtkaccessibility.h"
+#include "gtkadjustmentaccessible.h"
+
+static void atk_value_interface_init (AtkValueIface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (GtkAdjustmentAccessible, gtk_adjustment_accessible, ATK_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (ATK_TYPE_VALUE, atk_value_interface_init))
+
+static void
+gtk_adjustment_accessible_initialize (AtkObject *obj,
+                                      gpointer  data)
+{
+  GtkAdjustmentAccessible *accessible = GTK_ADJUSTMENT_ACCESSIBLE (obj);
+
+  ATK_OBJECT_CLASS (gtk_adjustment_accessible_parent_class)->initialize (obj, data);
+  atk_object_set_role (obj, ATK_ROLE_UNKNOWN);
+
+  accessible->adjustment = GTK_ADJUSTMENT (data);
+
+  g_object_add_weak_pointer (G_OBJECT (data),
+                             (gpointer *) &accessible->adjustment);
+}
+
+static void
+gtk_adjustment_accessible_class_init (GtkAdjustmentAccessibleClass *klass)
+{
+  AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+
+  class->initialize = gtk_adjustment_accessible_initialize;
+}
+
+static void
+gtk_adjustment_accessible_init (GtkAdjustmentAccessible *accessible)
+{
+}
+
+static void
+gtk_adjustment_accessible_get_current_value (AtkValue *obj,
+                                             GValue   *value)
+{
+  GtkAdjustment *adjustment;
+
+  adjustment = GTK_ADJUSTMENT_ACCESSIBLE (obj)->adjustment;
+  if (adjustment == NULL)
+    return;
+
+  memset (value,  0, sizeof (GValue));
+  g_value_init (value, G_TYPE_DOUBLE);
+  g_value_set_double (value, gtk_adjustment_get_value (adjustment));
+}
+
+static void
+gtk_adjustment_accessible_get_maximum_value (AtkValue *obj,
+                                             GValue   *value)
+{
+  GtkAdjustment *adjustment;
+
+  adjustment = GTK_ADJUSTMENT_ACCESSIBLE (obj)->adjustment;
+  if (adjustment == NULL)
+    return;
+
+  memset (value,  0, sizeof (GValue));
+  g_value_init (value, G_TYPE_DOUBLE);
+  g_value_set_double (value, gtk_adjustment_get_upper (adjustment));
+}
+
+static void
+gtk_adjustment_accessible_get_minimum_value (AtkValue *obj,
+                                             GValue   *value)
+{
+  GtkAdjustment *adjustment;
+
+  adjustment = GTK_ADJUSTMENT_ACCESSIBLE (obj)->adjustment;
+  if (adjustment == NULL)
+    return;
+
+  memset (value,  0, sizeof (GValue));
+  g_value_init (value, G_TYPE_DOUBLE);
+  g_value_set_double (value, gtk_adjustment_get_lower (adjustment));
+}
+
+static void
+gtk_adjustment_accessible_get_minimum_increment (AtkValue *obj,
+                                                 GValue   *value)
+{
+  GtkAdjustment* adjustment;
+  gdouble minimum_increment;
+
+  adjustment = GTK_ADJUSTMENT_ACCESSIBLE (obj)->adjustment;
+  if (adjustment == NULL)
+    return;
+
+  if (gtk_adjustment_get_step_increment (adjustment) != 0 &&
+      gtk_adjustment_get_page_increment (adjustment) != 0)
+    {
+      if (ABS (gtk_adjustment_get_step_increment (adjustment)) < ABS (gtk_adjustment_get_page_increment (adjustment)))
+        minimum_increment = gtk_adjustment_get_step_increment (adjustment);
+      else
+        minimum_increment = gtk_adjustment_get_page_increment (adjustment);
+    }
+  else if (gtk_adjustment_get_step_increment (adjustment) == 0 &&
+           gtk_adjustment_get_page_increment (adjustment) == 0)
+    {
+      minimum_increment = 0;
+    }
+  else if (gtk_adjustment_get_step_increment (adjustment) == 0)
+    {
+      minimum_increment = gtk_adjustment_get_page_increment (adjustment);
+    }
+  else
+    {
+      minimum_increment = gtk_adjustment_get_step_increment (adjustment);
+    }
+
+  memset (value,  0, sizeof (GValue));
+  g_value_init (value, G_TYPE_DOUBLE);
+  g_value_set_double (value, minimum_increment);
+}
+
+static gboolean
+gtk_adjustment_accessible_set_current_value (AtkValue     *obj,
+                                             const GValue *value)
+{
+  GtkAdjustment* adjustment;
+  gdouble new_value;
+
+  if (!G_VALUE_HOLDS_DOUBLE (value))
+    return FALSE;
+
+  adjustment = GTK_ADJUSTMENT_ACCESSIBLE (obj)->adjustment;
+  if (adjustment == NULL)
+    return FALSE;
+
+  new_value = g_value_get_double (value);
+  gtk_adjustment_set_value (adjustment, new_value);
+
+  return TRUE;
+}
+
+static void
+atk_value_interface_init (AtkValueIface *iface)
+{
+  iface->get_current_value = gtk_adjustment_accessible_get_current_value;
+  iface->get_maximum_value = gtk_adjustment_accessible_get_maximum_value;
+  iface->get_minimum_value = gtk_adjustment_accessible_get_minimum_value;
+  iface->get_minimum_increment = gtk_adjustment_accessible_get_minimum_increment;
+  iface->set_current_value = gtk_adjustment_accessible_set_current_value;
+}
+
+GTK_ACCESSIBLE_FACTORY(GTK_TYPE_ADJUSTMENT_ACCESSIBLE, gtk_adjustment_accessible)
diff --git a/gtk/gtkadjustmentaccessible.h b/gtk/gtkadjustmentaccessible.h
new file mode 100644
index 0000000..ef8dfa0
--- /dev/null
+++ b/gtk/gtkadjustmentaccessible.h
@@ -0,0 +1,59 @@
+/* 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_ADJUSTMENT_ACCESSIBLE_H__
+#define __GTK_ADJUSTMENT_ACCESSIBLE_H__
+
+#include <atk/atk.h>
+#include <gtk/gtkadjustment.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_ADJUSTMENT_ACCESSIBLE (gtk_adjustment_accessible_get_type ())
+#define GTK_ADJUSTMENT_ACCESSIBLE(obj)(G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ADJUSTMENT_ACCESSIBLE, GtkAdjustmentAccessible))
+#define GTK_ADJUSTMENT_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ADJUSTMENT_ACCESSIBLE, GtkAdjustmentAccessibleClass))
+#define GTK_ADJUSTMENT_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ADJUSTMENT_ACCESSIBLE, GtkAdjustmentAccessibleClass))
+
+typedef struct _GtkAdjustmentAccessible GtkAdjustmentAccessible;
+typedef struct _GtkAdjustmentAccessibleClass GtkAdjustmentAccessibleClass;
+
+struct _GtkAdjustmentAccessible
+{
+  AtkObject parent;
+
+  GtkAdjustment *adjustment;
+};
+
+struct _GtkAdjustmentAccessibleClass
+{
+  AtkObjectClass parent_class;
+};
+
+
+GType gtk_adjustment_accessible_get_type (void) G_GNUC_CONST;
+GType gtk_adjustment_accessible_factory_get_type (void) G_GNUC_CONST;
+
+
+G_END_DECLS
+
+#endif  /* __GTK_ADJUSTMENT_ACCESSIBLE_H__ */



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