diff --git a/ChangeLog b/ChangeLog index ae249dce26..3d8e1b3c2a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +1999-08-22 Tor Lillqvist + + * app/convert.c: Use spinbutton for number of colours. + + * app/preferences_dialog.h: Export gimp_spin_button_new. Not the + most logical place for it, though. + Sat Aug 21 17:34:53 PDT 1999 Manish Singh * configure.in: version number bump diff --git a/app/convert.c b/app/convert.c index 4a93f5b6ee..107bfeebe2 100644 --- a/app/convert.c +++ b/app/convert.c @@ -87,6 +87,7 @@ #include "interface.h" #include "undo.h" #include "palette.h" +#include "preferences_dialog.h" /* ick. */ #include "libgimp/gimpintl.h" @@ -316,9 +317,12 @@ convert_to_indexed (GimpImage *gimage) GtkWidget *hbox; GtkWidget *label; GtkWidget *text; + GtkObject *adjustment; + GtkWidget *spinbutton; GtkWidget *frame; GtkWidget *toggle; GSList *group = NULL; + gint maxval; dialog = g_new(IndexedDialog, 1); dialog->gimage = gimage; @@ -368,40 +372,37 @@ convert_to_indexed (GimpImage *gimage) gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, FALSE, 0); gtk_widget_show (label); - text = gtk_entry_new (); - { - if (dialog->num_cols == 256) - { - if ((!gimage_is_empty (gimage)) - && - ( - gimage->layers->next - || - layer_has_alpha((Layer *) gimage->layers->data) - ) - ) - { - gtk_entry_set_text (GTK_ENTRY (text), "255"); - dialog->num_cols = 255; - } - else - { - gtk_entry_set_text (GTK_ENTRY (text), "256"); - } - } - else - { - gchar tempstr[50]; - g_snprintf (tempstr, sizeof (tempstr), "%d", dialog->num_cols); - gtk_entry_set_text (GTK_ENTRY (text), tempstr); - } - gtk_widget_set_usize (text, 50, 25); - gtk_box_pack_start (GTK_BOX (hbox), text, FALSE, FALSE, 0); - gtk_signal_connect (GTK_OBJECT (text), "changed", - (GtkSignalFunc) indexed_num_cols_update, - dialog); - } - gtk_widget_show (text); + if (dialog->num_cols == 256) + { + if ((!gimage_is_empty (gimage)) + && + ( + gimage->layers->next + || + layer_has_alpha((Layer *) gimage->layers->data) + ) + ) + { + maxval = 255; + dialog->num_cols = 255; + } + else + { + maxval = 256; + } + } + else + { + maxval = 256; + } + + spinbutton = gimp_spin_button_new (&adjustment, dialog->num_cols, + 2, maxval, 1, 5, 0, 1, 0); + gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed", + (GtkSignalFunc) indexed_num_cols_update, + dialog); + gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0); + gtk_widget_show (spinbutton); gtk_widget_show (hbox); if (TRUE /* gimage->base_type == RGB */ ) @@ -701,12 +702,7 @@ static void indexed_num_cols_update (GtkWidget *w, gpointer data) { - IndexedDialog *dialog; - char *str; - - str = gtk_entry_get_text (GTK_ENTRY (w)); - dialog = (IndexedDialog *) data; - dialog->num_cols = BOUNDS(((int) atof (str)), 1, 256); + ((IndexedDialog *) data)->num_cols = GTK_ADJUSTMENT (w)->value; } static void diff --git a/app/core/gimpimage-convert.c b/app/core/gimpimage-convert.c index 4a93f5b6ee..107bfeebe2 100644 --- a/app/core/gimpimage-convert.c +++ b/app/core/gimpimage-convert.c @@ -87,6 +87,7 @@ #include "interface.h" #include "undo.h" #include "palette.h" +#include "preferences_dialog.h" /* ick. */ #include "libgimp/gimpintl.h" @@ -316,9 +317,12 @@ convert_to_indexed (GimpImage *gimage) GtkWidget *hbox; GtkWidget *label; GtkWidget *text; + GtkObject *adjustment; + GtkWidget *spinbutton; GtkWidget *frame; GtkWidget *toggle; GSList *group = NULL; + gint maxval; dialog = g_new(IndexedDialog, 1); dialog->gimage = gimage; @@ -368,40 +372,37 @@ convert_to_indexed (GimpImage *gimage) gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, FALSE, 0); gtk_widget_show (label); - text = gtk_entry_new (); - { - if (dialog->num_cols == 256) - { - if ((!gimage_is_empty (gimage)) - && - ( - gimage->layers->next - || - layer_has_alpha((Layer *) gimage->layers->data) - ) - ) - { - gtk_entry_set_text (GTK_ENTRY (text), "255"); - dialog->num_cols = 255; - } - else - { - gtk_entry_set_text (GTK_ENTRY (text), "256"); - } - } - else - { - gchar tempstr[50]; - g_snprintf (tempstr, sizeof (tempstr), "%d", dialog->num_cols); - gtk_entry_set_text (GTK_ENTRY (text), tempstr); - } - gtk_widget_set_usize (text, 50, 25); - gtk_box_pack_start (GTK_BOX (hbox), text, FALSE, FALSE, 0); - gtk_signal_connect (GTK_OBJECT (text), "changed", - (GtkSignalFunc) indexed_num_cols_update, - dialog); - } - gtk_widget_show (text); + if (dialog->num_cols == 256) + { + if ((!gimage_is_empty (gimage)) + && + ( + gimage->layers->next + || + layer_has_alpha((Layer *) gimage->layers->data) + ) + ) + { + maxval = 255; + dialog->num_cols = 255; + } + else + { + maxval = 256; + } + } + else + { + maxval = 256; + } + + spinbutton = gimp_spin_button_new (&adjustment, dialog->num_cols, + 2, maxval, 1, 5, 0, 1, 0); + gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed", + (GtkSignalFunc) indexed_num_cols_update, + dialog); + gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0); + gtk_widget_show (spinbutton); gtk_widget_show (hbox); if (TRUE /* gimage->base_type == RGB */ ) @@ -701,12 +702,7 @@ static void indexed_num_cols_update (GtkWidget *w, gpointer data) { - IndexedDialog *dialog; - char *str; - - str = gtk_entry_get_text (GTK_ENTRY (w)); - dialog = (IndexedDialog *) data; - dialog->num_cols = BOUNDS(((int) atof (str)), 1, 256); + ((IndexedDialog *) data)->num_cols = GTK_ADJUSTMENT (w)->value; } static void diff --git a/app/dialogs/preferences-dialog.h b/app/dialogs/preferences-dialog.h index ed92c84cea..de5b153e12 100644 --- a/app/dialogs/preferences-dialog.h +++ b/app/dialogs/preferences-dialog.h @@ -20,5 +20,14 @@ #define __PREFERENCES_DIALOG_H__ void file_pref_cmd_callback (GtkWidget *, gpointer); +GtkWidget* gimp_spin_button_new (GtkObject **, + gfloat, + gfloat, + gfloat, + gfloat, + gfloat, + gfloat, + gfloat, + guint); #endif /* __PREFERENCES_DIALOG_H__ */ diff --git a/app/gimpimage-convert.c b/app/gimpimage-convert.c index 4a93f5b6ee..107bfeebe2 100644 --- a/app/gimpimage-convert.c +++ b/app/gimpimage-convert.c @@ -87,6 +87,7 @@ #include "interface.h" #include "undo.h" #include "palette.h" +#include "preferences_dialog.h" /* ick. */ #include "libgimp/gimpintl.h" @@ -316,9 +317,12 @@ convert_to_indexed (GimpImage *gimage) GtkWidget *hbox; GtkWidget *label; GtkWidget *text; + GtkObject *adjustment; + GtkWidget *spinbutton; GtkWidget *frame; GtkWidget *toggle; GSList *group = NULL; + gint maxval; dialog = g_new(IndexedDialog, 1); dialog->gimage = gimage; @@ -368,40 +372,37 @@ convert_to_indexed (GimpImage *gimage) gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, FALSE, 0); gtk_widget_show (label); - text = gtk_entry_new (); - { - if (dialog->num_cols == 256) - { - if ((!gimage_is_empty (gimage)) - && - ( - gimage->layers->next - || - layer_has_alpha((Layer *) gimage->layers->data) - ) - ) - { - gtk_entry_set_text (GTK_ENTRY (text), "255"); - dialog->num_cols = 255; - } - else - { - gtk_entry_set_text (GTK_ENTRY (text), "256"); - } - } - else - { - gchar tempstr[50]; - g_snprintf (tempstr, sizeof (tempstr), "%d", dialog->num_cols); - gtk_entry_set_text (GTK_ENTRY (text), tempstr); - } - gtk_widget_set_usize (text, 50, 25); - gtk_box_pack_start (GTK_BOX (hbox), text, FALSE, FALSE, 0); - gtk_signal_connect (GTK_OBJECT (text), "changed", - (GtkSignalFunc) indexed_num_cols_update, - dialog); - } - gtk_widget_show (text); + if (dialog->num_cols == 256) + { + if ((!gimage_is_empty (gimage)) + && + ( + gimage->layers->next + || + layer_has_alpha((Layer *) gimage->layers->data) + ) + ) + { + maxval = 255; + dialog->num_cols = 255; + } + else + { + maxval = 256; + } + } + else + { + maxval = 256; + } + + spinbutton = gimp_spin_button_new (&adjustment, dialog->num_cols, + 2, maxval, 1, 5, 0, 1, 0); + gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed", + (GtkSignalFunc) indexed_num_cols_update, + dialog); + gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0); + gtk_widget_show (spinbutton); gtk_widget_show (hbox); if (TRUE /* gimage->base_type == RGB */ ) @@ -701,12 +702,7 @@ static void indexed_num_cols_update (GtkWidget *w, gpointer data) { - IndexedDialog *dialog; - char *str; - - str = gtk_entry_get_text (GTK_ENTRY (w)); - dialog = (IndexedDialog *) data; - dialog->num_cols = BOUNDS(((int) atof (str)), 1, 256); + ((IndexedDialog *) data)->num_cols = GTK_ADJUSTMENT (w)->value; } static void diff --git a/app/gui/preferences-dialog.h b/app/gui/preferences-dialog.h index ed92c84cea..de5b153e12 100644 --- a/app/gui/preferences-dialog.h +++ b/app/gui/preferences-dialog.h @@ -20,5 +20,14 @@ #define __PREFERENCES_DIALOG_H__ void file_pref_cmd_callback (GtkWidget *, gpointer); +GtkWidget* gimp_spin_button_new (GtkObject **, + gfloat, + gfloat, + gfloat, + gfloat, + gfloat, + gfloat, + gfloat, + guint); #endif /* __PREFERENCES_DIALOG_H__ */ diff --git a/app/preferences_dialog.h b/app/preferences_dialog.h index ed92c84cea..de5b153e12 100644 --- a/app/preferences_dialog.h +++ b/app/preferences_dialog.h @@ -20,5 +20,14 @@ #define __PREFERENCES_DIALOG_H__ void file_pref_cmd_callback (GtkWidget *, gpointer); +GtkWidget* gimp_spin_button_new (GtkObject **, + gfloat, + gfloat, + gfloat, + gfloat, + gfloat, + gfloat, + gfloat, + guint); #endif /* __PREFERENCES_DIALOG_H__ */