Added fixes for bugs #81730 and #81732 from the 1.2 branch.

2002-05-14  Dave Neary  <bolsh@gimp.org>

        * plug-ins/common/plasma.c: Added fixes for bugs #81730 and
        #81732 from the 1.2 branch.
This commit is contained in:
Dave Neary 2002-05-14 16:58:29 +00:00 committed by David Neary
parent 1eedb95e3e
commit 918e633529
2 changed files with 53 additions and 17 deletions

View File

@ -1,3 +1,8 @@
2002-05-14 Dave Neary <bolsh@gimp.org>
* plug-ins/common/plasma.c: Added fixes for bugs #81730 and
#81732 from the 1.2 branch.
2002-05-14 Sven Neumann <sven@gimp.org>
* libgimp/Makefile.am

View File

@ -106,10 +106,13 @@ static void run (gchar *name,
gint *nreturn_vals,
GimpParam **return_vals);
static GtkWidget *preview_widget (void);
static gint plasma_dialog (GimpDrawable *drawable);
static GtkWidget *preview_widget (GimpImageType drawable_type);
static gint plasma_dialog (GimpDrawable *drawable,
GimpImageType drawable_type);
static void plasma_ok_callback (GtkWidget *widget,
gpointer data);
static void plasma_seed_changed_callback (GimpDrawable *drawable,
gboolean preview_mode);
static void plasma (GimpDrawable *drawable,
gboolean preview_mode);
@ -207,6 +210,7 @@ run (gchar *name,
{
static GimpParam values[1];
GimpDrawable *drawable;
GimpImageType drawable_type;
GimpRunMode run_mode;
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
@ -220,6 +224,7 @@ run (gchar *name,
/* Get the specified drawable */
drawable = gimp_drawable_get (param[2].data.d_drawable);
drawable_type = gimp_drawable_type (param[2].data.d_drawable);
switch (run_mode)
{
@ -229,7 +234,7 @@ run (gchar *name,
gimp_get_data ("plug_in_plasma", &pvals);
/* First acquire information with a dialog */
if (! plasma_dialog (drawable))
if (! plasma_dialog (drawable, drawable_type))
{
gimp_drawable_detach (drawable);
return;
@ -258,6 +263,9 @@ run (gchar *name,
INIT_I18N();
/* Possibly retrieve data */
gimp_get_data ("plug_in_plasma", &pvals);
/* If we're using a time seed, set it at the start */
if (pvals.timeseed)
pvals.seed = time(NULL);
break;
default:
@ -281,7 +289,7 @@ run (gchar *name,
/* Store data */
if (run_mode == GIMP_RUN_INTERACTIVE ||
(pvals.timeseed && run_mode == GIMP_RUN_WITH_LAST_VALS))
gimp_set_data ("plug_in_plasma", &pvals, sizeof (PlasmaValues));
gimp_set_data ("plug_in_plasma", &pvals, sizeof (PlasmaValues));
}
else
{
@ -295,7 +303,7 @@ run (gchar *name,
}
static gint
plasma_dialog (GimpDrawable *drawable)
plasma_dialog (GimpDrawable *drawable, GimpImageType drawable_type)
{
GtkWidget *dlg;
GtkWidget *main_vbox;
@ -306,7 +314,7 @@ plasma_dialog (GimpDrawable *drawable)
GtkObject *adj;
gimp_ui_init ("plasma", TRUE);
dlg = gimp_dialog_new (_("Plasma"), "plasma",
gimp_standard_help_func, "filters/plasma.html",
GTK_WIN_POS_MOUSE,
@ -343,9 +351,13 @@ plasma_dialog (GimpDrawable *drawable)
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_container_add (GTK_CONTAINER (abox), frame);
gtk_widget_show (frame);
preview = preview_widget (); /* we are here */
preview = preview_widget (drawable_type); /* we are here */
gtk_container_add (GTK_CONTAINER (frame), preview);
if (pvals.timeseed)
pvals.seed = time(NULL);
plasma (drawable, TRUE); /* preview image */
gtk_widget_show (preview);
/* parameter settings */
@ -368,11 +380,11 @@ plasma_dialog (GimpDrawable *drawable)
seed, 1, TRUE);
g_signal_connect_swapped (G_OBJECT (GIMP_RANDOM_SEED_SPINBUTTON_ADJ (seed)),
"value_changed",
G_CALLBACK (plasma),
G_CALLBACK (plasma_seed_changed_callback),
drawable);
g_signal_connect_swapped (G_OBJECT (GIMP_RANDOM_SEED_TOGGLEBUTTON (seed)),
"toggled",
G_CALLBACK (plasma),
G_CALLBACK (plasma_seed_changed_callback),
drawable);
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 1,
@ -385,7 +397,7 @@ plasma_dialog (GimpDrawable *drawable)
G_CALLBACK (gimp_double_adjustment_update),
&pvals.turbulence);
g_signal_connect_swapped (G_OBJECT (adj), "value_changed",
G_CALLBACK (plasma),
G_CALLBACK (plasma_seed_changed_callback),
drawable);
gtk_widget_show (frame);
@ -408,6 +420,16 @@ plasma_ok_callback (GtkWidget *widget,
gtk_widget_destroy (GTK_WIDGET (data));
}
static void
plasma_seed_changed_callback (GimpDrawable *drawable,
gboolean preview_mode)
{
if (pvals.timeseed)
pvals.seed = time(NULL);
plasma(drawable, preview_mode);
}
#define AVE(n, v1, v2) n[0] = ((gint)v1[0] + (gint)v2[0]) / 2;\
n[1] = ((gint)v1[1] + (gint)v2[1]) / 2;\
n[2] = ((gint)v1[2] + (gint)v2[2]) / 2;
@ -460,8 +482,6 @@ static void
init_plasma (GimpDrawable *drawable,
gboolean preview_mode)
{
if (pvals.timeseed)
pvals.seed = time(NULL);
srand (pvals.seed);
turbulence = pvals.turbulence;
@ -799,20 +819,31 @@ do_plasma (GimpDrawable *drawable,
static GtkWidget *
preview_widget (void)
preview_widget (GimpImageType drawable_type)
{
GtkWidget *preview;
guchar *buf;
gint y;
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
gtk_preview_size (GTK_PREVIEW (preview), PREVIEW_SIZE, PREVIEW_SIZE);
if (drawable_type == GIMP_GRAY_IMAGE ||
drawable_type == GIMP_GRAYA_IMAGE)
{
preview = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
buf = g_malloc0 (PREVIEW_SIZE);
}
else /* Gray & colour are the only possibilities here */
{
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
buf = g_malloc0 (PREVIEW_SIZE * 3);
}
buf = g_malloc0 (PREVIEW_SIZE * 3);
gtk_preview_size (GTK_PREVIEW (preview), PREVIEW_SIZE, PREVIEW_SIZE);
for (y = 0; y < PREVIEW_SIZE; y++)
gtk_preview_draw_row (GTK_PREVIEW (preview), buf, 0, y, PREVIEW_SIZE);
g_free (buf);
return preview;
}