1
1
mirror of https://gitlab.gnome.org/GNOME/gimp.git synced 2025-10-06 01:12:40 +02:00

app, libgimp*, pdb, plug-ins: capabilities should not be part of GimpParamSpecExportOptions.

The param option just contains an options object, not a separate
capabilities. Also even when passing the options object across the wire,
the capabilities within this object are not part of the "options". These
are actually handled separated by GimpExportProcedure.

Therefore the changes are:

* GimpExportCapabilities moved to gimpbaseenums.h with a proper GType.
* "capabilities" properties are changed to flags param spec with type
  GimpExportCapabilities.
* GimpParamSpecExportOptions doesn't have a capabilities variable
  anymore.
* Consequently gimp_param_spec_export_options() doesn't have a
  capabilities arg.
* Wire protocol updated as we don't need to pass any capabilities
  neither for the param definition, nor for the argument values.
* GimpExportOptionsEditFunc renamed GimpExportGetCapabilitiesFunc and
  returning GimpExportCapabilities flags, instead of setting the
  "capabilities" property. I believe it makes it much more obvious what
  this callback is for and how to use it.
* Annotations improved or completed.
* Don't make the GimpParamSpecExportOptions public anymore since it is
  the same as its parent.
This commit is contained in:
Jehan
2024-11-01 19:13:02 +01:00
parent 6934fd20e0
commit a0fa9cc191
20 changed files with 401 additions and 376 deletions

View File

@@ -521,7 +521,6 @@ register_file_procs (GimpPDB *pdb)
gimp_param_spec_export_options ("options",
"options",
"Export option settings",
0,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);

View File

