[gtk/matthiasc/for-master: 8/9] spinbutton: Add some missing accessors




commit 60b1b4669eec5b5b550b64e8966b07aeb021a1f3
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Oct 3 13:02:38 2020 -0400

    spinbutton: Add some missing accessors
    
    Add a setter and getter for the climb-rate property.

 docs/reference/gtk/gtk4-sections.txt | 20 ++++----
 gtk/gtkspinbutton.c                  | 39 +++++++++++++++
 gtk/gtkspinbutton.h                  | 92 +++++++++++++++++++-----------------
 3 files changed, 99 insertions(+), 52 deletions(-)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index a2e4dbc60a..71ffac0806 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -2786,24 +2786,26 @@ gtk_spin_button_new_with_range
 gtk_spin_button_set_adjustment
 gtk_spin_button_get_adjustment
 gtk_spin_button_set_digits
+gtk_spin_button_get_digits
 gtk_spin_button_set_increments
+gtk_spin_button_get_increments
 gtk_spin_button_set_range
+gtk_spin_button_get_range
 gtk_spin_button_get_value_as_int
 gtk_spin_button_set_value
+gtk_spin_button_get_value
 gtk_spin_button_set_update_policy
+gtk_spin_button_get_update_policy
 gtk_spin_button_set_numeric
-gtk_spin_button_spin
+gtk_spin_button_get_numeric
 gtk_spin_button_set_wrap
+gtk_spin_button_get_wrap
 gtk_spin_button_set_snap_to_ticks
-gtk_spin_button_update
-gtk_spin_button_get_digits
-gtk_spin_button_get_increments
-gtk_spin_button_get_numeric
-gtk_spin_button_get_range
 gtk_spin_button_get_snap_to_ticks
-gtk_spin_button_get_update_policy
-gtk_spin_button_get_value
-gtk_spin_button_get_wrap
+gtk_spin_button_set_climb_rate
+gtk_spin_button_get_climb_rate
+gtk_spin_button_spin
+gtk_spin_button_update
 GTK_INPUT_ERROR
 <SUBSECTION Standard>
 GTK_SPIN_BUTTON
diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c
index 9d669162db..b0cbfcf852 100644
--- a/gtk/gtkspinbutton.c
+++ b/gtk/gtkspinbutton.c
@@ -2147,6 +2147,45 @@ gtk_spin_button_get_snap_to_ticks (GtkSpinButton *spin_button)
   return spin_button->snap_to_ticks;
 }
 
