libgimpwidgets/gimpwidgets.c Modify random seed widget to allow the user

2004-02-01  Dave Neary  <bolsh@gimp.org>

        * libgimpwidgets/gimpwidgets.c
        * libgimpwidgets/gimpwidgets.h: Modify random seed widget to
        allow the user to specify that a seed should be chosen
        randomly for them (useful to allow re-running random plug-ins
        several times to get several different results).

        * plug-ins/common/blur.c
        * plug-ins/common/plasma.c
        * plug-ins/common/randomize.c
        * plug-ins/common/sinus.c
        * plug-ins/common/snoise.c
        * plug-ins/gflare/gflare.c
        * plug-ins/maze/algorithms.c
        * plug-ins/maze/maze.c
        * plug-ins/maze/maze.h
        * plug-ins/maze/maze_face.c: Changed appropriately.

        This fixes bug #129529.
This commit is contained in:
Dave Neary
2004-01-31 23:34:56 +00:00
committed by David Neary
parent 736fd660b9
commit 95ed7031f4
13 changed files with 119 additions and 29 deletions

View File

@ -1236,16 +1236,20 @@ GtkWidget *
gimp_random_seed_new (guint *seed, gboolean *random_seed)
{
GtkWidget *hbox;
GtkWidget *toggle;
GtkWidget *spinbutton;
GtkObject *adj;
GtkWidget *button;
hbox = gtk_hbox_new (FALSE, 4);
/* If we're being asked to generate a random seed, generate one. */
/* I'm not sure this should be here
if (*random_seed)
{
*seed = g_random_int ();
}
*/
spinbutton = gimp_spin_button_new (&adj, *seed,
0, (guint32) -1 , 1, 10, 0, 1, 0);
@ -1260,22 +1264,41 @@ gimp_random_seed_new (guint *seed, gboolean *random_seed)
"seed - this allows you to repeat a "
"given \"random\" operation"), NULL);
button = gtk_button_new_with_mnemonic (_("_Randomize"));
button = gtk_button_new_with_mnemonic (_("_New seed"));
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
/* Send spinbutton as data so that we can change the value in
* gimp_random_seed_update() */
g_signal_connect (button, "clicked",
G_CALLBACK (gimp_random_seed_update),
spinbutton);
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
gimp_help_set_help_data (button,
_("Seed random number generator with a generated random number"),
NULL);
toggle = gtk_check_button_new_with_label (_("Randomize"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), *random_seed);
gtk_box_pack_start (GTK_BOX (hbox), toggle, FALSE, FALSE, 0);
gtk_widget_show (toggle);
g_signal_connect (toggle, "toggled",
G_CALLBACK (gimp_toggle_button_update),
random_seed);
g_object_set_data (G_OBJECT (hbox), "spinbutton", spinbutton);
g_object_set_data (G_OBJECT (hbox), "button", button);
g_object_set_data (G_OBJECT (hbox), "toggle", toggle);
/* Set sensitivity data for the toggle, this stuff makes
* gimp_toggle_button_sensitive_update work */
g_object_set_data (G_OBJECT (toggle), "inverse_sensitive", spinbutton);
g_object_set_data (G_OBJECT (spinbutton), "inverse_sensitive", button);
// g_object_set_data (G_OBJECT (button), "inverse_sensitive", adj);
/* Initialise sensitivity */
gimp_toggle_button_update (toggle, random_seed);
return hbox;
}