gimp/plug-ins/common/shift.c

417 lines
11 KiB
C
Raw Normal View History

1997-11-24 22:05:25 +00:00
/* Shift --- image filter plug-in for The Gimp image manipulation program
* Copyright (C) 1997 Brian Degenhardt and Federico Mena Quintero
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1997-11-24 22:05:25 +00:00
*
* Please direct all comments, questions, bug reports etc to Brian Degenhardt
* bdegenha@ucsd.edu
*
* You can contact Federico Mena Quintero at quartic@polloux.fciencias.unam.mx
* You can contact the original The Gimp authors at gimp@xcf.berkeley.edu
*/
#include "config.h"
1997-11-24 22:05:25 +00:00
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include "libgimp/stdplugins-intl.h"
1997-11-24 22:05:25 +00:00
1997-11-24 22:05:25 +00:00
/* Some useful macros */
changed "Number of Colors" to "Max Number of Colors" to clarify what this 2002-09-06 Michael Natterer <mitch@gimp.org> * app/gui/convert-dialog.c: changed "Number of Colors" to "Max Number of Colors" to clarify what this parameter does. (fixes #92194). * app/gui/menus.c: use GIMP_STOCK_INFO for "View/Info Window". Specify spibutton sizes in chars, not pixels (eek) all over the place. Also removed explicit sizes where the GtkSpinButton default size does not disturbe tabular widget layouts. * libgimpwidgets/gimpwidgets.c: removed the hardcoded width of 75 pixels in gimp_spin_button_new(). Changed gimp_scale_entry_new() and gimp_coordinates_new() to interpret their "spinbutton_width" parameters as chars if < 16, and as pixels otherwise. This gives reasonable results and doesn't cause unchanged plug-ins to suddenly have spinbuttons of dozens of chars width :) * libgimpwidgets/gimpsizeentry.c: added the same heuristic here. * libgimpwidgets/gimpquerybox.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/tools/gimpairbrushtool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpconvolvetool.c * app/tools/gimpdodgeburntool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpposterizetool.c * app/tools/gimpsmudgetool.c * app/tools/gimptexttool.c * app/tools/gimpthresholdtool.c * app/tools/paint_options.c * app/tools/selection_options.c * app/widgets/gimpbrusheditor.c * app/widgets/gimpbrushfactoryview.c * app/widgets/gimppaletteeditor.c: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/FractalExplorer.c * plug-ins/Lighting/lighting_ui.c * plug-ins/common/AlienMap.c * plug-ins/common/AlienMap2.c * plug-ins/common/CML_explorer.c * plug-ins/common/bumpmap.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/depthmerge.c * plug-ins/common/despeckle.c * plug-ins/common/diffraction.c * plug-ins/common/emboss.c * plug-ins/common/film.c * plug-ins/common/flarefx.c * plug-ins/common/fractaltrace.c * plug-ins/common/gauss_iir.c * plug-ins/common/gauss_rle.c * plug-ins/common/glasstile.c * plug-ins/common/grid.c * plug-ins/common/illusion.c * plug-ins/common/iwarp.c * plug-ins/common/jigsaw.c * plug-ins/common/lic.c * plug-ins/common/max_rgb.c * plug-ins/common/mblur.c * plug-ins/common/newsprint.c * plug-ins/common/nova.c * plug-ins/common/pixelize.c * plug-ins/common/sample_colorize.c * plug-ins/common/scatter_hsv.c * plug-ins/common/shift.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/spread.c * plug-ins/common/tile.c * plug-ins/common/tileit.c * plug-ins/common/unsharp.c * plug-ins/common/vpropagate.c * plug-ins/common/waves.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/mosaic/mosaic.c * plug-ins/rcm/rcm_dialog.c: changed accordingly, which involves removals of gtk_widget_set_size_request(spinbutton), removal of lots of explicit spinbutton sizes in gimp_scale_entry_new(), and adding of new ones because GtkSpinButton's auto-size trashed tabular layouts. Lots of cleanup & indentation while browsing the plug-ins' code. Changed spacings, moved toggle buttons into frame titles, use stock items, stuff...
2002-09-06 20:44:47 +00:00
#define SPIN_BUTTON_WIDTH 8
#define TILE_CACHE_SIZE 16
#define HORIZONTAL 0
#define VERTICAL 1
1997-11-24 22:05:25 +00:00
typedef struct
{
gint shift_amount;
gint orientation;
1997-11-24 22:05:25 +00:00
} ShiftValues;
typedef struct
{
1997-11-24 22:05:25 +00:00
gint run;
} ShiftInterface;
/* Declare local functions.
*/
static void query (void);
static void run (gchar *name,
gint nparams,
GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static void shift (GimpDrawable *drawable);
static gint shift_dialog (gint32 image_ID);
static void shift_ok_callback (GtkWidget *widget,
gpointer data);
static void shift_amount_update_callback(GtkWidget * widget, gpointer data);
1997-11-24 22:05:25 +00:00
/***** Local vars *****/
GimpPlugInInfo PLUG_IN_INFO =
1997-11-24 22:05:25 +00:00
{
NULL, /* init_proc */
NULL, /* quit_proc */
query, /* query_proc */
run, /* run_proc */
1997-11-24 22:05:25 +00:00
};
static ShiftValues shvals =
{
5, /* shift amount */
HORIZONTAL /* orientation */
1997-11-24 22:05:25 +00:00
};
static ShiftInterface shint =
{
FALSE /* run */
};
/***** Functions *****/
MAIN ()
static void
query (void)
1997-11-24 22:05:25 +00:00
{
static GimpParamDef args[] =
1997-11-24 22:05:25 +00:00
{
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
{ GIMP_PDB_IMAGE, "image", "Input image (unused)" },
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
{ GIMP_PDB_INT32, "shift_amount", "shift amount (0 <= shift_amount_x <= 200)" },
{ GIMP_PDB_INT32, "orientation", "vertical, horizontal orientation" }
1997-11-24 22:05:25 +00:00
};
gimp_install_procedure ("plug_in_shift",
2000-01-31 02:32:30 +00:00
"Shift the contents of the specified drawable",
"Shifts the pixels of the specified drawable. Each row will be displaced a random value of pixels.",
1997-11-24 22:05:25 +00:00
"Spencer Kimball and Peter Mattis, ported by Brian Degenhardt and Federico Mena Quintero",
"Brian Degenhardt",
"1997",
N_("<Image>/Filters/Distorts/Shift..."),
1997-11-24 22:05:25 +00:00
"RGB*, GRAY*",
GIMP_PLUGIN,
G_N_ELEMENTS (args), 0,
args, NULL);
1997-11-24 22:05:25 +00:00
}
static void
run (gchar *name,
gint nparams,
GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals)
1997-11-24 22:05:25 +00:00
{
static GimpParam values[1];
GimpDrawable *drawable;
gint32 image_ID;
GimpRunMode run_mode;
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
1997-11-24 22:05:25 +00:00
run_mode = param[0].data.d_int32;
image_ID = param[1].data.d_int32;
1997-11-24 22:05:25 +00:00
INIT_I18N ();
1997-11-24 22:05:25 +00:00
/* Get the specified drawable */
drawable = gimp_drawable_get (param[2].data.d_drawable);
*nreturn_vals = 1;
*return_vals = values;
1997-11-24 22:05:25 +00:00
values[0].type = GIMP_PDB_STATUS;
1997-11-24 22:05:25 +00:00
values[0].data.d_status = status;
switch (run_mode)
{
case GIMP_RUN_INTERACTIVE:
1997-11-24 22:05:25 +00:00
/* Possibly retrieve data */
gimp_get_data ("plug_in_shift", &shvals);
/* First acquire information with a dialog */
if (! shift_dialog (image_ID))
1997-11-24 22:05:25 +00:00
return;
break;
case GIMP_RUN_NONINTERACTIVE:
1997-11-24 22:05:25 +00:00
/* Make sure all the arguments are there! */
if (nparams != 5)
{
status = GIMP_PDB_CALLING_ERROR;
}
else
1997-11-24 22:05:25 +00:00
{
shvals.shift_amount = param[3].data.d_int32;
shvals.orientation = (param[4].data.d_int32) ? HORIZONTAL : VERTICAL;
if (shvals.shift_amount < 0 || shvals.shift_amount > 200)
status = GIMP_PDB_CALLING_ERROR;
}
1997-11-24 22:05:25 +00:00
break;
case GIMP_RUN_WITH_LAST_VALS:
1997-11-24 22:05:25 +00:00
/* Possibly retrieve data */
gimp_get_data ("plug_in_shift", &shvals);
break;
default:
break;
}
if (status == GIMP_PDB_SUCCESS)
1997-11-24 22:05:25 +00:00
{
/* Make sure that the drawable is gray or RGB color */
if (gimp_drawable_is_rgb (drawable->drawable_id) ||
gimp_drawable_is_gray (drawable->drawable_id))
1997-11-24 22:05:25 +00:00
{
gimp_progress_init ( _("Shifting..."));
1997-11-24 22:05:25 +00:00
/* set the tile cache size */
gimp_tile_cache_ntiles (TILE_CACHE_SIZE);
/* run the shift effect */
shift (drawable);
if (run_mode != GIMP_RUN_NONINTERACTIVE)
1997-11-24 22:05:25 +00:00
gimp_displays_flush ();
/* Store data */
if (run_mode == GIMP_RUN_INTERACTIVE)
1997-11-24 22:05:25 +00:00
gimp_set_data ("plug_in_shift", &shvals, sizeof (ShiftValues));
}
else
{
/* gimp_message ("shift: cannot operate on indexed color images"); */
status = GIMP_PDB_EXECUTION_ERROR;
1997-11-24 22:05:25 +00:00
}
}
values[0].data.d_status = status;
gimp_drawable_detach (drawable);
}
static void
shift (GimpDrawable *drawable)
1997-11-24 22:05:25 +00:00
{
GimpPixelRgn dest_rgn;
1997-11-24 22:05:25 +00:00
gpointer pr;
2002-12-15 20:31:07 +00:00
GimpPixelFetcher *pft;
1997-11-24 22:05:25 +00:00
gint width, height;
gint bytes;
guchar *destline;
guchar *dest;
gint x1, y1, x2, y2;
gint x, y;
gint progress, max_progress;
2002-12-15 20:31:07 +00:00
gint amount;
gint xdist, ydist;
1997-11-24 22:05:25 +00:00
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c 2002-11-20 Dave Neary <bolsh@gimp.org> * configure.in * app/core/gimpbrushpipe.c * app/gui/about-dialog.c * app/paint-funcs/paint-funcs-generic.h * app/paint-funcs/paint-funcs.c * libgimpmath/gimpmath.h * libgimpwidgets/gimpwidgets.c * plug-ins/common/CML_explorer.c * plug-ins/common/blur.c * plug-ins/common/cubism.c * plug-ins/common/gee.c * plug-ins/common/gee_zoom.c * plug-ins/common/gqbist.c * plug-ins/common/jigsaw.c * plug-ins/common/lic.c * plug-ins/common/noisify.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/plasma.c * plug-ins/common/randomize.c * plug-ins/common/sample_colorize.c * plug-ins/common/scatter_hsv.c * plug-ins/common/shift.c * plug-ins/common/sinus.c * plug-ins/common/smooth_palette.c * plug-ins/common/snoise.c * plug-ins/common/sparkle.c * plug-ins/common/spheredesigner.c * plug-ins/common/spread.c * plug-ins/common/warp.c * plug-ins/common/wind.c * plug-ins/flame/cmap.c * plug-ins/flame/flame.c * plug-ins/flame/libifs.c * plug-ins/gflare/gflare.c * plug-ins/gimpressionist/gimpressionist.c * plug-ins/gimpressionist/gimpressionist.h * plug-ins/gimpressionist/plasma.c * plug-ins/gimpressionist/repaint.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/maze/algorithms.c * plug-ins/maze/maze.c * plug-ins/maze/maze.h * plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX, G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(), srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand* equivalent. Programs which require seed setting for reproducible results, and anything in the core, gets a dedicated GRand * for the lifetime required. Programs which only ever used random numbers for tossing a coin, rolling a dice, etc use g_random functions. For the rest, judgement was used. Where it was easy, a GRand * object was used and g_rand_* functions were preferred. This fixes bug #67386 in HEAD.
2002-11-20 09:27:48 +00:00
GRand *gr; /* The random number generator we're using */
1997-11-24 22:05:25 +00:00
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c 2002-11-20 Dave Neary <bolsh@gimp.org> * configure.in * app/core/gimpbrushpipe.c * app/gui/about-dialog.c * app/paint-funcs/paint-funcs-generic.h * app/paint-funcs/paint-funcs.c * libgimpmath/gimpmath.h * libgimpwidgets/gimpwidgets.c * plug-ins/common/CML_explorer.c * plug-ins/common/blur.c * plug-ins/common/cubism.c * plug-ins/common/gee.c * plug-ins/common/gee_zoom.c * plug-ins/common/gqbist.c * plug-ins/common/jigsaw.c * plug-ins/common/lic.c * plug-ins/common/noisify.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/plasma.c * plug-ins/common/randomize.c * plug-ins/common/sample_colorize.c * plug-ins/common/scatter_hsv.c * plug-ins/common/shift.c * plug-ins/common/sinus.c * plug-ins/common/smooth_palette.c * plug-ins/common/snoise.c * plug-ins/common/sparkle.c * plug-ins/common/spheredesigner.c * plug-ins/common/spread.c * plug-ins/common/warp.c * plug-ins/common/wind.c * plug-ins/flame/cmap.c * plug-ins/flame/flame.c * plug-ins/flame/libifs.c * plug-ins/gflare/gflare.c * plug-ins/gimpressionist/gimpressionist.c * plug-ins/gimpressionist/gimpressionist.h * plug-ins/gimpressionist/plasma.c * plug-ins/gimpressionist/repaint.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/maze/algorithms.c * plug-ins/maze/maze.c * plug-ins/maze/maze.h * plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX, G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(), srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand* equivalent. Programs which require seed setting for reproducible results, and anything in the core, gets a dedicated GRand * for the lifetime required. Programs which only ever used random numbers for tossing a coin, rolling a dice, etc use g_random functions. For the rest, judgement was used. Where it was easy, a GRand * object was used and g_rand_* functions were preferred. This fixes bug #67386 in HEAD.
2002-11-20 09:27:48 +00:00
gr = g_rand_new ();
1997-11-24 22:05:25 +00:00
2002-12-15 20:31:07 +00:00
pft = gimp_pixel_fetcher_new (drawable);
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
1997-11-24 22:05:25 +00:00
width = drawable->width;
height = drawable->height;
bytes = drawable->bpp;
progress = 0;
max_progress = (x2 - x1) * (y2 - y1);
amount = shvals.shift_amount;
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c 2002-11-20 Dave Neary <bolsh@gimp.org> * configure.in * app/core/gimpbrushpipe.c * app/gui/about-dialog.c * app/paint-funcs/paint-funcs-generic.h * app/paint-funcs/paint-funcs.c * libgimpmath/gimpmath.h * libgimpwidgets/gimpwidgets.c * plug-ins/common/CML_explorer.c * plug-ins/common/blur.c * plug-ins/common/cubism.c * plug-ins/common/gee.c * plug-ins/common/gee_zoom.c * plug-ins/common/gqbist.c * plug-ins/common/jigsaw.c * plug-ins/common/lic.c * plug-ins/common/noisify.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/plasma.c * plug-ins/common/randomize.c * plug-ins/common/sample_colorize.c * plug-ins/common/scatter_hsv.c * plug-ins/common/shift.c * plug-ins/common/sinus.c * plug-ins/common/smooth_palette.c * plug-ins/common/snoise.c * plug-ins/common/sparkle.c * plug-ins/common/spheredesigner.c * plug-ins/common/spread.c * plug-ins/common/warp.c * plug-ins/common/wind.c * plug-ins/flame/cmap.c * plug-ins/flame/flame.c * plug-ins/flame/libifs.c * plug-ins/gflare/gflare.c * plug-ins/gimpressionist/gimpressionist.c * plug-ins/gimpressionist/gimpressionist.h * plug-ins/gimpressionist/plasma.c * plug-ins/gimpressionist/repaint.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/maze/algorithms.c * plug-ins/maze/maze.c * plug-ins/maze/maze.h * plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX, G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(), srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand* equivalent. Programs which require seed setting for reproducible results, and anything in the core, gets a dedicated GRand * for the lifetime required. Programs which only ever used random numbers for tossing a coin, rolling a dice, etc use g_random functions. For the rest, judgement was used. Where it was easy, a GRand * object was used and g_rand_* functions were preferred. This fixes bug #67386 in HEAD.
2002-11-20 09:27:48 +00:00
/* Shift the image. It's a pretty simple algorithm. If horizontal
1997-11-24 22:05:25 +00:00
is selected, then every row is shifted a random number of pixels
in the range of -shift_amount/2 to shift_amount/2. The effect is
just reproduced with columns if vertical is selected. Vertical
has been added since 0.54 so that the user doesn't have to rotate
the image to do a vertical shift.
*/
gimp_pixel_rgn_init (&dest_rgn, drawable,
x1, y1, (x2 - x1), (y2 - y1), TRUE, TRUE);
for (pr = gimp_pixel_rgns_register (1, &dest_rgn);
pr != NULL;
pr = gimp_pixel_rgns_process (pr))
1997-11-24 22:05:25 +00:00
{
2002-12-15 20:31:07 +00:00
destline = dest_rgn.data;
if (shvals.orientation == VERTICAL)
1997-11-24 22:05:25 +00:00
{
2002-12-15 20:31:07 +00:00
for (x = dest_rgn.x; x < dest_rgn.x + dest_rgn.w; x++)
1997-11-24 22:05:25 +00:00
{
dest = destline;
2002-12-15 20:31:07 +00:00
ydist = g_rand_int_range (gr, -(amount + 1) / 2.0,
(amount + 1) / 2.0 );
for (y = dest_rgn.y; y < dest_rgn.y + dest_rgn.h; y++)
1997-11-24 22:05:25 +00:00
{
2002-12-15 20:31:07 +00:00
gimp_pixel_fetcher_get_pixel2 (pft, x, y + ydist,
PIXEL_WRAP, dest);
dest += dest_rgn.rowstride;
}
destline += bytes;
}
1997-11-24 22:05:25 +00:00
}
else
1997-11-24 22:05:25 +00:00
{
2002-12-15 20:31:07 +00:00
for (y = dest_rgn.y; y < dest_rgn.y + dest_rgn.h; y++)
1997-11-24 22:05:25 +00:00
{
dest = destline;
2002-12-15 20:31:07 +00:00
xdist = g_rand_int_range (gr, -(amount + 1) / 2.0,
(amount + 1) / 2.0);
for (x = dest_rgn.x; x < dest_rgn.x + dest_rgn.w; x++)
1997-11-24 22:05:25 +00:00
{
2002-12-15 20:31:07 +00:00
gimp_pixel_fetcher_get_pixel2 (pft, x + xdist, y,
PIXEL_WRAP, dest);
dest += bytes;
}
destline += dest_rgn.rowstride;
}
1997-11-24 22:05:25 +00:00
}
2002-12-15 20:31:07 +00:00
progress += dest_rgn.w * dest_rgn.h;
gimp_progress_update ((double) progress / (double) max_progress);
}
1997-11-24 22:05:25 +00:00
2002-12-15 20:31:07 +00:00
gimp_pixel_fetcher_destroy (pft);
1997-11-24 22:05:25 +00:00
/* update the region */
1997-11-24 22:05:25 +00:00
gimp_drawable_flush (drawable);
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
gimp_drawable_update (drawable->drawable_id, x1, y1, (x2 - x1), (y2 - y1));
}
1997-11-24 22:05:25 +00:00
static gint
shift_dialog (gint32 image_ID)
1997-11-24 22:05:25 +00:00
{
GtkWidget *dlg;
GtkWidget *frame;
GtkWidget *radio_vbox;
GtkWidget *sep;
GtkWidget *size_entry;
GimpUnit unit;
gdouble xres;
gdouble yres;
1997-11-24 22:05:25 +00:00
gimp_ui_init ("shift", FALSE);
1997-11-24 22:05:25 +00:00
dlg = gimp_dialog_new (_("Shift"), "shift",
gimp_standard_help_func, "filters/shift.html",
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
2001-08-03 19:52:08 +00:00
GTK_STOCK_CANCEL, gtk_widget_destroy,
NULL, 1, NULL, FALSE, TRUE,
GTK_STOCK_OK, shift_ok_callback,
NULL, NULL, NULL, TRUE, FALSE,
NULL);
g_signal_connect (dlg, "destroy",
G_CALLBACK (gtk_main_quit),
NULL);
1997-11-24 22:05:25 +00:00
/* parameter settings */
frame = gimp_radio_group_new2 (TRUE, _("Parameter Settings"),
G_CALLBACK (gimp_radio_button_update),
&shvals.orientation,
GINT_TO_POINTER (shvals.orientation),
_("Shift _Horizontally"),
GINT_TO_POINTER (HORIZONTAL), NULL,
_("Shift _Vertically"),
GINT_TO_POINTER (VERTICAL), NULL,
NULL);
1997-11-24 22:05:25 +00:00
gtk_container_set_border_width (GTK_CONTAINER (frame), 6);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, TRUE, TRUE, 0);
radio_vbox = GTK_BIN (frame)->child;
gtk_container_set_border_width (GTK_CONTAINER (radio_vbox), 4);
sep = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (radio_vbox), sep, FALSE, FALSE, 3);
gtk_widget_show (sep);
/* Get the image resolution and unit */
gimp_image_get_resolution (image_ID, &xres, &yres);
unit = gimp_image_get_unit (image_ID);
changed "Number of Colors" to "Max Number of Colors" to clarify what this 2002-09-06 Michael Natterer <mitch@gimp.org> * app/gui/convert-dialog.c: changed "Number of Colors" to "Max Number of Colors" to clarify what this parameter does. (fixes #92194). * app/gui/menus.c: use GIMP_STOCK_INFO for "View/Info Window". Specify spibutton sizes in chars, not pixels (eek) all over the place. Also removed explicit sizes where the GtkSpinButton default size does not disturbe tabular widget layouts. * libgimpwidgets/gimpwidgets.c: removed the hardcoded width of 75 pixels in gimp_spin_button_new(). Changed gimp_scale_entry_new() and gimp_coordinates_new() to interpret their "spinbutton_width" parameters as chars if < 16, and as pixels otherwise. This gives reasonable results and doesn't cause unchanged plug-ins to suddenly have spinbuttons of dozens of chars width :) * libgimpwidgets/gimpsizeentry.c: added the same heuristic here. * libgimpwidgets/gimpquerybox.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/tools/gimpairbrushtool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpconvolvetool.c * app/tools/gimpdodgeburntool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpposterizetool.c * app/tools/gimpsmudgetool.c * app/tools/gimptexttool.c * app/tools/gimpthresholdtool.c * app/tools/paint_options.c * app/tools/selection_options.c * app/widgets/gimpbrusheditor.c * app/widgets/gimpbrushfactoryview.c * app/widgets/gimppaletteeditor.c: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/FractalExplorer.c * plug-ins/Lighting/lighting_ui.c * plug-ins/common/AlienMap.c * plug-ins/common/AlienMap2.c * plug-ins/common/CML_explorer.c * plug-ins/common/bumpmap.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/depthmerge.c * plug-ins/common/despeckle.c * plug-ins/common/diffraction.c * plug-ins/common/emboss.c * plug-ins/common/film.c * plug-ins/common/flarefx.c * plug-ins/common/fractaltrace.c * plug-ins/common/gauss_iir.c * plug-ins/common/gauss_rle.c * plug-ins/common/glasstile.c * plug-ins/common/grid.c * plug-ins/common/illusion.c * plug-ins/common/iwarp.c * plug-ins/common/jigsaw.c * plug-ins/common/lic.c * plug-ins/common/max_rgb.c * plug-ins/common/mblur.c * plug-ins/common/newsprint.c * plug-ins/common/nova.c * plug-ins/common/pixelize.c * plug-ins/common/sample_colorize.c * plug-ins/common/scatter_hsv.c * plug-ins/common/shift.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/spread.c * plug-ins/common/tile.c * plug-ins/common/tileit.c * plug-ins/common/unsharp.c * plug-ins/common/vpropagate.c * plug-ins/common/waves.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/mosaic/mosaic.c * plug-ins/rcm/rcm_dialog.c: changed accordingly, which involves removals of gtk_widget_set_size_request(spinbutton), removal of lots of explicit spinbutton sizes in gimp_scale_entry_new(), and adding of new ones because GtkSpinButton's auto-size trashed tabular layouts. Lots of cleanup & indentation while browsing the plug-ins' code. Changed spacings, moved toggle buttons into frame titles, use stock items, stuff...
2002-09-06 20:44:47 +00:00
size_entry = gimp_size_entry_new (1, unit, "%a", TRUE, FALSE, FALSE,
SPIN_BUTTON_WIDTH,
GIMP_SIZE_ENTRY_UPDATE_SIZE);
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (size_entry), GIMP_UNIT_PIXEL);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (size_entry), 0, xres, TRUE);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (size_entry), 0,
1.0, 200.0);
gtk_table_set_col_spacing (GTK_TABLE (size_entry), 0, 4);
gtk_table_set_col_spacing (GTK_TABLE (size_entry), 2, 12);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (size_entry), 0,
(gdouble) shvals.shift_amount);
gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (size_entry),
_("Shift _Amount:"), 1, 0, 0.0);
g_signal_connect (size_entry, "value_changed",
G_CALLBACK (shift_amount_update_callback),
&shvals.shift_amount);
gtk_box_pack_start (GTK_BOX (radio_vbox), size_entry, FALSE, FALSE, 0);
gtk_widget_show (size_entry);
1997-11-24 22:05:25 +00:00
gtk_widget_show (frame);
1997-11-24 22:05:25 +00:00
gtk_widget_show (dlg);
gtk_main ();
gdk_flush ();
return shint.run;
}
static void
shift_amount_update_callback(GtkWidget * widget, gpointer data)
{
shvals.shift_amount = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget),
0);
}
static void
shift_ok_callback (GtkWidget *widget,
gpointer data)
{
shint.run = TRUE;
gtk_widget_destroy (GTK_WIDGET (data));
}