GtkSpinButton retrieve an integer or floating-point number from the user. A #GtkSpinButton is an ideal way to allow the user to set the value of some attribute. Rather than having to directly type a number into a #GtkEntry, #GtkSpinButton allows the user to click on one of two arrows to increment or decrement the displayed value. A value can still be typed in, with the bonus that it can be checked to ensure it is in a given range. The main properties of a #GtkSpinButton are through a #GtkAdjustment. See the #GtkAdjustment section for more details about an adjustment's properties. Using a <structname>GtkSpinButton</structname> to get an integer. /* Provides a function to retrieve an integer value from a GtkSpinButton * and creates a spin button to model percentage values. */ gint grab_int_value (GtkSpinButton *a_spinner, gpointer user_data) { return gtk_spin_button_get_value_as_int (a_spinner); } void create_integer_spin_button (void) { GtkWidget *window, *spinner; GtkAdjustment *spinner_adj; spinner_adj = (GtkAdjustment *) gtk_adjustment_new (50.0, 0.0, 100.0, 1.0, 5.0, 5.0); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_container_set_border_width (GTK_CONTAINER (window), 5); /* creates the spinner, with no decimal places */ spinner = gtk_spin_button_new (spinner_adj, 1.0, 0); gtk_container_add (GTK_CONTAINER (window), spinner); gtk_widget_show_all (window); return; } Using a <structname>GtkSpinButton</structname> to get a floating point value. /* Provides a function to retrieve a floating point value from a * GtkSpinButton, and creates a high precision spin button. */ gfloat grab_int_value (GtkSpinButton *a_spinner, gpointer user_data) { return gtk_spin_button_get_value (a_spinner); } void create_floating_spin_button (void) { GtkWidget *window, *spinner; GtkAdjustment *spinner_adj; spinner_adj = (GtkAdjustment *) gtk_adjustment_new (2.500, 0.0, 5.0, 0.001, 0.1, 0.1); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_container_set_border_width (GTK_CONTAINER (window), 5); /* creates the spinner, with three decimal places */ spinner = gtk_spin_button_new (spinner_adj, 0.001, 3); gtk_container_add (GTK_CONTAINER (window), spinner); gtk_widget_show_all (window); return; } #GtkEntry retrieve text rather than numbers. entry is the #GtkEntry part of the #GtkSpinButton widget, and can be used accordingly. All other fields contain private data and should only be modified using the functions below. GTK_UPDATE_ALWAYS When refreshing your #GtkSpinButton, the value is always displayed. GTK_UPDATE_IF_VALID When refreshing your #GtkSpinButton, the value is only displayed if it is valid within the bounds of the spin button's #GtkAdjustment. @GTK_UPDATE_ALWAYS: @GTK_UPDATE_IF_VALID: GTK_SPIN_STEP_FORWARD, GTK_SPIN_STEP_BACKWARD, GTK_SPIN_PAGE_FORWARD, GTK_SPIN_PAGE_BACKWARD These values spin a #GtkSpinButton by the relevant values of the spin button's #GtkAdjustment. GTK_SPIN_HOME, GTK_SPIN_END These set the spin button's value to the minimum or maxmimum possible values, (set by it's #GtkAdjustment), respectively. GTK_SPIN_USER_DEFINED The programmer must specify the exact amount to spin the #GtkSpinButton. @GTK_SPIN_STEP_FORWARD: @GTK_SPIN_STEP_BACKWARD: @GTK_SPIN_PAGE_FORWARD: @GTK_SPIN_PAGE_BACKWARD: @GTK_SPIN_HOME: @GTK_SPIN_END: @GTK_SPIN_USER_DEFINED: 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. @spin_button: a #GtkSpinButton. @adjustment: a #GtkAdjustment. @climb_rate: the new climb rate. @digits: the number of decimal places to display in the spin button. Creates a new #GtkSpinButton. @adjustment: the #GtkAdjustment object that this spin button should use. @climb_rate: specifies how much the spin button changes when an arrow is clicked on. @digits: the number of decimal places to display. @Returns: The new spin button as a #GtkWidget. @min: @max: @step: @Returns: @spin_button: @adjustment: @spin_button: @Returns: @spin_button: @digits: @spin_button: @step: @page: @spin_button: @min: @max: Gets the value in the @spin_button. This function is deprecated, use gtk_spin_button_get_value() instead. @Returns: the value of @spin_button. @spin_button: a #GtkSpinButton. @spin_button: @Returns: @spin_button: @value: @spin_button: @policy: @spin_button: @numeric: @spin_button: @direction: @increment: @spin_button: @wrap: @spin_button: @snap_to_ticks: @spin_button: @spin_button: @Returns: @spin_button: @step: @page: @spin_button: @Returns: @spin_button: @min: @max: @spin_button: @Returns: @spin_button: @Returns: @spin_button: @Returns: @spin_button: @Returns: @spinbutton: the object which received the signal. @arg1: @spinbutton: the object which received the signal. @arg1: @Returns: @spinbutton: the object which received the signal. @Returns: @spinbutton: the object which received the signal. the #GtkAdjustment that defines a spin button's main properties. the amount a spin button changes when an arrow is clicked. the number of decimal places to display. whether erroneous values are automatically changed to a spin button's nearest step increment. whether non-numeric characters should be ignored. whether a spin button should wrap upon reaching its limits. how a spin button should be updated. reads the current value, or sets a new value.