1997-11-25 06:05:25 +08:00
|
|
|
/*
|
|
|
|
* pat plug-in version 1.01
|
|
|
|
* Loads/saves version 1 GIMP .pat files, by Tim Newsome <drz@frody.bloke.com>
|
|
|
|
* Some bits stolen from the .99.7 source tree.
|
2000-04-05 11:02:00 +08:00
|
|
|
* Updated to fix various outstanding problems, brief help -- Nick Lamb
|
|
|
|
* njl195@zepler.org.uk, April 2000
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
|
|
|
|
1999-05-29 09:28:24 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2003-06-13 22:37:00 +08:00
|
|
|
#include <errno.h>
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <setjmp.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
1999-05-29 09:28:24 +08:00
|
|
|
#ifdef HAVE_UNISTD_H
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <unistd.h>
|
1999-05-29 09:28:24 +08:00
|
|
|
#endif
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2000-01-26 01:46:56 +08:00
|
|
|
|
1999-05-29 09:28:24 +08:00
|
|
|
#include <libgimp/gimp.h>
|
1999-10-10 03:06:14 +08:00
|
|
|
#include <libgimp/gimpui.h>
|
2000-01-26 01:46:56 +08:00
|
|
|
|
2000-01-01 15:35:13 +08:00
|
|
|
#include "libgimp/stdplugins-intl.h"
|
1999-05-29 09:28:24 +08:00
|
|
|
|
2000-05-02 01:01:18 +08:00
|
|
|
|
1999-10-05 03:26:07 +08:00
|
|
|
#ifdef G_OS_WIN32
|
1999-05-29 09:28:24 +08:00
|
|
|
#include <io.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _O_BINARY
|
|
|
|
#define _O_BINARY 0
|
|
|
|
#endif
|
|
|
|
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "app/core/gimppattern-header.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
2000-12-19 09:58:39 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
|
|
|
static void query (void);
|
|
|
|
static void run (gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals);
|
|
|
|
static gint32 load_image (gchar *filename);
|
|
|
|
static gboolean save_image (gchar *filename,
|
|
|
|
gint32 image_ID,
|
|
|
|
gint32 drawable_ID);
|
|
|
|
|
|
|
|
static gboolean save_dialog (void);
|
|
|
|
static void ok_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void entry_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
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-01-26 01:46:56 +08:00
|
|
|
NULL, /* init_proc */
|
|
|
|
NULL, /* quit_proc */
|
|
|
|
query, /* query_proc */
|
|
|
|
run, /* run_proc */
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
2000-12-19 09:58:39 +08:00
|
|
|
/* private variables */
|
|
|
|
|
|
|
|
static gchar description[256] = "GIMP Pattern";
|
|
|
|
static gboolean run_flag = FALSE;
|
|
|
|
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
MAIN ()
|
|
|
|
|
|
|
|
static void
|
2000-01-08 23:23:28 +08:00
|
|
|
query (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
static GimpParamDef load_args[] =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-12-19 09:58:39 +08:00
|
|
|
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
|
2000-08-22 09:26:57 +08:00
|
|
|
{ GIMP_PDB_STRING, "filename", "The name of the file to load" },
|
|
|
|
{ GIMP_PDB_STRING, "raw_filename", "The name of the file to load" }
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
2000-08-22 09:26:57 +08:00
|
|
|
static GimpParamDef load_return_vals[] =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
{ GIMP_PDB_IMAGE, "image", "Output image" }
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
static GimpParamDef save_args[] =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-12-19 09:58:39 +08:00
|
|
|
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
|
|
|
|
{ GIMP_PDB_IMAGE, "image", "Input image" },
|
2000-08-22 09:26:57 +08:00
|
|
|
{ GIMP_PDB_DRAWABLE, "drawable", "Drawable to save" },
|
2000-12-19 09:58:39 +08:00
|
|
|
{ GIMP_PDB_STRING, "filename", "The name of the file to save the image in" },
|
|
|
|
{ GIMP_PDB_STRING, "raw_filename", "The name of the file to save the image in" },
|
|
|
|
{ GIMP_PDB_STRING, "description", "Short description of the pattern" },
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
gimp_install_procedure ("file_pat_load",
|
2000-04-05 11:02:00 +08:00
|
|
|
"Loads Gimp's .PAT pattern files",
|
2000-12-19 09:58:39 +08:00
|
|
|
"The images in the pattern dialog can be loaded "
|
|
|
|
"directly with this plug-in",
|
1997-11-25 06:05:25 +08:00
|
|
|
"Tim Newsome",
|
|
|
|
"Tim Newsome",
|
|
|
|
"1997",
|
|
|
|
"<Load>/PAT",
|
|
|
|
NULL,
|
2000-08-22 09:26:57 +08:00
|
|
|
GIMP_PLUGIN,
|
2001-12-06 10:28:58 +08:00
|
|
|
G_N_ELEMENTS (load_args),
|
|
|
|
G_N_ELEMENTS (load_return_vals),
|
1997-11-25 06:05:25 +08:00
|
|
|
load_args, load_return_vals);
|
|
|
|
|
|
|
|
gimp_install_procedure ("file_pat_save",
|
2000-04-05 11:02:00 +08:00
|
|
|
"Saves Gimp pattern file (.PAT)",
|
2000-12-19 09:58:39 +08:00
|
|
|
"New Gimp patterns can be created by saving them "
|
|
|
|
"in the appropriate place with this plug-in.",
|
1997-11-25 06:05:25 +08:00
|
|
|
"Tim Newsome",
|
|
|
|
"Tim Newsome",
|
|
|
|
"1997",
|
|
|
|
"<Save>/PAT",
|
2003-06-28 20:36:52 +08:00
|
|
|
"RGB*, GRAY*",
|
2000-08-22 09:26:57 +08:00
|
|
|
GIMP_PLUGIN,
|
2001-12-06 10:28:58 +08:00
|
|
|
G_N_ELEMENTS (save_args), 0,
|
1997-11-25 06:05:25 +08:00
|
|
|
save_args, NULL);
|
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
gimp_register_magic_load_handler ("file_pat_load",
|
|
|
|
"pat",
|
|
|
|
"",
|
|
|
|
"20,string,GPAT");
|
|
|
|
gimp_register_save_handler ("file_pat_save",
|
|
|
|
"pat",
|
|
|
|
"");
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-12-19 09:58:39 +08:00
|
|
|
run (gchar *name,
|
|
|
|
gint nparams,
|
2000-08-22 09:26:57 +08:00
|
|
|
GimpParam *param,
|
2000-12-19 09:58:39 +08:00
|
|
|
gint *nreturn_vals,
|
2000-08-22 09:26:57 +08:00
|
|
|
GimpParam **return_vals)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-12-19 09:58:39 +08:00
|
|
|
static GimpParam values[2];
|
2001-12-31 08:21:10 +08:00
|
|
|
GimpRunMode run_mode;
|
2000-12-19 09:58:39 +08:00
|
|
|
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
|
|
|
gint32 image_ID;
|
|
|
|
gint32 drawable_ID;
|
2000-08-24 22:17:34 +08:00
|
|
|
GimpExportReturnType export = GIMP_EXPORT_CANCEL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
run_mode = param[0].data.d_int32;
|
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
*nreturn_vals = 1;
|
|
|
|
*return_vals = values;
|
2003-06-13 22:37:00 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
values[0].type = GIMP_PDB_STATUS;
|
|
|
|
values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
INIT_I18N ();
|
|
|
|
|
1999-10-10 03:06:14 +08:00
|
|
|
if (strcmp (name, "file_pat_load") == 0)
|
|
|
|
{
|
|
|
|
image_ID = load_image (param[1].data.d_string);
|
2000-01-26 01:46:56 +08:00
|
|
|
|
1999-10-10 03:06:14 +08:00
|
|
|
if (image_ID != -1)
|
|
|
|
{
|
2000-01-26 01:46:56 +08:00
|
|
|
*nreturn_vals = 2;
|
2000-08-22 09:26:57 +08:00
|
|
|
values[1].type = GIMP_PDB_IMAGE;
|
1999-10-10 03:06:14 +08:00
|
|
|
values[1].data.d_image = image_ID;
|
2000-12-19 09:58:39 +08:00
|
|
|
}
|
2000-01-26 01:46:56 +08:00
|
|
|
else
|
1999-10-10 03:06:14 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
status = GIMP_PDB_EXECUTION_ERROR;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1999-10-10 03:06:14 +08:00
|
|
|
}
|
|
|
|
else if (strcmp (name, "file_pat_save") == 0)
|
|
|
|
{
|
|
|
|
image_ID = param[1].data.d_int32;
|
|
|
|
drawable_ID = param[2].data.d_int32;
|
|
|
|
|
|
|
|
/* eventually export the image */
|
|
|
|
switch (run_mode)
|
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_INTERACTIVE:
|
|
|
|
case GIMP_RUN_WITH_LAST_VALS:
|
2000-05-02 01:01:18 +08:00
|
|
|
gimp_ui_init ("pat", FALSE);
|
1999-10-10 03:06:14 +08:00
|
|
|
export = gimp_export_image (&image_ID, &drawable_ID, "PAT",
|
2003-06-13 22:37:00 +08:00
|
|
|
GIMP_EXPORT_CAN_HANDLE_GRAY |
|
2003-06-28 20:36:52 +08:00
|
|
|
GIMP_EXPORT_CAN_HANDLE_RGB |
|
|
|
|
GIMP_EXPORT_CAN_HANDLE_ALPHA);
|
2000-08-24 22:17:34 +08:00
|
|
|
if (export == GIMP_EXPORT_CANCEL)
|
1999-10-10 03:06:14 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
values[0].data.d_status = GIMP_PDB_CANCEL;
|
1999-10-10 03:06:14 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1999-10-10 03:06:14 +08:00
|
|
|
switch (run_mode)
|
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_INTERACTIVE:
|
1999-10-10 03:06:14 +08:00
|
|
|
/* Possibly retrieve data */
|
2000-01-26 01:46:56 +08:00
|
|
|
gimp_get_data ("file_pat_save", description);
|
|
|
|
if (!save_dialog ())
|
2000-08-22 09:26:57 +08:00
|
|
|
status = GIMP_PDB_CANCEL;
|
1999-10-10 03:06:14 +08:00
|
|
|
break;
|
2000-01-26 01:46:56 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_NONINTERACTIVE:
|
1999-10-10 03:06:14 +08:00
|
|
|
if (nparams != 6)
|
2000-01-26 01:46:56 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
2000-01-26 01:46:56 +08:00
|
|
|
}
|
1999-10-10 03:06:14 +08:00
|
|
|
else
|
2000-01-26 01:46:56 +08:00
|
|
|
{
|
|
|
|
strcpy (description, param[5].data.d_string);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_WITH_LAST_VALS:
|
1999-10-10 03:06:14 +08:00
|
|
|
gimp_get_data ("file_pat_save", description);
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2000-01-26 01:46:56 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
if (status == GIMP_PDB_SUCCESS)
|
1999-10-10 03:06:14 +08:00
|
|
|
{
|
2000-01-26 01:46:56 +08:00
|
|
|
if (save_image (param[3].data.d_string, image_ID, drawable_ID))
|
|
|
|
{
|
|
|
|
gimp_set_data ("file_pat_save", description, 256);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
status = GIMP_PDB_EXECUTION_ERROR;
|
2000-01-26 01:46:56 +08:00
|
|
|
}
|
|
|
|
}
|
1999-10-10 03:06:14 +08:00
|
|
|
|
2000-08-24 22:17:34 +08:00
|
|
|
if (export == GIMP_EXPORT_EXPORT)
|
1999-10-10 03:06:14 +08:00
|
|
|
gimp_image_delete (image_ID);
|
|
|
|
}
|
2000-01-26 01:46:56 +08:00
|
|
|
else
|
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
2000-01-26 01:46:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
values[0].data.d_status = status;
|
1999-10-10 03:06:14 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-10-10 03:06:14 +08:00
|
|
|
static gint32
|
2000-01-08 23:23:28 +08:00
|
|
|
load_image (gchar *filename)
|
1999-10-10 03:06:14 +08:00
|
|
|
{
|
2000-12-19 09:58:39 +08:00
|
|
|
gchar *temp;
|
|
|
|
gint fd;
|
|
|
|
PatternHeader ph;
|
|
|
|
guchar *buffer;
|
|
|
|
gint32 image_ID;
|
|
|
|
gint32 layer_ID;
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
gint line;
|
|
|
|
GimpPixelRgn pixel_rgn;
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
GimpImageBaseType base_type;
|
|
|
|
GimpImageType image_type;
|
1999-10-10 03:06:14 +08:00
|
|
|
|
|
|
|
fd = open (filename, O_RDONLY | _O_BINARY);
|
|
|
|
|
|
|
|
if (fd == -1)
|
2003-06-13 22:37:00 +08:00
|
|
|
{
|
|
|
|
g_message (_("Can't open '%s':\n%s"), filename, g_strerror (errno));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
temp = g_strdup_printf (_("Opening '%s'..."), filename);
|
|
|
|
gimp_progress_init (temp);
|
|
|
|
g_free (temp);
|
1999-10-10 03:06:14 +08:00
|
|
|
|
2000-12-19 09:58:39 +08:00
|
|
|
if (read (fd, &ph, sizeof (PatternHeader)) != sizeof (PatternHeader))
|
1999-10-10 03:06:14 +08:00
|
|
|
{
|
2000-12-19 09:58:39 +08:00
|
|
|
close (fd);
|
1999-10-10 03:06:14 +08:00
|
|
|
return -1;
|
|
|
|
}
|
2000-12-19 09:58:39 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* rearrange the bytes in each unsigned int */
|
1999-10-10 03:06:14 +08:00
|
|
|
ph.header_size = g_ntohl (ph.header_size);
|
|
|
|
ph.version = g_ntohl (ph.version);
|
|
|
|
ph.width = g_ntohl (ph.width);
|
|
|
|
ph.height = g_ntohl (ph.height);
|
|
|
|
ph.bytes = g_ntohl (ph.bytes);
|
|
|
|
ph.magic_number = g_ntohl (ph.magic_number);
|
|
|
|
|
2000-12-19 09:58:39 +08:00
|
|
|
if (ph.magic_number != GPATTERN_MAGIC ||
|
|
|
|
ph.version != 1 ||
|
|
|
|
ph.header_size <= sizeof (PatternHeader))
|
1999-10-10 03:06:14 +08:00
|
|
|
{
|
2000-12-19 09:58:39 +08:00
|
|
|
close (fd);
|
1999-10-10 03:06:14 +08:00
|
|
|
return -1;
|
|
|
|
}
|
2000-12-19 09:58:39 +08:00
|
|
|
|
|
|
|
if (lseek (fd, ph.header_size - sizeof (PatternHeader), SEEK_CUR) != ph.header_size)
|
1999-10-10 03:06:14 +08:00
|
|
|
{
|
2000-12-19 09:58:39 +08:00
|
|
|
close (fd);
|
1999-10-10 03:06:14 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now there's just raw data left. */
|
2003-06-13 22:37:00 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/*
|
1999-10-10 03:06:14 +08:00
|
|
|
* Create a new image of the proper size and associate the filename with it.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
|
|
|
|
switch (ph.bytes)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
base_type = GIMP_GRAY;
|
|
|
|
image_type = GIMP_GRAY_IMAGE;
|
|
|
|
break;
|
2000-12-19 09:58:39 +08:00
|
|
|
case 2:
|
|
|
|
base_type = GIMP_GRAY;
|
|
|
|
image_type = GIMP_GRAYA_IMAGE;
|
|
|
|
break;
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
case 3:
|
|
|
|
base_type = GIMP_RGB;
|
|
|
|
image_type = GIMP_RGB_IMAGE;
|
|
|
|
break;
|
2000-12-19 09:58:39 +08:00
|
|
|
case 4:
|
|
|
|
base_type = GIMP_RGB;
|
|
|
|
image_type = GIMP_RGBA_IMAGE;
|
|
|
|
break;
|
|
|
|
default:
|
2003-06-13 22:37:00 +08:00
|
|
|
g_message ("Unsupported pattern depth: %d\n"
|
|
|
|
"GIMP Patterns must be GRAY or RGB", ph.bytes);
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
image_ID = gimp_image_new (ph.width, ph.height, base_type);
|
2000-12-19 09:58:39 +08:00
|
|
|
gimp_image_set_filename (image_ID, filename);
|
|
|
|
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
layer_ID = gimp_layer_new (image_ID, _("Background"), ph.width, ph.height,
|
|
|
|
image_type, 100, GIMP_NORMAL_MODE);
|
|
|
|
gimp_image_add_layer (image_ID, layer_ID, 0);
|
2000-12-19 09:58:39 +08:00
|
|
|
|
|
|
|
drawable = gimp_drawable_get (layer_ID);
|
|
|
|
gimp_pixel_rgn_init (&pixel_rgn, drawable, 0, 0,
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
drawable->width, drawable->height,
|
1999-10-10 03:06:14 +08:00
|
|
|
TRUE, FALSE);
|
2000-12-19 09:58:39 +08:00
|
|
|
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
buffer = g_malloc (ph.width * ph.bytes);
|
2000-12-19 09:58:39 +08:00
|
|
|
|
1999-10-10 03:06:14 +08:00
|
|
|
for (line = 0; line < ph.height; line++)
|
|
|
|
{
|
2000-12-19 09:58:39 +08:00
|
|
|
if (read (fd, buffer, ph.width * ph.bytes) != ph.width * ph.bytes)
|
|
|
|
{
|
|
|
|
close (fd);
|
|
|
|
g_free (buffer);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
1999-10-10 03:06:14 +08:00
|
|
|
gimp_pixel_rgn_set_row (&pixel_rgn, buffer, 0, line, ph.width);
|
2000-12-19 09:58:39 +08:00
|
|
|
|
|
|
|
gimp_progress_update ((gdouble) line / (gdouble) ph.height);
|
1999-10-10 03:06:14 +08:00
|
|
|
}
|
2000-12-19 09:58:39 +08:00
|
|
|
|
1999-10-10 03:06:14 +08:00
|
|
|
gimp_drawable_flush (drawable);
|
2000-12-19 09:58:39 +08:00
|
|
|
|
1999-10-10 03:06:14 +08:00
|
|
|
return image_ID;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-12-19 09:58:39 +08:00
|
|
|
static gboolean
|
2000-01-08 23:23:28 +08:00
|
|
|
save_image (gchar *filename,
|
1999-10-10 03:06:14 +08:00
|
|
|
gint32 image_ID,
|
|
|
|
gint32 drawable_ID)
|
|
|
|
{
|
2000-12-19 09:58:39 +08:00
|
|
|
gint fd;
|
1999-10-10 03:06:14 +08:00
|
|
|
PatternHeader ph;
|
2000-12-19 09:58:39 +08:00
|
|
|
guchar *buffer;
|
2000-08-22 09:26:57 +08:00
|
|
|
GimpDrawable *drawable;
|
2000-12-19 09:58:39 +08:00
|
|
|
gint line;
|
|
|
|
GimpPixelRgn pixel_rgn;
|
|
|
|
gchar *temp;
|
|
|
|
|
2003-06-13 22:37:00 +08:00
|
|
|
fd = open (filename, O_CREAT | O_TRUNC | O_WRONLY | _O_BINARY, 0644);
|
|
|
|
|
|
|
|
if (fd == -1)
|
|
|
|
{
|
|
|
|
g_message (_("Can't open '%s' for writing:\n%s"),
|
|
|
|
filename, g_strerror (errno));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
temp = g_strdup_printf (_("Saving '%s'..."), filename);
|
1999-10-10 03:06:14 +08:00
|
|
|
gimp_progress_init (temp);
|
|
|
|
g_free (temp);
|
2000-12-19 09:58:39 +08:00
|
|
|
|
1999-10-10 03:06:14 +08:00
|
|
|
drawable = gimp_drawable_get (drawable_ID);
|
|
|
|
gimp_pixel_rgn_init (&pixel_rgn, drawable, 0, 0, drawable->width,
|
|
|
|
drawable->height, FALSE, FALSE);
|
2000-12-19 09:58:39 +08:00
|
|
|
|
|
|
|
ph.header_size = g_htonl (sizeof (PatternHeader) + strlen (description) + 1);
|
1999-10-10 03:06:14 +08:00
|
|
|
ph.version = g_htonl (1);
|
|
|
|
ph.width = g_htonl (drawable->width);
|
|
|
|
ph.height = g_htonl (drawable->height);
|
|
|
|
ph.bytes = g_htonl (drawable->bpp);
|
|
|
|
ph.magic_number = g_htonl (GPATTERN_MAGIC);
|
|
|
|
|
2000-12-19 09:58:39 +08:00
|
|
|
if (write (fd, &ph, sizeof (PatternHeader)) != sizeof (PatternHeader))
|
1999-10-10 03:06:14 +08:00
|
|
|
{
|
2000-12-19 09:58:39 +08:00
|
|
|
close (fd);
|
|
|
|
return FALSE;
|
1999-10-10 03:06:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (write (fd, description, strlen (description) + 1) != strlen (description) + 1)
|
|
|
|
{
|
2000-12-19 09:58:39 +08:00
|
|
|
close (fd);
|
|
|
|
return FALSE;
|
1999-10-10 03:06:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
buffer = g_malloc (drawable->width * drawable->bpp);
|
|
|
|
if (buffer == NULL)
|
|
|
|
{
|
2000-12-19 09:58:39 +08:00
|
|
|
close (fd);
|
|
|
|
return FALSE;
|
1999-10-10 03:06:14 +08:00
|
|
|
}
|
2000-12-19 09:58:39 +08:00
|
|
|
|
1999-10-10 03:06:14 +08:00
|
|
|
for (line = 0; line < drawable->height; line++)
|
|
|
|
{
|
|
|
|
gimp_pixel_rgn_get_row (&pixel_rgn, buffer, 0, line, drawable->width);
|
2000-12-19 09:58:39 +08:00
|
|
|
|
1999-10-10 03:06:14 +08:00
|
|
|
if (write (fd, buffer, drawable->width * drawable->bpp) !=
|
|
|
|
drawable->width * drawable->bpp)
|
|
|
|
{
|
2000-12-19 09:58:39 +08:00
|
|
|
close (fd);
|
|
|
|
return FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2000-12-19 09:58:39 +08:00
|
|
|
|
|
|
|
gimp_progress_update ((gdouble) line / (gdouble) drawable->height);
|
1999-10-10 03:06:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
g_free (buffer);
|
|
|
|
close (fd);
|
2000-12-19 09:58:39 +08:00
|
|
|
|
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-12-19 09:58:39 +08:00
|
|
|
static gboolean
|
2000-01-08 23:23:28 +08:00
|
|
|
save_dialog (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-10-10 03:06:14 +08:00
|
|
|
GtkWidget *dlg;
|
|
|
|
GtkWidget *table;
|
2000-01-26 01:46:56 +08:00
|
|
|
GtkWidget *entry;
|
1999-10-10 03:06:14 +08:00
|
|
|
|
2000-01-08 23:23:28 +08:00
|
|
|
dlg = gimp_dialog_new (_("Save as Pattern"), "pat",
|
2000-05-23 01:10:28 +08:00
|
|
|
gimp_standard_help_func, "filters/pat.html",
|
2000-01-08 23:23:28 +08:00
|
|
|
GTK_WIN_POS_MOUSE,
|
|
|
|
FALSE, TRUE, FALSE,
|
|
|
|
|
2001-08-04 03:52:08 +08:00
|
|
|
GTK_STOCK_CANCEL, gtk_widget_destroy,
|
2000-01-08 23:23:28 +08:00
|
|
|
NULL, 1, NULL, FALSE, TRUE,
|
2001-11-29 21:23:44 +08:00
|
|
|
GTK_STOCK_OK, ok_callback,
|
|
|
|
NULL, NULL, NULL, TRUE, FALSE,
|
2000-01-08 23:23:28 +08:00
|
|
|
|
|
|
|
NULL);
|
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (dlg, "destroy",
|
2001-12-31 08:21:10 +08:00
|
|
|
G_CALLBACK (gtk_main_quit),
|
|
|
|
NULL);
|
1999-11-27 04:58:27 +08:00
|
|
|
|
1999-10-10 03:06:14 +08:00
|
|
|
/* The main table */
|
2000-01-08 23:23:28 +08:00
|
|
|
table = gtk_table_new (1, 2, FALSE);
|
2000-01-26 01:46:56 +08:00
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
2000-08-28 08:42:32 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (table), 6);
|
2000-01-08 23:23:28 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), table, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (table);
|
2000-12-19 09:58:39 +08:00
|
|
|
|
2000-01-08 23:23:28 +08:00
|
|
|
entry = gtk_entry_new ();
|
2001-11-12 02:35:25 +08:00
|
|
|
gtk_widget_set_size_request (entry, 200, -1);
|
2000-01-08 23:23:28 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry), description);
|
2000-01-31 11:13:02 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
2000-01-26 01:46:56 +08:00
|
|
|
_("Description:"), 1.0, 0.5,
|
2000-01-31 11:13:02 +08:00
|
|
|
entry, 1, FALSE);
|
2000-01-08 23:23:28 +08:00
|
|
|
gtk_widget_show (entry);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (entry, "changed",
|
2001-12-31 08:21:10 +08:00
|
|
|
G_CALLBACK (entry_callback),
|
|
|
|
description);
|
|
|
|
|
2000-01-08 23:23:28 +08:00
|
|
|
gtk_widget_show (dlg);
|
|
|
|
|
|
|
|
gtk_main ();
|
|
|
|
gdk_flush ();
|
|
|
|
|
|
|
|
return run_flag;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1999-10-10 03:06:14 +08:00
|
|
|
static void
|
|
|
|
ok_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-01-08 23:23:28 +08:00
|
|
|
run_flag = TRUE;
|
|
|
|
|
|
|
|
gtk_widget_destroy (GTK_WIDGET (data));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1999-10-10 03:06:14 +08:00
|
|
|
static void
|
|
|
|
entry_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-10-10 03:06:14 +08:00
|
|
|
if (data == description)
|
2000-01-08 23:23:28 +08:00
|
|
|
strncpy (description, gtk_entry_get_text (GTK_ENTRY (widget)), 256);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|