@@ -40,7 +40,7 @@
#include "gimp-intl.h"
#define PLUG_IN_RC_FILE_VERSION 14
#define PLUG_IN_RC_FILE_VERSION 15
/*
@@ -1000,12 +1000,6 @@ plug_in_proc_arg_deserialize (GScanner *scanner,
break;
case GP_PARAM_DEF_TYPE_EXPORT_OPTIONS:
if (! gimp_scanner_parse_int (scanner,
&param_def.meta.m_export_options.capabilities))
{
token = G_TOKEN_INT;
goto error;
}
break;
case GP_PARAM_DEF_TYPE_RESOURCE:
@@ -1271,8 +1265,6 @@ plug_in_rc_write_proc_arg (GimpConfigWriter *writer,
break;
case GP_PARAM_DEF_TYPE_EXPORT_OPTIONS:
gimp_config_writer_printf (writer, "%d",
param_def.meta.m_export_options.capabilities);
break;
case GP_PARAM_DEF_TYPE_RESOURCE:

View File

@@ -20,6 +20,7 @@ static const GimpGetTypeFunc get_type_funcs[] =
gimp_convolve_type_get_type,
gimp_desaturate_mode_get_type,
gimp_dodge_burn_type_get_type,
gimp_export_capabilities_get_type,
gimp_fill_type_get_type,
gimp_foreground_extract_mode_get_type,
gimp_gradient_blend_color_space_get_type,
@@ -84,6 +85,7 @@ static const gchar * const type_names[] =
"GimpConvolveType",
"GimpDesaturateMode",
"GimpDodgeBurnType",
"GimpExportCapabilities",
"GimpFillType",
"GimpForegroundExtractMode",
"GimpGradientBlendColorSpace",

View File

@@ -65,9 +65,9 @@ struct _GimpExportProcedure
GDestroyNotify run_data_destroy;
GimpExportCapabilities capabilities;
GimpExportOptionsEditFunc edit_func;
gpointer edit_data;
GDestroyNotify edit_data_destroy;
GimpExportGetCapabilitiesFunc get_capabilities_func;
gpointer get_capabilities_data;
GDestroyNotify get_capabilities_data_destroy;
gboolean supports_exif;
gboolean supports_iptc;
@@ -135,10 +135,11 @@ gimp_export_procedure_class_init (GimpExportProcedureClass *klass)
*
* Since: 3.0.0
*/
props[PROP_CAPABILITIES] = g_param_spec_int ("capabilities",
props[PROP_CAPABILITIES] = g_param_spec_flags ("capabilities",
"Supported image capabilities",
NULL,
0, G_MAXINT, 0,
GIMP_TYPE_EXPORT_CAPABILITIES,
0,
G_PARAM_CONSTRUCT |
GIMP_PARAM_READWRITE);
@@ -251,7 +252,7 @@ gimp_export_procedure_constructed (GObject *object)
_gimp_procedure_add_argument (procedure,
gimp_param_spec_export_options ("options", "Options",
"Export options", 0,
"Export options",
G_PARAM_READWRITE));
}
@@ -277,7 +278,7 @@ gimp_export_procedure_set_property (GObject *object,
switch (property_id)
{
case PROP_CAPABILITIES:
procedure->capabilities = g_value_get_int (value);
procedure->capabilities = g_value_get_flags (value);
break;
case PROP_SUPPORTS_EXIF:
procedure->supports_exif = g_value_get_boolean (value);
@@ -315,7 +316,7 @@ gimp_export_procedure_get_property (GObject *object,
switch (property_id)
{
case PROP_CAPABILITIES:
g_value_set_int (value, procedure->capabilities);
g_value_set_flags (value, procedure->capabilities);
break;
case PROP_SUPPORTS_EXIF:
g_value_set_boolean (value, procedure->supports_exif);
@@ -445,10 +446,16 @@ gimp_export_procedure_run (GimpProcedure *procedure,
free_options = TRUE;
}
if (export_proc->edit_func != NULL)
if (export_proc->get_capabilities_func != NULL)
{
export_proc->edit_func (procedure, config, options,
export_proc->edit_data);
GimpExportCapabilities capabilities;
capabilities = export_proc->get_capabilities_func (procedure, config, options,
export_proc->get_capabilities_data);
g_object_set (G_OBJECT (options),
"capabilities", capabilities,
NULL);
g_signal_connect_object (config, "notify",
G_CALLBACK (gimp_export_procedure_update_options),
@@ -486,8 +493,8 @@ gimp_export_procedure_run (GimpProcedure *procedure,
g_object_unref (config);
gimp_value_array_unref (remaining);
if (export_proc->edit_data_destroy && export_proc->edit_data)
export_proc->edit_data_destroy (export_proc->edit_data);
if (export_proc->get_capabilities_data_destroy && export_proc->get_capabilities_data)
export_proc->get_capabilities_data_destroy (export_proc->get_capabilities_data);
return return_values;
}
@@ -582,12 +589,18 @@ gimp_export_procedure_update_options (GimpProcedureConfig *config,
GimpProcedure *procedure;
GimpExportProcedure *export_proc;
GimpExportOptions *options = GIMP_EXPORT_OPTIONS (data);
GimpExportCapabilities capabilities;
procedure = gimp_procedure_config_get_procedure (config);
export_proc = GIMP_EXPORT_PROCEDURE (procedure);
export_proc->edit_func (procedure, config, options,
export_proc->edit_data);
capabilities = export_proc->get_capabilities_func (procedure, config, options,
export_proc->get_capabilities_data);
g_object_set (G_OBJECT (options),
"capabilities", capabilities,
NULL);
}
@@ -665,23 +678,33 @@ gimp_export_procedure_new (GimpPlugIn *plug_in,
/**
* gimp_export_procedure_set_capabilities:
* @procedure: a #GimpProcedure.
* @capabilities: a #GimpExportCapabilities enum
* @edit_func: (nullable): callback function to update export options
* @edit_data: (nullable): data for @edit_func
* @edit_data_destroy: (nullable): free function for @edit_data, or %NULL
* @capabilities: a #GimpExportCapabilities bitfield.
* @get_capabilities_func: (nullable): callback function to update export options
* @get_capabilities_data: (nullable): data for @get_capabilities_func
* @get_capabilities_data_destroy: (nullable): free function for @get_capabilities_data, or %NULL
*
* Sets default #GimpExportCapabilities for image export.
*
* @capabilities and @get_capabilities_func are overlapping arguments.
* Either set @capabilities if your format capabilities are stable or
* @get_capabilities_func if they depend on other options.
* If @get_capabilities_func is set, @capabilities must be 0.
*
* If set, @get_capabilities_func will be called every time an argument
* in the [class@Gimp.ProcedureConfig] is edited and it will be used to
* edit the export capabilities dynamically.
*
* Since: 3.0
**/
void
gimp_export_procedure_set_capabilities (GimpExportProcedure *procedure,
GimpExportCapabilities capabilities,
GimpExportOptionsEditFunc edit_func,
gpointer edit_data,
GDestroyNotify edit_data_destroy)
GimpExportGetCapabilitiesFunc get_capabilities_func,
gpointer get_capabilities_data,
GDestroyNotify get_capabilities_data_destroy)
{
g_return_if_fail (GIMP_IS_EXPORT_PROCEDURE (procedure));
g_return_if_fail (get_capabilities_func == NULL || capabilities == 0);
/* Assign default image capabilities */
g_object_set (procedure,
@@ -690,11 +713,11 @@ gimp_export_procedure_set_capabilities (GimpExportProcedure *procedure,
/* TODO: Do more with this when we have user-specified callbacks for
* image capabilities */
if (edit_func != NULL)
if (get_capabilities_func != NULL)
{
procedure->edit_func = edit_func;
procedure->edit_data = edit_data;
procedure->edit_data_destroy = edit_data_destroy;
procedure->get_capabilities_func = get_capabilities_func;
procedure->get_capabilities_data = get_capabilities_data;
procedure->get_capabilities_data_destroy = get_capabilities_data_destroy;
}
}

View File

@@ -64,21 +64,25 @@ typedef GimpValueArray * (* GimpRunExportFunc) (GimpProcedure *procedure,
gpointer run_data);
/**
* GimpExportOptionsEditFunc:
* GimpExportGetCapabilitiesFunc:
* @procedure: the #GimpProcedure that runs.
* @config: the #GimpProcedureConfig.
* @options: the @GimpExportOptions object to update.
* @create_data: (closure): the create_data given.
* @get_capabilities_data: (closure): the @get_capabilities_data argument
* given to [method@Gimp.ExportProcedure.set_capabilities].
*
* To be described.
* This function returns the capabilities requested by your export
* procedure, depending on @config or @options.
*
* Returns: a bitfield of the capabilities you want when preparing the
* image for exporting.
*
* Since: 3.0
**/
typedef void (* GimpExportOptionsEditFunc) (GimpProcedure *procedure,
typedef GimpExportCapabilities (* GimpExportGetCapabilitiesFunc) (GimpProcedure *procedure,
GimpProcedureConfig *config,
GimpExportOptions *options,
gpointer create_data);
gpointer get_capabilities_data);
#define GIMP_TYPE_EXPORT_PROCEDURE (gimp_export_procedure_get_type ())
@@ -95,9 +99,9 @@ GimpProcedure * gimp_export_procedure_new (GimpPlugIn
void gimp_export_procedure_set_capabilities (GimpExportProcedure *procedure,
GimpExportCapabilities capabilities,
GimpExportOptionsEditFunc edit_func,
gpointer edit_data,
GDestroyNotify edit_data_destroy);
GimpExportGetCapabilitiesFunc get_capabilities_func,
gpointer get_capabilities_data,
GDestroyNotify get_capabilities_data_destroy);
void gimp_export_procedure_set_support_exif (GimpExportProcedure *procedure,

View File

@@ -290,9 +290,7 @@ _gimp_gp_param_def_to_param_spec (const GPParamDef *param_def)
case GP_PARAM_DEF_TYPE_EXPORT_OPTIONS:
if (! strcmp (param_def->type_name, "GimpParamExportOptions"))
{
return gimp_param_spec_export_options (name, nick, blurb,
param_def->meta.m_export_options.capabilities,
flags);
return gimp_param_spec_export_options (name, nick, blurb, flags);
}
break;
@@ -522,11 +520,7 @@ _gimp_param_spec_to_gp_param_def (GParamSpec *pspec,
}
else if (pspec_type == GIMP_TYPE_PARAM_EXPORT_OPTIONS)
{
GimpParamSpecExportOptions *eospec = GIMP_PARAM_SPEC_EXPORT_OPTIONS (pspec);
param_def->param_def_type = GP_PARAM_DEF_TYPE_EXPORT_OPTIONS;
param_def->meta.m_export_options.capabilities = eospec->capabilities;
}
else if (pspec_type == G_TYPE_PARAM_OBJECT &&
value_type != G_TYPE_FILE &&
@@ -980,9 +974,11 @@ gimp_gp_param_to_value (gpointer gimp,
{
GimpExportOptions *options;
options = g_object_new (GIMP_TYPE_EXPORT_OPTIONS,
"capabilities", param->data.d_export_options.capabilities,
NULL);
/* Recreating the same options when it'll have settings. The
* "capabilities" property doesn't need to be recreated. It is
* managed by the GimpExportProcedure code.
*/
options = g_object_new (GIMP_TYPE_EXPORT_OPTIONS, NULL);
g_value_set_object (value, options);
@@ -1499,17 +1495,7 @@ gimp_value_to_gp_param (const GValue *value,
}
else if (g_type_is_a (G_VALUE_TYPE (value), GIMP_TYPE_EXPORT_OPTIONS))
{
GimpExportOptions *options = g_value_get_object (value);
gint capabilities = 0;
param->param_type = GP_PARAM_TYPE_INT;
if (options)
g_object_get (options,
"capabilities", &capabilities,
NULL);
param->data.d_export_options.capabilities = capabilities;
param->param_type = GP_PARAM_TYPE_EXPORT_OPTIONS;
}
else if (G_VALUE_HOLDS_PARAM (value))
{

View File

@@ -57,6 +57,7 @@ EXPORTS
gimp_enum_value_get_help
gimp_env_init
gimp_escape_uline
gimp_export_capabilities_get_type
gimp_export_options_get_type
gimp_file_get_utf8_name
gimp_file_has_extension

View File

@@ -1925,6 +1925,54 @@ gimp_path_stroke_type_get_type (void)
return type;
}
GType
gimp_export_capabilities_get_type (void)
{
static const GFlagsValue values[] =
{
{ GIMP_EXPORT_CAN_HANDLE_RGB, "GIMP_EXPORT_CAN_HANDLE_RGB", "can-handle-rgb" },
{ GIMP_EXPORT_CAN_HANDLE_GRAY, "GIMP_EXPORT_CAN_HANDLE_GRAY", "can-handle-gray" },
{ GIMP_EXPORT_CAN_HANDLE_INDEXED, "GIMP_EXPORT_CAN_HANDLE_INDEXED", "can-handle-indexed" },
{ GIMP_EXPORT_CAN_HANDLE_BITMAP, "GIMP_EXPORT_CAN_HANDLE_BITMAP", "can-handle-bitmap" },
{ GIMP_EXPORT_CAN_HANDLE_ALPHA, "GIMP_EXPORT_CAN_HANDLE_ALPHA", "can-handle-alpha" },
{ GIMP_EXPORT_CAN_HANDLE_LAYERS, "GIMP_EXPORT_CAN_HANDLE_LAYERS", "can-handle-layers" },
{ GIMP_EXPORT_CAN_HANDLE_LAYERS_AS_ANIMATION, "GIMP_EXPORT_CAN_HANDLE_LAYERS_AS_ANIMATION", "can-handle-layers-as-animation" },
{ GIMP_EXPORT_CAN_HANDLE_LAYER_MASKS, "GIMP_EXPORT_CAN_HANDLE_LAYER_MASKS", "can-handle-layer-masks" },
{ GIMP_EXPORT_CAN_HANDLE_LAYER_EFFECTS, "GIMP_EXPORT_CAN_HANDLE_LAYER_EFFECTS", "can-handle-layer-effects" },
{ GIMP_EXPORT_NEEDS_ALPHA, "GIMP_EXPORT_NEEDS_ALPHA", "needs-alpha" },
{ GIMP_EXPORT_NEEDS_CROP, "GIMP_EXPORT_NEEDS_CROP", "needs-crop" },
{ 0, NULL, NULL }
};
static const GimpFlagsDesc descs[] =
{
{ GIMP_EXPORT_CAN_HANDLE_RGB, "GIMP_EXPORT_CAN_HANDLE_RGB", NULL },
{ GIMP_EXPORT_CAN_HANDLE_GRAY, "GIMP_EXPORT_CAN_HANDLE_GRAY", NULL },
{ GIMP_EXPORT_CAN_HANDLE_INDEXED, "GIMP_EXPORT_CAN_HANDLE_INDEXED", NULL },
{ GIMP_EXPORT_CAN_HANDLE_BITMAP, "GIMP_EXPORT_CAN_HANDLE_BITMAP", NULL },
{ GIMP_EXPORT_CAN_HANDLE_ALPHA, "GIMP_EXPORT_CAN_HANDLE_ALPHA", NULL },
{ GIMP_EXPORT_CAN_HANDLE_LAYERS, "GIMP_EXPORT_CAN_HANDLE_LAYERS", NULL },
{ GIMP_EXPORT_CAN_HANDLE_LAYERS_AS_ANIMATION, "GIMP_EXPORT_CAN_HANDLE_LAYERS_AS_ANIMATION", NULL },
{ GIMP_EXPORT_CAN_HANDLE_LAYER_MASKS, "GIMP_EXPORT_CAN_HANDLE_LAYER_MASKS", NULL },
{ GIMP_EXPORT_CAN_HANDLE_LAYER_EFFECTS, "GIMP_EXPORT_CAN_HANDLE_LAYER_EFFECTS", NULL },
{ GIMP_EXPORT_NEEDS_ALPHA, "GIMP_EXPORT_NEEDS_ALPHA", NULL },
{ GIMP_EXPORT_NEEDS_CROP, "GIMP_EXPORT_NEEDS_CROP", NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (G_UNLIKELY (! type))
{
type = g_flags_register_static ("GimpExportCapabilities", values);
gimp_type_set_translation_domain (type, GETTEXT_PACKAGE "-libgimp");
gimp_type_set_translation_context (type, "export-capabilities");
gimp_flags_set_value_descriptions (type, descs);
}
return type;
}
/* Generated data ends here */

View File

@@ -1322,6 +1322,43 @@ typedef enum
GIMP_PATH_STROKE_TYPE_BEZIER
} GimpPathStrokeType;
/**
* GimpExportCapabilities:
* @GIMP_EXPORT_CAN_HANDLE_RGB: Handles RGB images
* @GIMP_EXPORT_CAN_HANDLE_GRAY: Handles grayscale images
* @GIMP_EXPORT_CAN_HANDLE_INDEXED: Handles indexed images
* @GIMP_EXPORT_CAN_HANDLE_BITMAP: Handles two-color indexed images
* @GIMP_EXPORT_CAN_HANDLE_ALPHA: Handles alpha channels
* @GIMP_EXPORT_CAN_HANDLE_LAYERS: Handles layers
* @GIMP_EXPORT_CAN_HANDLE_LAYERS_AS_ANIMATION: Handles animation of layers
* @GIMP_EXPORT_CAN_HANDLE_LAYER_EFFECTS: Handles layer effects
* @GIMP_EXPORT_CAN_HANDLE_LAYER_MASKS: Handles layer masks
* @GIMP_EXPORT_NEEDS_ALPHA: Needs alpha channels
* @GIMP_EXPORT_NEEDS_CROP: Needs to crop content to image bounds
*
* The types of images and layers an export procedure can handle
**/
#define GIMP_TYPE_EXPORT_CAPABILITIES (gimp_export_capabilities_get_type ())
GType gimp_export_capabilities_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_EXPORT_CAN_HANDLE_RGB = 1 << 0,
GIMP_EXPORT_CAN_HANDLE_GRAY = 1 << 1,
GIMP_EXPORT_CAN_HANDLE_INDEXED = 1 << 2,
GIMP_EXPORT_CAN_HANDLE_BITMAP = 1 << 3,
GIMP_EXPORT_CAN_HANDLE_ALPHA = 1 << 4,
GIMP_EXPORT_CAN_HANDLE_LAYERS = 1 << 5,
GIMP_EXPORT_CAN_HANDLE_LAYERS_AS_ANIMATION = 1 << 6,
GIMP_EXPORT_CAN_HANDLE_LAYER_MASKS = 1 << 7,
GIMP_EXPORT_CAN_HANDLE_LAYER_EFFECTS = 1 << 8,
GIMP_EXPORT_NEEDS_ALPHA = 1 << 9,
GIMP_EXPORT_NEEDS_CROP = 1 << 10
} GimpExportCapabilities;
G_END_DECLS
#endif /* __GIMP_BASE_ENUMS_H__ */

View File

@@ -90,10 +90,11 @@ gimp_export_options_class_init (GimpExportOptionsClass *klass)
*
* Since: 3.0.0
*/
props[PROP_CAPABILITIES] = g_param_spec_int ("capabilities",
props[PROP_CAPABILITIES] = g_param_spec_flags ("capabilities",
"Supported image capabilities",
NULL,
0, G_MAXINT, 0,
GIMP_TYPE_EXPORT_CAPABILITIES,
0,
G_PARAM_CONSTRUCT |
G_PARAM_READWRITE);
@@ -123,7 +124,7 @@ gimp_export_options_set_property (GObject *object,
switch (property_id)
{
case PROP_CAPABILITIES:
options->capabilities = g_value_get_int (value);
options->capabilities = g_value_get_flags (value);
break;
default:
@@ -143,7 +144,7 @@ gimp_export_options_get_property (GObject *object,
switch (property_id)
{
case PROP_CAPABILITIES:
g_value_set_int (value, options->capabilities);
g_value_set_flags (value, options->capabilities);
break;
default:
@@ -173,7 +174,7 @@ gimp_param_export_options_get_type (void)
NULL, NULL,
(GClassInitFunc) gimp_param_export_options_class_init,
NULL, NULL,
sizeof (GimpParamSpecExportOptions),
sizeof (GParamSpecObject),
0,
(GInstanceInitFunc) gimp_param_export_options_init
};
@@ -194,9 +195,6 @@ gimp_param_export_options_class_init (GParamSpecClass *klass)
static void
gimp_param_export_options_init (GParamSpec *pspec)
{
GimpParamSpecExportOptions *options = GIMP_PARAM_SPEC_EXPORT_OPTIONS (pspec);
options->capabilities = 0;
}
/**
@@ -204,7 +202,6 @@ gimp_param_export_options_init (GParamSpec *pspec)
* @name: Canonical name of the property specified.
* @nick: Nick name of the property specified.
* @blurb: Description of the property specified.
* @capabilities: Int representing the image export capabilities
* @flags: Flags for the property specified.
*
* Creates a new #GimpParamSpecExportOptions specifying a
@@ -220,17 +217,14 @@ GParamSpec *
gimp_param_spec_export_options (const gchar *name,
const gchar *nick,
const gchar *blurb,
gint capabilities,
GParamFlags flags)
{
GimpParamSpecExportOptions *options_spec;
GParamSpec *options_spec;
options_spec = g_param_spec_internal (GIMP_TYPE_PARAM_EXPORT_OPTIONS,
name, nick, blurb, flags);
g_return_val_if_fail (options_spec, NULL);
options_spec->capabilities = capabilities;
return G_PARAM_SPEC (options_spec);
return options_spec;
}

View File

@@ -37,61 +37,20 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GimpExportOptions, gimp_export_options, GIMP, EXPORT_OPTIONS, GObject)
/**
* GimpExportCapabilities:
* @GIMP_EXPORT_CAN_HANDLE_RGB: Handles RGB images
* @GIMP_EXPORT_CAN_HANDLE_GRAY: Handles grayscale images
* @GIMP_EXPORT_CAN_HANDLE_INDEXED: Handles indexed images
* @GIMP_EXPORT_CAN_HANDLE_BITMAP: Handles two-color indexed images
* @GIMP_EXPORT_CAN_HANDLE_ALPHA: Handles alpha channels
* @GIMP_EXPORT_CAN_HANDLE_LAYERS: Handles layers
* @GIMP_EXPORT_CAN_HANDLE_LAYERS_AS_ANIMATION: Handles animation of layers
* @GIMP_EXPORT_CAN_HANDLE_LAYER_EFFECTS: Handles layer effects
* @GIMP_EXPORT_CAN_HANDLE_LAYER_MASKS: Handles layer masks
* @GIMP_EXPORT_NEEDS_ALPHA: Needs alpha channels
* @GIMP_EXPORT_NEEDS_CROP: Needs to crop content to image bounds
*
* The types of images and layers an export procedure can handle
**/
typedef enum
{
GIMP_EXPORT_CAN_HANDLE_RGB = 1 << 0,
GIMP_EXPORT_CAN_HANDLE_GRAY = 1 << 1,
GIMP_EXPORT_CAN_HANDLE_INDEXED = 1 << 2,
GIMP_EXPORT_CAN_HANDLE_BITMAP = 1 << 3,
GIMP_EXPORT_CAN_HANDLE_ALPHA = 1 << 4,
GIMP_EXPORT_CAN_HANDLE_LAYERS = 1 << 5,
GIMP_EXPORT_CAN_HANDLE_LAYERS_AS_ANIMATION = 1 << 6,
GIMP_EXPORT_CAN_HANDLE_LAYER_MASKS = 1 << 7,
GIMP_EXPORT_CAN_HANDLE_LAYER_EFFECTS = 1 << 8,
GIMP_EXPORT_NEEDS_ALPHA = 1 << 9,
GIMP_EXPORT_NEEDS_CROP = 1 << 10
} GimpExportCapabilities;
/*
* GIMP_TYPE_PARAM_EXPORT_OPTIONS
*/
#define GIMP_TYPE_PARAM_EXPORT_OPTIONS (gimp_param_export_options_get_type ())
#define GIMP_PARAM_SPEC_EXPORT_OPTIONS(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), GIMP_TYPE_PARAM_EXPORT_OPTIONS, GimpParamSpecExportOptions))
#define GIMP_IS_PARAM_SPEC_EXPORT_OPTIONS(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), GIMP_TYPE_PARAM_EXPORT_OPTIONS))
typedef struct _GimpParamSpecExportOptions GimpParamSpecExportOptions;
struct _GimpParamSpecExportOptions
{
GParamSpecObject parent_instance;
gint capabilities;
};
GType gimp_param_export_options_get_type (void) G_GNUC_CONST;
GParamSpec * gimp_param_spec_export_options (const gchar *name,
const gchar *nick,
const gchar *blurb,
gint capabilities,
GParamFlags flags);

View File

@@ -1113,6 +1113,7 @@ _gp_param_def_read (GIOChannel *channel,
switch (param_def->param_def_type)
{
case GP_PARAM_DEF_TYPE_DEFAULT:
case GP_PARAM_DEF_TYPE_EXPORT_OPTIONS:
break;
case GP_PARAM_DEF_TYPE_INT:
@@ -1278,13 +1279,6 @@ _gp_param_def_read (GIOChannel *channel,
return FALSE;
break;
case GP_PARAM_DEF_TYPE_EXPORT_OPTIONS:
if (! _gimp_wire_read_int32 (channel,
(guint32 *) &param_def->meta.m_export_options.capabilities, 1,
user_data))
return FALSE;
break;
case GP_PARAM_DEF_TYPE_RESOURCE:
if (! _gimp_wire_read_int32 (channel,
(guint32 *) &param_def->meta.m_resource.none_ok, 1,
@@ -1475,6 +1469,7 @@ _gp_param_def_write (GIOChannel *channel,
switch (param_def->param_def_type)
{
case GP_PARAM_DEF_TYPE_DEFAULT:
case GP_PARAM_DEF_TYPE_EXPORT_OPTIONS:
break;
case GP_PARAM_DEF_TYPE_INT:
@@ -1632,13 +1627,6 @@ _gp_param_def_write (GIOChannel *channel,
return FALSE;
break;
case GP_PARAM_DEF_TYPE_EXPORT_OPTIONS:
if (! _gimp_wire_write_int32 (channel,
(guint32 *) &param_def->meta.m_export_options.capabilities, 1,
user_data))
return FALSE;
break;
case GP_PARAM_DEF_TYPE_RESOURCE:
if (! _gimp_wire_write_int32 (channel,
(guint32 *) &param_def->meta.m_resource.none_ok, 1,
@@ -2137,10 +2125,7 @@ _gp_params_read (GIOChannel *channel,
break;
case GP_PARAM_TYPE_EXPORT_OPTIONS:
if (! _gimp_wire_read_int32 (channel,
(guint32 *) &(*params)[i].data.d_export_options.capabilities, 1,
user_data))
goto cleanup;
/* XXX: reading export options when we'll have any. */
break;
case GP_PARAM_TYPE_PARAM_DEF:
@@ -2361,10 +2346,9 @@ _gp_params_write (GIOChannel *channel,
break;
case GP_PARAM_TYPE_EXPORT_OPTIONS:
if (! _gimp_wire_write_int32 (channel,
(const guint32 *) &params[i].data.d_export_options.capabilities, 1,
user_data))
return;
/* XXX When we'll have actual export options, this is where
* we'll want to pass them through the wire.
*/
break;
case GP_PARAM_TYPE_PARAM_DEF:

View File

@@ -26,7 +26,7 @@ G_BEGIN_DECLS
/* Increment every time the protocol changes
*/
#define GIMP_PROTOCOL_VERSION 0x0113
#define GIMP_PROTOCOL_VERSION 0x0114
enum
@@ -98,7 +98,6 @@ typedef struct _GPParamStrv GPParamStrv;
typedef struct _GPParamDefGeglColor GPParamDefGeglColor;
typedef struct _GPParamDefID GPParamDefID;
typedef struct _GPParamDefIDArray GPParamDefIDArray;
typedef struct _GPParamDefExportOptions GPParamDefExportOptions;
typedef struct _GPParamDefResource GPParamDefResource;
typedef struct _GPParam GPParam;
typedef struct _GPParamArray GPParamArray;
@@ -231,11 +230,6 @@ struct _GPParamDefChoice
gchar *default_val;
};
struct _GPParamDefExportOptions
{
gint capabilities;
};
struct _GPParamDefResource
{
gint32 none_ok;
@@ -265,7 +259,6 @@ struct _GPParamDef
GPParamDefID m_id;
GPParamDefIDArray m_id_array;
GPParamDefChoice m_choice;
GPParamDefExportOptions m_export_options;
GPParamDefResource m_resource;
} meta;
};
@@ -307,7 +300,10 @@ struct _GPParamColorArray
struct _GPParamExportOptions
{
gint capabilities;
/* XXX: this is an empty shell right now, because there are no export
* options yet. The capabilities property doesn't need to be passed
* through the wire because it is set by libgimp, not at run call.
*/
};
struct _GPParam

View File

@@ -304,11 +304,7 @@ gimp_config_param_spec_duplicate (GParamSpec *pspec)
}
else if (GIMP_IS_PARAM_SPEC_EXPORT_OPTIONS (pspec))
{
GimpParamSpecExportOptions *spec = GIMP_PARAM_SPEC_EXPORT_OPTIONS (pspec);
copy = gimp_param_spec_export_options (name, nick, blurb,
spec->capabilities,
flags);
copy = gimp_param_spec_export_options (name, nick, blurb, flags);
}
else if (G_IS_PARAM_SPEC_OBJECT (pspec))
{

View File

@@ -484,7 +484,6 @@ CODE
gimp_param_spec_export_options ("$name",
"$nick",
"$blurb",
0,
$flags)
CODE
}

View File

@@ -636,6 +636,31 @@ package Gimp::CodeGen::enums;
symbols => [ qw(GIMP_PATH_STROKE_TYPE_BEZIER) ],
mapping => { GIMP_PATH_STROKE_TYPE_BEZIER => '0' }
},
GimpExportCapabilities =>
{ contig => 0,
header => 'libgimpbase/gimpbaseenums.h',
symbols => [ qw(GIMP_EXPORT_CAN_HANDLE_RGB
GIMP_EXPORT_CAN_HANDLE_GRAY
GIMP_EXPORT_CAN_HANDLE_INDEXED
GIMP_EXPORT_CAN_HANDLE_BITMAP
GIMP_EXPORT_CAN_HANDLE_ALPHA
GIMP_EXPORT_CAN_HANDLE_LAYERS
GIMP_EXPORT_CAN_HANDLE_LAYERS_AS_ANIMATION
GIMP_EXPORT_CAN_HANDLE_LAYER_MASKS
GIMP_EXPORT_CAN_HANDLE_LAYER_EFFECTS
GIMP_EXPORT_NEEDS_ALPHA GIMP_EXPORT_NEEDS_CROP) ],
mapping => { GIMP_EXPORT_CAN_HANDLE_RGB => '1 << 0',
GIMP_EXPORT_CAN_HANDLE_GRAY => '1 << 1',
GIMP_EXPORT_CAN_HANDLE_INDEXED => '1 << 2',
GIMP_EXPORT_CAN_HANDLE_BITMAP => '1 << 3',
GIMP_EXPORT_CAN_HANDLE_ALPHA => '1 << 4',
GIMP_EXPORT_CAN_HANDLE_LAYERS => '1 << 5',
GIMP_EXPORT_CAN_HANDLE_LAYERS_AS_ANIMATION => '1 << 6',
GIMP_EXPORT_CAN_HANDLE_LAYER_MASKS => '1 << 7',
GIMP_EXPORT_CAN_HANDLE_LAYER_EFFECTS => '1 << 8',
GIMP_EXPORT_NEEDS_ALPHA => '1 << 9',
GIMP_EXPORT_NEEDS_CROP => '1 << 10' }
},
GimpColorManagementMode =>
{ contig => 1,
header => 'libgimpconfig/gimpconfigenums.h',

View File

@@ -91,7 +91,7 @@ static gboolean export_image (GFile *file,
GObject *config,
GError **error);
static void export_edit_options (GimpProcedure *procedure,
static GimpExportCapabilities export_edit_options (GimpProcedure *procedure,
GimpProcedureConfig *config,
GimpExportOptions *options,
gpointer create_data);
@@ -186,10 +186,7 @@ gif_create_procedure (GimpPlugIn *plug_in,
"gif");
gimp_export_procedure_set_capabilities (GIMP_EXPORT_PROCEDURE (procedure),
GIMP_EXPORT_CAN_HANDLE_INDEXED |
GIMP_EXPORT_CAN_HANDLE_GRAY |
GIMP_EXPORT_CAN_HANDLE_ALPHA,
export_edit_options, NULL, NULL);
0, export_edit_options, NULL, NULL);
gimp_procedure_add_boolean_argument (procedure, "interlace",
_("_Interlace"),
@@ -1173,7 +1170,7 @@ export_image (GFile *file,
return TRUE;
}
static void
static GimpExportCapabilities
export_edit_options (GimpProcedure *procedure,
GimpProcedureConfig *config,
GimpExportOptions *options,
@@ -1193,9 +1190,7 @@ export_edit_options (GimpProcedure *procedure,
if (as_animation)
capabilities |= GIMP_EXPORT_CAN_HANDLE_LAYERS;
g_object_set (G_OBJECT (options),
"capabilities", capabilities,
NULL);
return capabilities;
}
static gboolean

View File

@@ -202,7 +202,7 @@ static GimpPDBStatusType pdf_export_image (GimpProcedure *procedur
gboolean show_progress,
GError **error);
static void export_edit_options (GimpProcedure *procedure,
static GimpExportCapabilities export_edit_options (GimpProcedure *procedure,
GimpProcedureConfig *config,
GimpExportOptions *options,
gpointer create_data);
@@ -341,12 +341,7 @@ pdf_create_procedure (GimpPlugIn *plug_in,
"pdf");
gimp_export_procedure_set_capabilities (GIMP_EXPORT_PROCEDURE (procedure),
GIMP_EXPORT_CAN_HANDLE_RGB |
GIMP_EXPORT_CAN_HANDLE_ALPHA |
GIMP_EXPORT_CAN_HANDLE_GRAY |
GIMP_EXPORT_CAN_HANDLE_LAYERS |
GIMP_EXPORT_CAN_HANDLE_INDEXED,
export_edit_options, NULL, NULL);
0, export_edit_options, NULL, NULL);
gimp_procedure_add_boolean_argument (procedure, "vectorize",
_("Convert _bitmaps to vector graphics where possible"),
@@ -835,7 +830,7 @@ pdf_export_image (GimpProcedure *procedure,
return GIMP_PDB_SUCCESS;
}
static void
static GimpExportCapabilities
export_edit_options (GimpProcedure *procedure,
GimpProcedureConfig *config,
GimpExportOptions *options,
@@ -854,13 +849,10 @@ export_edit_options (GimpProcedure *procedure,
GIMP_EXPORT_CAN_HANDLE_LAYERS |
GIMP_EXPORT_CAN_HANDLE_INDEXED);
if (! apply_masks)
capabilities |= GIMP_EXPORT_CAN_HANDLE_LAYER_MASKS;
g_object_set (G_OBJECT (options),
"capabilities", capabilities,
NULL);
return capabilities;
}
/******************************************************/

View File

@@ -108,7 +108,7 @@ static GimpPDBStatusType tiff_export_rec (GimpProcedure *procedure
GimpMetadata *metadata,
gboolean retried,
GError **error);
static void export_edit_options (GimpProcedure *procedure,
static GimpExportCapabilities export_edit_options (GimpProcedure *procedure,
GimpProcedureConfig *config,
GimpExportOptions *options,
gpointer create_data);
@@ -452,7 +452,7 @@ tiff_export_rec (GimpProcedure *procedure,
return status;
}
static void
static GimpExportCapabilities
export_edit_options (GimpProcedure *procedure,
GimpProcedureConfig *config,
GimpExportOptions *options,
@@ -493,9 +493,7 @@ export_edit_options (GimpProcedure *procedure,
capabilities |= GIMP_EXPORT_NEEDS_CROP;
}
g_object_set (G_OBJECT (options),
"capabilities", capabilities,
NULL);
return capabilities;
}
static gboolean

View File

@@ -75,11 +75,12 @@ static GimpValueArray * webp_export (GimpProcedure *procedure,
GimpProcedureConfig *config,
gpointer run_data);
static void export_edit_options (GimpProcedure *procedure,
static GimpExportCapabilities export_edit_options (GimpProcedure *procedure,
GimpProcedureConfig *config,
GimpExportOptions *options,
gpointer create_data);
G_DEFINE_TYPE (Webp, webp, GIMP_TYPE_PLUG_IN)
GIMP_MAIN (WEBP_TYPE)
@@ -171,11 +172,7 @@ webp_create_procedure (GimpPlugIn *plug_in,
"webp");
gimp_export_procedure_set_capabilities (GIMP_EXPORT_PROCEDURE (procedure),
GIMP_EXPORT_CAN_HANDLE_RGB |
GIMP_EXPORT_CAN_HANDLE_GRAY |
GIMP_EXPORT_CAN_HANDLE_INDEXED |
GIMP_EXPORT_CAN_HANDLE_ALPHA,
export_edit_options, NULL, NULL);
0, export_edit_options, NULL, NULL);
gimp_procedure_add_choice_argument (procedure, "preset",
_("Source _type"),
@@ -373,7 +370,7 @@ webp_export (GimpProcedure *procedure,
return gimp_procedure_new_return_values (procedure, status, error);
}
static void
static GimpExportCapabilities
export_edit_options (GimpProcedure *procedure,
GimpProcedureConfig *config,
GimpExportOptions *options,
@@ -394,7 +391,5 @@ export_edit_options (GimpProcedure *procedure,
if (animation)
capabilities |= GIMP_EXPORT_CAN_HANDLE_LAYERS_AS_ANIMATION;
g_object_set (G_OBJECT (options),
"capabilities", capabilities,
NULL);
return capabilities;
}