mirror of https://github.com/GNOME/gimp.git
Change signature of gimp_random_seed_new() to allow caller to specify that
2003-12-17 Dave Neary <bolsh@gimp.org> * 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.
This commit is contained in:
parent
74f546d714
commit
5907708efa
20
ChangeLog
20
ChangeLog
|
@ -1,3 +1,23 @@
|
||||||
|
2003-12-17 Dave Neary <bolsh@gimp.org>
|
||||||
|
|
||||||
|
* 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 <bolsh@gimp.org>
|
2003-12-17 Dave Neary <bolsh@gimp.org>
|
||||||
|
|
||||||
* plug-ins/script-fu/script-fu-server.c: Destroy widget, not data.
|
* plug-ins/script-fu/script-fu-server.c: Destroy widget, not data.
|
||||||
|
|
|
@ -1222,7 +1222,9 @@ gimp_random_seed_update (GtkWidget *widget,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gimp_random_seed_new:
|
* 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
|
* Creates a widget that allows the user to control how the random number
|
||||||
* generator is initialized.
|
* generator is initialized.
|
||||||
|
@ -1231,7 +1233,7 @@ gimp_random_seed_update (GtkWidget *widget,
|
||||||
* a #GtkButton for setting a random seed.
|
* a #GtkButton for setting a random seed.
|
||||||
**/
|
**/
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
gimp_random_seed_new (guint *seed)
|
gimp_random_seed_new (guint *seed, gboolean random_seed)
|
||||||
{
|
{
|
||||||
GtkWidget *hbox;
|
GtkWidget *hbox;
|
||||||
GtkWidget *spinbutton;
|
GtkWidget *spinbutton;
|
||||||
|
@ -1240,6 +1242,10 @@ gimp_random_seed_new (guint *seed)
|
||||||
|
|
||||||
hbox = gtk_hbox_new (FALSE, 4);
|
hbox = gtk_hbox_new (FALSE, 4);
|
||||||
|
|
||||||
|
if (random_seed)
|
||||||
|
{
|
||||||
|
*seed = g_random_int ();
|
||||||
|
}
|
||||||
spinbutton = gimp_spin_button_new (&adj, *seed,
|
spinbutton = gimp_spin_button_new (&adj, *seed,
|
||||||
0, (guint32) -1 , 1, 10, 0, 1, 0);
|
0, (guint32) -1 , 1, 10, 0, 1, 0);
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
|
||||||
|
|
|
@ -238,7 +238,8 @@ void gimp_scale_entry_set_sensitive (GtkObject *adjustment,
|
||||||
gtk_spin_button_get_adjustment \
|
gtk_spin_button_get_adjustment \
|
||||||
(GTK_SPIN_BUTTON (g_object_get_data (G_OBJECT (hbox), "spinbutton")))
|
(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) \
|
#define GIMP_COORDINATES_CHAINBUTTON(sizeentry) \
|
||||||
(g_object_get_data (G_OBJECT (sizeentry), "chainbutton"))
|
(g_object_get_data (G_OBJECT (sizeentry), "chainbutton"))
|
||||||
|
|
|
@ -93,16 +93,18 @@
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
gdouble blur_pct; /* likelihood of randomization (as %age) */
|
gdouble blur_pct; /* likelihood of randomization (as %age) */
|
||||||
gdouble blur_rcount; /* repeat count */
|
gdouble blur_rcount; /* repeat count */
|
||||||
guint blur_seed; /* seed value for g_random_set_seed() function */
|
gboolean blur_randomize; /* Generate a random seed value */
|
||||||
|
guint blur_seed; /* seed value for g_random_set_seed() function */
|
||||||
} BlurVals;
|
} BlurVals;
|
||||||
|
|
||||||
static BlurVals pivals =
|
static BlurVals pivals =
|
||||||
{
|
{
|
||||||
100.0,
|
100.0,
|
||||||
1.0,
|
1.0,
|
||||||
0,
|
FALSE,
|
||||||
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -166,7 +168,8 @@ query (void)
|
||||||
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
|
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
|
||||||
{ GIMP_PDB_FLOAT, "blur_pct", "Randomization percentage (1 - 100)" },
|
{ GIMP_PDB_FLOAT, "blur_pct", "Randomization percentage (1 - 100)" },
|
||||||
{ GIMP_PDB_FLOAT, "blur_rcount", "Repeat count(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.";
|
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) &&
|
if ((strcmp (name, "plug_in_blur_randomize") == 0) &&
|
||||||
(nparams == 7))
|
(nparams == 7))
|
||||||
{
|
{
|
||||||
pivals.blur_pct = (gdouble) param[3].data.d_float;
|
pivals.blur_pct = (gdouble) param[3].data.d_float;
|
||||||
pivals.blur_pct = (gdouble) MIN (100.0, pivals.blur_pct);
|
pivals.blur_pct = (gdouble) MIN (100.0, pivals.blur_pct);
|
||||||
pivals.blur_pct = (gdouble) MAX (1.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) param[4].data.d_float;
|
||||||
pivals.blur_rcount = (gdouble) MIN (100.0,pivals.blur_rcount);
|
pivals.blur_rcount = (gdouble) MIN (100.0,pivals.blur_rcount);
|
||||||
pivals.blur_rcount = (gdouble) MAX (1.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_randomize = (gboolean) param[5].data.d_int32;
|
||||||
|
pivals.blur_seed = (gint) param[6].data.d_int32;
|
||||||
}
|
}
|
||||||
else if ((strcmp (name, PLUG_IN_NAME) == 0) &&
|
else if ((strcmp (name, PLUG_IN_NAME) == 0) &&
|
||||||
(nparams == 3))
|
(nparams == 3))
|
||||||
{
|
{
|
||||||
pivals.blur_pct = (gdouble) 100.0;
|
pivals.blur_pct = (gdouble) 100.0;
|
||||||
pivals.blur_rcount = (gdouble) 1.0;
|
pivals.blur_rcount = (gdouble) 1.0;
|
||||||
pivals.blur_seed = g_random_int ();
|
pivals.blur_randomize = FALSE;
|
||||||
|
pivals.blur_seed = g_random_int ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -604,7 +609,7 @@ blur_dialog (void)
|
||||||
gtk_widget_show (table);
|
gtk_widget_show (table);
|
||||||
|
|
||||||
/* Random Seed */
|
/* 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,
|
label = gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
||||||
_("_Random Seed:"), 1.0, 0.5,
|
_("_Random Seed:"), 1.0, 0.5,
|
||||||
seed_hbox, 1, TRUE);
|
seed_hbox, 1, TRUE);
|
||||||
|
|
|
@ -331,7 +331,7 @@ plasma_dialog (GimpDrawable *drawable,
|
||||||
gtk_container_add (GTK_CONTAINER (frame), table);
|
gtk_container_add (GTK_CONTAINER (frame), table);
|
||||||
gtk_widget_show (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,
|
label = gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
||||||
_("Random _Seed:"), 1.0, 0.5,
|
_("Random _Seed:"), 1.0, 0.5,
|
||||||
seed, 1, TRUE);
|
seed, 1, TRUE);
|
||||||
|
|
|
@ -128,15 +128,17 @@ gint rndm_type = RNDM_HURL; /* hurl, pick, etc. */
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
gdouble rndm_pct; /* likelihood of randomization (as %age) */
|
gdouble rndm_pct; /* likelihood of randomization (as %age) */
|
||||||
gdouble rndm_rcount; /* repeat count */
|
gdouble rndm_rcount; /* repeat count */
|
||||||
guint rndm_seed; /* seed value for g_rand_set_seed() function */
|
gboolean randomize; /* Whether to use a random seed */
|
||||||
|
guint seed; /* seed value for g_rand_set_seed() function */
|
||||||
} RandomizeVals;
|
} RandomizeVals;
|
||||||
|
|
||||||
static RandomizeVals pivals =
|
static RandomizeVals pivals =
|
||||||
{
|
{
|
||||||
50.0,
|
50.0,
|
||||||
1.0,
|
1.0,
|
||||||
|
FALSE,
|
||||||
SEED_DEFAULT
|
SEED_DEFAULT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -196,7 +198,8 @@ query (void)
|
||||||
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
|
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
|
||||||
{ GIMP_PDB_FLOAT, "rndm_pct", "Randomization percentage (1.0 - 100.0)" },
|
{ GIMP_PDB_FLOAT, "rndm_pct", "Randomization percentage (1.0 - 100.0)" },
|
||||||
{ GIMP_PDB_FLOAT, "rndm_rcount", "Repeat count (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 =
|
const gchar *hurl_blurb =
|
||||||
|
@ -333,7 +336,8 @@ run (const gchar *name,
|
||||||
{
|
{
|
||||||
pivals.rndm_pct = (gdouble) param[3].data.d_float;
|
pivals.rndm_pct = (gdouble) param[3].data.d_float;
|
||||||
pivals.rndm_rcount = (gdouble) param[4].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 &&
|
if ((rndm_type != RNDM_PICK &&
|
||||||
rndm_type != RNDM_SLUR &&
|
rndm_type != RNDM_SLUR &&
|
||||||
|
@ -376,7 +380,7 @@ run (const gchar *name,
|
||||||
/*
|
/*
|
||||||
* Initialize the g_rand() function seed
|
* Initialize the g_rand() function seed
|
||||||
*/
|
*/
|
||||||
g_rand_set_seed (gr, pivals.rndm_seed);
|
g_rand_set_seed (gr, pivals.seed);
|
||||||
|
|
||||||
randomize (drawable, gr);
|
randomize (drawable, gr);
|
||||||
/*
|
/*
|
||||||
|
@ -715,7 +719,7 @@ randomize_dialog (void)
|
||||||
gtk_widget_show(table);
|
gtk_widget_show(table);
|
||||||
|
|
||||||
/* Random Seed */
|
/* 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,
|
label = gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
||||||
_("_Random Seed:"), 1.0, 0.5,
|
_("_Random Seed:"), 1.0, 0.5,
|
||||||
seed_hbox, 1, TRUE);
|
seed_hbox, 1, TRUE);
|
||||||
|
|
|
@ -727,7 +727,7 @@ sinus_dialog (void)
|
||||||
table = gtk_table_new(3, 1, FALSE);
|
table = gtk_table_new(3, 1, FALSE);
|
||||||
gtk_table_set_col_spacings(GTK_TABLE(table), 4);
|
gtk_table_set_col_spacings(GTK_TABLE(table), 4);
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
|
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,
|
label = gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
||||||
_("R_andom Seed:"), 1.0, 0.5,
|
_("R_andom Seed:"), 1.0, 0.5,
|
||||||
hbox, 1, TRUE);
|
hbox, 1, TRUE);
|
||||||
|
|
|
@ -514,7 +514,7 @@ solid_noise_dialog (void)
|
||||||
gtk_widget_show (table);
|
gtk_widget_show (table);
|
||||||
|
|
||||||
/* Random Seed */
|
/* 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,
|
label = gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
||||||
_("_Random Seed:"), 1.0, 0.5,
|
_("_Random Seed:"), 1.0, 0.5,
|
||||||
seed_hbox, 1, TRUE);
|
seed_hbox, 1, TRUE);
|
||||||
|
|
|
@ -3846,7 +3846,7 @@ ed_make_page_sflare (GFlareEditor *ed,
|
||||||
gtk_box_pack_start (GTK_BOX (seed_hbox), label, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (seed_hbox), label, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (label);
|
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));
|
entry = GTK_WIDGET (GIMP_RANDOM_SEED_SPINBUTTON (seed));
|
||||||
|
|
||||||
|
|
|
@ -287,7 +287,7 @@ maze_dialog (void)
|
||||||
&mvals.tile);
|
&mvals.tile);
|
||||||
|
|
||||||
/* Seed input box */
|
/* 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,
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, trow,
|
||||||
_("Seed:"), 1.0, 0.5,
|
_("Seed:"), 1.0, 0.5,
|
||||||
seed_hbox, 1, TRUE);
|
seed_hbox, 1, TRUE);
|
||||||
|
|
Loading…
Reference in New Issue