]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkspinbutton.c
Deprecate widget flag: GTK_WIDGET_MAPPED
[~andy/gtk] / gtk / gtkspinbutton.c
index b24d985769815a1c2ff6659330c4d63fb1741b2c..315adc4e4840aadfbcb1c036b8ba526d2aeab13a 100644 (file)
@@ -517,7 +517,7 @@ gtk_spin_button_destroy (GtkObject *object)
 static void
 gtk_spin_button_map (GtkWidget *widget)
 {
-  if (GTK_WIDGET_REALIZED (widget) && !GTK_WIDGET_MAPPED (widget))
+  if (GTK_WIDGET_REALIZED (widget) && !gtk_widget_get_mapped (widget))
     {
       GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->map (widget);
       gdk_window_show (GTK_SPIN_BUTTON (widget)->panel);
@@ -527,7 +527,7 @@ gtk_spin_button_map (GtkWidget *widget)
 static void
 gtk_spin_button_unmap (GtkWidget *widget)
 {
-  if (GTK_WIDGET_MAPPED (widget))
+  if (gtk_widget_get_mapped (widget))
     {
       gtk_spin_button_stop_spinning (GTK_SPIN_BUTTON (widget));
 
@@ -731,7 +731,7 @@ gtk_spin_button_expose (GtkWidget      *widget,
 {
   GtkSpinButton *spin = GTK_SPIN_BUTTON (widget);
 
-  if (GTK_WIDGET_DRAWABLE (widget))
+  if (gtk_widget_is_drawable (widget))
     {
       if (event->window == spin->panel)
        {
@@ -804,7 +804,7 @@ gtk_spin_button_draw_arrow (GtkSpinButton *spin_button,
 
   widget = GTK_WIDGET (spin_button);
 
-  if (GTK_WIDGET_DRAWABLE (widget))
+  if (gtk_widget_is_drawable (widget))
     {
       width = spin_button_get_arrow_size (spin_button) + 2 * widget->style->xthickness;
 
@@ -966,7 +966,7 @@ gtk_spin_button_state_changed (GtkWidget    *widget,
 {
   GtkSpinButton *spin = GTK_SPIN_BUTTON (widget);
 
-  if (!GTK_WIDGET_IS_SENSITIVE (widget))
+  if (!gtk_widget_is_sensitive (widget))
     {
       gtk_spin_button_stop_spinning (spin);    
       gtk_widget_queue_draw (GTK_WIDGET (spin));
@@ -994,13 +994,13 @@ gtk_spin_button_scroll (GtkWidget      *widget,
 
   if (event->direction == GDK_SCROLL_UP)
     {
-      if (!GTK_WIDGET_HAS_FOCUS (widget))
+      if (!gtk_widget_has_focus (widget))
        gtk_widget_grab_focus (widget);
       gtk_spin_button_real_spin (spin, spin->adjustment->step_increment);
     }
   else if (event->direction == GDK_SCROLL_DOWN)
     {
-      if (!GTK_WIDGET_HAS_FOCUS (widget))
+      if (!gtk_widget_has_focus (widget))
        gtk_widget_grab_focus (widget);
       gtk_spin_button_real_spin (spin, -spin->adjustment->step_increment); 
     }
@@ -1067,7 +1067,7 @@ gtk_spin_button_button_press (GtkWidget      *widget,
     {
       if (event->window == spin->panel)
        {
-         if (!GTK_WIDGET_HAS_FOCUS (widget))
+         if (!gtk_widget_has_focus (widget))
            gtk_widget_grab_focus (widget);
          spin->button = event->button;
          
@@ -1427,8 +1427,10 @@ gtk_spin_button_insert_text (GtkEditable *editable,
       GdkWChar pos_sign;
       GdkWChar neg_sign;
       gint entry_length;
+      const gchar *entry_text;
 
-      entry_length = entry->text_length;
+      entry_length = gtk_entry_get_text_length (entry);
+      entry_text = gtk_entry_get_text (entry);
 
       lc = localeconv ();
 
@@ -1463,8 +1465,8 @@ gtk_spin_button_insert_text (GtkEditable *editable,
 #endif
 
       for (sign=0, i=0; i<entry_length; i++)
-       if ((entry->text[i] == neg_sign) ||
-           (entry->text[i] == pos_sign))
+       if ((entry_text[i] == neg_sign) ||
+           (entry_text[i] == pos_sign))
          {
            sign = 1;
            break;
@@ -1474,7 +1476,7 @@ gtk_spin_button_insert_text (GtkEditable *editable,
        return;
 
       for (dotpos=-1, i=0; i<entry_length; i++)
-       if (entry->text[i] == *(lc->decimal_point))
+       if (entry_text[i] == *(lc->decimal_point))
          {
            dotpos = i;
            break;
@@ -1594,6 +1596,16 @@ gtk_spin_button_default_output (GtkSpinButton *spin_button)
  ***********************************************************/
 
 
+/**
+ * gtk_spin_button_configure:
+ * @spin_button: a #GtkSpinButton
+ * @adjustment: (allow-none):  a #GtkAdjustment.
+ * @climb_rate: the new climb rate.
+ * @digits: the number of decimal places to display in the spin button.
+ *
+ * Changes the properties of an existing spin button. The adjustment, climb rate,
+ * and number of decimal places are all changed accordingly, after this function call.
+ */
 void
 gtk_spin_button_configure (GtkSpinButton  *spin_button,
                           GtkAdjustment  *adjustment,
@@ -1690,6 +1702,13 @@ gtk_spin_button_new_with_range (gdouble min,
   return GTK_WIDGET (spin);
 }
 
+static void
+warn_nonzero_page_size (GtkAdjustment *adjustment)
+{
+  if (gtk_adjustment_get_page_size (adjustment) != 0.0)
+    g_warning ("GtkSpinButton: setting an adjustment with non-zero page size is deprecated");
+}
+
 /* Callback used when the spin button's adjustment changes.  We need to redraw
  * the arrows when the adjustment's range changes, and reevaluate our size request.
  */
@@ -1701,6 +1720,7 @@ adjustment_changed_cb (GtkAdjustment *adjustment, gpointer data)
   spin_button = GTK_SPIN_BUTTON (data);
 
   spin_button->timer_step = spin_button->adjustment->step_increment;
+  warn_nonzero_page_size (adjustment);
   gtk_widget_queue_resize (GTK_WIDGET (spin_button));
 }
 
@@ -1740,6 +1760,7 @@ gtk_spin_button_set_adjustment (GtkSpinButton *spin_button,
                            G_CALLBACK (adjustment_changed_cb),
                            spin_button);
          spin_button->timer_step = spin_button->adjustment->step_increment;
+          warn_nonzero_page_size (adjustment);
         }
 
       gtk_widget_queue_resize (GTK_WIDGET (spin_button));
@@ -1828,8 +1849,8 @@ gtk_spin_button_set_increments (GtkSpinButton *spin_button,
 /**
  * gtk_spin_button_get_increments:
  * @spin_button: a #GtkSpinButton
- * @step: location to store step increment, or %NULL
- * @page: location to store page increment, or %NULL
+ * @step: (allow-none): location to store step increment, or %NULL
+ * @page: (allow-none): location to store page increment, or %NULL
  *
  * Gets the current step and page the increments used by @spin_button. See
  * gtk_spin_button_set_increments().
@@ -1880,8 +1901,8 @@ gtk_spin_button_set_range (GtkSpinButton *spin_button,
 /**
  * gtk_spin_button_get_range:
  * @spin_button: a #GtkSpinButton
- * @min: location to store minimum allowed value, or %NULL
- * @max: location to store maximum allowed value, or %NULL
+ * @min: (allow-none): location to store minimum allowed value, or %NULL
+ * @max: (allow-none): location to store maximum allowed value, or %NULL
  *
  * Gets the range allowed for @spin_button. See
  * gtk_spin_button_set_range().