Commit a498acb3 authored by Maurits Rijk's avatar Maurits Rijk

Fix for #82490 (Use standard GIMP size entry in Smooth Palette) and #101902...

Fix for #82490 (Use standard GIMP size entry in Smooth Palette) and #101902 (Smooth Palette crashes on 1x1 image).
parent a8c844ff
2002-12-27 Maurits Rijk <lpeek.mrijk@consunet.nl>
* plug-ins/common/smooth_palette.c (dialog): fix for #82490 (Smooth
Palette: use standard GIMP size entry) and #101902 (Smooth Palette
crashes on 1x1 image). Minimum width for Smooth Palette is set to
2, since in the code g_rand_int_range (gr, 0, width - 2) is used.
Allowing a width of 1 results in an assertion in g_rand_int_range.
2002-12-26 Tor Lillqvist <tml@iki.fi> 2002-12-26 Tor Lillqvist <tml@iki.fi>
* app/Makefile.am: On Win32, create export file gimp.exp. * app/Makefile.am: On Win32, create export file gimp.exp.
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <time.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
...@@ -43,7 +42,7 @@ static void run (gchar *name, ...@@ -43,7 +42,7 @@ static void run (gchar *name,
gint *nreturn_vals, gint *nreturn_vals,
GimpParam **return_vals); GimpParam **return_vals);
static gboolean dialog (void); static gboolean dialog (GimpDrawable *drawable);
static gint32 doit (GimpDrawable *drawable, static gint32 doit (GimpDrawable *drawable,
gint32 *layer_id); gint32 *layer_id);
...@@ -57,6 +56,7 @@ GimpPlugInInfo PLUG_IN_INFO = ...@@ -57,6 +56,7 @@ GimpPlugInInfo PLUG_IN_INFO =
}; };
static gboolean run_flag = FALSE; static gboolean run_flag = FALSE;
static GtkWidget *sizeentry;
MAIN () MAIN ()
...@@ -131,12 +131,14 @@ run (gchar *name, ...@@ -131,12 +131,14 @@ run (gchar *name,
values[1].type = GIMP_PDB_IMAGE; values[1].type = GIMP_PDB_IMAGE;
values[2].type = GIMP_PDB_LAYER; values[2].type = GIMP_PDB_LAYER;
drawable = gimp_drawable_get (param[2].data.d_drawable);
switch (run_mode) switch (run_mode)
{ {
case GIMP_RUN_INTERACTIVE: case GIMP_RUN_INTERACTIVE:
INIT_I18N_UI(); INIT_I18N_UI();
gimp_get_data ("plug_in_smooth_palette", &config); gimp_get_data ("plug_in_smooth_palette", &config);
if (! dialog ()) if (! dialog (drawable))
return; return;
break; break;
...@@ -172,7 +174,6 @@ run (gchar *name, ...@@ -172,7 +174,6 @@ run (gchar *name,
if (status == GIMP_PDB_SUCCESS) if (status == GIMP_PDB_SUCCESS)
{ {
drawable = gimp_drawable_get (param[2].data.d_drawable);
if (gimp_drawable_is_rgb (drawable->drawable_id)) if (gimp_drawable_is_rgb (drawable->drawable_id))
{ {
gimp_progress_init (_("Deriving smooth palette...")); gimp_progress_init (_("Deriving smooth palette..."));
...@@ -392,17 +393,25 @@ ok_callback (GtkWidget *widget, ...@@ -392,17 +393,25 @@ ok_callback (GtkWidget *widget,
{ {
run_flag = TRUE; run_flag = TRUE;
config.width =
gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (sizeentry), 0);
config.height =
gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (sizeentry), 1);
gtk_widget_destroy (GTK_WIDGET (data)); gtk_widget_destroy (GTK_WIDGET (data));
} }
static gboolean static gboolean
dialog (void) dialog (GimpDrawable *drawable)
{ {
GtkWidget *dlg; GtkWidget *dlg;
GtkWidget *frame; GtkWidget *frame;
GtkWidget *table;
GtkWidget *spinbutton; GtkWidget *spinbutton;
GtkObject *adj; GtkObject *adj;
guint32 image_id;
GimpUnit unit;
gdouble xres, yres;
gimp_ui_init ("smooth_palette", FALSE); gimp_ui_init ("smooth_palette", FALSE);
...@@ -428,35 +437,29 @@ dialog (void) ...@@ -428,35 +437,29 @@ dialog (void)
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame); gtk_widget_show (frame);
table = gtk_table_new (3, 2, FALSE); image_id = gimp_drawable_image (drawable->drawable_id);
gtk_table_set_row_spacings (GTK_TABLE (table), 2); unit = gimp_image_get_unit (image_id);
gtk_table_set_col_spacings (GTK_TABLE (table), 4); gimp_image_get_resolution (image_id, &xres, &yres);
gtk_container_set_border_width (GTK_CONTAINER (table), 4);
gtk_container_add (GTK_CONTAINER (frame), table); sizeentry = gimp_coordinates_new (unit, "%a", TRUE, FALSE, 6,
gtk_widget_show (table); GIMP_SIZE_ENTRY_UPDATE_SIZE,
FALSE, FALSE,
spinbutton = gimp_spin_button_new (&adj, config.width, _("_Width:"),
1, GIMP_MAX_IMAGE_SIZE, 1, 10, 0, 1, 0); config.width, xres,
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, 2, GIMP_MAX_IMAGE_SIZE,
_("_Width:"), 1.0, 0.5, 2, GIMP_MAX_IMAGE_SIZE,
spinbutton, 1, FALSE);
g_signal_connect (G_OBJECT (adj), "value_changed", _("_Height:"),
G_CALLBACK (gimp_int_adjustment_update), config.height, yres,
&config.width); 1, GIMP_MAX_IMAGE_SIZE,
1, GIMP_MAX_IMAGE_SIZE);
spinbutton = gimp_spin_button_new (&adj, config.height, gtk_container_add (GTK_CONTAINER (frame), sizeentry);
1, GIMP_MAX_IMAGE_SIZE, 1, 10, 0, 1, 0); gtk_widget_show (sizeentry);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
_("_Height:"), 1.0, 0.5,
spinbutton, 1, FALSE);
g_signal_connect (G_OBJECT (adj), "value_changed",
G_CALLBACK (gimp_int_adjustment_update),
&config.height);
spinbutton = gimp_spin_button_new (&adj, config.ntries, spinbutton = gimp_spin_button_new (&adj, config.ntries,
1, 1024, 1, 10, 0, 1, 0); 1, 1024, 1, 10, 0, 1, 0);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 2, gimp_table_attach_aligned (GTK_TABLE (sizeentry), 0, 2,
_("_Search Depth:"), 1.0, 0.5, _("_Search Depth:"), 1.0, 0.5,
spinbutton, 1, FALSE); spinbutton, 1, FALSE);
g_signal_connect (G_OBJECT (adj), "value_changed", g_signal_connect (G_OBJECT (adj), "value_changed",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment