2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2005-06-01 03:10:46 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2005-06-01 03:10:46 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2005-06-01 03:10:46 +08:00
|
|
|
* (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
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2005-06-01 03:10:46 +08:00
|
|
|
*/
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/*
|
|
|
|
* gbr plug-in version 1.00
|
2016-02-16 09:35:43 +08:00
|
|
|
* Loads/exports version 2 GIMP .gbr files, by Tim Newsome <drz@frody.bloke.com>
|
1997-11-25 06:05:25 +08:00
|
|
|
* Some bits stolen from the .99.7 source tree.
|
2003-09-04 00:59:22 +08:00
|
|
|
*
|
|
|
|
* Added in GBR version 1 support after learning that there wasn't a
|
|
|
|
* tool to read them.
|
1998-07-07 06:19:56 +08:00
|
|
|
* July 6, 1998 by Seth Burgess <sjburges@gimp.org>
|
|
|
|
*
|
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
|
|
|
* Dec 17, 2000
|
|
|
|
* Load and save GIMP brushes in GRAY or RGBA. jtl + neo
|
2003-09-04 00:59:22 +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
|
|
|
*
|
1998-07-07 06:19:56 +08:00
|
|
|
* TODO: Give some better error reporting on not opening files/bad headers
|
2003-09-04 00:59:22 +08:00
|
|
|
* etc.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
|
|
|
|
1999-05-29 09:28:24 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
#include <libgimp/gimp.h>
|
|
|
|
#include <libgimp/gimpui.h>
|
2000-01-07 06:26:10 +08:00
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
#include "libgimp/stdplugins-intl.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-14 06:52:41 +08:00
|
|
|
#define SAVE_PROC "file-gbr-save"
|
2008-08-11 18:06:13 +08:00
|
|
|
#define PLUG_IN_BINARY "file-gbr"
|
2011-04-09 02:31:34 +08:00
|
|
|
#define PLUG_IN_ROLE "gimp-file-gbr"
|
2005-08-14 06:52:41 +08:00
|
|
|
|
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
gchar description[256];
|
|
|
|
gint spacing;
|
2004-01-22 22:04:45 +08:00
|
|
|
} BrushInfo;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
2004-01-22 22:04:45 +08:00
|
|
|
/* local function prototypes */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-01-22 22:04:45 +08:00
|
|
|
static void query (void);
|
|
|
|
static void run (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals);
|
1999-10-09 04:09:04 +08:00
|
|
|
|
2004-01-22 22:04:45 +08:00
|
|
|
static gboolean save_dialog (void);
|
|
|
|
static void entry_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
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
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-05-16 20:26:20 +08:00
|
|
|
const 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
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-01-22 22:04:45 +08:00
|
|
|
/* private variables */
|
|
|
|
|
2008-03-29 10:30:58 +08:00
|
|
|
static BrushInfo info =
|
2004-01-22 22:04:45 +08:00
|
|
|
{
|
|
|
|
"GIMP Brush",
|
|
|
|
10
|
|
|
|
};
|
|
|
|
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
MAIN ()
|
|
|
|
|
|
|
|
static void
|
2000-01-26 01:46:56 +08:00
|
|
|
query (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-05-16 20:26:20 +08:00
|
|
|
static const GimpParamDef save_args[] =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2012-11-19 05:56:29 +08:00
|
|
|
{ GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" },
|
|
|
|
{ GIMP_PDB_IMAGE, "image", "Input image" },
|
2016-02-16 09:35:43 +08:00
|
|
|
{ GIMP_PDB_DRAWABLE, "drawable", "Drawable to export" },
|
|
|
|
{ GIMP_PDB_STRING, "uri", "The URI of the file to export the image in" },
|
|
|
|
{ GIMP_PDB_STRING, "raw-uri", "The URI of the file to export the image in" },
|
2012-11-19 05:56:29 +08:00
|
|
|
{ GIMP_PDB_INT32, "spacing", "Spacing of the brush" },
|
|
|
|
{ GIMP_PDB_STRING, "description", "Short description of the brush" }
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
2005-08-14 06:52:41 +08:00
|
|
|
gimp_install_procedure (SAVE_PROC,
|
2016-02-16 09:35:43 +08:00
|
|
|
"Exports files in the GIMP brush file format",
|
|
|
|
"Exports files in the GIMP brush file format",
|
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
|
|
|
"Tim Newsome, Jens Lautenbacher, Sven Neumann",
|
|
|
|
"Tim Newsome, Jens Lautenbacher, Sven Neumann",
|
|
|
|
"1997-2000",
|
2004-05-14 08:42:38 +08:00
|
|
|
N_("GIMP brush"),
|
2012-11-28 03:58:05 +08:00
|
|
|
"RGB*, GRAY*, INDEXED*",
|
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);
|
|
|
|
|
2014-05-12 05:56:30 +08:00
|
|
|
gimp_plugin_icon_register (SAVE_PROC, GIMP_ICON_TYPE_ICON_NAME,
|
2017-03-05 23:01:59 +08:00
|
|
|
(const guint8 *) GIMP_ICON_BRUSH);
|
2005-08-14 06:52:41 +08:00
|
|
|
gimp_register_file_handler_mime (SAVE_PROC, "image/x-gimp-gbr");
|
2012-11-19 05:56:29 +08:00
|
|
|
gimp_register_file_handler_uri (SAVE_PROC);
|
2005-08-14 06:52:41 +08:00
|
|
|
gimp_register_save_handler (SAVE_PROC, "gbr", "");
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-07-02 19:07:41 +08:00
|
|
|
run (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2008-08-19 03:35:55 +08:00
|
|
|
static GimpParam values[2];
|
|
|
|
GimpRunMode run_mode;
|
|
|
|
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
|
|
|
gint32 image_ID;
|
|
|
|
gint32 drawable_ID;
|
|
|
|
GimpExportReturn export = GIMP_EXPORT_CANCEL;
|
|
|
|
GError *error = NULL;
|
2000-01-26 01:46:56 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
INIT_I18N ();
|
2012-09-14 04:36:31 +08:00
|
|
|
|
2012-11-19 06:20:36 +08:00
|
|
|
run_mode = param[0].data.d_int32;
|
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
*nreturn_vals = 1;
|
2001-12-29 21:26:29 +08:00
|
|
|
*return_vals = values;
|
|
|
|
|
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
|
|
|
|
2019-02-11 19:45:06 +08:00
|
|
|
if (strcmp (name, SAVE_PROC) == 0)
|
1999-10-09 04:09:04 +08:00
|
|
|
{
|
2014-11-05 09:34:45 +08:00
|
|
|
GFile *file;
|
2004-01-22 22:04:45 +08:00
|
|
|
GimpParasite *parasite;
|
|
|
|
gint32 orig_image_ID;
|
|
|
|
|
1999-10-09 04:09:04 +08:00
|
|
|
image_ID = param[1].data.d_int32;
|
|
|
|
drawable_ID = param[2].data.d_int32;
|
2014-11-05 09:34:45 +08:00
|
|
|
file = g_file_new_for_uri (param[3].data.d_string);
|
1999-10-09 04:09:04 +08:00
|
|
|
|
2004-01-22 22:04:45 +08:00
|
|
|
orig_image_ID = image_ID;
|
|
|
|
|
1999-10-09 04:09:04 +08:00
|
|
|
switch (run_mode)
|
2008-10-20 14:04:39 +08:00
|
|
|
{
|
|
|
|
case GIMP_RUN_INTERACTIVE:
|
|
|
|
case GIMP_RUN_WITH_LAST_VALS:
|
|
|
|
gimp_ui_init (PLUG_IN_BINARY, FALSE);
|
2013-11-10 07:18:48 +08:00
|
|
|
|
|
|
|
export = gimp_export_image (&image_ID, &drawable_ID, "GBR",
|
2012-11-28 03:58:05 +08:00
|
|
|
GIMP_EXPORT_CAN_HANDLE_GRAY |
|
|
|
|
GIMP_EXPORT_CAN_HANDLE_RGB |
|
|
|
|
GIMP_EXPORT_CAN_HANDLE_INDEXED |
|
2008-10-20 14:04:39 +08:00
|
|
|
GIMP_EXPORT_CAN_HANDLE_ALPHA);
|
2013-11-10 07:18:48 +08:00
|
|
|
|
2008-10-20 14:04:39 +08:00
|
|
|
if (export == GIMP_EXPORT_CANCEL)
|
|
|
|
{
|
|
|
|
values[0].data.d_status = GIMP_PDB_CANCEL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Possibly retrieve data */
|
|
|
|
gimp_get_data (SAVE_PROC, &info);
|
|
|
|
|
2014-11-05 09:34:45 +08:00
|
|
|
parasite = gimp_image_get_parasite (orig_image_ID,
|
|
|
|
"gimp-brush-name");
|
|
|
|
if (parasite)
|
|
|
|
{
|
|
|
|
strncpy (info.description,
|
|
|
|
gimp_parasite_data (parasite),
|
|
|
|
MIN (sizeof (info.description),
|
|
|
|
gimp_parasite_data_size (parasite)));
|
|
|
|
info.description[sizeof (info.description) - 1] = '\0';
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2014-11-05 09:34:45 +08:00
|
|
|
gimp_parasite_free (parasite);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gchar *name = g_path_get_basename (gimp_file_get_utf8_name (file));
|
2004-01-22 22:04:45 +08:00
|
|
|
|
2014-11-05 09:34:45 +08:00
|
|
|
if (g_str_has_suffix (name, ".gbr"))
|
|
|
|
name[strlen (name) - 4] = '\0';
|
2010-06-23 03:10:28 +08:00
|
|
|
|
2014-11-05 09:34:45 +08:00
|
|
|
if (strlen (name))
|
|
|
|
{
|
|
|
|
strncpy (info.description, name, sizeof (info.description));
|
|
|
|
info.description[sizeof (info.description) - 1] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (name);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2004-01-22 22:04:45 +08:00
|
|
|
}
|
|
|
|
|
2003-09-04 00:59:22 +08:00
|
|
|
switch (run_mode)
|
2008-10-20 14:04:39 +08:00
|
|
|
{
|
|
|
|
case GIMP_RUN_INTERACTIVE:
|
|
|
|
if (! save_dialog ())
|
|
|
|
status = GIMP_PDB_CANCEL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_RUN_NONINTERACTIVE:
|
|
|
|
if (nparams != 7)
|
|
|
|
{
|
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
info.spacing = (param[5].data.d_int32);
|
|
|
|
strncpy (info.description, param[6].data.d_string,
|
2004-01-22 22:04:45 +08:00
|
|
|
sizeof (info.description));
|
|
|
|
info.description[sizeof (info.description) - 1] = '\0';
|
2008-10-20 14:04:39 +08:00
|
|
|
}
|
|
|
|
break;
|
2000-01-26 01:46:56 +08:00
|
|
|
|
2008-10-20 14:04:39 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2000-01-26 01:46:56 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
if (status == GIMP_PDB_SUCCESS)
|
2008-10-20 14:04:39 +08:00
|
|
|
{
|
2019-02-17 02:00:04 +08:00
|
|
|
GimpParam *save_retvals;
|
|
|
|
gint n_save_retvals;
|
|
|
|
|
|
|
|
save_retvals =
|
|
|
|
gimp_run_procedure ("file-gbr-save-internal",
|
|
|
|
&n_save_retvals,
|
|
|
|
GIMP_PDB_INT32, GIMP_RUN_NONINTERACTIVE,
|
|
|
|
GIMP_PDB_IMAGE, image_ID,
|
|
|
|
GIMP_PDB_DRAWABLE, drawable_ID,
|
|
|
|
GIMP_PDB_STRING, param[3].data.d_string,
|
|
|
|
GIMP_PDB_STRING, param[4].data.d_string,
|
|
|
|
GIMP_PDB_INT32, info.spacing,
|
|
|
|
GIMP_PDB_STRING, info.description,
|
|
|
|
GIMP_PDB_END);
|
|
|
|
|
|
|
|
if (save_retvals[0].data.d_status == GIMP_PDB_SUCCESS)
|
2008-10-20 14:04:39 +08:00
|
|
|
{
|
|
|
|
gimp_set_data (SAVE_PROC, &info, sizeof (info));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-02-17 02:00:04 +08:00
|
|
|
g_set_error (&error, 0, 0,
|
|
|
|
"Running procedure 'file-gbr-save-internal' "
|
|
|
|
"failed: %s",
|
|
|
|
gimp_get_pdb_error ());
|
|
|
|
|
2008-10-20 14:04:39 +08:00
|
|
|
status = GIMP_PDB_EXECUTION_ERROR;
|
|
|
|
}
|
2019-02-17 02:00:04 +08:00
|
|
|
|
|
|
|
gimp_destroy_params (save_retvals, n_save_retvals);
|
2008-10-20 14:04:39 +08:00
|
|
|
}
|
1999-10-09 04:09:04 +08:00
|
|
|
|
2000-08-24 22:17:34 +08:00
|
|
|
if (export == GIMP_EXPORT_EXPORT)
|
2008-10-20 14:04:39 +08:00
|
|
|
gimp_image_delete (image_ID);
|
2004-01-22 22:04:45 +08:00
|
|
|
|
2014-11-05 09:34:45 +08:00
|
|
|
if (strlen (info.description))
|
2004-01-22 22:04:45 +08:00
|
|
|
{
|
2010-07-09 20:15:55 +08:00
|
|
|
GimpParasite *parasite;
|
|
|
|
|
|
|
|
parasite = gimp_parasite_new ("gimp-brush-name",
|
|
|
|
GIMP_PARASITE_PERSISTENT,
|
|
|
|
strlen (info.description) + 1,
|
|
|
|
info.description);
|
2011-03-08 20:19:21 +08:00
|
|
|
gimp_image_attach_parasite (orig_image_ID, parasite);
|
2010-07-09 20:15:55 +08:00
|
|
|
gimp_parasite_free (parasite);
|
2004-01-22 22:04:45 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-03-08 20:19:21 +08:00
|
|
|
gimp_image_detach_parasite (orig_image_ID, "gimp-brush-name");
|
2004-01-22 22:04:45 +08:00
|
|
|
}
|
1999-10-09 04:09:04 +08:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2008-08-19 03:35:55 +08:00
|
|
|
if (status != GIMP_PDB_SUCCESS && error)
|
|
|
|
{
|
|
|
|
*nreturn_vals = 2;
|
|
|
|
values[1].type = GIMP_PDB_STRING;
|
|
|
|
values[1].data.d_string = error->message;
|
|
|
|
}
|
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
values[0].data.d_status = status;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2004-01-22 22:04:45 +08:00
|
|
|
static gboolean
|
1999-10-09 04:09:04 +08:00
|
|
|
save_dialog (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2014-06-23 05:01:31 +08:00
|
|
|
GtkWidget *dialog;
|
2018-05-06 06:35:26 +08:00
|
|
|
GtkWidget *grid;
|
2014-06-23 05:01:31 +08:00
|
|
|
GtkWidget *entry;
|
|
|
|
GtkWidget *spinbutton;
|
|
|
|
GtkAdjustment *adj;
|
|
|
|
gboolean run;
|
2000-01-07 06:26:10 +08:00
|
|
|
|
2009-07-21 20:10:29 +08:00
|
|
|
dialog = gimp_export_dialog_new (_("Brush"), PLUG_IN_BINARY, SAVE_PROC);
|
2005-09-10 02:38:00 +08:00
|
|
|
|
2018-05-06 06:35:26 +08:00
|
|
|
/* The main grid */
|
|
|
|
grid = gtk_grid_new ();
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (grid), 12);
|
|
|
|
gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
|
|
|
|
gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
|
2009-07-21 20:10:29 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (gimp_export_dialog_get_content_area (dialog)),
|
2018-05-06 06:35:26 +08:00
|
|
|
grid, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (grid);
|
2000-01-07 06:26:10 +08:00
|
|
|
|
2014-11-05 09:34:45 +08:00
|
|
|
entry = gtk_entry_new ();
|
|
|
|
gtk_entry_set_width_chars (GTK_ENTRY (entry), 20);
|
|
|
|
gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry), info.description);
|
2018-05-06 06:35:26 +08:00
|
|
|
gimp_grid_attach_aligned (GTK_GRID (grid), 0, 0,
|
|
|
|
_("Description:"), 1.0, 0.5,
|
|
|
|
entry, 1);
|
2014-11-05 09:34:45 +08:00
|
|
|
|
|
|
|
g_signal_connect (entry, "changed",
|
|
|
|
G_CALLBACK (entry_callback),
|
|
|
|
info.description);
|
|
|
|
|
2018-06-25 00:15:16 +08:00
|
|
|
adj = gtk_adjustment_new (info.spacing, 1, 1000, 1, 10, 0);
|
2014-06-23 05:01:31 +08:00
|
|
|
spinbutton = gtk_spin_button_new (adj, 1.0, 0);
|
|
|
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
2014-11-01 22:00:08 +08:00
|
|
|
gtk_entry_set_activates_default (GTK_ENTRY (spinbutton), TRUE);
|
2018-05-06 06:35:26 +08:00
|
|
|
gimp_grid_attach_aligned (GTK_GRID (grid), 0, 1,
|
|
|
|
_("Spacing:"), 1.0, 0.5,
|
|
|
|
spinbutton, 1);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (adj, "value-changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gimp_int_adjustment_update),
|
|
|
|
&info.spacing);
|
2000-01-26 01:46:56 +08:00
|
|
|
|
2005-09-10 02:38:00 +08:00
|
|
|
gtk_widget_show (dialog);
|
2003-09-04 00:59:22 +08:00
|
|
|
|
2005-09-10 02:38:00 +08:00
|
|
|
run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
|
2003-09-04 00:59:22 +08:00
|
|
|
|
2005-09-10 02:38:00 +08:00
|
|
|
gtk_widget_destroy (dialog);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
return run;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-09-04 00:59:22 +08:00
|
|
|
static void
|
|
|
|
entry_callback (GtkWidget *widget,
|
2008-10-20 14:04:39 +08:00
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-01-22 22:04:45 +08:00
|
|
|
strncpy (info.description, gtk_entry_get_text (GTK_ENTRY (widget)),
|
|
|
|
sizeof (info.description));
|
|
|
|
info.description[sizeof (info.description) - 1] = '\0';
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|