1997-11-24 22:05:25 +00:00
|
|
|
/*
|
|
|
|
* pat plug-in version 1.01
|
2016-02-16 02:35:43 +01:00
|
|
|
* Loads/exports version 1 GIMP .pat files, by Tim Newsome <drz@frody.bloke.com>
|
2005-05-31 19:10:46 +00:00
|
|
|
*
|
2006-12-09 21:33:38 +00:00
|
|
|
* GIMP - The GNU Image Manipulation Program
|
2005-05-31 19:10:46 +00:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2005-05-31 19:10:46 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2005-05-31 19:10:46 +00: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-11 23:27:07 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1997-11-24 22:05:25 +00:00
|
|
|
*/
|
|
|
|
|
1999-05-29 01:28:24 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <libgimp/gimp.h>
|
1999-10-09 19:06:14 +00:00
|
|
|
#include <libgimp/gimpui.h>
|
2000-01-25 17:46:56 +00:00
|
|
|
|
2000-01-01 07:35:13 +00:00
|
|
|
#include "libgimp/stdplugins-intl.h"
|
1999-05-29 01:28:24 +00:00
|
|
|
|
2000-05-01 17:01:18 +00:00
|
|
|
|
2024-04-13 15:10:25 +00:00
|
|
|
#define EXPORT_PROC "file-pat-export"
|
2008-08-11 10:06:13 +00:00
|
|
|
#define PLUG_IN_BINARY "file-pat"
|
1999-05-29 01:28:24 +00:00
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2019-08-10 21:20:09 +02:00
|
|
|
typedef struct _Pat Pat;
|
|
|
|
typedef struct _PatClass PatClass;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2019-08-10 21:20:09 +02:00
|
|
|
struct _Pat
|
|
|
|
{
|
|
|
|
GimpPlugIn parent_instance;
|
|
|
|
};
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2019-08-10 21:20:09 +02:00
|
|
|
struct _PatClass
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2019-08-10 21:20:09 +02:00
|
|
|
GimpPlugInClass parent_class;
|
1997-11-24 22:05:25 +00:00
|
|
|
};
|
|
|
|
|
2004-01-22 14:04:45 +00:00
|
|
|
|
2019-08-10 21:20:09 +02:00
|
|
|
#define PAT_TYPE (pat_get_type ())
|
2023-10-18 18:29:37 +02:00
|
|
|
#define PAT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PAT_TYPE, Pat))
|
2000-12-19 01:58:39 +00:00
|
|
|
|
2019-08-10 21:20:09 +02:00
|
|
|
GType pat_get_type (void) G_GNUC_CONST;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2019-08-10 21:20:09 +02:00
|
|
|
static GList * pat_query_procedures (GimpPlugIn *plug_in);
|
|
|
|
static GimpProcedure * pat_create_procedure (GimpPlugIn *plug_in,
|
|
|
|
const gchar *name);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2024-04-13 15:10:25 +00:00
|
|
|
static GimpValueArray * pat_export (GimpProcedure *procedure,
|
2019-08-10 21:20:09 +02:00
|
|
|
GimpRunMode run_mode,
|
2019-08-14 15:41:47 +02:00
|
|
|
GimpImage *image,
|
2019-08-10 21:20:09 +02:00
|
|
|
GFile *file,
|
2024-05-06 18:38:12 +00:00
|
|
|
GimpExportOptions *options,
|
2023-07-20 23:58:41 +02:00
|
|
|
GimpMetadata *metadata,
|
|
|
|
GimpProcedureConfig *config,
|
2019-08-10 21:20:09 +02:00
|
|
|
gpointer run_data);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2023-05-20 14:30:41 +00:00
|
|
|
static gboolean save_dialog (GimpImage *image,
|
|
|
|
GimpProcedure *procedure,
|
2019-09-23 23:27:25 +02:00
|
|
|
GObject *config);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2012-11-18 23:20:36 +01:00
|
|
|
|
2019-08-10 21:20:09 +02:00
|
|
|
G_DEFINE_TYPE (Pat, pat, GIMP_TYPE_PLUG_IN)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2019-08-10 21:20:09 +02:00
|
|
|
GIMP_MAIN (PAT_TYPE)
|
2022-05-26 00:59:36 +02:00
|
|
|
DEFINE_STD_SET_I18N
|
2003-06-13 14:37:00 +00:00
|
|
|
|
2004-01-22 14:04:45 +00:00
|
|
|
|
2019-08-10 21:20:09 +02:00
|
|
|
static void
|
|
|
|
pat_class_init (PatClass *klass)
|
|
|
|
{
|
|
|
|
GimpPlugInClass *plug_in_class = GIMP_PLUG_IN_CLASS (klass);
|
1999-10-09 19:06:14 +00:00
|
|
|
|
2019-08-10 21:20:09 +02:00
|
|
|
plug_in_class->query_procedures = pat_query_procedures;
|
|
|
|
plug_in_class->create_procedure = pat_create_procedure;
|
2022-05-26 00:59:36 +02:00
|
|
|
plug_in_class->set_i18n = STD_SET_I18N;
|
2019-08-10 21:20:09 +02:00
|
|
|
}
|
2004-01-22 14:04:45 +00:00
|
|
|
|
2019-08-10 21:20:09 +02:00
|
|
|
static void
|
|
|
|
pat_init (Pat *pat)
|
|
|
|
{
|
|
|
|
}
|
2013-11-10 00:18:48 +01:00
|
|
|
|
2019-08-10 21:20:09 +02:00
|
|
|
static GList *
|
|
|
|
pat_query_procedures (GimpPlugIn *plug_in)
|
|
|
|
{
|
2024-04-13 15:10:25 +00:00
|
|
|
return g_list_append (NULL, g_strdup (EXPORT_PROC));
|
2019-08-10 21:20:09 +02:00
|
|
|
}
|
2013-11-10 00:18:48 +01:00
|
|
|
|
2019-08-10 21:20:09 +02:00
|
|
|
static GimpProcedure *
|
|
|
|
pat_create_procedure (GimpPlugIn *plug_in,
|
|
|
|
const gchar *name)
|
|
|
|
{
|
|
|
|
GimpProcedure *procedure = NULL;
|
2004-01-22 14:04:45 +00:00
|
|
|
|
2024-04-13 15:10:25 +00:00
|
|
|
if (! strcmp (name, EXPORT_PROC))
|
2019-08-10 21:20:09 +02:00
|
|
|
{
|
2024-04-20 03:08:57 +00:00
|
|
|
procedure = gimp_export_procedure_new (plug_in, name,
|
|
|
|
GIMP_PDB_PROC_TYPE_PLUGIN,
|
|
|
|
FALSE, pat_export, NULL, NULL);
|
2019-08-10 21:20:09 +02:00
|
|
|
|
2019-08-18 13:45:58 +02:00
|
|
|
gimp_procedure_set_image_types (procedure, "*");
|
2019-08-10 21:20:09 +02:00
|
|
|
|
2022-07-04 22:50:53 +02:00
|
|
|
gimp_procedure_set_menu_label (procedure, _("GIMP pattern"));
|
2019-08-18 13:45:58 +02:00
|
|
|
gimp_procedure_set_icon_name (procedure, GIMP_ICON_PATTERN);
|
2019-08-10 21:20:09 +02:00
|
|
|
|
|
|
|
gimp_procedure_set_documentation (procedure,
|
2023-03-26 12:46:47 +02:00
|
|
|
_("Exports GIMP pattern file (.PAT)"),
|
|
|
|
_("New GIMP patterns can be created "
|
2023-03-26 01:56:38 +00:00
|
|
|
"by exporting them in the "
|
|
|
|
"appropriate place with this plug-in."),
|
2024-04-13 15:10:25 +00:00
|
|
|
EXPORT_PROC);
|
2019-08-10 21:20:09 +02:00
|
|
|
gimp_procedure_set_attribution (procedure,
|
|
|
|
"Tim Newsome",
|
|
|
|
"Tim Newsome",
|
|
|
|
"1997");
|
|
|
|
|
2023-05-20 14:30:41 +00:00
|
|
|
gimp_file_procedure_set_format_name (GIMP_FILE_PROCEDURE (procedure),
|
|
|
|
_("Pattern"));
|
2019-08-10 21:20:09 +02:00
|
|
|
gimp_file_procedure_set_mime_types (GIMP_FILE_PROCEDURE (procedure),
|
|
|
|
"image/x-gimp-pat");
|
|
|
|
gimp_file_procedure_set_extensions (GIMP_FILE_PROCEDURE (procedure),
|
|
|
|
"pat");
|
2019-08-19 12:05:12 +02:00
|
|
|
gimp_file_procedure_set_handles_remote (GIMP_FILE_PROCEDURE (procedure),
|
|
|
|
TRUE);
|
2019-08-10 21:20:09 +02:00
|
|
|
|
2024-05-06 18:38:12 +00:00
|
|
|
gimp_export_procedure_set_capabilities (GIMP_EXPORT_PROCEDURE (procedure),
|
|
|
|
GIMP_EXPORT_CAN_HANDLE_GRAY |
|
|
|
|
GIMP_EXPORT_CAN_HANDLE_RGB |
|
|
|
|
GIMP_EXPORT_CAN_HANDLE_INDEXED |
|
|
|
|
GIMP_EXPORT_CAN_HANDLE_ALPHA,
|
app, libgimp*, pdb, plug-ins: review and enhance MR !1549.
- Fix annotations for gimp_export_options_get_image() to make it
actually introspectable with the GimpImage being both input and
output. Even though the logic doesn't change much (the input image may
be overriden or not), it doesn't matter for introspection because
images are handled centrally by libgimp and therefore must not be
freed. Actually deleting the image from the central list of images
though remains a manual action depending on code logic, not some
automatic action to be handled by binding engines.
- Add G_GNUC_WARN_UNUSED_RESULT to gimp_export_options_get_image()
because ignoring the returned value is rarely a good idea (as you
usually want to delete the image).
- Remove gimp_export_options_new(): we don't need this constructor
because at this point, the best is to tell plug-in developers to just
pass NULL everywhere. This leaves us free to create a more useful
default constructor if needed, in the future. Main description for
GimpExportOptions has also been updated to say this.
- Add a data_destroy callback for the user data passed in
gimp_export_procedure_set_capabilities().
- Fixing annotations of 'export_options' object from pdb/pdb.pl: input
args would actually be (nullable) and would not transfer ownership
(calling code must still free the object). Return value's ownership on
the other hand is fully transfered.
- Add C and Python unit testing for GimpExportOptions and
gimp_export_options_get_image() in particular.
- Fix or improve various details.
Note that I have also considered for a long time changing the signature
of gimp_export_options_get_image() to return a boolean indicating
whether `image` had been replaced (hence needed deletion) or not. This
also meant getting rid of the GimpExportReturn enum. Right now it would
work because there are no third case, but I was considering the future
possibility that for instance we got some impossible conversion for some
future capability. I'm not sure it would ever happen; and for sure, this
is not desirable because it implies an export failure a bit late in the
workflow. But just in case, let's keep the enum return value. It does
not even make the using code that much more complicated (well just a
value comparison instead of a simple boolean test).
2024-08-17 15:06:27 +02:00
|
|
|
NULL, NULL, NULL);
|
2024-05-06 18:38:12 +00:00
|
|
|
|
2024-06-12 16:53:12 +00:00
|
|
|
gimp_procedure_add_string_argument (procedure, "description",
|
|
|
|
_("_Description"),
|
|
|
|
_("Short description of the pattern"),
|
|
|
|
_("GIMP Pattern"),
|
|
|
|
GIMP_PARAM_READWRITE);
|
2019-08-10 21:20:09 +02:00
|
|
|
}
|
2004-01-22 14:04:45 +00:00
|
|
|
|
2019-08-10 21:20:09 +02:00
|
|
|
return procedure;
|
|
|
|
}
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2019-08-10 21:20:09 +02:00
|
|
|
static GimpValueArray *
|
2024-04-13 15:10:25 +00:00
|
|
|
pat_export (GimpProcedure *procedure,
|
|
|
|
GimpRunMode run_mode,
|
2024-04-30 13:50:24 +00:00
|
|
|
GimpImage *image,
|
2024-04-13 15:10:25 +00:00
|
|
|
GFile *file,
|
2024-05-06 18:38:12 +00:00
|
|
|
GimpExportOptions *options,
|
2024-04-13 15:10:25 +00:00
|
|
|
GimpMetadata *metadata,
|
|
|
|
GimpProcedureConfig *config,
|
|
|
|
gpointer run_data)
|
2019-08-10 21:20:09 +02:00
|
|
|
{
|
2023-07-20 23:58:41 +02:00
|
|
|
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
2024-04-30 04:25:51 +00:00
|
|
|
GimpExportReturn export = GIMP_EXPORT_IGNORE;
|
2024-10-22 22:46:21 +02:00
|
|
|
GimpLayer **layers;
|
2023-07-20 23:58:41 +02:00
|
|
|
gchar *description;
|
|
|
|
GError *error = NULL;
|
2010-06-22 16:10:28 -03:00
|
|
|
|
2019-09-23 23:27:25 +02:00
|
|
|
g_object_get (config,
|
|
|
|
"description", &description,
|
|
|
|
NULL);
|
2008-10-20 06:04:39 +00:00
|
|
|
|
2019-09-23 23:27:25 +02:00
|
|
|
if (! description || ! strlen (description))
|
|
|
|
{
|
|
|
|
gchar *name = g_path_get_basename (gimp_file_get_utf8_name (file));
|
2019-08-10 21:20:09 +02:00
|
|
|
|
2019-09-23 23:27:25 +02:00
|
|
|
if (g_str_has_suffix (name, ".pat"))
|
|
|
|
name[strlen (name) - 4] = '\0';
|
2000-01-25 17:46:56 +00:00
|
|
|
|
2019-09-23 23:27:25 +02:00
|
|
|
if (strlen (name))
|
|
|
|
g_object_set (config,
|
|
|
|
"description", name,
|
|
|
|
NULL);
|
2000-01-25 17:46:56 +00:00
|
|
|
|
2019-09-23 23:27:25 +02:00
|
|
|
g_free (name);
|
2019-08-10 21:20:09 +02:00
|
|
|
}
|
1999-10-09 19:06:14 +00:00
|
|
|
|
2019-09-23 23:27:25 +02:00
|
|
|
g_free (description);
|
|
|
|
|
2024-07-14 20:12:57 +00:00
|
|
|
if (run_mode == GIMP_RUN_INTERACTIVE)
|
2019-09-26 00:44:52 +02:00
|
|
|
{
|
|
|
|
gimp_ui_init (PLUG_IN_BINARY);
|
|
|
|
|
2023-05-20 14:30:41 +00:00
|
|
|
if (! save_dialog (image, procedure, G_OBJECT (config)))
|
2019-09-24 15:58:54 +02:00
|
|
|
status = GIMP_PDB_CANCEL;
|
2019-08-10 21:20:09 +02:00
|
|
|
}
|
2004-01-22 14:04:45 +00:00
|
|
|
|
2024-05-06 18:38:12 +00:00
|
|
|
export = gimp_export_options_get_image (options, &image);
|
2024-10-22 22:46:21 +02:00
|
|
|
layers = gimp_image_get_layers (image);
|
2024-07-14 20:12:57 +00:00
|
|
|
|
2019-08-10 21:20:09 +02:00
|
|
|
if (status == GIMP_PDB_SUCCESS)
|
|
|
|
{
|
libgimp, plug-ins: move gimp_pdb_run_procedure*() to gimp_procedure_run*().
The gimp_procedure_run() already existed, though it was with an ordered
GimpValueArray array of arguments. Its usage feels redundant to the series of
gimp_pdb_run_procedure*() functions (which is confusing), but
gimp_procedure_run() was actually a bit more generic, because it does not
necessarily calls GimpProcedure-s through the PDB! For instance, it can runs a
local GimpProcedure, such as the case of one procedure which would want to call
another procedure in the same plug-in, but without having to go through PDB. Of
course, for local code, you may as well run relevant functions directly, yet it
makes sense that if one of the redundant-looking function is removed, it should
be the more specific one. Also gimp_procedure_run() feels a lot simpler and
logical, API wise.
A main difference in usage is that now, plug-in developers have to first
explicitly look up the GimpPdbProcedure with gimp_pdb_lookup_procedure() when
they wish to call PDB procedures on the wire. This was done anyway in the
gimp_pdb_run_procedure*() code, now it's explicit (rather than calling by name
directly).
Concretely:
* gimp_pdb_run_procedure(), gimp_pdb_run_procedure_config() and
gimp_pdb_run_procedure_valist() are removed.
* gimp_procedure_run() API is modified to use a variable args list instead of a
GimpValueArray.
* gimp_procedure_run_config() and gimp_procedure_run_valist() are added.
* gimp_procedure_run_config() in particular will be the one used in bindings
which don't have variable args support through a (rename-to
gimp_procedure_run) annotation.
2023-10-18 17:11:20 +02:00
|
|
|
GimpProcedure *procedure;
|
libgimp: PDB procedure arguments are not order-based anymore (API-wise).
As far as plug-in API is concerned, at least the calling API, order of arguments
when calling PDB procedures doesn't matter anymore.
Order still matters for creating procedures with standard arguments (for
instance, "run-mode" is first, then image, or file, drawables or whatnot,
depending on the subtype of procedure), but not for calling with libgimp.
Concretely in this commit:
- gimp_pdb_run_procedure_argv() was removed as it's intrinsically order-based.
- gimp_pdb_run_procedure() and gimp_pdb_run_procedure_valist() stay but their
semantic changes. Instead of an ordered list of (type, value) couple, it's now
an unordered list of (name, type, value) triplets. This way, you can also
ignore as many args as you want if you intend to keep them default. For
instance, say you have a procedure with 20 args and you only want to change
the last one and keep the 19 first with default values: while you used to have
to write down all 20 args annoyingly, now you can just list the only arg you
care about.
There are 2 important consequences here:
1. Calling PDB procedures becomes much more semantic, which means scripts with
PDB calls are simpler (smaller list of arguments) and easier to read (when
you had 5 int arguments in a row, you couldn't know what they refer to,
except by always checking the PDB source; now you'll have associated names,
such as "width", "height" and so on) hence maintain.
2. We will have the ability to add arguments and even order the new arguments in
middle of existing arguments without breaking compatibility. The only thing
which will matter will be that default values of new arguments will have to
behave like when the arg didn't exist. This way, existing scripts will not be
broken. This will avoid us having to always create variants of PDB procedure
(like original "file-bla-save", then variant "file-bla-save-2" and so on)
each time we add arguments.
Note: gimp_pdb_run_procedure_array() was not removed yet because it's currently
used by the PDB. To be followed.
2023-10-16 16:44:06 +02:00
|
|
|
GimpValueArray *save_retvals;
|
2019-09-23 23:27:25 +02:00
|
|
|
|
|
|
|
g_object_get (config,
|
|
|
|
"description", &description,
|
|
|
|
NULL);
|
2019-08-10 21:20:09 +02:00
|
|
|
|
libgimp, plug-ins: move gimp_pdb_run_procedure*() to gimp_procedure_run*().
The gimp_procedure_run() already existed, though it was with an ordered
GimpValueArray array of arguments. Its usage feels redundant to the series of
gimp_pdb_run_procedure*() functions (which is confusing), but
gimp_procedure_run() was actually a bit more generic, because it does not
necessarily calls GimpProcedure-s through the PDB! For instance, it can runs a
local GimpProcedure, such as the case of one procedure which would want to call
another procedure in the same plug-in, but without having to go through PDB. Of
course, for local code, you may as well run relevant functions directly, yet it
makes sense that if one of the redundant-looking function is removed, it should
be the more specific one. Also gimp_procedure_run() feels a lot simpler and
logical, API wise.
A main difference in usage is that now, plug-in developers have to first
explicitly look up the GimpPdbProcedure with gimp_pdb_lookup_procedure() when
they wish to call PDB procedures on the wire. This was done anyway in the
gimp_pdb_run_procedure*() code, now it's explicit (rather than calling by name
directly).
Concretely:
* gimp_pdb_run_procedure(), gimp_pdb_run_procedure_config() and
gimp_pdb_run_procedure_valist() are removed.
* gimp_procedure_run() API is modified to use a variable args list instead of a
GimpValueArray.
* gimp_procedure_run_config() and gimp_procedure_run_valist() are added.
* gimp_procedure_run_config() in particular will be the one used in bindings
which don't have variable args support through a (rename-to
gimp_procedure_run) annotation.
2023-10-18 17:11:20 +02:00
|
|
|
procedure = gimp_pdb_lookup_procedure (gimp_get_pdb (),
|
2024-04-18 16:02:00 +02:00
|
|
|
"file-pat-export-internal");
|
libgimp, plug-ins: move gimp_pdb_run_procedure*() to gimp_procedure_run*().
The gimp_procedure_run() already existed, though it was with an ordered
GimpValueArray array of arguments. Its usage feels redundant to the series of
gimp_pdb_run_procedure*() functions (which is confusing), but
gimp_procedure_run() was actually a bit more generic, because it does not
necessarily calls GimpProcedure-s through the PDB! For instance, it can runs a
local GimpProcedure, such as the case of one procedure which would want to call
another procedure in the same plug-in, but without having to go through PDB. Of
course, for local code, you may as well run relevant functions directly, yet it
makes sense that if one of the redundant-looking function is removed, it should
be the more specific one. Also gimp_procedure_run() feels a lot simpler and
logical, API wise.
A main difference in usage is that now, plug-in developers have to first
explicitly look up the GimpPdbProcedure with gimp_pdb_lookup_procedure() when
they wish to call PDB procedures on the wire. This was done anyway in the
gimp_pdb_run_procedure*() code, now it's explicit (rather than calling by name
directly).
Concretely:
* gimp_pdb_run_procedure(), gimp_pdb_run_procedure_config() and
gimp_pdb_run_procedure_valist() are removed.
* gimp_procedure_run() API is modified to use a variable args list instead of a
GimpValueArray.
* gimp_procedure_run_config() and gimp_procedure_run_valist() are added.
* gimp_procedure_run_config() in particular will be the one used in bindings
which don't have variable args support through a (rename-to
gimp_procedure_run) annotation.
2023-10-18 17:11:20 +02:00
|
|
|
save_retvals = gimp_procedure_run (procedure,
|
2024-10-22 22:46:21 +02:00
|
|
|
"image", image,
|
|
|
|
"drawables", (GimpDrawable **) layers,
|
|
|
|
"file", file,
|
|
|
|
"name", description,
|
libgimp, plug-ins: move gimp_pdb_run_procedure*() to gimp_procedure_run*().
The gimp_procedure_run() already existed, though it was with an ordered
GimpValueArray array of arguments. Its usage feels redundant to the series of
gimp_pdb_run_procedure*() functions (which is confusing), but
gimp_procedure_run() was actually a bit more generic, because it does not
necessarily calls GimpProcedure-s through the PDB! For instance, it can runs a
local GimpProcedure, such as the case of one procedure which would want to call
another procedure in the same plug-in, but without having to go through PDB. Of
course, for local code, you may as well run relevant functions directly, yet it
makes sense that if one of the redundant-looking function is removed, it should
be the more specific one. Also gimp_procedure_run() feels a lot simpler and
logical, API wise.
A main difference in usage is that now, plug-in developers have to first
explicitly look up the GimpPdbProcedure with gimp_pdb_lookup_procedure() when
they wish to call PDB procedures on the wire. This was done anyway in the
gimp_pdb_run_procedure*() code, now it's explicit (rather than calling by name
directly).
Concretely:
* gimp_pdb_run_procedure(), gimp_pdb_run_procedure_config() and
gimp_pdb_run_procedure_valist() are removed.
* gimp_procedure_run() API is modified to use a variable args list instead of a
GimpValueArray.
* gimp_procedure_run_config() and gimp_procedure_run_valist() are added.
* gimp_procedure_run_config() in particular will be the one used in bindings
which don't have variable args support through a (rename-to
gimp_procedure_run) annotation.
2023-10-18 17:11:20 +02:00
|
|
|
NULL);
|
2019-08-10 21:20:09 +02:00
|
|
|
|
2019-09-25 12:09:03 +02:00
|
|
|
if (GIMP_VALUES_GET_ENUM (save_retvals, 0) != GIMP_PDB_SUCCESS)
|
2004-01-22 14:04:45 +00:00
|
|
|
{
|
2019-08-10 21:20:09 +02:00
|
|
|
g_set_error (&error, 0, 0,
|
2024-04-18 16:02:00 +02:00
|
|
|
"Running procedure 'file-pat-export-internal' "
|
2019-08-10 21:20:09 +02:00
|
|
|
"failed: %s",
|
2019-08-11 16:41:58 +02:00
|
|
|
gimp_pdb_get_last_error (gimp_get_pdb ()));
|
2019-08-10 21:20:09 +02:00
|
|
|
|
|
|
|
status = GIMP_PDB_EXECUTION_ERROR;
|
2004-01-22 14:04:45 +00:00
|
|
|
}
|
2019-08-10 21:20:09 +02:00
|
|
|
|
|
|
|
gimp_value_array_unref (save_retvals);
|
1999-10-09 19:06:14 +00:00
|
|
|
}
|
2019-08-10 21:20:09 +02:00
|
|
|
|
2019-08-13 13:36:20 +02:00
|
|
|
if (export == GIMP_EXPORT_EXPORT)
|
2024-04-30 13:50:24 +00:00
|
|
|
gimp_image_delete (image);
|
2019-08-13 13:36:20 +02:00
|
|
|
|
2024-10-22 22:46:21 +02:00
|
|
|
g_free (layers);
|
|
|
|
|
2019-08-10 21:20:09 +02:00
|
|
|
return gimp_procedure_new_return_values (procedure, status, error);
|
1999-10-09 19:06:14 +00:00
|
|
|
}
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2000-12-19 01:58:39 +00:00
|
|
|
static gboolean
|
2023-05-20 14:30:41 +00:00
|
|
|
save_dialog (GimpImage *image,
|
|
|
|
GimpProcedure *procedure,
|
2019-09-23 23:27:25 +02:00
|
|
|
GObject *config)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2005-09-09 18:38:00 +00:00
|
|
|
GtkWidget *dialog;
|
2000-01-25 17:46:56 +00:00
|
|
|
GtkWidget *entry;
|
2023-03-26 01:56:38 +00:00
|
|
|
GtkWidget *real_entry;
|
2003-11-06 15:27:05 +00:00
|
|
|
gboolean run;
|
1999-10-09 19:06:14 +00:00
|
|
|
|
2024-04-20 03:08:57 +00:00
|
|
|
dialog = gimp_export_procedure_dialog_new (GIMP_EXPORT_PROCEDURE (procedure),
|
|
|
|
GIMP_PROCEDURE_CONFIG (config),
|
|
|
|
image);
|
2005-09-09 18:38:00 +00:00
|
|
|
|
2023-03-26 01:56:38 +00:00
|
|
|
entry = gimp_procedure_dialog_get_widget (GIMP_PROCEDURE_DIALOG (dialog),
|
|
|
|
"description", GIMP_TYPE_LABEL_ENTRY);
|
|
|
|
real_entry = gimp_label_entry_get_entry (GIMP_LABEL_ENTRY (entry));
|
|
|
|
gtk_entry_set_max_length (GTK_ENTRY (real_entry), 256);
|
|
|
|
gtk_entry_set_width_chars (GTK_ENTRY (real_entry), 20);
|
|
|
|
gtk_entry_set_activates_default (GTK_ENTRY (real_entry), TRUE);
|
2000-12-19 01:58:39 +00:00
|
|
|
|
2023-03-26 01:56:38 +00:00
|
|
|
gimp_procedure_dialog_fill (GIMP_PROCEDURE_DIALOG (dialog), NULL);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2005-09-09 18:38:00 +00:00
|
|
|
gtk_widget_show (dialog);
|
2000-01-08 15:23:28 +00:00
|
|
|
|
2019-09-23 23:27:25 +02:00
|
|
|
run = gimp_procedure_dialog_run (GIMP_PROCEDURE_DIALOG (dialog));
|
2006-08-02 12:32:10 +00:00
|
|
|
|
2005-09-09 18:38:00 +00:00
|
|
|
gtk_widget_destroy (dialog);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2003-11-06 15:27:05 +00:00
|
|
|
return run;
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|