diff --git a/ChangeLog b/ChangeLog index 98d55d0157..54be6692a9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2005-04-17 Sven Neumann + + * libgimpwidgets/gimpsizeentry.c: use gimp_spin_button_new() which + calls gtk_spin_button_set_numeric() for us. Part of a fix for bug + #300935. + + * libgimpwidgets/gimpwidgets.c: improved the API docs for + gimp_spin_button_new(). + + * app/tools/gimpcolorbalancetool.c + * app/tools/gimplevelstool.c + * plug-ins/common/screenshot.c + * plug-ins/ifscompose/ifscompose.c + * plug-ins/rcm/rcm_dialog.c + * plug-ins/script-fu/script-fu-interface.c + * plug-ins/winsnap/winsnap.c: use gimp_spin_button_new(). + 2005-04-17 Sven Neumann * plug-ins/helpbrowser/dialog.c: set a busy cursor while loading a diff --git a/app/tools/gimpcolorbalancetool.c b/app/tools/gimpcolorbalancetool.c index b5ce1d4240..9d5cff9357 100644 --- a/app/tools/gimpcolorbalancetool.c +++ b/app/tools/gimpcolorbalancetool.c @@ -226,12 +226,10 @@ create_levels_scale (const gchar *left, GtkWidget *table, gint col) { - GtkWidget *label; - GtkWidget *slider; - GtkWidget *spinbutton; - GtkAdjustment *adj; - - adj = GTK_ADJUSTMENT (gtk_adjustment_new (0, -100.0, 100.0, 1.0, 10.0, 0.0)); + GtkWidget *label; + GtkWidget *slider; + GtkWidget *spinbutton; + GtkObject *adj; label = gtk_label_new (left); gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); @@ -239,7 +237,10 @@ create_levels_scale (const gchar *left, GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); gtk_widget_show (label); - slider = gtk_hscale_new (adj); + spinbutton = gimp_spin_button_new (&adj, + 0, -100.0, 100.0, 1.0, 10.0, 0.0, 1.0, 0); + + slider = gtk_hscale_new (GTK_ADJUSTMENT (adj)); gtk_scale_set_draw_value (GTK_SCALE (slider), FALSE); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_widget_set_size_request (slider, 100, -1); @@ -252,12 +253,11 @@ create_levels_scale (const gchar *left, GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); gtk_widget_show (label); - spinbutton = gtk_spin_button_new (adj, 1.0, 0); gtk_table_attach (GTK_TABLE (table), spinbutton, 3, 4, col, col + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); gtk_widget_show (spinbutton); - return adj; + return GTK_ADJUSTMENT (adj); } static void diff --git a/app/tools/gimplevelstool.c b/app/tools/gimplevelstool.c index aaa9c73c2b..07181b7571 100644 --- a/app/tools/gimplevelstool.c +++ b/app/tools/gimplevelstool.c @@ -518,28 +518,22 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool) gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, FALSE, 0); gtk_widget_show (button); - data = gtk_adjustment_new (0, 0, 255, 1, 10, 10); - tool->low_input = GTK_ADJUSTMENT (data); - - spinbutton = gtk_spin_button_new (tool->low_input, 0.5, 0); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE); + spinbutton = gimp_spin_button_new (&data, 0, 0, 255, 1, 10, 10, 0.5, 0); gtk_box_pack_start (GTK_BOX (hbox2), spinbutton, FALSE, FALSE, 0); gtk_widget_show (spinbutton); + tool->low_input = GTK_ADJUSTMENT (data); g_signal_connect (tool->low_input, "value_changed", G_CALLBACK (levels_low_input_adjustment_update), tool); /* input gamma spin */ - data = gtk_adjustment_new (1, 0.1, 10, 0.01, 0.1, 1); - tool->gamma = GTK_ADJUSTMENT (data); - - spinbutton = gtk_spin_button_new (tool->gamma, 0.5, 2); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE); + spinbutton = gimp_spin_button_new (&data, 1, 0.1, 10, 0.01, 0.1, 1, 0.5, 2); gtk_box_pack_start (GTK_BOX (hbox), spinbutton, TRUE, FALSE, 0); gimp_help_set_help_data (spinbutton, _("Gamma"), NULL); gtk_widget_show (spinbutton); + tool->gamma = GTK_ADJUSTMENT (data); g_signal_connect (tool->gamma, "value_changed", G_CALLBACK (levels_gamma_adjustment_update), tool); @@ -553,19 +547,15 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool) gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, FALSE, 0); gtk_widget_show (button); - data = gtk_adjustment_new (255, 0, 255, 1, 10, 10); - tool->high_input = GTK_ADJUSTMENT (data); - - spinbutton = gtk_spin_button_new (tool->high_input, 0.5, 0); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE); + spinbutton = gimp_spin_button_new (&data, 255, 0, 255, 1, 10, 10, 0.5, 0); gtk_box_pack_start (GTK_BOX (hbox2), spinbutton, FALSE, FALSE, 0); gtk_widget_show (spinbutton); + tool->high_input = GTK_ADJUSTMENT (data); g_signal_connect (tool->high_input, "value_changed", G_CALLBACK (levels_high_input_adjustment_update), tool); - /* Output levels frame */ frame = gimp_frame_new (_("Output Levels")); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); @@ -612,27 +602,21 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool) gtk_widget_show (hbox); /* low output spin */ - data = gtk_adjustment_new (0, 0, 255, 1, 10, 10); - tool->low_output = GTK_ADJUSTMENT (data); - - spinbutton = gtk_spin_button_new (tool->low_output, 0.5, 0); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE); + spinbutton = gimp_spin_button_new (&data, 0, 0, 255, 1, 10, 10, 0.5, 0); gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0); gtk_widget_show (spinbutton); + tool->low_output = GTK_ADJUSTMENT (data); g_signal_connect (tool->low_output, "value_changed", G_CALLBACK (levels_low_output_adjustment_update), tool); /* high output spin */ - data = gtk_adjustment_new (255, 0, 255, 1, 10, 10); - tool->high_output = GTK_ADJUSTMENT (data); - - spinbutton = gtk_spin_button_new (tool->high_output, 0.5, 0); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE); + spinbutton = gimp_spin_button_new (&data, 255, 0, 255, 1, 10, 10, 0.5, 0); gtk_box_pack_end (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0); gtk_widget_show (spinbutton); + tool->high_output = GTK_ADJUSTMENT (data); g_signal_connect (tool->high_output, "value_changed", G_CALLBACK (levels_high_output_adjustment_update), tool); diff --git a/libgimpwidgets/gimpsizeentry.c b/libgimpwidgets/gimpsizeentry.c index 70f95566c2..210ec11ecb 100644 --- a/libgimpwidgets/gimpsizeentry.c +++ b/libgimpwidgets/gimpsizeentry.c @@ -291,6 +291,7 @@ gimp_size_entry_new (gint number_of_fields, for (i = 0; i < number_of_fields; i++) { GimpSizeEntryField *gsef; + gint digits; gsef = g_new0 (GimpSizeEntryField, 1); gse->fields = g_slist_append (gse->fields, gsef); @@ -311,15 +312,16 @@ gimp_size_entry_new (gint number_of_fields, (update_policy == GIMP_SIZE_ENTRY_UPDATE_SIZE) ? 0 : 3; gsef->stop_recursion = 0; - gsef->value_adjustment = gtk_adjustment_new (gsef->value, - gsef->min_value, - gsef->max_value, - 1.0, 10.0, 0.0); - gsef->value_spinbutton = - gtk_spin_button_new (GTK_ADJUSTMENT (gsef->value_adjustment), 1.0, - (unit == GIMP_UNIT_PIXEL) ? gsef->refval_digits : - (unit == GIMP_UNIT_PERCENT) ? 2 : - GIMP_SIZE_ENTRY_DIGITS (unit)); + digits = ((unit == GIMP_UNIT_PIXEL) ? + gsef->refval_digits : ((unit == GIMP_UNIT_PERCENT) ? + 2 : GIMP_SIZE_ENTRY_DIGITS (unit))); + + gsef->value_spinbutton = gimp_spin_button_new (&gsef->value_adjustment, + gsef->value, + gsef->min_value, + gsef->max_value, + 1.0, 10.0, 0.0, + 1.0, digits); if (spinbutton_width > 0) { @@ -342,14 +344,12 @@ gimp_size_entry_new (gint number_of_fields, if (gse->show_refval) { - gsef->refval_adjustment = gtk_adjustment_new (gsef->refval, - gsef->min_refval, - gsef->max_refval, - 1.0, 10.0, 0.0); - gsef->refval_spinbutton = - gtk_spin_button_new (GTK_ADJUSTMENT (gsef->refval_adjustment), - 1.0, - gsef->refval_digits); + gsef->refval_spinbutton = + gimp_spin_button_new (&gsef->refval_adjustment, + gsef->refval, + gsef->min_refval, gsef->max_refval, + 1.0, 10.0, 0.0, 1.0, gsef->refval_digits); + gtk_widget_set_size_request (gsef->refval_spinbutton, spinbutton_width, -1); gtk_table_attach_defaults (GTK_TABLE (gse), gsef->refval_spinbutton, diff --git a/libgimpwidgets/gimpwidgets.c b/libgimpwidgets/gimpwidgets.c index 9aecbf93b1..92bf997735 100644 --- a/libgimpwidgets/gimpwidgets.c +++ b/libgimpwidgets/gimpwidgets.c @@ -419,9 +419,10 @@ gimp_int_radio_group_set_active (GtkRadioButton *radio_button, * @climb_rate: The spinbutton's climb rate. * @digits: The spinbutton's number of decimal digits. * - * This function is a shortcut for gtk_adjustment_new() and a subsequent - * gtk_spin_button_new() and does some more initialisation stuff like - * setting a standard minimum horizontal size. + * This function is a shortcut for gtk_adjustment_new() and a + * subsequent gtk_spin_button_new(). It also calls + * gtk_spin_button_set_numeric() so that non-numeric text cannot be + * entered. * * Returns: A #GtkSpinbutton and it's #GtkAdjustment. **/ @@ -443,6 +444,7 @@ gimp_spin_button_new (GtkObject **adjustment, /* return value */ spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (*adjustment), climb_rate, digits); + gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE); return spinbutton; diff --git a/plug-ins/common/screenshot.c b/plug-ins/common/screenshot.c index 2a6376878b..fd21162eac 100644 --- a/plug-ins/common/screenshot.c +++ b/plug-ins/common/screenshot.c @@ -846,8 +846,8 @@ shoot_dialog (GdkScreen **screen) gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); - adj = gtk_adjustment_new (shootvals.select_delay, 0.0, 100.0, 1.0, 5.0, 0.0); - spinner = gtk_spin_button_new (GTK_ADJUSTMENT (adj), 0, 0); + spinner = gimp_spin_button_new (&adj, shootvals.select_delay, + 0.0, 100.0, 1.0, 5.0, 0.0, 0, 0); gtk_box_pack_start (GTK_BOX (hbox), spinner, FALSE, FALSE, 0); gtk_widget_show (spinner); diff --git a/plug-ins/ifscompose/ifscompose.c b/plug-ins/ifscompose/ifscompose.c index 7367511941..cedb70663a 100644 --- a/plug-ins/ifscompose/ifscompose.c +++ b/plug-ins/ifscompose/ifscompose.c @@ -247,8 +247,6 @@ static ValuePair *value_pair_create (gpointer data, gboolean create_scale, ValuePairType type); static void value_pair_update (ValuePair *value_pair); -static void value_pair_destroy_callback (GtkWidget *widget, - ValuePair *value_pair); static void value_pair_scale_callback (GtkAdjustment *adjustment, ValuePair *value_pair); @@ -2114,48 +2112,35 @@ value_pair_create (gpointer data, value_pair->data.d = data; value_pair->type = type; - value_pair->adjustment = - gtk_adjustment_new (1.0, lower, upper, - (upper-lower) / 100, (upper-lower) / 10, - 0.0); - /* We need to sink the adjustment, since we may not create a scale for - * it, so nobody will assume the initial refcount - */ - g_object_ref (value_pair->adjustment); - gtk_object_sink (value_pair->adjustment); + value_pair->spin = gimp_spin_button_new (&value_pair->adjustment, + 1.0, lower, upper, + (upper - lower) / 100, + (upper - lower) / 10, + 0.0, 1.0, 3); + gtk_widget_set_size_request (value_pair->spin, 72, -1); + + g_signal_connect (value_pair->adjustment, "value_changed", + G_CALLBACK (value_pair_scale_callback), + value_pair); if (create_scale) { value_pair->scale = gtk_hscale_new (GTK_ADJUSTMENT (value_pair->adjustment)); - gtk_widget_ref (value_pair->scale); if (type == VALUE_PAIR_INT) - gtk_scale_set_digits (GTK_SCALE (value_pair->scale), 0); + gtk_scale_set_digits (GTK_SCALE (value_pair->scale), 0); else - gtk_scale_set_digits (GTK_SCALE (value_pair->scale), 3); + gtk_scale_set_digits (GTK_SCALE (value_pair->scale), 3); gtk_scale_set_draw_value (GTK_SCALE (value_pair->scale), FALSE); gtk_range_set_update_policy (GTK_RANGE (value_pair->scale), GTK_UPDATE_DELAYED); } else - value_pair->scale = NULL; - - /* We destroy the value pair when the spinbutton is destroyed, so - * we don't need to hold a refcount on the entry - */ - - value_pair->spin - = gtk_spin_button_new (GTK_ADJUSTMENT (value_pair->adjustment), - 1.0, 3); - gtk_widget_set_size_request (value_pair->spin, 72, -1); - g_signal_connect (value_pair->spin, "destroy", - G_CALLBACK (value_pair_destroy_callback), - value_pair); - g_signal_connect (value_pair->adjustment, "value_changed", - G_CALLBACK (value_pair_scale_callback), - value_pair); + { + value_pair->scale = NULL; + } return value_pair; } @@ -2199,15 +2184,6 @@ value_pair_scale_callback (GtkAdjustment *adjustment, val_changed_update (); } -static void -value_pair_destroy_callback (GtkWidget *widget, - ValuePair *value_pair) -{ - if (value_pair->scale) - g_object_unref (value_pair->scale); - g_object_unref (value_pair->adjustment); -} - static void design_op_update_callback (GtkRadioAction *action, GtkRadioAction *current, diff --git a/plug-ins/rcm/rcm_dialog.c b/plug-ins/rcm/rcm_dialog.c index 7a60c2f02f..09b28529dc 100644 --- a/plug-ins/rcm/rcm_dialog.c +++ b/plug-ins/rcm/rcm_dialog.c @@ -551,6 +551,7 @@ rcm_create_gray (void) 0.0, 1.0, 0.0001, 0.001, 0.0); entry = gtk_spin_button_new (adj, 0.01, 4); + gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (entry), TRUE); gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0); gtk_widget_show (entry); diff --git a/plug-ins/script-fu/script-fu-interface.c b/plug-ins/script-fu/script-fu-interface.c index 8054b811a1..0759089826 100644 --- a/plug-ins/script-fu/script-fu-interface.c +++ b/plug-ins/script-fu/script-fu-interface.c @@ -276,6 +276,7 @@ script_fu_interface (SFScript *script) for (i = script->image_based ? 2 : 0; i < script->num_args; i++) { GtkWidget *widget = NULL; + GtkObject *adj; gchar *label_text; gfloat label_yalign = 0.5; gint *ID_ptr = NULL; @@ -412,15 +413,16 @@ script_fu_interface (SFScript *script) case SF_SPINNER: left_align = TRUE; - script->arg_values[i].sfa_adjustment.adj = (GtkAdjustment *) - gtk_adjustment_new (script->arg_values[i].sfa_adjustment.value, - script->arg_defaults[i].sfa_adjustment.lower, - script->arg_defaults[i].sfa_adjustment.upper, - script->arg_defaults[i].sfa_adjustment.step, - script->arg_defaults[i].sfa_adjustment.page, 0); - widget = gtk_spin_button_new (script->arg_values[i].sfa_adjustment.adj, - 0, - script->arg_defaults[i].sfa_adjustment.digits); + widget = + gimp_spin_button_new (&adj, + script->arg_values[i].sfa_adjustment.value, + script->arg_defaults[i].sfa_adjustment.lower, + script->arg_defaults[i].sfa_adjustment.upper, + script->arg_defaults[i].sfa_adjustment.step, + script->arg_defaults[i].sfa_adjustment.page, + 0, 0, + script->arg_defaults[i].sfa_adjustment.digits); + script->arg_values[i].sfa_adjustment.adj = GTK_ADJUSTMENT (adj); break; } diff --git a/plug-ins/winsnap/winsnap.c b/plug-ins/winsnap/winsnap.c index 8cb62665ad..df36e611ae 100644 --- a/plug-ins/winsnap/winsnap.c +++ b/plug-ins/winsnap/winsnap.c @@ -838,15 +838,15 @@ snap_toggle_update (GtkWidget *widget, static gboolean snap_dialog (void) { - GtkWidget *dialog; - GtkWidget *vbox; - GtkWidget *hbox; - GtkWidget *label; - GtkAdjustment *adj; - GSList *radio_group = NULL; - gint radio_pressed[2]; - gint decorations; - gboolean run; + GtkWidget *dialog; + GtkWidget *vbox; + GtkWidget *hbox; + GtkWidget *label; + GtkObject *adj; + GSList *radio_group = NULL; + gint radio_pressed[2]; + gint decorations; + gboolean run; /* Set defaults */ radio_pressed[0] = (winsnapvals.root == FALSE); @@ -912,10 +912,10 @@ snap_dialog (void) gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); - adj = (GtkAdjustment *) gtk_adjustment_new ((gfloat) winsnapvals.delay, - 0.0, 100.0, - 1.0, 5.0, 0.0); - winsnapintf.delay_spinner = gtk_spin_button_new (adj, 0, 0); + winsnapintf.delay_spinner = gimp_spin_button_new (&adj, + winsnapvals.delay, + 0.0, 100.0, + 1.0, 5.0, 0.0, 0, 0); gtk_box_pack_start (GTK_BOX (hbox), winsnapintf.delay_spinner, FALSE, FALSE, 0); gtk_widget_show (winsnapintf.delay_spinner);