* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
-#include <config.h>
+#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "gdk/gdkkeysyms.h"
#include "gtkbindings.h"
#include "gtkspinbutton.h"
+#include "gtkentryprivate.h"
#include "gtkmain.h"
#include "gtkmarshalers.h"
#include "gtksettings.h"
gboolean was_grabbed);
static void gtk_spin_button_state_changed (GtkWidget *widget,
GtkStateType previous_state);
+static void gtk_spin_button_style_set (GtkWidget *widget,
+ GtkStyle *previous_style);
static void gtk_spin_button_draw_arrow (GtkSpinButton *spin_button,
+ GdkRectangle *area,
GtkArrowType arrow_type);
-static gint gtk_spin_button_timer (GtkSpinButton *spin_button);
+static gboolean gtk_spin_button_timer (GtkSpinButton *spin_button);
static void gtk_spin_button_stop_spinning (GtkSpinButton *spin);
static void gtk_spin_button_value_changed (GtkAdjustment *adjustment,
GtkSpinButton *spin_button);
static gint gtk_spin_button_scroll (GtkWidget *widget,
GdkEventScroll *event);
static void gtk_spin_button_activate (GtkEntry *entry);
+static void gtk_spin_button_get_text_area_size (GtkEntry *entry,
+ gint *x,
+ gint *y,
+ gint *width,
+ gint *height);
static void gtk_spin_button_snap (GtkSpinButton *spin_button,
gdouble val);
static void gtk_spin_button_insert_text (GtkEditable *editable,
static gint spin_button_get_arrow_size (GtkSpinButton *spin_button);
static gint spin_button_get_shadow_type (GtkSpinButton *spin_button);
-static void spin_button_redraw (GtkSpinButton *spin_button);
-
static guint spinbutton_signals[LAST_SIGNAL] = {0};
gtk_spin_button_class_init (GtkSpinButtonClass *class)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
- GtkEntryClass *entry_class;
+ GtkObjectClass *object_class = GTK_OBJECT_CLASS (class);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
+ GtkEntryClass *entry_class = GTK_ENTRY_CLASS (class);
GtkBindingSet *binding_set;
- object_class = (GtkObjectClass*) class;
- widget_class = (GtkWidgetClass*) class;
- entry_class = (GtkEntryClass*) class;
-
gobject_class->finalize = gtk_spin_button_finalize;
gobject_class->set_property = gtk_spin_button_set_property;
widget_class->focus_out_event = gtk_spin_button_focus_out;
widget_class->grab_notify = gtk_spin_button_grab_notify;
widget_class->state_changed = gtk_spin_button_state_changed;
+ widget_class->style_set = gtk_spin_button_style_set;
entry_class->activate = gtk_spin_button_activate;
+ entry_class->get_text_area_size = gtk_spin_button_get_text_area_size;
class->input = NULL;
class->output = NULL;
G_TYPE_INT, 1,
G_TYPE_POINTER);
+ /**
+ * GtkSpinButton::output:
+ * @spin_button: the object which received the signal
+ *
+ * The ::output signal can be used to change to formatting
+ * of the value that is displayed in the spin buttons entry.
+ * |[
+ * /* show leading zeros */
+ * static gboolean
+ * on_output (GtkSpinButton *spin,
+ * gpointer data)
+ * {
+ * GtkAdjustment *adj;
+ * gchar *text;
+ * int value;
+ *
+ * adj = gtk_spin_button_get_adjustment (spin);
+ * value = (int)gtk_adjustment_get_value (adj);
+ * text = g_strdup_printf ("%02d", value);
+ * gtk_entry_set_text (GTK_ENTRY (spin), text);
+ * g_free (text);
+ *
+ * return TRUE;
+ * }
+ * ]|
+ *
+ * Returns: %TRUE if the value has been displayed.
+ */
spinbutton_signals[OUTPUT] =
g_signal_new (I_("output"),
G_TYPE_FROM_CLASS (gobject_class),
G_TYPE_BOOLEAN, 0);
spinbutton_signals[VALUE_CHANGED] =
- g_signal_new (I_("value_changed"),
+ g_signal_new (I_("value-changed"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkSpinButtonClass, value_changed),
/* Action signals */
spinbutton_signals[CHANGE_VALUE] =
- g_signal_new (I_("change_value"),
+ g_signal_new (I_("change-value"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (GtkSpinButtonClass, change_value),
const GValue *value,
GParamSpec *pspec)
{
- GtkSpinButton *spin_button;
+ GtkSpinButton *spin_button = GTK_SPIN_BUTTON (object);
- spin_button = GTK_SPIN_BUTTON (object);
-
switch (prop_id)
{
GtkAdjustment *adjustment;
gtk_spin_button_set_value (spin_button, g_value_get_double (value));
break;
default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
GValue *value,
GParamSpec *pspec)
{
- GtkSpinButton *spin_button;
+ GtkSpinButton *spin_button = GTK_SPIN_BUTTON (object);
- spin_button = GTK_SPIN_BUTTON (object);
-
switch (prop_id)
{
case PROP_ADJUSTMENT:
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);
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));
static void
gtk_spin_button_realize (GtkWidget *widget)
{
- GtkSpinButton *spin_button;
+ GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget);
GdkWindowAttr attributes;
gint attributes_mask;
- guint real_width;
gboolean return_val;
gint arrow_size;
- spin_button = GTK_SPIN_BUTTON (widget);
arrow_size = spin_button_get_arrow_size (spin_button);
- real_width = widget->allocation.width;
- widget->allocation.width -= arrow_size + 2 * widget->style->xthickness;
gtk_widget_set_events (widget, gtk_widget_get_events (widget) |
GDK_KEY_RELEASE_MASK);
GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->realize (widget);
- widget->allocation.width = real_width;
-
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- attributes.x = (widget->allocation.x +
- widget->allocation.width - arrow_size -
+ attributes.x = (widget->allocation.width - arrow_size -
2 * widget->style->xthickness);
- attributes.y = widget->allocation.y + (widget->allocation.height -
+ attributes.y = (widget->allocation.height -
widget->requisition.height) / 2;
attributes.width = arrow_size + 2 * widget->style->xthickness;
attributes.height = widget->requisition.height;
- spin_button->panel = gdk_window_new (gtk_widget_get_parent_window (widget),
+ spin_button->panel = gdk_window_new (widget->window,
&attributes, attributes_mask);
gdk_window_set_user_data (spin_button->panel, widget);
gtk_spin_button_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
- GtkEntry *entry;
- GtkSpinButton *spin_button;
+ GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget);
+ GtkEntry *entry = GTK_ENTRY (widget);
gint arrow_size;
- entry = GTK_ENTRY (widget);
- spin_button = GTK_SPIN_BUTTON (widget);
arrow_size = spin_button_get_arrow_size (spin_button);
-
+
GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->size_request (widget, requisition);
if (entry->width_chars < 0)
gboolean interior_focus;
gint focus_width;
gint xborder, yborder;
+ GtkBorder inner_border;
gtk_widget_style_get (widget,
"interior-focus", &interior_focus,
width = MAX (width, w);
_gtk_entry_get_borders (entry, &xborder, &yborder);
-
- xborder += 2; /* INNER_BORDER */
+ _gtk_entry_effective_inner_border (entry, &inner_border);
- requisition->width = width + xborder * 2;
+ requisition->width = width + xborder * 2 + inner_border.left + inner_border.right;
}
requisition->width += arrow_size + 2 * widget->style->xthickness;
gtk_spin_button_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
- GtkSpinButton *spin;
- GtkAllocation entry_allocation;
+ GtkSpinButton *spin = GTK_SPIN_BUTTON (widget);
GtkAllocation panel_allocation;
gint arrow_size;
gint panel_width;
- g_return_if_fail (GTK_IS_SPIN_BUTTON (widget));
- g_return_if_fail (allocation != NULL);
-
- spin = GTK_SPIN_BUTTON (widget);
arrow_size = spin_button_get_arrow_size (spin);
panel_width = arrow_size + 2 * widget->style->xthickness;
widget->allocation = *allocation;
- entry_allocation = *allocation;
- entry_allocation.width -= panel_width;
-
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- {
- entry_allocation.x += panel_width;
- panel_allocation.x = allocation->x;
- }
+ panel_allocation.x = 0;
else
- {
- panel_allocation.x = allocation->x + allocation->width - panel_width;
- }
+ panel_allocation.x = allocation->width - panel_width;
panel_allocation.width = panel_width;
panel_allocation.height = MIN (widget->requisition.height, allocation->height);
- panel_allocation.y = allocation->y + (allocation->height -
- panel_allocation.height) / 2;
+ panel_allocation.y = 0;
- GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->size_allocate (widget, &entry_allocation);
+ GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->size_allocate (widget, allocation);
if (GTK_WIDGET_REALIZED (widget))
{
panel_allocation.height);
}
- spin_button_redraw (spin);
+ gtk_widget_queue_draw (GTK_WIDGET (spin));
}
static gint
gtk_spin_button_expose (GtkWidget *widget,
GdkEventExpose *event)
{
- GtkSpinButton *spin;
-
- g_return_val_if_fail (GTK_IS_SPIN_BUTTON (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- spin = GTK_SPIN_BUTTON (widget);
+ GtkSpinButton *spin = GTK_SPIN_BUTTON (widget);
- if (GTK_WIDGET_DRAWABLE (widget))
+ if (gtk_widget_is_drawable (widget))
{
- GtkShadowType shadow_type;
- GdkRectangle rect;
+ if (event->window == spin->panel)
+ {
+ GtkShadowType shadow_type;
- if (event->window != spin->panel)
- GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->expose_event (widget, event);
+ shadow_type = spin_button_get_shadow_type (spin);
- /* we redraw the panel even if it wasn't exposed. This is
- * because spin->panel is not a child window of widget->window,
- * so it will not be invalidated by eg. gtk_widget_queue_draw().
- */
- rect.x = 0;
- rect.y = 0;
+ if (shadow_type != GTK_SHADOW_NONE)
+ {
+ gint width, height;
- gdk_drawable_get_size (spin->panel, &rect.width, &rect.height);
+ gdk_drawable_get_size (spin->panel, &width, &height);
- shadow_type = spin_button_get_shadow_type (spin);
-
- gdk_window_begin_paint_rect (spin->panel, &rect);
+ gtk_paint_box (widget->style, spin->panel,
+ GTK_STATE_NORMAL, shadow_type,
+ &event->area, widget, "spinbutton",
+ 0, 0, width, height);
+ }
- if (shadow_type != GTK_SHADOW_NONE)
- {
- gtk_paint_box (widget->style, spin->panel,
- GTK_STATE_NORMAL, shadow_type,
- NULL, widget, "spinbutton",
- rect.x, rect.y, rect.width, rect.height);
+ gtk_spin_button_draw_arrow (spin, &event->area, GTK_ARROW_UP);
+ gtk_spin_button_draw_arrow (spin, &event->area, GTK_ARROW_DOWN);
}
-
- gtk_spin_button_draw_arrow (spin, GTK_ARROW_UP);
- gtk_spin_button_draw_arrow (spin, GTK_ARROW_DOWN);
-
- gdk_window_end_paint (spin->panel);
+ else
+ GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->expose_event (widget, event);
}
return FALSE;
static void
gtk_spin_button_draw_arrow (GtkSpinButton *spin_button,
+ GdkRectangle *area,
GtkArrowType arrow_type)
{
GtkStateType state_type;
gint width;
gint h, w;
- g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button));
g_return_if_fail (arrow_type == GTK_ARROW_UP || arrow_type == GTK_ARROW_DOWN);
-
+
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;
gtk_paint_box (widget->style, spin_button->panel,
state_type, shadow_type,
- NULL, widget,
+ area, widget,
(arrow_type == GTK_ARROW_UP)? "spinbutton_up" : "spinbutton_down",
x, y, width, height);
gtk_paint_arrow (widget->style, spin_button->panel,
state_type, shadow_type,
- NULL, widget, "spinbutton",
+ area, widget, "spinbutton",
arrow_type, TRUE,
x, y, width, height);
}
else
spin->in_child = GTK_ARROW_DOWN;
- spin_button_redraw (spin);
+ gtk_widget_queue_draw (GTK_WIDGET (spin));
}
-
+
+ if (GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->enter_notify_event)
+ return GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->enter_notify_event (widget, event);
+
return FALSE;
}
GtkSpinButton *spin = GTK_SPIN_BUTTON (widget);
spin->in_child = NO_ARROW;
- spin_button_redraw (spin);
-
+ gtk_widget_queue_draw (GTK_WIDGET (spin));
+
+ if (GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->leave_notify_event)
+ return GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->leave_notify_event (widget, event);
+
return FALSE;
}
if (!was_grabbed)
{
gtk_spin_button_stop_spinning (spin);
- spin_button_redraw (spin);
+ gtk_widget_queue_draw (GTK_WIDGET (spin));
}
}
{
GtkSpinButton *spin = GTK_SPIN_BUTTON (widget);
- if (!GTK_WIDGET_IS_SENSITIVE (widget))
+ if (!gtk_widget_is_sensitive (widget))
{
gtk_spin_button_stop_spinning (spin);
- spin_button_redraw (spin);
+ gtk_widget_queue_draw (GTK_WIDGET (spin));
}
}
+static void
+gtk_spin_button_style_set (GtkWidget *widget,
+ GtkStyle *previous_style)
+{
+ GtkSpinButton *spin = GTK_SPIN_BUTTON (widget);
+
+ if (previous_style && GTK_WIDGET_REALIZED (widget))
+ gtk_style_set_background (widget->style, spin->panel, GTK_STATE_NORMAL);
+
+ GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->style_set (widget, previous_style);
+}
+
+
static gint
gtk_spin_button_scroll (GtkWidget *widget,
GdkEventScroll *event)
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);
}
spin->timer_step = step;
spin->need_timer = TRUE;
- spin->timer = g_timeout_add (timeout,
+ spin->timer = gdk_threads_add_timeout (timeout,
(GSourceFunc) gtk_spin_button_timer,
(gpointer) spin);
}
gtk_spin_button_real_spin (spin, click_child == GTK_ARROW_UP ? step : -step);
- spin_button_redraw (spin);
+ gtk_widget_queue_draw (GTK_WIDGET (spin));
}
static gint
{
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;
}
}
}
- spin_button_redraw (spin);
+ gtk_widget_queue_draw (GTK_WIDGET (spin));
return TRUE;
}
if (event->window == spin->panel)
{
- gint y;
-
- gdk_window_get_pointer (spin->panel, NULL, &y, NULL);
+ gint y = event->y;
+
+ gdk_event_request_motions (event);
if (y <= widget->requisition.height / 2 &&
spin->in_child == GTK_ARROW_DOWN)
{
spin->in_child = GTK_ARROW_UP;
- spin_button_redraw (spin);
+ gtk_widget_queue_draw (GTK_WIDGET (spin));
}
else if (y > widget->requisition.height / 2 &&
spin->in_child == GTK_ARROW_UP)
{
spin->in_child = GTK_ARROW_DOWN;
- spin_button_redraw (spin);
+ gtk_widget_queue_draw (GTK_WIDGET (spin));
}
return FALSE;
{
gboolean retval = FALSE;
- GDK_THREADS_ENTER ();
-
if (spin_button->timer)
{
if (spin_button->click_child == GTK_ARROW_UP)
g_object_get (settings, "gtk-timeout-repeat", &timeout, NULL);
spin_button->need_timer = FALSE;
- spin_button->timer = g_timeout_add (timeout,
+ spin_button->timer = gdk_threads_add_timeout (timeout,
(GSourceFunc) gtk_spin_button_timer,
(gpointer) spin_button);
}
}
}
- GDK_THREADS_LEAVE ();
-
return retval;
}
g_signal_emit (spin_button, spinbutton_signals[VALUE_CHANGED], 0);
- spin_button_redraw (spin_button);
+ gtk_widget_queue_draw (GTK_WIDGET (spin_button));
g_object_notify (G_OBJECT (spin_button), "value");
}
gtk_spin_button_real_change_value (GtkSpinButton *spin,
GtkScrollType scroll)
{
+ gdouble old_value;
+
+ /* When the key binding is activated, there may be an outstanding
+ * value, so we first have to commit what is currently written in
+ * the spin buttons text entry. See #106574
+ */
+ gtk_spin_button_update (spin);
+
+ old_value = spin->adjustment->value;
+
/* We don't test whether the entry is editable, since
* this key binding conceptually corresponds to changing
* the value with the buttons using the mouse, which
}
gtk_spin_button_update (spin);
+
+ if (spin->adjustment->value == old_value)
+ gtk_widget_error_bell (GTK_WIDGET (spin));
}
static gint
else
val = spin_button->adjustment->lower + ceil (tmp) * inc;
- if (fabs (val - spin_button->adjustment->value) > EPSILON)
- gtk_adjustment_set_value (spin_button->adjustment, val);
- else
- {
- gint return_val = FALSE;
- g_signal_emit (spin_button, spinbutton_signals[OUTPUT], 0, &return_val);
- if (return_val == FALSE)
- gtk_spin_button_default_output (spin_button);
- }
+ gtk_spin_button_set_value (spin_button, val);
}
static void
GTK_ENTRY_CLASS (gtk_spin_button_parent_class)->activate (entry);
}
+static void
+gtk_spin_button_get_text_area_size (GtkEntry *entry,
+ gint *x,
+ gint *y,
+ gint *width,
+ gint *height)
+{
+ gint arrow_size;
+ gint panel_width;
+
+ GTK_ENTRY_CLASS (gtk_spin_button_parent_class)->get_text_area_size (entry, x, y, width, height);
+
+ arrow_size = spin_button_get_arrow_size (GTK_SPIN_BUTTON (entry));
+ panel_width = arrow_size + 2 * GTK_WIDGET (entry)->style->xthickness;
+
+ if (width)
+ *width -= panel_width;
+
+ if (gtk_widget_get_direction (GTK_WIDGET (entry)) == GTK_TEXT_DIR_RTL && x)
+ *x += panel_width;
+}
+
static void
gtk_spin_button_insert_text (GtkEditable *editable,
const gchar *new_text,
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 ();
else
pos_sign = '+';
+#ifdef G_OS_WIN32
+ /* Workaround for bug caused by some Windows application messing
+ * up the positive sign of the current locale, more specifically
+ * HKEY_CURRENT_USER\Control Panel\International\sPositiveSign.
+ * See bug #330743 and for instance
+ * http://www.msnewsgroups.net/group/microsoft.public.dotnet.languages.csharp/topic36024.aspx
+ *
+ * I don't know if the positive sign always gets bogusly set to
+ * a digit when the above Registry value is corrupted as
+ * described. (In my test case, it got set to "8", and in the
+ * bug report above it presumably was set ot "0".) Probably it
+ * might get set to almost anything? So how to distinguish a
+ * bogus value from some correct one for some locale? That is
+ * probably hard, but at least we should filter out the
+ * digits...
+ */
+ if (pos_sign >= '0' && pos_sign <= '9')
+ pos_sign = '+';
+#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;
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;
if (wrapped)
g_signal_emit (spin_button, spinbutton_signals[WRAPPED], 0);
- spin_button_redraw (spin_button);
+ gtk_widget_queue_draw (GTK_WIDGET (spin_button));
}
static gint
***********************************************************/
+/**
+ * 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,
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.
*/
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));
}
if (adjustment)
{
g_object_ref_sink (adjustment);
- g_signal_connect (adjustment, "value_changed",
+ g_signal_connect (adjustment, "value-changed",
G_CALLBACK (gtk_spin_button_value_changed),
spin_button);
g_signal_connect (adjustment, "changed",
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));
/**
* 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().
/**
* 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().
else if (return_val == GTK_INPUT_ERROR)
error = 1;
- spin_button_redraw (spin_button);
+ gtk_widget_queue_draw (GTK_WIDGET (spin_button));
if (spin_button->update_policy == GTK_UPDATE_ALWAYS)
{
if (spin_button->snap_to_ticks)
gtk_spin_button_snap (spin_button, val);
else
- {
- if (fabs (val - spin_button->adjustment->value) > EPSILON)
- gtk_adjustment_set_value (spin_button->adjustment, val);
- else
- {
- return_val = FALSE;
- g_signal_emit (spin_button, spinbutton_signals[OUTPUT], 0,
- &return_val);
- if (return_val == FALSE)
- gtk_spin_button_default_output (spin_button);
- }
- }
+ gtk_spin_button_set_value (spin_button, val);
}
-static void
-spin_button_redraw (GtkSpinButton *spin_button)
-{
- GtkWidget *widget;
-
- widget = GTK_WIDGET (spin_button);
-
- if (GTK_WIDGET_DRAWABLE (widget))
- {
- gtk_widget_queue_draw (widget);
-
- /* We must invalidate the panel window ourselves, because it
- * is not a child of widget->window
- */
- gdk_window_invalidate_rect (spin_button->panel, NULL, TRUE);
- }
-}
-
#define __GTK_SPIN_BUTTON_C__
#include "gtkaliasdef.c"