diff --git a/ChangeLog b/ChangeLog index 0c53742701..a2262d49fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2003-12-17 Dave Neary + + * libgimpwidgets/gimpwidgets.[ch]: Change signature of + gimp_random_seed_new() to allow caller to specify that he wants to + use a random seed rather than the specified seed. Previously it was + up to the caller to initialise the seed. + + * plug-ins/gflare/gflare.c + * plug-ins/maze/maze_face.c + * plug-ins/common/ + * plug-ins/common/plasma.c + * plug-ins/common/sinus.c + * plug-ins/common/snoise.c: Trivial modifications of call to + gimp_random_seed_new() with FALSE. + + * plug-ins/common/blur.c + * plug-ins/common/randomize.c: Modify PDB routines and tool options + to allow a random seed to be specified. Useful for scripts. Reverts + PDB to 1.2 state. Fixes bug #129529. + 2003-12-17 Dave Neary * plug-ins/script-fu/script-fu-server.c: Destroy widget, not data. diff --git a/libgimpwidgets/gimpwidgets.c b/libgimpwidgets/gimpwidgets.c index 9ccd1857a8..5bbba26762 100644 --- a/libgimpwidgets/gimpwidgets.c +++ b/libgimpwidgets/gimpwidgets.c @@ -1222,7 +1222,9 @@ gimp_random_seed_update (GtkWidget *widget, /** * gimp_random_seed_new: - * @seed: A pointer to the variable which stores the random seed. + * @seed: A pointer to the variable which stores the random seed. + * @random_seed: A boolean indicating whether seed should be initialised + * randomly or not. * * Creates a widget that allows the user to control how the random number * generator is initialized. @@ -1231,7 +1233,7 @@ gimp_random_seed_update (GtkWidget *widget, * a #GtkButton for setting a random seed. **/ GtkWidget * -gimp_random_seed_new (guint *seed) +gimp_random_seed_new (guint *seed, gboolean random_seed) { GtkWidget *hbox; GtkWidget *spinbutton; @@ -1240,6 +1242,10 @@ gimp_random_seed_new (guint *seed) hbox = gtk_hbox_new (FALSE, 4); + if (random_seed) + { + *seed = g_random_int (); + } spinbutton = gimp_spin_button_new (&adj, *seed, 0, (guint32) -1 , 1, 10, 0, 1, 0); gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0); diff --git a/libgimpwidgets/gimpwidgets.h b/libgimpwidgets/gimpwidgets.h index f14672eaae..64324a620e 100644 --- a/libgimpwidgets/gimpwidgets.h +++ b/libgimpwidgets/gimpwidgets.h @@ -238,7 +238,8 @@ void gimp_scale_entry_set_sensitive (GtkObject *adjustment, gtk_spin_button_get_adjustment \ (GTK_SPIN_BUTTON (g_object_get_data (G_OBJECT (hbox), "spinbutton"))) -GtkWidget * gimp_random_seed_new (guint32 *seed); +GtkWidget * gimp_random_seed_new (guint32 *seed, + gboolean random_seed); #define GIMP_COORDINATES_CHAINBUTTON(sizeentry) \ (g_object_get_data (G_OBJECT (sizeentry), "chainbutton")) diff --git a/plug-ins/common/blur.c b/plug-ins/common/blur.c index 92e3aca946..db3a014593 100644 --- a/plug-ins/common/blur.c +++ b/plug-ins/common/blur.c @@ -93,16 +93,18 @@ typedef struct { - gdouble blur_pct; /* likelihood of randomization (as %age) */ - gdouble blur_rcount; /* repeat count */ - guint blur_seed; /* seed value for g_random_set_seed() function */ + gdouble blur_pct; /* likelihood of randomization (as %age) */ + gdouble blur_rcount; /* repeat count */ + gboolean blur_randomize; /* Generate a random seed value */ + guint blur_seed; /* seed value for g_random_set_seed() function */ } BlurVals; static BlurVals pivals = { 100.0, 1.0, - 0, + FALSE, + 0 }; @@ -166,7 +168,8 @@ query (void) { GIMP_PDB_DRAWABLE, "drawable", "Input drawable" }, { GIMP_PDB_FLOAT, "blur_pct", "Randomization percentage (1 - 100)" }, { GIMP_PDB_FLOAT, "blur_rcount", "Repeat count(1 - 100)" }, - { GIMP_PDB_INT32, "blur_seed", "Seed value (used only if seed type is 11)" } + { GIMP_PDB_INT32, "randomize", "Use a random seed (TRUE, FALSE)" }, + { GIMP_PDB_INT32, "seed", "Seed value (used only if randomize is FALSE)" } }; const gchar *blurb = "Apply a 3x3 blurring convolution kernel to the specified drawable."; @@ -261,20 +264,22 @@ run (const gchar *name, if ((strcmp (name, "plug_in_blur_randomize") == 0) && (nparams == 7)) { - pivals.blur_pct = (gdouble) param[3].data.d_float; - pivals.blur_pct = (gdouble) MIN (100.0, pivals.blur_pct); - pivals.blur_pct = (gdouble) MAX (1.0, pivals.blur_pct); - pivals.blur_rcount = (gdouble) param[4].data.d_float; - pivals.blur_rcount = (gdouble) MIN (100.0,pivals.blur_rcount); - pivals.blur_rcount = (gdouble) MAX (1.0, pivals.blur_rcount); - pivals.blur_seed = (gint) param[6].data.d_int32; + pivals.blur_pct = (gdouble) param[3].data.d_float; + pivals.blur_pct = (gdouble) MIN (100.0, pivals.blur_pct); + pivals.blur_pct = (gdouble) MAX (1.0, pivals.blur_pct); + pivals.blur_rcount = (gdouble) param[4].data.d_float; + pivals.blur_rcount = (gdouble) MIN (100.0,pivals.blur_rcount); + pivals.blur_rcount = (gdouble) MAX (1.0, pivals.blur_rcount); + pivals.blur_randomize = (gboolean) param[5].data.d_int32; + pivals.blur_seed = (gint) param[6].data.d_int32; } else if ((strcmp (name, PLUG_IN_NAME) == 0) && (nparams == 3)) { - pivals.blur_pct = (gdouble) 100.0; - pivals.blur_rcount = (gdouble) 1.0; - pivals.blur_seed = g_random_int (); + pivals.blur_pct = (gdouble) 100.0; + pivals.blur_rcount = (gdouble) 1.0; + pivals.blur_randomize = FALSE; + pivals.blur_seed = g_random_int (); } else { @@ -604,7 +609,7 @@ blur_dialog (void) gtk_widget_show (table); /* Random Seed */ - seed_hbox = gimp_random_seed_new (&pivals.blur_seed); + seed_hbox = gimp_random_seed_new (&pivals.blur_seed, pivals.blur_randomize); label = gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, _("_Random Seed:"), 1.0, 0.5, seed_hbox, 1, TRUE); diff --git a/plug-ins/common/plasma.c b/plug-ins/common/plasma.c index 7222743dfa..745f7b8054 100644 --- a/plug-ins/common/plasma.c +++ b/plug-ins/common/plasma.c @@ -331,7 +331,7 @@ plasma_dialog (GimpDrawable *drawable, gtk_container_add (GTK_CONTAINER (frame), table); gtk_widget_show (table); - seed = gimp_random_seed_new (&pvals.seed); + seed = gimp_random_seed_new (&pvals.seed, FALSE); label = gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, _("Random _Seed:"), 1.0, 0.5, seed, 1, TRUE); diff --git a/plug-ins/common/randomize.c b/plug-ins/common/randomize.c index cd5fdc2c62..c1e9179e3d 100644 --- a/plug-ins/common/randomize.c +++ b/plug-ins/common/randomize.c @@ -128,15 +128,17 @@ gint rndm_type = RNDM_HURL; /* hurl, pick, etc. */ typedef struct { - gdouble rndm_pct; /* likelihood of randomization (as %age) */ - gdouble rndm_rcount; /* repeat count */ - guint rndm_seed; /* seed value for g_rand_set_seed() function */ + gdouble rndm_pct; /* likelihood of randomization (as %age) */ + gdouble rndm_rcount; /* repeat count */ + gboolean randomize; /* Whether to use a random seed */ + guint seed; /* seed value for g_rand_set_seed() function */ } RandomizeVals; static RandomizeVals pivals = { 50.0, 1.0, + FALSE, SEED_DEFAULT }; @@ -196,7 +198,8 @@ query (void) { GIMP_PDB_DRAWABLE, "drawable", "Input drawable" }, { GIMP_PDB_FLOAT, "rndm_pct", "Randomization percentage (1.0 - 100.0)" }, { GIMP_PDB_FLOAT, "rndm_rcount", "Repeat count (1.0 - 100.0)" }, - { GIMP_PDB_INT32, "rndm_seed", "Seed value (used only if seed type is 11)" } + { GIMP_PDB_INT32, "randomize", "Use random seed (TRUE, FALSE)" }, + { GIMP_PDB_INT32, "seed", "Seed value (used only if randomize is FALSE)" } }; const gchar *hurl_blurb = @@ -333,7 +336,8 @@ run (const gchar *name, { pivals.rndm_pct = (gdouble) param[3].data.d_float; pivals.rndm_rcount = (gdouble) param[4].data.d_float; - pivals.rndm_seed = (gint) param[6].data.d_int32; + pivals.randomize = (gboolean) param[5].data.d_int32; + pivals.seed = (gint) param[6].data.d_int32; if ((rndm_type != RNDM_PICK && rndm_type != RNDM_SLUR && @@ -376,7 +380,7 @@ run (const gchar *name, /* * Initialize the g_rand() function seed */ - g_rand_set_seed (gr, pivals.rndm_seed); + g_rand_set_seed (gr, pivals.seed); randomize (drawable, gr); /* @@ -715,7 +719,7 @@ randomize_dialog (void) gtk_widget_show(table); /* Random Seed */ - seed_hbox = gimp_random_seed_new (&pivals.rndm_seed); + seed_hbox = gimp_random_seed_new (&pivals.seed, &pivals.randomize); label = gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, _("_Random Seed:"), 1.0, 0.5, seed_hbox, 1, TRUE); diff --git a/plug-ins/common/sinus.c b/plug-ins/common/sinus.c index b7c39ebd24..5cafe7605e 100644 --- a/plug-ins/common/sinus.c +++ b/plug-ins/common/sinus.c @@ -727,7 +727,7 @@ sinus_dialog (void) table = gtk_table_new(3, 1, FALSE); gtk_table_set_col_spacings(GTK_TABLE(table), 4); gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); - hbox = gimp_random_seed_new (&svals.seed); + hbox = gimp_random_seed_new (&svals.seed, FALSE); label = gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, _("R_andom Seed:"), 1.0, 0.5, hbox, 1, TRUE); diff --git a/plug-ins/common/snoise.c b/plug-ins/common/snoise.c index 076495ea66..effd74b3d6 100644 --- a/plug-ins/common/snoise.c +++ b/plug-ins/common/snoise.c @@ -514,7 +514,7 @@ solid_noise_dialog (void) gtk_widget_show (table); /* Random Seed */ - seed_hbox = gimp_random_seed_new (&snvals.seed); + seed_hbox = gimp_random_seed_new (&snvals.seed, FALSE); label = gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, _("_Random Seed:"), 1.0, 0.5, seed_hbox, 1, TRUE); diff --git a/plug-ins/gflare/gflare.c b/plug-ins/gflare/gflare.c index c7868732de..0f0d1f77fa 100644 --- a/plug-ins/gflare/gflare.c +++ b/plug-ins/gflare/gflare.c @@ -3846,7 +3846,7 @@ ed_make_page_sflare (GFlareEditor *ed, gtk_box_pack_start (GTK_BOX (seed_hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); - seed = gimp_random_seed_new (&gflare->sflare_seed); + seed = gimp_random_seed_new (&gflare->sflare_seed, FALSE); entry = GTK_WIDGET (GIMP_RANDOM_SEED_SPINBUTTON (seed)); diff --git a/plug-ins/maze/maze_face.c b/plug-ins/maze/maze_face.c index 8f1b6e7511..61d9f88905 100644 --- a/plug-ins/maze/maze_face.c +++ b/plug-ins/maze/maze_face.c @@ -287,7 +287,7 @@ maze_dialog (void) &mvals.tile); /* Seed input box */ - seed_hbox = gimp_random_seed_new (&mvals.seed); + seed_hbox = gimp_random_seed_new (&mvals.seed, FALSE); gimp_table_attach_aligned (GTK_TABLE (table), 0, trow, _("Seed:"), 1.0, 0.5, seed_hbox, 1, TRUE);