]> Pileus Git - ~andy/gtk/commitdiff
GtkAdjustment: add an auxiliary function
authorMatthias Clasen <mclasen@redhat.com>
Tue, 28 Jun 2011 04:38:20 +0000 (00:38 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 5 Jul 2011 20:08:54 +0000 (16:08 -0400)
This is going to be used in AtkValue implementations.

gtk/a11y/gailadjustment.c [deleted file]
gtk/a11y/gailadjustment.h [deleted file]
gtk/gtk.symbols
gtk/gtkadjustment.c
gtk/gtkadjustment.h

diff --git a/gtk/a11y/gailadjustment.c b/gtk/a11y/gailadjustment.c
deleted file mode 100644 (file)
index 58e19ea..0000000
+++ /dev/null
@@ -1,230 +0,0 @@
-/* GAIL - The GNOME Accessibility Implementation Library
- * Copyright 2001, 2002, 2003 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 <string.h>
-#include <gtk/gtk.h>
-#include "gailadjustment.h"
-
-static void     gail_adjustment_class_init        (GailAdjustmentClass *klass);
-
-static void     gail_adjustment_init              (GailAdjustment      *adjustment);
-
-static void     gail_adjustment_real_initialize   (AtkObject           *obj,
-                                                    gpointer            data);
-
-static void     atk_value_interface_init          (AtkValueIface       *iface);
-
-static void     gail_adjustment_get_current_value (AtkValue            *obj,
-                                                    GValue              *value);
-static void     gail_adjustment_get_maximum_value (AtkValue            *obj,
-                                                    GValue              *value);
-static void     gail_adjustment_get_minimum_value (AtkValue            *obj,
-                                                    GValue              *value);
-static void     gail_adjustment_get_minimum_increment (AtkValue        *obj,
-                                                    GValue              *value);
-static gboolean         gail_adjustment_set_current_value (AtkValue            *obj,
-                                                    const GValue        *value);
-
-G_DEFINE_TYPE_WITH_CODE (GailAdjustment, gail_adjustment, ATK_TYPE_OBJECT,
-                         G_IMPLEMENT_INTERFACE (ATK_TYPE_VALUE, atk_value_interface_init))
-
-static void     
-gail_adjustment_class_init (GailAdjustmentClass *klass)
-{
-  AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
-
-  class->initialize = gail_adjustment_real_initialize;
-}
-
-static void
-gail_adjustment_init (GailAdjustment *adjustment)
-{
-}
-
-AtkObject* 
-gail_adjustment_new (GtkAdjustment *adjustment)
-{
-  GObject *object;
-  AtkObject *atk_object;
-
-  g_return_val_if_fail (GTK_IS_ADJUSTMENT (adjustment), NULL);
-
-  object = g_object_new (GAIL_TYPE_ADJUSTMENT, NULL);
-
-  atk_object = ATK_OBJECT (object);
-  atk_object_initialize (atk_object, adjustment);
-
-  return atk_object;
-}
-
-static void
-gail_adjustment_real_initialize (AtkObject *obj,
-                                 gpointer  data)
-{
-  GtkAdjustment *adjustment;
-  GailAdjustment *gail_adjustment;
-
-  ATK_OBJECT_CLASS (gail_adjustment_parent_class)->initialize (obj, data);
-
-  adjustment = GTK_ADJUSTMENT (data);
-
-  obj->role = ATK_ROLE_UNKNOWN;
-  gail_adjustment = GAIL_ADJUSTMENT (obj);
-  gail_adjustment->adjustment = adjustment;
-
-  g_object_add_weak_pointer (G_OBJECT (adjustment),
-                             (gpointer *) &gail_adjustment->adjustment);
-}
-
-static void     
-atk_value_interface_init (AtkValueIface *iface)
-{
-  iface->get_current_value = gail_adjustment_get_current_value;
-  iface->get_maximum_value = gail_adjustment_get_maximum_value;
-  iface->get_minimum_value = gail_adjustment_get_minimum_value;
-  iface->get_minimum_increment = gail_adjustment_get_minimum_increment;
-  iface->set_current_value = gail_adjustment_set_current_value;
-}
-
-static void     
-gail_adjustment_get_current_value (AtkValue             *obj,
-                                   GValue               *value)
-{
-  GtkAdjustment* adjustment;
-  gdouble current_value;
-  adjustment = GAIL_ADJUSTMENT (obj)->adjustment;
-  if (adjustment == NULL)
-  {
-    /* State is defunct */
-    return;
-  }
-
-  current_value = gtk_adjustment_get_value (adjustment);
-  memset (value,  0, sizeof (GValue));
-  g_value_init (value, G_TYPE_DOUBLE);
-  g_value_set_double (value,current_value);
-}
-
-static void     
-gail_adjustment_get_maximum_value (AtkValue             *obj,
-                                   GValue               *value)
-{
-  GtkAdjustment* adjustment;
-  gdouble maximum_value;
-  adjustment = GAIL_ADJUSTMENT (obj)->adjustment;
-  if (adjustment == NULL)
-  {
-    /* State is defunct */
-    return;
-  }
-
-  maximum_value = gtk_adjustment_get_upper (adjustment);
-  memset (value,  0, sizeof (GValue));
-  g_value_init (value, G_TYPE_DOUBLE);
-  g_value_set_double (value, maximum_value);
-}
-
-static void     
-gail_adjustment_get_minimum_value (AtkValue             *obj,
-                                   GValue               *value)
-{
-  GtkAdjustment* adjustment;
-  gdouble minimum_value;
-  adjustment = GAIL_ADJUSTMENT (obj)->adjustment;
-  if (adjustment == NULL)
-  {
-    /* State is defunct */
-    return;
-  }
-
-  minimum_value = gtk_adjustment_get_lower (adjustment);
-  memset (value,  0, sizeof (GValue));
-  g_value_init (value, G_TYPE_DOUBLE);
-  g_value_set_double (value, minimum_value);
-}
-
-static void
-gail_adjustment_get_minimum_increment (AtkValue        *obj,
-                                       GValue          *value)
-{
-  GtkAdjustment* adjustment;
-  gdouble minimum_increment;
-  adjustment = GAIL_ADJUSTMENT (obj)->adjustment;
-  if (adjustment == NULL)
-  {
-    /* State is defunct */
-    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         
-gail_adjustment_set_current_value (AtkValue             *obj,
-                                   const GValue         *value)
-{
-  if (G_VALUE_HOLDS_DOUBLE (value))
-  {
-    GtkAdjustment* adjustment;
-    gdouble new_value;
-    adjustment = GAIL_ADJUSTMENT (obj)->adjustment;
-    if (adjustment == NULL)
-    {
-      /* State is defunct */
-      return FALSE;
-    }
-    new_value = g_value_get_double (value);
-    gtk_adjustment_set_value (adjustment, new_value);
-
-    return TRUE;
-  }
-  else
-    return FALSE;
-}
diff --git a/gtk/a11y/gailadjustment.h b/gtk/a11y/gailadjustment.h
deleted file mode 100644 (file)
index 790534d..0000000
+++ /dev/null
@@ -1,55 +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_ADJUSTMENT_H__
-#define __GAIL_ADJUSTMENT_H__
-
-#include <atk/atk.h>
-
-G_BEGIN_DECLS
-
-#define GAIL_TYPE_ADJUSTMENT                     (gail_adjustment_get_type ())
-#define GAIL_ADJUSTMENT(obj)                     (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_ADJUSTMENT, GailAdjustment))
-#define GAIL_ADJUSTMENT_CLASS(klass)             (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_ADJUSTMENT, GailAdjustmentClass))
-#define GAIL_IS_ADJUSTMENT(obj)                  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_ADJUSTMENT))
-#define GAIL_IS_ADJUSTMENT_CLASS(klass)          (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_ADJUSTMENT))
-#define GAIL_ADJUSTMENT_GET_CLASS(obj)           (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_ADJUSTMENT, GailAdjustmentClass))
-
-typedef struct _GailAdjustment                  GailAdjustment;
-typedef struct _GailAdjustmentClass            GailAdjustmentClass;
-
-struct _GailAdjustment
-{
-  AtkObject parent;
-
-  GtkAdjustment *adjustment;
-};
-
-GType gail_adjustment_get_type (void);
-
-struct _GailAdjustmentClass
-{
-  AtkObjectClass parent_class;
-};
-
-AtkObject *gail_adjustment_new (GtkAdjustment *adjustment);
-
-G_END_DECLS
-
-#endif /* __GAIL_ADJUSTMENT_H__ */
index 5bac657ba3a463c617162082223add02fe4a8aaf..83e83fd3b8746b4a19d698c10ec99076f47f5ddd 100644 (file)
@@ -157,6 +157,7 @@ gtk_adjustment_changed
 gtk_adjustment_clamp_page
 gtk_adjustment_configure
 gtk_adjustment_get_lower
+gtk_adjustment_get_minimum_increment
 gtk_adjustment_get_page_increment
 gtk_adjustment_get_page_size
 gtk_adjustment_get_step_increment
index 40329a4ef318ffca600a5aa6153d3daa73b6707b..29aa1c9370761a6578ac9deece126499ce24e9e7 100644 (file)
@@ -809,3 +809,47 @@ gtk_adjustment_clamp_page (GtkAdjustment *adjustment,
   if (need_emission)
     gtk_adjustment_value_changed (adjustment);
 }
+
+/**
+ * gtk_adjustment_get_minimum_increment:
+ * @adjustment: a #GtkAdjustment
+ *
+ * Gets the smaller of step increment and page increment.
+ *
+ * Returns: the minimum increment of @adjustment
+ *
+ * Since: 3.2
+ */
+gdouble
+gtk_adjustment_get_minimum_increment (GtkAdjustment *adjustment)
+{
+  GtkAdjustmentPrivate *priv;
+  gdouble minimum_increment;
+
+  g_return_val_if_fail (GTK_IS_ADJUSTMENT (adjustment), 0);
+
+  priv = adjustment->priv;
+
+    if (priv->step_increment != 0 && priv->page_increment != 0)
+    {
+      if (ABS (priv->step_increment) < ABS (priv->page_increment))
+        minimum_increment = priv->step_increment;
+      else
+        minimum_increment = priv->page_increment;
+    }
+  else if (priv->step_increment == 0 && priv->page_increment == 0)
+    {
+      minimum_increment = 0;
+    }
+  else if (priv->step_increment == 0)
+    {
+      minimum_increment = priv->page_increment;
+    }
+  else
+    {
+      minimum_increment = priv->step_increment;
+    }
+
+  return minimum_increment;
+}
+
index 1ea9de5011dfcf6bdc3ff9d5ca7f7c9f079fd7c0..d3ff03a6ac84cac6d9e54ffe2abf9e93536edf84 100644 (file)
@@ -116,6 +116,8 @@ void       gtk_adjustment_configure             (GtkAdjustment   *adjustment,
                                                  gdouble          page_increment,
                                                  gdouble          page_size);
 
+gdouble    gtk_adjustment_get_minimum_increment (GtkAdjustment   *adjustment);
+
 G_END_DECLS
 
 #endif /* __GTK_ADJUSTMENT_H__ */