+/**
+ * gtk_spin_button_set_climb_rate:
+ * @spin_button: a #GtkSpinButton
+ * @climb_rate: the rate of acceleration, must be >= 0
+ *
+ * Sets the acceleration rate for repeated changes when you
+ * hold down a button or key.
+ */
+void
+gtk_spin_button_set_climb_rate (GtkSpinButton  *spin_button,
+                                double          climb_rate)
+{
+  g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button));
+  g_return_if_fail (0.0 <= climb_rate);
+
+  if (spin_button->climb_rate == climb_rate)
+    return;
+
+  spin_button->climb_rate = climb_rate;
+
+  g_object_notify_by_pspec (G_OBJECT (spin_button), spinbutton_props[PROP_CLIMB_RATE]);
+}
+
+/**
+ * gtk_spin_button_get_climb_rate:
+ * @spin_button: a #GtkSpinButton
+ *
+ * Returns the acceleration rate for repeated changes.
+ *
+ * Returns: the acceleration rate
+ */
+double
+gtk_spin_button_get_climb_rate (GtkSpinButton  *spin_button)
+{
+  g_return_val_if_fail (GTK_IS_SPIN_BUTTON (spin_button), 0.0);
+
+  return spin_button->climb_rate;
+}
+
 /**
  * gtk_spin_button_spin:
  * @spin_button: a #GtkSpinButton
diff --git a/gtk/gtkspinbutton.h b/gtk/gtkspinbutton.h
index 28fa0c1499..ccab4464b4 100644
--- a/gtk/gtkspinbutton.h
+++ b/gtk/gtkspinbutton.h
@@ -11,7 +11,7 @@
  *
  * 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
+ * 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
@@ -96,96 +96,102 @@ typedef enum
 typedef struct _GtkSpinButton              GtkSpinButton;
 
 GDK_AVAILABLE_IN_ALL
-GType          gtk_spin_button_get_type           (void) G_GNUC_CONST;
+GType           gtk_spin_button_get_type           (void) G_GNUC_CONST;
 
 GDK_AVAILABLE_IN_ALL
-void           gtk_spin_button_configure          (GtkSpinButton  *spin_button,
-                                                   GtkAdjustment  *adjustment,
-                                                   double          climb_rate,
-                                                   guint           digits);
+void            gtk_spin_button_configure          (GtkSpinButton  *spin_button,
+                                                    GtkAdjustment  *adjustment,
+                                                    double          climb_rate,
+                                                    guint           digits);
 
 GDK_AVAILABLE_IN_ALL
-GtkWidget*     gtk_spin_button_new                (GtkAdjustment  *adjustment,
-                                                   double          climb_rate,
-                                                   guint           digits);
+GtkWidget*      gtk_spin_button_new                (GtkAdjustment  *adjustment,
+                                                    double          climb_rate,
+                                                    guint           digits);
 
 GDK_AVAILABLE_IN_ALL
-GtkWidget*     gtk_spin_button_new_with_range     (double   min,
-                                                   double   max,
-                                                   double   step);
+GtkWidget*      gtk_spin_button_new_with_range     (double   min,
+                                                    double   max,
+                                                    double   step);
 
 GDK_AVAILABLE_IN_ALL
-void           gtk_spin_button_set_adjustment     (GtkSpinButton  *spin_button,
-                                                   GtkAdjustment  *adjustment);
+void            gtk_spin_button_set_adjustment     (GtkSpinButton  *spin_button,
+                                                    GtkAdjustment  *adjustment);
 
 GDK_AVAILABLE_IN_ALL
-GtkAdjustment* gtk_spin_button_get_adjustment     (GtkSpinButton  *spin_button);
+GtkAdjustment*  gtk_spin_button_get_adjustment     (GtkSpinButton  *spin_button);
 
 GDK_AVAILABLE_IN_ALL
-void           gtk_spin_button_set_digits         (GtkSpinButton  *spin_button,
-                                                   guint           digits);
+void            gtk_spin_button_set_digits         (GtkSpinButton  *spin_button,
+                                                    guint           digits);
 GDK_AVAILABLE_IN_ALL
 guint           gtk_spin_button_get_digits         (GtkSpinButton  *spin_button);
 
 GDK_AVAILABLE_IN_ALL
-void           gtk_spin_button_set_increments     (GtkSpinButton  *spin_button,
-                                                   double          step,
-                                                   double          page);
+void            gtk_spin_button_set_increments     (GtkSpinButton  *spin_button,
+                                                    double          step,
+                                                    double          page);
 GDK_AVAILABLE_IN_ALL
 void            gtk_spin_button_get_increments     (GtkSpinButton  *spin_button,
-                                                   double         *step,
-                                                   double         *page);
+                                                    double         *step,
+                                                    double         *page);
 
 GDK_AVAILABLE_IN_ALL
-void           gtk_spin_button_set_range          (GtkSpinButton  *spin_button,
-                                                   double          min,
-                                                   double          max);
+void            gtk_spin_button_set_range          (GtkSpinButton  *spin_button,
+                                                    double          min,
+                                                    double          max);
 GDK_AVAILABLE_IN_ALL
 void            gtk_spin_button_get_range          (GtkSpinButton  *spin_button,
-                                                   double         *min,
-                                                   double         *max);
+                                                    double         *min,
+                                                    double         *max);
 
 GDK_AVAILABLE_IN_ALL
-double         gtk_spin_button_get_value          (GtkSpinButton  *spin_button);
+double          gtk_spin_button_get_value          (GtkSpinButton  *spin_button);
 
 GDK_AVAILABLE_IN_ALL
-int            gtk_spin_button_get_value_as_int   (GtkSpinButton  *spin_button);
+int             gtk_spin_button_get_value_as_int   (GtkSpinButton  *spin_button);
 
 GDK_AVAILABLE_IN_ALL
-void           gtk_spin_button_set_value          (GtkSpinButton  *spin_button,
-                                                   double          value);
+void            gtk_spin_button_set_value          (GtkSpinButton  *spin_button,
+                                                    double          value);
 
 GDK_AVAILABLE_IN_ALL
-void           gtk_spin_button_set_update_policy  (GtkSpinButton  *spin_button,
-                                                   GtkSpinButtonUpdatePolicy  policy);
+void            gtk_spin_button_set_update_policy  (GtkSpinButton  *spin_button,
+                                                    GtkSpinButtonUpdatePolicy  policy);
 GDK_AVAILABLE_IN_ALL
 GtkSpinButtonUpdatePolicy gtk_spin_button_get_update_policy (GtkSpinButton *spin_button);
 
 GDK_AVAILABLE_IN_ALL
-void           gtk_spin_button_set_numeric        (GtkSpinButton  *spin_button,
-                                                   gboolean        numeric);
+void            gtk_spin_button_set_numeric        (GtkSpinButton  *spin_button,
+                                                    gboolean        numeric);
 GDK_AVAILABLE_IN_ALL
 gboolean        gtk_spin_button_get_numeric        (GtkSpinButton  *spin_button);
 
 GDK_AVAILABLE_IN_ALL
-void           gtk_spin_button_spin               (GtkSpinButton  *spin_button,
-                                                   GtkSpinType     direction,
-                                                   double          increment);
+void            gtk_spin_button_spin               (GtkSpinButton  *spin_button,
+                                                    GtkSpinType     direction,
+                                                    double          increment);
 
 GDK_AVAILABLE_IN_ALL
-void           gtk_spin_button_set_wrap           (GtkSpinButton  *spin_button,
-                                                   gboolean        wrap);
+void            gtk_spin_button_set_wrap           (GtkSpinButton  *spin_button,
+                                                    gboolean        wrap);
 GDK_AVAILABLE_IN_ALL
 gboolean        gtk_spin_button_get_wrap           (GtkSpinButton  *spin_button);
 
 GDK_AVAILABLE_IN_ALL
-void           gtk_spin_button_set_snap_to_ticks  (GtkSpinButton  *spin_button,
-                                                   gboolean        snap_to_ticks);
+void            gtk_spin_button_set_snap_to_ticks  (GtkSpinButton  *spin_button,
+                                                    gboolean        snap_to_ticks);
 GDK_AVAILABLE_IN_ALL
 gboolean        gtk_spin_button_get_snap_to_ticks  (GtkSpinButton  *spin_button);
+
 GDK_AVAILABLE_IN_ALL
-void            gtk_spin_button_update             (GtkSpinButton  *spin_button);
+void            gtk_spin_button_set_climb_rate     (GtkSpinButton  *spin_button,
+                                                    double          climb_rate);
+GDK_AVAILABLE_IN_ALL
+double          gtk_spin_button_get_climb_rate     (GtkSpinButton  *spin_button);
 
+GDK_AVAILABLE_IN_ALL
+void            gtk_spin_button_update             (GtkSpinButton  *spin_button);
 
 
 G_END_DECLS


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