2003-11-06 23:27:05 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
1999-08-25 02:36:38 +08:00
|
|
|
*
|
2003-11-06 23:27:05 +08:00
|
|
|
* 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,
|
1999-08-25 02:36:38 +08:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2003-11-06 23:27:05 +08:00
|
|
|
* 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.
|
1999-08-25 02:36:38 +08:00
|
|
|
*/
|
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
/* Original plug-in coded by Tim Newsome.
|
|
|
|
*
|
1999-08-25 02:36:38 +08:00
|
|
|
* Changed to make use of real-life units by Sven Neumann <sven@gimp.org>.
|
2003-11-06 23:27:05 +08:00
|
|
|
*
|
1999-08-25 02:36:38 +08:00
|
|
|
* The interface code is heavily commented in the hope that it will
|
|
|
|
* help other plug-in developers to adapt their plug-ins to make use
|
2003-11-06 23:27:05 +08:00
|
|
|
* of the gimp_size_entry functionality.
|
|
|
|
*
|
2000-02-23 05:25:18 +08:00
|
|
|
* Note: There is a convenience constructor called gimp_coordinetes_new ()
|
2003-11-06 23:27:05 +08:00
|
|
|
* which simplifies the task of setting up a standard X,Y sizeentry.
|
1999-08-25 02:36:38 +08:00
|
|
|
*
|
2000-05-22 21:53:43 +08:00
|
|
|
* For more info and bugs see libgimp/gimpsizeentry.h and libgimp/gimpwidgets.h
|
|
|
|
*
|
|
|
|
* May 2000 tim copperfield [timecop@japan.co.jp]
|
|
|
|
* http://www.ne.jp/asahi/linux/timecop
|
|
|
|
* Added dynamic preview. Due to weird implementation of signals from all
|
|
|
|
* controls, preview will not auto-update. But this plugin isn't really
|
|
|
|
* crying for real-time updating either.
|
|
|
|
*
|
1999-08-25 02:36:38 +08:00
|
|
|
*/
|
|
|
|
|
1999-11-20 10:16:17 +08:00
|
|
|
#include "config.h"
|
2000-01-07 06:26:10 +08:00
|
|
|
|
2000-10-01 04:13:06 +08:00
|
|
|
#include <string.h>
|
2000-01-07 06:26:10 +08:00
|
|
|
|
2000-05-01 05:03:44 +08:00
|
|
|
#include <libgimp/gimp.h>
|
|
|
|
#include <libgimp/gimpui.h>
|
2000-01-07 06:26:10 +08:00
|
|
|
|
1999-11-15 05:56:01 +08:00
|
|
|
#include "libgimp/stdplugins-intl.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-14 06:52:41 +08:00
|
|
|
|
|
|
|
#define PLUG_IN_PROC "plug-in-grid"
|
|
|
|
#define PLUG_IN_BINARY "grid"
|
2002-09-07 04:44:47 +08:00
|
|
|
#define SPIN_BUTTON_WIDTH 8
|
|
|
|
#define COLOR_BUTTON_WIDTH 55
|
|
|
|
|
1999-11-01 20:36:23 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Declare local functions. */
|
2000-02-23 05:25:18 +08:00
|
|
|
static void query (void);
|
2003-07-02 19:07:41 +08:00
|
|
|
static void run (const gchar *name,
|
2003-12-11 06:50:26 +08:00
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals);
|
2003-07-02 19:07:41 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
static guchar best_cmap_match (const guchar *cmap,
|
2003-12-11 06:50:26 +08:00
|
|
|
gint ncolors,
|
|
|
|
const GimpRGB *color);
|
2004-09-04 00:37:53 +08:00
|
|
|
static void grid (gint32 image_ID,
|
2003-12-11 06:50:26 +08:00
|
|
|
GimpDrawable *drawable,
|
2004-09-04 00:37:53 +08:00
|
|
|
GimpPreview *preview);
|
2003-11-06 23:27:05 +08:00
|
|
|
static gint dialog (gint32 image_ID,
|
2003-12-11 06:50:26 +08:00
|
|
|
GimpDrawable *drawable);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
GimpPlugInInfo PLUG_IN_INFO =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-05-01 05:03:44 +08:00
|
|
|
NULL, /* init_proc */
|
|
|
|
NULL, /* quit_proc */
|
|
|
|
query, /* query_proc */
|
|
|
|
run, /* run_proc */
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
2002-12-20 06:23:37 +08:00
|
|
|
static gint sx1, sy1, sx2, sy2;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-06-02 20:27:13 +08:00
|
|
|
static GtkWidget *main_dialog = NULL;
|
|
|
|
static GtkWidget *hcolor_button = NULL;
|
|
|
|
static GtkWidget *vcolor_button = NULL;
|
2004-08-07 08:04:16 +08:00
|
|
|
|
1998-01-30 08:31:16 +08:00
|
|
|
typedef struct
|
1999-08-25 02:36:38 +08:00
|
|
|
{
|
2001-01-12 07:36:59 +08:00
|
|
|
gint hwidth;
|
|
|
|
gint hspace;
|
|
|
|
gint hoffset;
|
|
|
|
GimpRGB hcolor;
|
|
|
|
gint vwidth;
|
|
|
|
gint vspace;
|
|
|
|
gint voffset;
|
|
|
|
GimpRGB vcolor;
|
|
|
|
gint iwidth;
|
|
|
|
gint ispace;
|
|
|
|
gint ioffset;
|
|
|
|
GimpRGB icolor;
|
2003-06-02 20:27:13 +08:00
|
|
|
} Config;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-11-01 20:36:23 +08:00
|
|
|
Config grid_cfg =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-08-05 02:53:04 +08:00
|
|
|
1, 16, 8, { 0.0, 0.0, 0.0, 1.0 }, /* horizontal */
|
|
|
|
1, 16, 8, { 0.0, 0.0, 0.0, 1.0 }, /* vertical */
|
|
|
|
0, 2, 6, { 0.0, 0.0, 0.0, 1.0 }, /* intersection */
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
1998-01-30 08:31:16 +08:00
|
|
|
MAIN ()
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
static
|
1999-08-25 02:36:38 +08:00
|
|
|
void query (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
static GimpParamDef args[] =
|
1998-01-30 08:31:16 +08:00
|
|
|
{
|
2005-08-14 06:52:41 +08:00
|
|
|
{ GIMP_PDB_INT32, "run-mode", "Interactive, non-interactive" },
|
|
|
|
{ GIMP_PDB_IMAGE, "image", "Input image" },
|
|
|
|
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
|
|
|
|
|
|
|
|
{ GIMP_PDB_INT32, "hwidth", "Horizontal Width (>= 0)" },
|
|
|
|
{ GIMP_PDB_INT32, "hspace", "Horizontal Spacing (>= 1)" },
|
|
|
|
{ GIMP_PDB_INT32, "hoffset", "Horizontal Offset (>= 0)" },
|
|
|
|
{ GIMP_PDB_COLOR, "hcolor", "Horizontal Colour" },
|
|
|
|
{ GIMP_PDB_INT8, "hopacity", "Horizontal Opacity (0...255)" },
|
|
|
|
|
|
|
|
{ GIMP_PDB_INT32, "vwidth", "Vertical Width (>= 0)" },
|
|
|
|
{ GIMP_PDB_INT32, "vspace", "Vertical Spacing (>= 1)" },
|
|
|
|
{ GIMP_PDB_INT32, "voffset", "Vertical Offset (>= 0)" },
|
|
|
|
{ GIMP_PDB_COLOR, "vcolor", "Vertical Colour" },
|
|
|
|
{ GIMP_PDB_INT8, "vopacity", "Vertical Opacity (0...255)" },
|
|
|
|
|
|
|
|
{ GIMP_PDB_INT32, "iwidth", "Intersection Width (>= 0)" },
|
|
|
|
{ GIMP_PDB_INT32, "ispace", "Intersection Spacing (>= 0)" },
|
|
|
|
{ GIMP_PDB_INT32, "ioffset", "Intersection Offset (>= 0)" },
|
|
|
|
{ GIMP_PDB_COLOR, "icolor", "Intersection Colour" },
|
2000-08-22 09:26:57 +08:00
|
|
|
{ GIMP_PDB_INT8, "iopacity", "Intersection Opacity (0...255)" }
|
1998-01-30 08:31:16 +08:00
|
|
|
};
|
1999-12-28 00:18:06 +08:00
|
|
|
|
2005-08-14 06:52:41 +08:00
|
|
|
gimp_install_procedure (PLUG_IN_PROC,
|
2003-12-11 06:50:26 +08:00
|
|
|
"Draws a grid.",
|
|
|
|
"Draws a grid using the specified colors. "
|
|
|
|
"The grid origin is the upper left corner.",
|
|
|
|
"Tim Newsome",
|
|
|
|
"Tim Newsome, Sven Neumann, Tom Rathborne, TC",
|
|
|
|
"1997 - 2000",
|
2004-05-07 21:15:52 +08:00
|
|
|
N_("_Grid..."),
|
2003-12-11 06:50:26 +08:00
|
|
|
"RGB*, GRAY*, INDEXED*",
|
|
|
|
GIMP_PLUGIN,
|
|
|
|
G_N_ELEMENTS (args), 0,
|
|
|
|
args, NULL);
|
2004-05-07 21:15:52 +08:00
|
|
|
|
2005-08-14 06:52:41 +08:00
|
|
|
gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/Filters/Render/Pattern");
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-06-01 13:07:31 +08:00
|
|
|
static void
|
2003-11-06 23:27:05 +08:00
|
|
|
run (const gchar *name,
|
|
|
|
gint n_params,
|
|
|
|
const GimpParam *param,
|
2003-07-02 19:07:41 +08:00
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-12-29 21:26:29 +08:00
|
|
|
static GimpParam values[1];
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
gint32 image_ID;
|
|
|
|
GimpRunMode run_mode;
|
|
|
|
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
1998-01-30 08:31:16 +08:00
|
|
|
|
|
|
|
*nreturn_vals = 1;
|
2001-12-29 21:26:29 +08:00
|
|
|
*return_vals = values;
|
1998-01-30 08:31:16 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
INIT_I18N ();
|
1999-11-17 22:39:11 +08:00
|
|
|
|
1998-01-30 08:31:16 +08:00
|
|
|
run_mode = param[0].data.d_int32;
|
1999-08-25 02:36:38 +08:00
|
|
|
image_ID = param[1].data.d_int32;
|
|
|
|
drawable = gimp_drawable_get (param[2].data.d_drawable);
|
1998-01-30 08:31:16 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
if (run_mode == GIMP_RUN_NONINTERACTIVE)
|
1998-01-30 08:31:16 +08:00
|
|
|
{
|
1999-11-01 20:36:23 +08:00
|
|
|
if (n_params != 18)
|
2003-12-11 06:50:26 +08:00
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
1999-11-01 20:36:23 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
if (status == GIMP_PDB_SUCCESS)
|
2003-12-11 06:50:26 +08:00
|
|
|
{
|
|
|
|
grid_cfg.hwidth = MAX (0, param[3].data.d_int32);
|
|
|
|
grid_cfg.hspace = MAX (1, param[4].data.d_int32);
|
|
|
|
grid_cfg.hoffset = MAX (0, param[5].data.d_int32);
|
|
|
|
grid_cfg.hcolor = param[6].data.d_color;
|
2001-01-25 09:20:05 +08:00
|
|
|
|
2004-10-30 07:54:17 +08:00
|
|
|
gimp_rgb_set_alpha (&(grid_cfg.hcolor),
|
|
|
|
((double) (guint) param[7].data.d_int8) / 255.0);
|
|
|
|
|
2001-01-25 09:20:05 +08:00
|
|
|
|
2003-12-11 06:50:26 +08:00
|
|
|
grid_cfg.vwidth = MAX (0, param[8].data.d_int32);
|
|
|
|
grid_cfg.vspace = MAX (1, param[9].data.d_int32);
|
|
|
|
grid_cfg.voffset = MAX (0, param[10].data.d_int32);
|
|
|
|
grid_cfg.vcolor = param[11].data.d_color;
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2004-10-30 07:54:17 +08:00
|
|
|
gimp_rgb_set_alpha (&(grid_cfg.vcolor),
|
|
|
|
((double) (guint) param[12].data.d_int8) / 255.0);
|
|
|
|
|
|
|
|
|
2003-12-11 06:50:26 +08:00
|
|
|
|
|
|
|
grid_cfg.iwidth = MAX (0, param[13].data.d_int32);
|
|
|
|
grid_cfg.ispace = MAX (0, param[14].data.d_int32);
|
|
|
|
grid_cfg.ioffset = MAX (0, param[15].data.d_int32);
|
|
|
|
grid_cfg.icolor = param[16].data.d_color;
|
|
|
|
|
2004-10-30 07:54:17 +08:00
|
|
|
gimp_rgb_set_alpha (&(grid_cfg.icolor),
|
|
|
|
((double) (guint) param[17].data.d_int8) / 255.0);
|
|
|
|
|
|
|
|
|
2003-12-11 06:50:26 +08:00
|
|
|
}
|
1998-01-30 08:31:16 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-09-23 02:43:09 +08:00
|
|
|
gimp_context_get_foreground (&grid_cfg.hcolor);
|
2004-08-05 02:53:04 +08:00
|
|
|
grid_cfg.vcolor = grid_cfg.icolor = grid_cfg.hcolor;
|
|
|
|
|
1998-01-30 08:31:16 +08:00
|
|
|
/* Possibly retrieve data */
|
2005-08-14 06:52:41 +08:00
|
|
|
gimp_get_data (PLUG_IN_PROC, &grid_cfg);
|
1999-11-01 20:36:23 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
if (run_mode == GIMP_RUN_INTERACTIVE)
|
1999-11-01 20:36:23 +08:00
|
|
|
{
|
|
|
|
if (!dialog (image_ID, drawable))
|
2003-12-11 06:50:26 +08:00
|
|
|
{
|
|
|
|
/* The dialog was closed, or something similarly evil happened. */
|
|
|
|
status = GIMP_PDB_EXECUTION_ERROR;
|
|
|
|
}
|
1998-01-30 08:31:16 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-11-01 20:36:23 +08:00
|
|
|
if (grid_cfg.hspace <= 0 || grid_cfg.vspace <= 0)
|
1998-01-30 08:31:16 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
status = GIMP_PDB_EXECUTION_ERROR;
|
1998-01-30 08:31:16 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
if (status == GIMP_PDB_SUCCESS)
|
1998-01-30 08:31:16 +08:00
|
|
|
{
|
2000-02-23 05:25:18 +08:00
|
|
|
gimp_progress_init (_("Drawing Grid..."));
|
|
|
|
gimp_tile_cache_ntiles (2 * (drawable->width / gimp_tile_width () + 1));
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2004-09-04 00:37:53 +08:00
|
|
|
grid (image_ID, drawable, NULL);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
if (run_mode != GIMP_RUN_NONINTERACTIVE)
|
2003-12-11 06:50:26 +08:00
|
|
|
gimp_displays_flush ();
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
if (run_mode == GIMP_RUN_INTERACTIVE)
|
2005-08-14 06:52:41 +08:00
|
|
|
gimp_set_data (PLUG_IN_PROC, &grid_cfg, sizeof (grid_cfg));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-02-23 05:25:18 +08:00
|
|
|
gimp_drawable_detach (drawable);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
values[0].type = GIMP_PDB_STATUS;
|
2000-02-23 05:25:18 +08:00
|
|
|
values[0].data.d_status = status;
|
|
|
|
}
|
1998-01-30 08:31:16 +08:00
|
|
|
|
2000-02-23 05:25:18 +08:00
|
|
|
|
|
|
|
#define MAXDIFF 195076
|
|
|
|
|
|
|
|
static guchar
|
2003-07-02 19:07:41 +08:00
|
|
|
best_cmap_match (const guchar *cmap,
|
2003-12-11 06:50:26 +08:00
|
|
|
gint ncolors,
|
|
|
|
const GimpRGB *color)
|
2000-02-23 05:25:18 +08:00
|
|
|
{
|
|
|
|
guchar cmap_index = 0;
|
2001-01-12 07:36:59 +08:00
|
|
|
gint max = MAXDIFF;
|
|
|
|
gint i, diff, sum;
|
|
|
|
guchar r, g, b;
|
|
|
|
|
|
|
|
gimp_rgb_get_uchar (color, &r, &g, &b);
|
2000-02-23 05:25:18 +08:00
|
|
|
|
|
|
|
for (i = 0; i < ncolors; i++)
|
|
|
|
{
|
2001-01-12 07:36:59 +08:00
|
|
|
diff = r - *cmap++;
|
2000-02-23 05:25:18 +08:00
|
|
|
sum = SQR (diff);
|
2001-01-12 07:36:59 +08:00
|
|
|
diff = g - *cmap++;
|
2000-02-23 05:25:18 +08:00
|
|
|
sum += SQR (diff);
|
2001-01-12 07:36:59 +08:00
|
|
|
diff = b - *cmap++;
|
2000-02-23 05:25:18 +08:00
|
|
|
sum += SQR (diff);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2000-02-23 05:25:18 +08:00
|
|
|
if (sum < max)
|
2003-12-11 06:50:26 +08:00
|
|
|
{
|
|
|
|
cmap_index = i;
|
|
|
|
max = sum;
|
|
|
|
}
|
1998-01-30 08:31:16 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-02-23 05:25:18 +08:00
|
|
|
return cmap_index;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2004-11-14 10:50:33 +08:00
|
|
|
static inline void
|
2003-11-06 23:27:05 +08:00
|
|
|
pix_composite (guchar *p1,
|
2003-12-11 06:50:26 +08:00
|
|
|
guchar p2[4],
|
|
|
|
gint bytes,
|
|
|
|
gboolean blend,
|
|
|
|
gboolean alpha)
|
1999-11-01 20:36:23 +08:00
|
|
|
{
|
2000-02-23 05:25:18 +08:00
|
|
|
gint b;
|
|
|
|
|
|
|
|
if (blend)
|
|
|
|
{
|
2005-08-17 09:31:37 +08:00
|
|
|
if (alpha)
|
|
|
|
bytes--;
|
|
|
|
|
2000-02-23 05:25:18 +08:00
|
|
|
for (b = 0; b < bytes; b++)
|
2003-12-11 06:50:26 +08:00
|
|
|
{
|
|
|
|
*p1 = *p1 * (1.0 - p2[3]/255.0) + p2[b] * p2[3]/255.0;
|
|
|
|
p1++;
|
|
|
|
}
|
2000-02-23 05:25:18 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* blend should only be TRUE for indexed (bytes == 1) */
|
|
|
|
*p1++ = *p2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (alpha && *p1 < 255)
|
|
|
|
{
|
2005-08-17 09:31:37 +08:00
|
|
|
b = *p1 + 255.0 * ((gdouble) p2[3] / (255.0 - *p1));
|
|
|
|
|
2000-02-23 05:25:18 +08:00
|
|
|
*p1 = b > 255 ? 255 : b;
|
|
|
|
}
|
1999-11-01 20:36:23 +08:00
|
|
|
}
|
|
|
|
|
1998-06-01 13:07:31 +08:00
|
|
|
static void
|
2004-09-04 00:37:53 +08:00
|
|
|
grid (gint32 image_ID,
|
2000-08-22 09:26:57 +08:00
|
|
|
GimpDrawable *drawable,
|
2004-09-04 00:37:53 +08:00
|
|
|
GimpPreview *preview)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-08-07 08:04:16 +08:00
|
|
|
GimpPixelRgn srcPR, destPR;
|
2004-09-04 00:37:53 +08:00
|
|
|
gint bytes;
|
2004-08-07 08:04:16 +08:00
|
|
|
gint x_offset, y_offset;
|
|
|
|
guchar *dest, *buffer = NULL;
|
|
|
|
gint x, y;
|
|
|
|
gboolean alpha;
|
|
|
|
gboolean blend;
|
|
|
|
guchar hcolor[4];
|
|
|
|
guchar vcolor[4];
|
|
|
|
guchar icolor[4];
|
|
|
|
guchar *cmap;
|
|
|
|
gint ncolors;
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2004-09-04 00:37:53 +08:00
|
|
|
gimp_rgba_get_uchar (&grid_cfg.hcolor,
|
|
|
|
hcolor, hcolor + 1, hcolor + 2, hcolor + 3);
|
|
|
|
gimp_rgba_get_uchar (&grid_cfg.vcolor,
|
|
|
|
vcolor, vcolor + 1, vcolor + 2, vcolor + 3);
|
|
|
|
gimp_rgba_get_uchar (&grid_cfg.icolor,
|
|
|
|
icolor, icolor + 1, icolor + 2, icolor + 3);
|
2001-01-12 07:36:59 +08:00
|
|
|
|
2004-08-07 08:04:16 +08:00
|
|
|
switch (gimp_image_base_type (image_ID))
|
2000-02-23 05:25:18 +08:00
|
|
|
{
|
2004-08-07 08:04:16 +08:00
|
|
|
case GIMP_RGB:
|
2000-02-23 05:25:18 +08:00
|
|
|
blend = TRUE;
|
2004-08-07 08:04:16 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_GRAY:
|
2005-08-03 08:36:41 +08:00
|
|
|
hcolor[0] = gimp_rgb_luminance_uchar (&grid_cfg.hcolor);
|
|
|
|
vcolor[0] = gimp_rgb_luminance_uchar (&grid_cfg.vcolor);
|
|
|
|
icolor[0] = gimp_rgb_luminance_uchar (&grid_cfg.icolor);
|
2004-08-07 08:04:16 +08:00
|
|
|
blend = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_INDEXED:
|
2004-11-02 20:00:25 +08:00
|
|
|
cmap = gimp_image_get_colormap (image_ID, &ncolors);
|
2004-09-04 00:37:53 +08:00
|
|
|
|
2004-08-07 08:04:16 +08:00
|
|
|
hcolor[0] = best_cmap_match (cmap, ncolors, &grid_cfg.hcolor);
|
|
|
|
vcolor[0] = best_cmap_match (cmap, ncolors, &grid_cfg.vcolor);
|
|
|
|
icolor[0] = best_cmap_match (cmap, ncolors, &grid_cfg.icolor);
|
2004-09-04 00:37:53 +08:00
|
|
|
|
2004-08-07 08:04:16 +08:00
|
|
|
g_free (cmap);
|
|
|
|
blend = FALSE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
blend = FALSE;
|
2000-05-22 21:53:43 +08:00
|
|
|
}
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2004-08-07 08:04:16 +08:00
|
|
|
bytes = drawable->bpp;
|
|
|
|
alpha = gimp_drawable_has_alpha (drawable->drawable_id);
|
2004-09-04 00:37:53 +08:00
|
|
|
|
|
|
|
if (preview)
|
2003-11-06 23:27:05 +08:00
|
|
|
{
|
2004-09-29 21:39:23 +08:00
|
|
|
gimp_preview_get_position (preview, &sx1, &sy1);
|
2004-09-04 00:37:53 +08:00
|
|
|
gimp_preview_get_size (preview, &sx2, &sy2);
|
|
|
|
|
|
|
|
buffer = g_new (guchar, bytes * sx2 * sy2);
|
2004-08-07 08:04:16 +08:00
|
|
|
|
2004-09-04 00:37:53 +08:00
|
|
|
sx2 += sx1;
|
|
|
|
sy2 += sy1;
|
2003-11-06 23:27:05 +08:00
|
|
|
}
|
|
|
|
else
|
2000-05-22 21:53:43 +08:00
|
|
|
{
|
2001-06-15 04:07:38 +08:00
|
|
|
gimp_drawable_mask_bounds (drawable->drawable_id, &sx1, &sy1, &sx2, &sy2);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2004-09-04 00:37:53 +08:00
|
|
|
gimp_pixel_rgn_init (&destPR,
|
|
|
|
drawable, 0, 0, sx2 - sx1, sy2 - sy1, TRUE, TRUE);
|
2000-02-23 05:25:18 +08:00
|
|
|
}
|
|
|
|
|
2004-09-04 00:37:53 +08:00
|
|
|
gimp_pixel_rgn_init (&srcPR,
|
|
|
|
drawable, 0, 0, sx2 - sx1, sy2 - sy1, FALSE, FALSE);
|
|
|
|
|
|
|
|
dest = g_new (guchar, (sx2 - sx1) * bytes);
|
2005-06-24 01:13:57 +08:00
|
|
|
|
1999-11-01 20:36:23 +08:00
|
|
|
for (y = sy1; y < sy2; y++)
|
1998-01-30 08:31:16 +08:00
|
|
|
{
|
2004-08-07 08:04:16 +08:00
|
|
|
gimp_pixel_rgn_get_row (&srcPR, dest, sx1, y, (sx2 - sx1));
|
1999-11-01 20:36:23 +08:00
|
|
|
|
2003-06-02 20:27:13 +08:00
|
|
|
y_offset = y - grid_cfg.hoffset;
|
2000-02-21 04:09:01 +08:00
|
|
|
while (y_offset < 0)
|
2003-12-11 06:50:26 +08:00
|
|
|
y_offset += grid_cfg.hspace;
|
2000-02-21 03:34:51 +08:00
|
|
|
|
2005-06-24 01:13:57 +08:00
|
|
|
if ((y_offset +
|
|
|
|
(grid_cfg.hwidth / 2)) % grid_cfg.hspace < grid_cfg.hwidth)
|
2003-12-11 06:50:26 +08:00
|
|
|
{
|
|
|
|
for (x = sx1; x < sx2; x++)
|
|
|
|
{
|
2005-06-24 01:13:57 +08:00
|
|
|
pix_composite (&dest[(x-sx1) * bytes],
|
|
|
|
hcolor, bytes, blend, alpha);
|
2003-12-11 06:50:26 +08:00
|
|
|
}
|
1999-11-01 20:36:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
for (x = sx1; x < sx2; x++)
|
|
|
|
{
|
2003-12-11 06:50:26 +08:00
|
|
|
x_offset = grid_cfg.vspace + x - grid_cfg.voffset;
|
|
|
|
while (x_offset < 0)
|
|
|
|
x_offset += grid_cfg.vspace;
|
2000-02-21 03:34:51 +08:00
|
|
|
|
2005-06-24 01:13:57 +08:00
|
|
|
if ((x_offset +
|
|
|
|
(grid_cfg.vwidth / 2)) % grid_cfg.vspace < grid_cfg.vwidth)
|
1999-11-01 20:36:23 +08:00
|
|
|
{
|
2005-06-24 01:13:57 +08:00
|
|
|
pix_composite (&dest[(x-sx1) * bytes],
|
|
|
|
vcolor, bytes, blend, alpha);
|
1999-11-01 20:36:23 +08:00
|
|
|
}
|
|
|
|
|
2005-06-24 01:13:57 +08:00
|
|
|
if ((x_offset +
|
|
|
|
(grid_cfg.iwidth / 2)) % grid_cfg.vspace < grid_cfg.iwidth
|
2003-12-11 06:50:26 +08:00
|
|
|
&&
|
|
|
|
((y_offset % grid_cfg.hspace >= grid_cfg.ispace
|
|
|
|
&&
|
|
|
|
y_offset % grid_cfg.hspace < grid_cfg.ioffset)
|
|
|
|
||
|
2005-06-24 01:13:57 +08:00
|
|
|
(grid_cfg.hspace -
|
|
|
|
(y_offset % grid_cfg.hspace) >= grid_cfg.ispace
|
2003-12-11 06:50:26 +08:00
|
|
|
&&
|
2005-06-24 01:13:57 +08:00
|
|
|
grid_cfg.hspace -
|
|
|
|
(y_offset % grid_cfg.hspace) < grid_cfg.ioffset)))
|
1999-11-01 20:36:23 +08:00
|
|
|
{
|
2005-06-24 01:13:57 +08:00
|
|
|
pix_composite (&dest[(x-sx1) * bytes],
|
|
|
|
icolor, bytes, blend, alpha);
|
1999-11-01 20:36:23 +08:00
|
|
|
}
|
|
|
|
}
|
2005-06-24 01:13:57 +08:00
|
|
|
|
|
|
|
if ((y_offset +
|
|
|
|
(grid_cfg.iwidth / 2)) % grid_cfg.hspace < grid_cfg.iwidth)
|
|
|
|
{
|
|
|
|
for (x = sx1; x < sx2; x++)
|
|
|
|
{
|
|
|
|
x_offset = grid_cfg.vspace + x - grid_cfg.voffset;
|
|
|
|
while (x_offset < 0)
|
|
|
|
x_offset += grid_cfg.vspace;
|
|
|
|
|
|
|
|
if ((x_offset % grid_cfg.vspace >= grid_cfg.ispace
|
|
|
|
&&
|
|
|
|
x_offset % grid_cfg.vspace < grid_cfg.ioffset)
|
|
|
|
||
|
|
|
|
(grid_cfg.vspace -
|
|
|
|
(x_offset % grid_cfg.vspace) >= grid_cfg.ispace
|
|
|
|
&&
|
|
|
|
grid_cfg.vspace -
|
|
|
|
(x_offset % grid_cfg.vspace) < grid_cfg.ioffset))
|
|
|
|
{
|
|
|
|
pix_composite (&dest[(x-sx1) * bytes],
|
|
|
|
icolor, bytes, blend, alpha);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-09-04 00:37:53 +08:00
|
|
|
if (preview)
|
2003-12-11 06:50:26 +08:00
|
|
|
{
|
2004-09-04 00:37:53 +08:00
|
|
|
memcpy (buffer + (y - sy1) * (sx2 - sx1) * bytes,
|
|
|
|
dest,
|
|
|
|
(sx2 - sx1) * bytes);
|
2003-12-11 06:50:26 +08:00
|
|
|
}
|
2003-11-06 23:27:05 +08:00
|
|
|
else
|
2003-12-11 06:50:26 +08:00
|
|
|
{
|
2005-08-17 09:31:37 +08:00
|
|
|
gimp_pixel_rgn_set_row (&destPR, dest, sx1, y, (sx2 - sx1));
|
|
|
|
|
|
|
|
if (y % 16 == 0)
|
|
|
|
gimp_progress_update ((gdouble) y / (gdouble) (sy2 - sy1));
|
2003-12-11 06:50:26 +08:00
|
|
|
}
|
2003-11-06 23:27:05 +08:00
|
|
|
}
|
2004-09-04 00:37:53 +08:00
|
|
|
|
2000-02-11 10:22:01 +08:00
|
|
|
g_free (dest);
|
1998-01-30 08:31:16 +08:00
|
|
|
|
2004-09-04 00:37:53 +08:00
|
|
|
if (preview)
|
2000-05-22 21:53:43 +08:00
|
|
|
{
|
2004-09-29 23:33:02 +08:00
|
|
|
gimp_preview_draw_buffer (preview, buffer, bytes * (sx2 - sx1));
|
2004-08-07 08:04:16 +08:00
|
|
|
g_free (buffer);
|
2003-11-06 23:27:05 +08:00
|
|
|
}
|
|
|
|
else
|
2000-05-22 21:53:43 +08:00
|
|
|
{
|
|
|
|
gimp_drawable_flush (drawable);
|
2001-06-15 04:07:38 +08:00
|
|
|
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
|
2003-06-02 20:27:13 +08:00
|
|
|
gimp_drawable_update (drawable->drawable_id,
|
|
|
|
sx1, sy1, sx2 - sx1, sy2 - sy1);
|
2000-05-22 21:53:43 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-02-23 05:25:18 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/***************************************************
|
|
|
|
* GUI stuff
|
|
|
|
*/
|
|
|
|
|
2003-06-02 20:27:13 +08:00
|
|
|
|
1998-06-01 13:07:31 +08:00
|
|
|
static void
|
2003-06-02 20:27:13 +08:00
|
|
|
update_values (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-08-25 02:36:38 +08:00
|
|
|
GtkWidget *entry;
|
|
|
|
|
2003-06-02 20:27:13 +08:00
|
|
|
entry = g_object_get_data (G_OBJECT (main_dialog), "width");
|
1999-08-25 02:36:38 +08:00
|
|
|
|
2003-06-02 20:27:13 +08:00
|
|
|
grid_cfg.hwidth =
|
|
|
|
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (entry), 0));
|
|
|
|
grid_cfg.vwidth =
|
|
|
|
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (entry), 1));
|
|
|
|
grid_cfg.iwidth =
|
|
|
|
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (entry), 2));
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2003-06-02 20:27:13 +08:00
|
|
|
entry = g_object_get_data (G_OBJECT (main_dialog), "space");
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2003-06-02 20:27:13 +08:00
|
|
|
grid_cfg.hspace =
|
|
|
|
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (entry), 0));
|
|
|
|
grid_cfg.vspace =
|
|
|
|
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (entry), 1));
|
|
|
|
grid_cfg.ispace =
|
|
|
|
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (entry), 2));
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2003-06-02 20:27:13 +08:00
|
|
|
entry = g_object_get_data (G_OBJECT (main_dialog), "offset");
|
|
|
|
|
|
|
|
grid_cfg.hoffset =
|
|
|
|
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (entry), 0));
|
|
|
|
grid_cfg.voffset =
|
|
|
|
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (entry), 1));
|
|
|
|
grid_cfg.ioffset =
|
|
|
|
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (entry), 2));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-09-04 00:37:53 +08:00
|
|
|
update_preview (GimpPreview *preview,
|
|
|
|
GimpDrawable *drawable)
|
2003-06-02 20:27:13 +08:00
|
|
|
{
|
|
|
|
update_values ();
|
|
|
|
|
2004-09-04 00:37:53 +08:00
|
|
|
grid (gimp_drawable_get_image (drawable->drawable_id), drawable, preview);
|
2003-06-02 20:27:13 +08:00
|
|
|
}
|
|
|
|
|
1998-06-01 13:07:31 +08:00
|
|
|
static void
|
2003-11-06 23:27:05 +08:00
|
|
|
entry_callback (GtkWidget *widget,
|
2003-12-11 06:50:26 +08:00
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-08-25 02:36:38 +08:00
|
|
|
static gdouble x = -1.0;
|
|
|
|
static gdouble y = -1.0;
|
|
|
|
gdouble new_x;
|
|
|
|
gdouble new_y;
|
|
|
|
|
|
|
|
new_x = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0);
|
|
|
|
new_y = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1);
|
|
|
|
|
|
|
|
if (gimp_chain_button_get_active (GIMP_CHAIN_BUTTON (data)))
|
|
|
|
{
|
|
|
|
if (new_x != x)
|
2003-12-11 06:50:26 +08:00
|
|
|
{
|
|
|
|
y = new_y = x = new_x;
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 1, y);
|
|
|
|
}
|
1999-08-25 02:36:38 +08:00
|
|
|
if (new_y != y)
|
2003-12-11 06:50:26 +08:00
|
|
|
{
|
|
|
|
x = new_x = y = new_y;
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 0, x);
|
|
|
|
}
|
1999-08-25 02:36:38 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-12-23 20:39:55 +08:00
|
|
|
x = new_x;
|
|
|
|
y = new_y;
|
2003-06-02 20:27:13 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1999-12-02 08:20:43 +08:00
|
|
|
static void
|
2001-01-11 06:49:45 +08:00
|
|
|
color_callback (GtkWidget *widget,
|
2003-12-11 06:50:26 +08:00
|
|
|
gpointer data)
|
1999-12-02 08:20:43 +08:00
|
|
|
{
|
|
|
|
if (gimp_chain_button_get_active (GIMP_CHAIN_BUTTON (data)))
|
|
|
|
{
|
2001-01-11 06:49:45 +08:00
|
|
|
GimpRGB color;
|
|
|
|
|
|
|
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (widget), &color);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2001-01-15 17:27:48 +08:00
|
|
|
if (widget == vcolor_button)
|
2004-09-04 00:37:53 +08:00
|
|
|
gimp_color_button_set_color (GIMP_COLOR_BUTTON (hcolor_button), &color);
|
2001-01-15 17:27:48 +08:00
|
|
|
else if (widget == hcolor_button)
|
2004-09-04 00:37:53 +08:00
|
|
|
gimp_color_button_set_color (GIMP_COLOR_BUTTON (vcolor_button), &color);
|
1999-12-02 08:20:43 +08:00
|
|
|
}
|
2000-05-22 21:53:43 +08:00
|
|
|
}
|
|
|
|
|
2003-06-02 20:27:13 +08:00
|
|
|
|
1998-06-01 13:07:31 +08:00
|
|
|
static gint
|
2000-10-27 07:21:34 +08:00
|
|
|
dialog (gint32 image_ID,
|
2003-12-11 06:50:26 +08:00
|
|
|
GimpDrawable *drawable)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-09-10 00:08:56 +08:00
|
|
|
GtkWidget *dlg;
|
|
|
|
GtkWidget *main_vbox;
|
|
|
|
GtkWidget *vbox;
|
2004-05-19 01:06:06 +08:00
|
|
|
GtkSizeGroup *group;
|
|
|
|
GtkWidget *label;
|
2004-09-10 00:08:56 +08:00
|
|
|
GtkWidget *preview;
|
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *width;
|
|
|
|
GtkWidget *space;
|
|
|
|
GtkWidget *offset;
|
|
|
|
GtkWidget *chain_button;
|
|
|
|
GtkWidget *table;
|
|
|
|
GimpUnit unit;
|
|
|
|
gdouble xres;
|
|
|
|
gdouble yres;
|
|
|
|
gboolean run;
|
1998-01-30 08:31:16 +08:00
|
|
|
|
2003-06-02 20:27:13 +08:00
|
|
|
g_return_val_if_fail (main_dialog == NULL, FALSE);
|
1998-01-30 08:31:16 +08:00
|
|
|
|
2005-08-14 06:52:41 +08:00
|
|
|
gimp_ui_init (PLUG_IN_BINARY, TRUE);
|
2000-01-05 23:47:06 +08:00
|
|
|
|
2005-08-14 06:52:41 +08:00
|
|
|
main_dialog = dlg = gimp_dialog_new (_("Grid"), PLUG_IN_BINARY,
|
2003-11-06 23:27:05 +08:00
|
|
|
NULL, 0,
|
2005-08-14 06:52:41 +08:00
|
|
|
gimp_standard_help_func, PLUG_IN_PROC,
|
1998-01-30 08:31:16 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
|
|
|
|
|
|
|
NULL);
|
2000-01-07 06:26:10 +08:00
|
|
|
|
2005-02-09 04:40:33 +08:00
|
|
|
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dlg),
|
2005-08-14 06:52:41 +08:00
|
|
|
GTK_RESPONSE_OK,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1);
|
2005-02-09 04:40:33 +08:00
|
|
|
|
1999-08-25 02:36:38 +08:00
|
|
|
/* Get the image resolution and unit */
|
|
|
|
gimp_image_get_resolution (image_ID, &xres, &yres);
|
2000-01-05 23:47:06 +08:00
|
|
|
unit = gimp_image_get_unit (image_ID);
|
1998-01-30 08:31:16 +08:00
|
|
|
|
2004-09-10 00:08:56 +08:00
|
|
|
main_vbox = gtk_vbox_new (FALSE, 12);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
|
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dlg)->vbox), main_vbox);
|
|
|
|
gtk_widget_show (main_vbox);
|
2000-05-22 21:53:43 +08:00
|
|
|
|
2004-09-04 00:37:53 +08:00
|
|
|
preview = gimp_drawable_preview_new (drawable, NULL);
|
2004-09-10 00:08:56 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), preview, TRUE, TRUE, 0);
|
2004-08-07 08:04:16 +08:00
|
|
|
gtk_widget_show (preview);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2004-09-04 00:37:53 +08:00
|
|
|
g_signal_connect (preview, "invalidated",
|
|
|
|
G_CALLBACK (update_preview),
|
|
|
|
drawable);
|
|
|
|
|
2004-09-10 00:08:56 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 2);
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (vbox);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2000-05-22 21:53:43 +08:00
|
|
|
/* The width entries */
|
2003-11-06 23:27:05 +08:00
|
|
|
width = gimp_size_entry_new (3, /* number_of_fields */
|
2003-12-11 06:50:26 +08:00
|
|
|
unit, /* unit */
|
|
|
|
"%a", /* unit_format */
|
|
|
|
TRUE, /* menu_show_pixels */
|
|
|
|
TRUE, /* menu_show_percent */
|
|
|
|
FALSE, /* show_refval */
|
|
|
|
SPIN_BUTTON_WIDTH, /* spinbutton_usize */
|
|
|
|
GIMP_SIZE_ENTRY_UPDATE_SIZE); /* update_policy */
|
1999-08-25 02:36:38 +08:00
|
|
|
|
2004-05-19 01:06:06 +08:00
|
|
|
|
2004-09-10 00:08:56 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), width, FALSE, FALSE, 0);
|
2004-05-19 01:06:06 +08:00
|
|
|
gtk_widget_show (width);
|
|
|
|
|
2000-01-19 05:01:45 +08:00
|
|
|
/* set the unit back to pixels, since most times we will want pixels */
|
2000-02-08 04:35:13 +08:00
|
|
|
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (width), GIMP_UNIT_PIXEL);
|
2000-01-19 05:01:45 +08:00
|
|
|
|
1999-08-25 02:36:38 +08:00
|
|
|
/* set the resolution to the image resolution */
|
1999-11-01 20:36:23 +08:00
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (width), 0, xres, TRUE);
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (width), 1, yres, TRUE);
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (width), 2, xres, TRUE);
|
1999-08-25 02:36:38 +08:00
|
|
|
|
|
|
|
/* set the size (in pixels) that will be treated as 0% and 100% */
|
2002-09-07 04:44:47 +08:00
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (width), 0, 0.0, drawable->width);
|
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (width), 1, 0.0, drawable->height);
|
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (width), 2, 0.0, drawable->width);
|
1999-08-25 02:36:38 +08:00
|
|
|
|
|
|
|
/* set upper and lower limits (in pixels) */
|
2003-11-06 23:27:05 +08:00
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (width), 0, 0.0,
|
2003-12-11 06:50:26 +08:00
|
|
|
drawable->width);
|
2003-11-06 23:27:05 +08:00
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (width), 1, 0.0,
|
2003-12-11 06:50:26 +08:00
|
|
|
drawable->height);
|
2003-11-06 23:27:05 +08:00
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (width), 2, 0.0,
|
2004-09-04 00:37:53 +08:00
|
|
|
MAX (drawable->width,
|
|
|
|
drawable->height));
|
2004-05-19 01:06:06 +08:00
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (width), 0, 6);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (width), 6);
|
1999-12-02 08:20:43 +08:00
|
|
|
gtk_table_set_col_spacing (GTK_TABLE (width), 2, 12);
|
|
|
|
|
1999-08-25 02:36:38 +08:00
|
|
|
/* initialize the values */
|
2002-09-07 04:44:47 +08:00
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (width), 0, grid_cfg.hwidth);
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (width), 1, grid_cfg.vwidth);
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (width), 2, grid_cfg.iwidth);
|
1999-08-25 02:36:38 +08:00
|
|
|
|
|
|
|
/* attach labels */
|
2002-09-07 04:44:47 +08:00
|
|
|
gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (width), _("Horizontal"),
|
|
|
|
0, 1, 0.0);
|
|
|
|
gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (width), _("Vertical"),
|
|
|
|
0, 2, 0.0);
|
|
|
|
gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (width), _("Intersection"),
|
|
|
|
0, 3, 0.0);
|
2004-05-19 01:06:06 +08:00
|
|
|
|
|
|
|
label = gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (width), _("Width:"),
|
|
|
|
1, 0, 0.0);
|
|
|
|
|
|
|
|
group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
|
|
|
gtk_size_group_add_widget (group, label);
|
|
|
|
g_object_unref (group);
|
1999-08-25 02:36:38 +08:00
|
|
|
|
|
|
|
/* put a chain_button under the size_entries */
|
1999-12-02 08:20:43 +08:00
|
|
|
chain_button = gimp_chain_button_new (GIMP_CHAIN_BOTTOM);
|
1999-11-01 20:36:23 +08:00
|
|
|
if (grid_cfg.hwidth == grid_cfg.vwidth)
|
1999-12-02 08:20:43 +08:00
|
|
|
gimp_chain_button_set_active (GIMP_CHAIN_BUTTON (chain_button), TRUE);
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (width), chain_button, 1, 3, 2, 3);
|
|
|
|
gtk_widget_show (chain_button);
|
2000-05-22 21:53:43 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
/* connect to the 'value_changed' signal because we have to take care
|
2001-12-29 21:26:29 +08:00
|
|
|
* of keeping the entries in sync when the chainbutton is active
|
|
|
|
*/
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (width, "value-changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (entry_callback),
|
|
|
|
chain_button);
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect_swapped (width, "value-changed",
|
2004-09-04 00:37:53 +08:00
|
|
|
G_CALLBACK (gimp_preview_invalidate),
|
|
|
|
preview);
|
1999-11-01 20:36:23 +08:00
|
|
|
|
1999-12-02 08:20:43 +08:00
|
|
|
/* The spacing entries */
|
2003-11-06 23:27:05 +08:00
|
|
|
space = gimp_size_entry_new (3, /* number_of_fields */
|
2003-12-11 06:50:26 +08:00
|
|
|
unit, /* unit */
|
|
|
|
"%a", /* unit_format */
|
|
|
|
TRUE, /* menu_show_pixels */
|
|
|
|
TRUE, /* menu_show_percent */
|
|
|
|
FALSE, /* show_refval */
|
|
|
|
SPIN_BUTTON_WIDTH, /* spinbutton_usize */
|
|
|
|
GIMP_SIZE_ENTRY_UPDATE_SIZE); /* update_policy */
|
2004-05-19 01:06:06 +08:00
|
|
|
|
2004-09-10 00:08:56 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), space, FALSE, FALSE, 0);
|
2004-05-19 01:06:06 +08:00
|
|
|
gtk_widget_show (space);
|
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (space), GIMP_UNIT_PIXEL);
|
2000-01-19 05:01:45 +08:00
|
|
|
|
1999-11-01 20:36:23 +08:00
|
|
|
/* set the resolution to the image resolution */
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (space), 0, xres, TRUE);
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (space), 1, yres, TRUE);
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (space), 2, xres, TRUE);
|
|
|
|
|
|
|
|
/* set the size (in pixels) that will be treated as 0% and 100% */
|
2005-05-10 03:32:03 +08:00
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (space), 0, 0.0, drawable->height);
|
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (space), 1, 0.0, drawable->width);
|
2002-09-07 04:44:47 +08:00
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (space), 2, 0.0, drawable->width);
|
1999-11-01 20:36:23 +08:00
|
|
|
|
|
|
|
/* set upper and lower limits (in pixels) */
|
2002-09-07 04:44:47 +08:00
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (space), 0, 1.0,
|
2003-12-11 06:50:26 +08:00
|
|
|
drawable->height);
|
2005-05-10 03:32:03 +08:00
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (space), 1, 1.0,
|
|
|
|
drawable->width);
|
2003-11-06 23:27:05 +08:00
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (space), 2, 0.0,
|
2004-09-04 00:37:53 +08:00
|
|
|
MAX (drawable->width,
|
|
|
|
drawable->height));
|
2004-05-19 01:06:06 +08:00
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (space), 6);
|
1999-12-02 08:20:43 +08:00
|
|
|
gtk_table_set_col_spacing (GTK_TABLE (space), 2, 12);
|
|
|
|
|
1999-11-01 20:36:23 +08:00
|
|
|
/* initialize the values */
|
2002-09-07 04:44:47 +08:00
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (space), 0, grid_cfg.hspace);
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (space), 1, grid_cfg.vspace);
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (space), 2, grid_cfg.ispace);
|
|
|
|
|
1999-11-01 20:36:23 +08:00
|
|
|
/* attach labels */
|
2004-05-19 01:06:06 +08:00
|
|
|
label = gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (space), _("Spacing:"),
|
|
|
|
1, 0, 0.0);
|
|
|
|
gtk_size_group_add_widget (group, label);
|
1999-11-01 20:36:23 +08:00
|
|
|
|
1999-12-02 08:20:43 +08:00
|
|
|
/* put a chain_button under the spacing_entries */
|
|
|
|
chain_button = gimp_chain_button_new (GIMP_CHAIN_BOTTOM);
|
1999-11-01 20:36:23 +08:00
|
|
|
if (grid_cfg.hspace == grid_cfg.vspace)
|
1999-12-02 08:20:43 +08:00
|
|
|
gimp_chain_button_set_active (GIMP_CHAIN_BUTTON (chain_button), TRUE);
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (space), chain_button, 1, 3, 2, 3);
|
|
|
|
gtk_widget_show (chain_button);
|
2000-05-22 21:53:43 +08:00
|
|
|
|
2001-12-29 21:26:29 +08:00
|
|
|
/* connect to the 'value_changed' and "unit_changed" signals because
|
|
|
|
* we have to take care of keeping the entries in sync when the
|
|
|
|
* chainbutton is active
|
|
|
|
*/
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (space, "value-changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (entry_callback),
|
|
|
|
chain_button);
|
2003-11-06 23:27:05 +08:00
|
|
|
g_signal_connect (space, "unit_changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (entry_callback),
|
|
|
|
chain_button);
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect_swapped (space, "value-changed",
|
2004-09-04 00:37:53 +08:00
|
|
|
G_CALLBACK (gimp_preview_invalidate),
|
|
|
|
preview);
|
1999-08-25 02:36:38 +08:00
|
|
|
|
1999-11-01 20:36:23 +08:00
|
|
|
/* The offset entries */
|
2003-11-06 23:27:05 +08:00
|
|
|
offset = gimp_size_entry_new (3, /* number_of_fields */
|
2003-12-11 06:50:26 +08:00
|
|
|
unit, /* unit */
|
|
|
|
"%a", /* unit_format */
|
|
|
|
TRUE, /* menu_show_pixels */
|
|
|
|
TRUE, /* menu_show_percent */
|
|
|
|
FALSE, /* show_refval */
|
|
|
|
SPIN_BUTTON_WIDTH, /* spinbutton_usize */
|
|
|
|
GIMP_SIZE_ENTRY_UPDATE_SIZE); /* update_policy */
|
2004-05-19 01:06:06 +08:00
|
|
|
|
2004-09-10 00:08:56 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), offset, FALSE, FALSE, 0);
|
2004-05-19 01:06:06 +08:00
|
|
|
gtk_widget_show (offset);
|
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (offset), GIMP_UNIT_PIXEL);
|
2000-01-19 05:01:45 +08:00
|
|
|
|
1999-11-01 20:36:23 +08:00
|
|
|
/* set the resolution to the image resolution */
|
1999-08-25 02:36:38 +08:00
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (offset), 0, xres, TRUE);
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (offset), 1, yres, TRUE);
|
1999-11-01 20:36:23 +08:00
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (offset), 2, xres, TRUE);
|
|
|
|
|
|
|
|
/* set the size (in pixels) that will be treated as 0% and 100% */
|
2005-05-10 03:32:03 +08:00
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (offset), 0, 0.0, drawable->height);
|
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (offset), 1, 0.0, drawable->width);
|
2002-09-07 04:44:47 +08:00
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (offset), 2, 0.0, drawable->width);
|
1999-11-01 20:36:23 +08:00
|
|
|
|
|
|
|
/* set upper and lower limits (in pixels) */
|
2003-11-06 23:27:05 +08:00
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (offset), 0, 0.0,
|
2003-12-11 06:50:26 +08:00
|
|
|
drawable->height);
|
2005-05-10 03:32:03 +08:00
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (offset), 1, 0.0,
|
|
|
|
drawable->width);
|
2003-11-06 23:27:05 +08:00
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (offset), 2, 0.0,
|
2004-09-04 00:37:53 +08:00
|
|
|
MAX (drawable->width,
|
|
|
|
drawable->height));
|
2004-05-19 01:06:06 +08:00
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (offset), 6);
|
1999-12-02 08:20:43 +08:00
|
|
|
gtk_table_set_col_spacing (GTK_TABLE (offset), 2, 12);
|
|
|
|
|
1999-11-01 20:36:23 +08:00
|
|
|
/* initialize the values */
|
2002-09-07 04:44:47 +08:00
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (offset), 0, grid_cfg.hoffset);
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (offset), 1, grid_cfg.voffset);
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (offset), 2, grid_cfg.ioffset);
|
1999-11-01 20:36:23 +08:00
|
|
|
|
|
|
|
/* attach labels */
|
2004-05-19 01:06:06 +08:00
|
|
|
label = gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (offset), _("Offset:"),
|
|
|
|
1, 0, 0.0);
|
|
|
|
gtk_size_group_add_widget (group, label);
|
1999-11-01 20:36:23 +08:00
|
|
|
|
1999-12-02 08:20:43 +08:00
|
|
|
/* this is a weird hack: we put a table into the offset table */
|
|
|
|
table = gtk_table_new (3, 3, FALSE);
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (offset), table, 1, 4, 2, 3);
|
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (table), 0, 10);
|
|
|
|
gtk_table_set_col_spacing (GTK_TABLE (table), 1, 12);
|
1999-11-01 20:36:23 +08:00
|
|
|
|
1999-12-02 08:20:43 +08:00
|
|
|
/* put a chain_button under the offset_entries */
|
|
|
|
chain_button = gimp_chain_button_new (GIMP_CHAIN_BOTTOM);
|
|
|
|
if (grid_cfg.hoffset == grid_cfg.voffset)
|
|
|
|
gimp_chain_button_set_active (GIMP_CHAIN_BUTTON (chain_button), TRUE);
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), chain_button, 0, 2, 0, 1);
|
|
|
|
gtk_widget_show (chain_button);
|
|
|
|
|
2001-12-29 21:26:29 +08:00
|
|
|
/* connect to the 'value_changed' and "unit_changed" signals because
|
|
|
|
* we have to take care of keeping the entries in sync when the
|
|
|
|
* chainbutton is active
|
|
|
|
*/
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (offset, "value-changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (entry_callback),
|
|
|
|
chain_button);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (offset, "unit_changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (entry_callback),
|
|
|
|
chain_button);
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect_swapped (offset, "value-changed",
|
2004-09-04 00:37:53 +08:00
|
|
|
G_CALLBACK (gimp_preview_invalidate),
|
|
|
|
preview);
|
1999-12-02 08:20:43 +08:00
|
|
|
|
|
|
|
/* put a chain_button under the color_buttons */
|
|
|
|
chain_button = gimp_chain_button_new (GIMP_CHAIN_BOTTOM);
|
2001-01-15 17:27:48 +08:00
|
|
|
if (gimp_rgba_distance (&grid_cfg.hcolor, &grid_cfg.vcolor) < 0.0001)
|
1999-12-02 08:20:43 +08:00
|
|
|
gimp_chain_button_set_active (GIMP_CHAIN_BUTTON (chain_button), TRUE);
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), chain_button, 0, 2, 2, 3);
|
|
|
|
gtk_widget_show (chain_button);
|
|
|
|
|
2000-02-23 05:25:18 +08:00
|
|
|
/* attach color selectors */
|
2003-11-06 23:27:05 +08:00
|
|
|
hcolor_button = gimp_color_button_new (_("Horizontal Color"),
|
2003-12-11 06:50:26 +08:00
|
|
|
COLOR_BUTTON_WIDTH, 16,
|
|
|
|
&grid_cfg.hcolor,
|
|
|
|
GIMP_COLOR_AREA_SMALL_CHECKS);
|
2003-11-12 02:11:56 +08:00
|
|
|
gimp_color_button_set_update (GIMP_COLOR_BUTTON (hcolor_button), TRUE);
|
2004-05-19 01:06:06 +08:00
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), hcolor_button, 0, 1, 1, 2);
|
1999-12-02 08:20:43 +08:00
|
|
|
gtk_widget_show (hcolor_button);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (hcolor_button, "color-changed",
|
2003-11-06 23:27:05 +08:00
|
|
|
G_CALLBACK (gimp_color_button_get_color),
|
2001-12-29 21:26:29 +08:00
|
|
|
&grid_cfg.hcolor);
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (hcolor_button, "color-changed",
|
2003-11-06 23:27:05 +08:00
|
|
|
G_CALLBACK (color_callback),
|
2001-12-29 21:26:29 +08:00
|
|
|
chain_button);
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect_swapped (hcolor_button, "color-changed",
|
2004-09-04 00:37:53 +08:00
|
|
|
G_CALLBACK (gimp_preview_invalidate),
|
|
|
|
preview);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
vcolor_button = gimp_color_button_new (_("Vertical Color"),
|
2003-12-11 06:50:26 +08:00
|
|
|
COLOR_BUTTON_WIDTH, 16,
|
|
|
|
&grid_cfg.vcolor,
|
|
|
|
GIMP_COLOR_AREA_SMALL_CHECKS);
|
2003-11-12 02:11:56 +08:00
|
|
|
gimp_color_button_set_update (GIMP_COLOR_BUTTON (vcolor_button), TRUE);
|
2004-05-19 01:06:06 +08:00
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), vcolor_button, 1, 2, 1, 2);
|
1999-12-02 08:20:43 +08:00
|
|
|
gtk_widget_show (vcolor_button);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (vcolor_button, "color-changed",
|
2003-11-06 23:27:05 +08:00
|
|
|
G_CALLBACK (gimp_color_button_get_color),
|
2001-12-29 21:26:29 +08:00
|
|
|
&grid_cfg.vcolor);
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (vcolor_button, "color-changed",
|
2003-11-06 23:27:05 +08:00
|
|
|
G_CALLBACK (color_callback),
|
|
|
|
chain_button);
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect_swapped (vcolor_button, "color-changed",
|
2004-09-04 00:37:53 +08:00
|
|
|
G_CALLBACK (gimp_preview_invalidate),
|
|
|
|
preview);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
button = gimp_color_button_new (_("Intersection Color"),
|
2003-12-11 06:50:26 +08:00
|
|
|
COLOR_BUTTON_WIDTH, 16,
|
|
|
|
&grid_cfg.icolor,
|
|
|
|
GIMP_COLOR_AREA_SMALL_CHECKS);
|
2003-11-12 02:11:56 +08:00
|
|
|
gimp_color_button_set_update (GIMP_COLOR_BUTTON (button), TRUE);
|
2004-05-19 01:06:06 +08:00
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), button, 2, 3, 1, 2);
|
1999-11-01 20:36:23 +08:00
|
|
|
gtk_widget_show (button);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (button, "color-changed",
|
2003-11-06 23:27:05 +08:00
|
|
|
G_CALLBACK (gimp_color_button_get_color),
|
2001-12-29 21:26:29 +08:00
|
|
|
&grid_cfg.icolor);
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect_swapped (button, "color-changed",
|
2004-09-04 00:37:53 +08:00
|
|
|
G_CALLBACK (gimp_preview_invalidate),
|
|
|
|
preview);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
1999-12-02 08:20:43 +08:00
|
|
|
gtk_widget_show (table);
|
|
|
|
|
1998-01-30 08:31:16 +08:00
|
|
|
gtk_widget_show (dlg);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-09-04 00:37:53 +08:00
|
|
|
g_object_set_data (G_OBJECT (dlg), "width", width);
|
|
|
|
g_object_set_data (G_OBJECT (dlg), "space", space);
|
|
|
|
g_object_set_data (G_OBJECT (dlg), "offset", offset);
|
2004-08-07 08:04:16 +08:00
|
|
|
|
2003-11-12 02:11:56 +08:00
|
|
|
run = (gimp_dialog_run (GIMP_DIALOG (dlg)) == GTK_RESPONSE_OK);
|
1998-01-30 08:31:16 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
if (run)
|
|
|
|
update_values ();
|
1998-01-30 08:31:16 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
gtk_widget_destroy (dlg);
|
|
|
|
|
|
|
|
return run;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2004-08-07 08:04:16 +08:00
|
|
|
|