[gimp] libgimpwidgets: deprecate gimp_spin_button_new()



commit eaea58f5e31c29717705ece18b01dcb7d9afbe4a
Author: Michael Natterer <mitch gimp org>
Date:   Sat Jun 21 22:35:39 2014 +0200

    libgimpwidgets: deprecate gimp_spin_button_new()
    
    it should have never been added in the first place. Port all users
    to using gtk_spin_button_new() directly.

 libgimpwidgets/gimpmemsizeentry.c |   14 ++++++----
 libgimpwidgets/gimppropwidgets.c  |   22 ++++++++-------
 libgimpwidgets/gimpquerybox.c     |   26 ++++++++++--------
 libgimpwidgets/gimpscaleentry.c   |   51 +++++++++++++++++++-----------------
 libgimpwidgets/gimpwidgets.c      |   24 +++++++++++------
 libgimpwidgets/gimpwidgets.h      |    1 +
 6 files changed, 77 insertions(+), 61 deletions(-)
---
diff --git a/libgimpwidgets/gimpmemsizeentry.c b/libgimpwidgets/gimpmemsizeentry.c
index 104265a..b03dfb2 100644
--- a/libgimpwidgets/gimpmemsizeentry.c
+++ b/libgimpwidgets/gimpmemsizeentry.c
@@ -174,7 +174,7 @@ gimp_memsize_entry_new (guint64  value,
                         guint64  upper)
 {
   GimpMemsizeEntry *entry;
-  GtkObject        *adj;
+  GtkAdjustment    *adj;
   guint             shift;
 
 #if _MSC_VER < 1300
@@ -199,11 +199,13 @@ gimp_memsize_entry_new (guint64  value,
   entry->upper = upper;
   entry->shift = shift;
 
-  entry->spinbutton = gimp_spin_button_new (&adj,
-                                            CAST (value >> shift),
-                                            CAST (lower >> shift),
-                                            CAST (upper >> shift),
-                                            1, 8, 0, 1, 0);
+  adj = (GtkAdjustment *) gtk_adjustment_new (CAST (value >> shift),
+                                              CAST (lower >> shift),
+                                              CAST (upper >> shift),
+                                              1, 8, 0);
+
+  entry->spinbutton = gtk_spin_button_new (adj, 1.0, 0);
+  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (entry->spinbutton), TRUE);
 
 #undef CAST
 
diff --git a/libgimpwidgets/gimppropwidgets.c b/libgimpwidgets/gimppropwidgets.c
index 45bd400..37e91ce 100644
--- a/libgimpwidgets/gimppropwidgets.c
+++ b/libgimpwidgets/gimppropwidgets.c
@@ -1071,12 +1071,12 @@ gimp_prop_spin_button_new (GObject     *config,
                            gdouble      page_increment,
                            gint         digits)
 {
-  GParamSpec *param_spec;
-  GtkWidget  *spinbutton;
-  GtkObject  *adjustment;
-  gdouble     value;
-  gdouble     lower;
-  gdouble     upper;
+  GParamSpec    *param_spec;
+  GtkWidget     *spinbutton;
+  GtkAdjustment *adjustment;
+  gdouble        value;
+  gdouble        lower;
+  gdouble        upper;
 
   param_spec = find_param_spec (config, property_name, G_STRFUNC);
   if (! param_spec)
@@ -1089,10 +1089,12 @@ gimp_prop_spin_button_new (GObject     *config,
   if (! G_IS_PARAM_SPEC_DOUBLE (param_spec))
     digits = 0;
 
-  spinbutton = gimp_spin_button_new (&adjustment,
-                                     value, lower, upper,
-                                     step_increment, page_increment,
-                                     0.0, 1.0, digits);
+  adjustment = (GtkAdjustment *)
+    gtk_adjustment_new (value, lower, upper,
+                        step_increment, page_increment, 0);
+
+  spinbutton = gtk_spin_button_new (adjustment, step_increment, digits);
+  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
 
   set_param_spec (G_OBJECT (adjustment), spinbutton, param_spec);
 
diff --git a/libgimpwidgets/gimpquerybox.c b/libgimpwidgets/gimpquerybox.c
index 72db450..76ad99c 100644
--- a/libgimpwidgets/gimpquerybox.c
+++ b/libgimpwidgets/gimpquerybox.c
@@ -323,9 +323,9 @@ gimp_query_int_box (const gchar          *title,
                     GimpQueryIntCallback  callback,
                     gpointer              data)
 {
-  QueryBox  *query_box;
-  GtkWidget *spinbutton;
-  GtkObject *adjustment;
+  QueryBox      *query_box;
+  GtkWidget     *spinbutton;
+  GtkAdjustment *adjustment;
 
   query_box = create_query_box (title, parent, help_func, help_id,
                                 G_CALLBACK (int_query_box_response),
@@ -338,9 +338,10 @@ gimp_query_int_box (const gchar          *title,
   if (! query_box)
     return NULL;
 
-  spinbutton = gimp_spin_button_new (&adjustment,
-                                     initial, lower, upper, 1, 10, 0,
-                                     1, 0);
+  adjustment = (GtkAdjustment *)
+    gtk_adjustment_new (initial, lower, upper, 1, 10, 0);
+  spinbutton = gtk_spin_button_new (adjustment, 1.0, 0);
+  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
   gtk_entry_set_activates_default (GTK_ENTRY (spinbutton), TRUE);
   gtk_box_pack_start (GTK_BOX (query_box->vbox), spinbutton, FALSE, FALSE, 0);
   gtk_widget_grab_focus (spinbutton);
@@ -386,9 +387,9 @@ gimp_query_double_box (const gchar             *title,
                        GimpQueryDoubleCallback  callback,
                        gpointer                 data)
 {
-  QueryBox  *query_box;
-  GtkWidget *spinbutton;
-  GtkObject *adjustment;
+  QueryBox      *query_box;
+  GtkWidget     *spinbutton;
+  GtkAdjustment *adjustment;
 
   query_box = create_query_box (title, parent, help_func, help_id,
                                 G_CALLBACK (double_query_box_response),
@@ -401,9 +402,10 @@ gimp_query_double_box (const gchar             *title,
   if (! query_box)
     return NULL;
 
-  spinbutton = gimp_spin_button_new (&adjustment,
-                                     initial, lower, upper, 1, 10, 0,
-                                     1, digits);
+  adjustment = (GtkAdjustment *)
+    gtk_adjustment_new (initial, lower, upper, 1, 10, 0);
+  spinbutton = gtk_spin_button_new (adjustment, 1.0, 0);
+  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
   gtk_entry_set_activates_default (GTK_ENTRY (spinbutton), TRUE);
   gtk_box_pack_start (GTK_BOX (query_box->vbox), spinbutton, FALSE, FALSE, 0);
   gtk_widget_grab_focus (spinbutton);
diff --git a/libgimpwidgets/gimpscaleentry.c b/libgimpwidgets/gimpscaleentry.c
index 5c86df9..295a8f8 100644
--- a/libgimpwidgets/gimpscaleentry.c
+++ b/libgimpwidgets/gimpscaleentry.c
@@ -137,11 +137,11 @@ gimp_scale_entry_new_internal (gboolean     color_scale,
                                const gchar *tooltip,
                                const gchar *help_id)
 {
-  GtkWidget *label;
-  GtkWidget *scale;
-  GtkWidget *spinbutton;
-  GtkObject *adjustment;
-  GtkObject *return_adj;
+  GtkWidget     *label;
+  GtkWidget     *scale;
+  GtkWidget     *spinbutton;
+  GtkAdjustment *adjustment;
+  GtkAdjustment *return_adj;
 
   label = gtk_label_new_with_mnemonic (text);
   gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
@@ -154,25 +154,28 @@ gimp_scale_entry_new_internal (gboolean     color_scale,
       unconstrained_lower <= lower &&
       unconstrained_upper >= upper)
     {
-      GtkObject *constrained_adj;
+      GtkAdjustment *constrained_adj;
 
-      constrained_adj = gtk_adjustment_new (value, lower, upper,
-                                            step_increment, page_increment,
-                                            0.0);
+      constrained_adj = (GtkAdjustment *)
+        gtk_adjustment_new (value, lower, upper,
+                            step_increment, page_increment,
+                            0.0);
 
-      spinbutton = gimp_spin_button_new (&adjustment, value,
-                                         unconstrained_lower,
-                                         unconstrained_upper,
-                                         step_increment, page_increment, 0.0,
-                                         step_increment, digits);
+      adjustment = (GtkAdjustment *)
+        gtk_adjustment_new (value,
+                            unconstrained_lower,
+                            unconstrained_upper,
+                            step_increment, page_increment, 0.0);
+      spinbutton = gtk_spin_button_new (adjustment, step_increment, digits);
+      gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
 
       g_signal_connect
-        (G_OBJECT (constrained_adj), "value-changed",
+        (constrained_adj, "value-changed",
          G_CALLBACK (gimp_scale_entry_unconstrained_adjustment_callback),
          adjustment);
 
       g_signal_connect
-        (G_OBJECT (adjustment), "value-changed",
+        (adjustment, "value-changed",
          G_CALLBACK (gimp_scale_entry_unconstrained_adjustment_callback),
          constrained_adj);
 
@@ -182,9 +185,11 @@ gimp_scale_entry_new_internal (gboolean     color_scale,
     }
   else
     {
-      spinbutton = gimp_spin_button_new (&adjustment, value, lower, upper,
-                                         step_increment, page_increment, 0.0,
-                                         step_increment, digits);
+      adjustment = (GtkAdjustment *)
+        gtk_adjustment_new (value, lower, upper,
+                            step_increment, page_increment, 0.0);
+      spinbutton = gtk_spin_button_new (adjustment, step_increment, digits);
+      gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
 
       return_adj = adjustment;
     }
@@ -204,13 +209,11 @@ gimp_scale_entry_new_internal (gboolean     color_scale,
       scale = gimp_color_scale_new (GTK_ORIENTATION_HORIZONTAL,
                                     GIMP_COLOR_SELECTOR_VALUE);
 
-      gtk_range_set_adjustment (GTK_RANGE (scale),
-                                GTK_ADJUSTMENT (adjustment));
+      gtk_range_set_adjustment (GTK_RANGE (scale), adjustment);
     }
   else
     {
-      scale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL,
-                             GTK_ADJUSTMENT (adjustment));
+      scale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, adjustment);
     }
 
   if (scale_width > 0)
@@ -238,7 +241,7 @@ gimp_scale_entry_new_internal (gboolean     color_scale,
   g_object_set_data (G_OBJECT (return_adj), "scale",      scale);
   g_object_set_data (G_OBJECT (return_adj), "spinbutton", spinbutton);
 
-  return return_adj;
+  return GTK_OBJECT (return_adj);
 }
 
 /**
diff --git a/libgimpwidgets/gimpwidgets.c b/libgimpwidgets/gimpwidgets.c
index 35b6bee..48d677b 100644
--- a/libgimpwidgets/gimpwidgets.c
+++ b/libgimpwidgets/gimpwidgets.c
@@ -430,6 +430,8 @@ gimp_int_radio_group_set_active (GtkRadioButton *radio_button,
  * gtk_spin_button_set_numeric() so that non-numeric text cannot be
  * entered.
  *
+ * Deprecated: 2.10: Use gtk_spin_button_new() instead.
+ *
  * Returns: A #GtkSpinButton and its #GtkAdjustment.
  **/
 GtkWidget *
@@ -489,11 +491,11 @@ GtkWidget *
 gimp_random_seed_new (guint    *seed,
                       gboolean *random_seed)
 {
-  GtkWidget *hbox;
-  GtkWidget *toggle;
-  GtkWidget *spinbutton;
-  GtkObject *adj;
-  GtkWidget *button;
+  GtkWidget     *hbox;
+  GtkWidget     *toggle;
+  GtkWidget     *spinbutton;
+  GtkAdjustment *adj;
+  GtkWidget     *button;
 
   g_return_val_if_fail (seed != NULL, NULL);
   g_return_val_if_fail (random_seed != NULL, NULL);
@@ -504,8 +506,10 @@ gimp_random_seed_new (guint    *seed,
   if (*random_seed)
     *seed = g_random_int ();
 
-  spinbutton = gimp_spin_button_new (&adj, *seed,
-                                     0, (guint32) -1 , 1, 10, 0, 1, 0);
+  adj = (GtkAdjustment *)
+    gtk_adjustment_new (*seed, 0, (guint32) -1, 1, 10, 0);
+  spinbutton = gtk_spin_button_new (adj, 1.0, 0);
+  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
   gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
   gtk_widget_show (spinbutton);
 
@@ -731,12 +735,14 @@ gimp_coordinates_new (GimpUnit         unit,
                       gdouble          ysize_100  /* % */)
 {
   GimpCoordinatesData *data;
-  GtkObject           *adjustment;
+  GtkAdjustment       *adjustment;
   GtkWidget           *spinbutton;
   GtkWidget           *sizeentry;
   GtkWidget           *chainbutton;
 
-  spinbutton = gimp_spin_button_new (&adjustment, 1, 0, 1, 1, 10, 0, 1, 2);
+  adjustment = (GtkAdjustment *) gtk_adjustment_new (1, 0, 1, 1, 10, 0);
+  spinbutton = gtk_spin_button_new (adjustment, 1.0, 2);
+  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
 
   if (spinbutton_width > 0)
     {
diff --git a/libgimpwidgets/gimpwidgets.h b/libgimpwidgets/gimpwidgets.h
index 222825b..52dd244 100644
--- a/libgimpwidgets/gimpwidgets.h
+++ b/libgimpwidgets/gimpwidgets.h
@@ -144,6 +144,7 @@ void   gimp_radio_group_set_active (GtkRadioButton     *radio_button,
                                     gpointer            item_data);
 
 
+GIMP_DEPRECATED_FOR(gtk_spin_button_new)
 GtkWidget * gimp_spin_button_new   (/* return value: */
                                     GtkObject         **adjustment,
 


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