mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 17:33:25 +00:00
app, libgimp*, plug-ins: int32 array arguments don't need a size argument anymore.
GimpArray (and therefore the int32 array typedef) contains its own size. We don't need to store the array size in a preceding argument. Also adding gimp_int32_array_get_values() and gimp_int32_array_set_values() to edit an existing GimpArray. This comes with the fact we should start making the GimpArray type more explicit, because clearly by trying to hide this type so much, it was too much looking like the int32 array param spec was expecting a C array (as was visible in the file-ico plug-in where we were getting a C array, which was a bug only made invisible by the fact we were not setting the C array back in the config object in the end). Last but not least, I finally implemented int32 array (de)serialization. As a side fix, the "images" arg in file-pdf-export-multi procedure is now a proper image array (not an int32 array), and of course the "count" arg was removed.
This commit is contained in:
parent
60eb27ab18
commit
f2b9babfb4
13 changed files with 306 additions and 187 deletions
|
@ -449,23 +449,23 @@ gimp_pdb_execute_procedure_by_name (GimpPDB *pdb,
|
|||
GIMP_VALUE_HOLDS_FLOAT_ARRAY (value) ||
|
||||
GIMP_VALUE_HOLDS_CORE_OBJECT_ARRAY (value))
|
||||
{
|
||||
/* Array arguments don't have their size information when they
|
||||
* are set by core code, in C array form.
|
||||
* By convention, the previous argument has to be the array
|
||||
* size argument.
|
||||
*/
|
||||
g_return_val_if_fail (prev_value_type == G_TYPE_INT && prev_int_value >= 0, NULL);
|
||||
|
||||
if (GIMP_VALUE_HOLDS_INT32_ARRAY (value))
|
||||
gimp_value_set_int32_array (value,
|
||||
(const gint32 *) va_arg (va_args, gpointer),
|
||||
prev_int_value);
|
||||
else if (GIMP_VALUE_HOLDS_FLOAT_ARRAY (value))
|
||||
gimp_value_set_float_array (value,
|
||||
(const gdouble *) va_arg (va_args, gpointer),
|
||||
prev_int_value);
|
||||
else if (GIMP_VALUE_HOLDS_CORE_OBJECT_ARRAY (value))
|
||||
g_value_set_boxed (value, va_arg (va_args, gpointer));
|
||||
if (GIMP_VALUE_HOLDS_FLOAT_ARRAY (value))
|
||||
{
|
||||
/* Array arguments don't have their size information when they
|
||||
* are set by core code, in C array form.
|
||||
* By convention, the previous argument has to be the array
|
||||
* size argument.
|
||||
*/
|
||||
g_return_val_if_fail (prev_value_type == G_TYPE_INT && prev_int_value >= 0, NULL);
|
||||
gimp_value_set_float_array (value,
|
||||
(const gdouble *) va_arg (va_args, gpointer),
|
||||
prev_int_value);
|
||||
}
|
||||
else if (GIMP_VALUE_HOLDS_CORE_OBJECT_ARRAY (value) ||
|
||||
GIMP_VALUE_HOLDS_INT32_ARRAY (value))
|
||||
{
|
||||
g_value_set_boxed (value, va_arg (va_args, gpointer));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -729,10 +729,7 @@ gimp_plug_in_handle_proc_install (GimpPlugIn *plug_in,
|
|||
GPParamDef *param_def = &proc_install->params[i];
|
||||
GPParamDef *prev_param_def = &proc_install->params[i - 1];
|
||||
|
||||
if ((! strcmp (param_def->type_name, "GimpParamInt32Array") ||
|
||||
! strcmp (param_def->type_name, "GimpParamIntFloatArray") ||
|
||||
! strcmp (param_def->type_name, "GimpParamIntColorArray"))
|
||||
&&
|
||||
if (! strcmp (param_def->type_name, "GimpParamFloatArray") &&
|
||||
strcmp (prev_param_def->type_name, "GParamInt"))
|
||||
{
|
||||
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
||||
|
|
|
@ -85,6 +85,8 @@ EXPORTS
|
|||
gimp_installation_directory
|
||||
gimp_installation_directory_file
|
||||
gimp_int32_array_get_type
|
||||
gimp_int32_array_get_values
|
||||
gimp_int32_array_set_values
|
||||
gimp_interpolation_type_get_type
|
||||
gimp_is_canonical_identifier
|
||||
gimp_join_style_get_type
|
||||
|
|
|
@ -452,6 +452,49 @@ gimp_value_take_array (GValue *value,
|
|||
typedef GimpArray GimpInt32Array;
|
||||
G_DEFINE_BOXED_TYPE (GimpInt32Array, gimp_int32_array, gimp_array_copy, gimp_array_free)
|
||||
|
||||
/**
|
||||
* gimp_int32_array_get_values:
|
||||
* @array: the #GimpArray representing #int32 values.
|
||||
* @length: the number of #int32 values in the returned array.
|
||||
*
|
||||
* Returns: (array length=length) (transfer none): a C-array of #gint32.
|
||||
*/
|
||||
const gint32 *
|
||||
gimp_int32_array_get_values (GimpArray *array,
|
||||
gsize *length)
|
||||
{
|
||||
g_return_val_if_fail (array->length % sizeof (gint32) == 0, NULL);
|
||||
|
||||
if (length)
|
||||
*length = array->length / sizeof (gint32);
|
||||
|
||||
return (const gint32 *) array->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_int32_array_set_values:
|
||||
* @array: the array to modify.
|
||||
* @values: (array length=length): the C-array.
|
||||
* @length: the number of #int32 values in @data.
|
||||
* @static_data: whether @data is a static rather than allocated array.
|
||||
*/
|
||||
void
|
||||
gimp_int32_array_set_values (GimpArray *array,
|
||||
const gint32 *values,
|
||||
gsize length,
|
||||
gboolean static_data)
|
||||
{
|
||||
g_return_if_fail ((values == NULL && length == 0) || (values != NULL && length > 0));
|
||||
|
||||
if (! array->static_data)
|
||||
g_free (array->data);
|
||||
|
||||
array->length = length * sizeof (gint32);
|
||||
array->data = static_data ? (guint8 *) values : g_memdup2 (values, array->length);
|
||||
array->static_data = static_data;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* GIMP_TYPE_PARAM_INT32_ARRAY
|
||||
*/
|
||||
|
|
|
@ -211,10 +211,17 @@ GParamSpec * gimp_param_spec_array (const gchar *name,
|
|||
* GIMP_TYPE_INT32_ARRAY
|
||||
*/
|
||||
|
||||
#define GIMP_TYPE_INT32_ARRAY (gimp_int32_array_get_type ())
|
||||
#define GIMP_VALUE_HOLDS_INT32_ARRAY(value) (G_TYPE_CHECK_VALUE_TYPE ((value), GIMP_TYPE_INT32_ARRAY))
|
||||
#define GIMP_TYPE_INT32_ARRAY (gimp_int32_array_get_type ())
|
||||
#define GIMP_VALUE_HOLDS_INT32_ARRAY(value) (G_TYPE_CHECK_VALUE_TYPE ((value), GIMP_TYPE_INT32_ARRAY))
|
||||
|
||||
GType gimp_int32_array_get_type (void) G_GNUC_CONST;
|
||||
GType gimp_int32_array_get_type (void) G_GNUC_CONST;
|
||||
|
||||
const gint32 * gimp_int32_array_get_values (GimpArray *array,
|
||||
gsize *length);
|
||||
void gimp_int32_array_set_values (GimpArray *array,
|
||||
const gint32 *values,
|
||||
gsize length,
|
||||
gboolean static_data);
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -85,6 +85,8 @@ static GTokenType gimp_config_deserialize_value_array (GValue *value,
|
|||
GimpConfig *config,
|
||||
GParamSpec *prop_spec,
|
||||
GScanner *scanner);
|
||||
static GTokenType gimp_config_deserialize_array (GValue *value,
|
||||
GScanner *scanner);
|
||||
static GTokenType gimp_config_deserialize_strv (GValue *value,
|
||||
GScanner *scanner);
|
||||
static GimpUnit * gimp_config_get_unit_from_identifier (const gchar *identifier);
|
||||
|
@ -382,6 +384,10 @@ gimp_config_deserialize_value (GValue *value,
|
|||
{
|
||||
return gimp_config_deserialize_strv (value, scanner);
|
||||
}
|
||||
else if (prop_spec->value_type == GIMP_TYPE_INT32_ARRAY)
|
||||
{
|
||||
return gimp_config_deserialize_array (value, scanner);
|
||||
}
|
||||
else if (prop_spec->value_type == GIMP_TYPE_UNIT)
|
||||
{
|
||||
return gimp_config_deserialize_unit (value, prop_spec, scanner);
|
||||
|
@ -926,6 +932,44 @@ gimp_config_deserialize_strv (GValue *value,
|
|||
return result_token;
|
||||
}
|
||||
|
||||
static GTokenType
|
||||
gimp_config_deserialize_array (GValue *value,
|
||||
GScanner *scanner)
|
||||
{
|
||||
gint32 *values;
|
||||
gint n_values;
|
||||
GTokenType result_token = G_TOKEN_RIGHT_PAREN;
|
||||
|
||||
if (! gimp_scanner_parse_int (scanner, &n_values))
|
||||
return G_TOKEN_INT;
|
||||
|
||||
values = g_new0 (gint32, n_values);
|
||||
|
||||
for (gint i = 0; i < n_values; i++)
|
||||
{
|
||||
gint value;
|
||||
|
||||
if (! gimp_scanner_parse_int (scanner, &value))
|
||||
{
|
||||
result_token = G_TOKEN_INT;
|
||||
break;
|
||||
}
|
||||
|
||||
values[i] = value;
|
||||
}
|
||||
|
||||
if (result_token == G_TOKEN_RIGHT_PAREN)
|
||||
{
|
||||
gimp_value_take_int32_array (value, values, n_values);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_scanner_error (scanner, "Missing value.");
|
||||
}
|
||||
|
||||
return result_token;
|
||||
}
|
||||
|
||||
static GimpUnit *
|
||||
gimp_config_get_unit_from_identifier (const gchar *identifier)
|
||||
{
|
||||
|
|
|
@ -48,8 +48,10 @@
|
|||
**/
|
||||
|
||||
|
||||
static gboolean gimp_config_serialize_strv (const GValue *value,
|
||||
GString *str);
|
||||
static gboolean gimp_config_serialize_strv (const GValue *value,
|
||||
GString *str);
|
||||
static gboolean gimp_config_serialize_array (const GValue *value,
|
||||
GString *str);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -512,6 +514,11 @@ gimp_config_serialize_value (const GValue *value,
|
|||
return gimp_config_serialize_strv (value, str);
|
||||
}
|
||||
|
||||
if (GIMP_VALUE_HOLDS_INT32_ARRAY (value))
|
||||
{
|
||||
return gimp_config_serialize_array (value, str);
|
||||
}
|
||||
|
||||
if (G_VALUE_HOLDS_BOOLEAN (value))
|
||||
{
|
||||
gboolean bool;
|
||||
|
@ -729,3 +736,38 @@ gimp_config_serialize_strv (const GValue *value,
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_config_serialize_array (const GValue *value,
|
||||
GString *str)
|
||||
{
|
||||
GimpArray *array;
|
||||
|
||||
g_return_val_if_fail (GIMP_VALUE_HOLDS_INT32_ARRAY (value), FALSE);
|
||||
|
||||
array = g_value_get_boxed (value);
|
||||
|
||||
if (array)
|
||||
{
|
||||
gint32 *values = (gint32 *) array->data;
|
||||
gint length = array->length / sizeof (gint32);
|
||||
|
||||
/* Write length */
|
||||
g_string_append_printf (str, "%d", length);
|
||||
|
||||
for (gint i = 0; i < length; i++)
|
||||
{
|
||||
gchar *istr;
|
||||
|
||||
istr = g_strdup_printf (" %d", values[i]);
|
||||
g_string_append (str, istr);
|
||||
g_free (istr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
g_string_append (str, "0");
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -483,7 +483,7 @@ gih_export (GimpProcedure *procedure,
|
|||
|
||||
static void
|
||||
gih_remove_guides (GimpProcedureConfig *config,
|
||||
GimpImage *image)
|
||||
GimpImage *image)
|
||||
{
|
||||
GimpArray *array;
|
||||
|
||||
|
|
|
@ -431,18 +431,12 @@ pdf_create_procedure (GimpPlugIn *plug_in,
|
|||
GIMP_RUN_INTERACTIVE,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
gimp_procedure_add_int_argument (procedure, "count",
|
||||
_("Count"),
|
||||
_("The number of images entered (This will be the "
|
||||
"number of pages)."),
|
||||
1, MAX_PAGE_COUNT, 1,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
gimp_procedure_add_int32_array_argument (procedure, "images",
|
||||
"Images",
|
||||
"Input image for each page (An image can "
|
||||
"appear more than once)",
|
||||
G_PARAM_READWRITE);
|
||||
gimp_procedure_add_core_object_array_argument (procedure, "images",
|
||||
"Images",
|
||||
"Input image for each page (An image can "
|
||||
"appear more than once)",
|
||||
GIMP_TYPE_IMAGE,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
gimp_procedure_add_boolean_argument (procedure, "vectorize",
|
||||
_("Convert _bitmaps to vector graphics where possible"),
|
||||
|
@ -528,7 +522,7 @@ pdf_export_multi (GimpProcedure *procedure,
|
|||
GimpRunMode run_mode;
|
||||
GimpExportOptions *options = NULL;
|
||||
gchar *uri;
|
||||
const gint32 *image_ids = NULL;
|
||||
GimpImage **images = NULL;
|
||||
GimpImage *image = NULL;
|
||||
GFile *file = NULL;
|
||||
|
||||
|
@ -537,8 +531,7 @@ pdf_export_multi (GimpProcedure *procedure,
|
|||
g_object_get (config,
|
||||
"run-mode", &run_mode,
|
||||
"uri", &uri,
|
||||
"count", &multi_page.image_count,
|
||||
"images", &image_ids,
|
||||
"images", &images,
|
||||
NULL);
|
||||
|
||||
options = g_object_new (GIMP_TYPE_EXPORT_OPTIONS,
|
||||
|
@ -559,11 +552,16 @@ pdf_export_multi (GimpProcedure *procedure,
|
|||
if (file != NULL)
|
||||
file_name = g_file_get_path (file);
|
||||
|
||||
if (image_ids)
|
||||
for (gint i = 0; i < multi_page.image_count; i++)
|
||||
multi_page.images[i] = gimp_image_get_by_id (image_ids[i]);
|
||||
if (images)
|
||||
{
|
||||
multi_page.image_count = gimp_core_object_array_get_length ((GObject **) images);
|
||||
for (gint i = 0; i < multi_page.image_count; i++)
|
||||
multi_page.images[i] = images[i];
|
||||
}
|
||||
else
|
||||
init_image_list_defaults (image);
|
||||
{
|
||||
init_image_list_defaults (image);
|
||||
}
|
||||
|
||||
validate_image_list ();
|
||||
|
||||
|
|
|
@ -51,8 +51,8 @@ gimp_plugin_pdf_load_error_quark (void)
|
|||
|
||||
typedef struct
|
||||
{
|
||||
gint n_pages;
|
||||
gint *pages;
|
||||
gsize n_pages;
|
||||
gint *pages;
|
||||
} PdfSelectedPages;
|
||||
|
||||
|
||||
|
@ -253,15 +253,9 @@ pdf_create_procedure (GimpPlugIn *plug_in,
|
|||
GIMP_PAGE_SELECTOR_TARGET_LAYERS,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
gimp_procedure_add_int_argument (procedure, "n-pages",
|
||||
_("N pages"),
|
||||
_("Number of pages to load (0 for all)"),
|
||||
0, G_MAXINT, 0,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
/* FIXME: shouldn't the whole selector be considered as one argument
|
||||
* containing properties "target", "n-pages" and "pages" as a single
|
||||
* object?
|
||||
* containing properties "target" and "pages" as a single object?
|
||||
*
|
||||
* Or actually should we store pages at all? While it makes sense to store
|
||||
* some settings generally, not sure that the list of page makes sense
|
||||
* from one PDF document loaded to another (different) one.
|
||||
|
@ -381,10 +375,14 @@ pdf_load (GimpProcedure *procedure,
|
|||
|
||||
if (test_page)
|
||||
{
|
||||
gint i;
|
||||
gint doc_n_pages;
|
||||
GimpArray *pages_array;
|
||||
const gint32 *page_numbers;
|
||||
gint i;
|
||||
gint doc_n_pages;
|
||||
|
||||
g_object_get (config, "pages", &pages_array, NULL);
|
||||
page_numbers = gimp_int32_array_get_values (pages_array, &pages.n_pages);
|
||||
|
||||
g_object_get (config, "n-pages", &pages.n_pages, NULL);
|
||||
doc_n_pages = poppler_document_get_n_pages (doc);
|
||||
/* The number of imported pages may be bigger than
|
||||
* the number of pages from the original document.
|
||||
|
@ -402,15 +400,11 @@ pdf_load (GimpProcedure *procedure,
|
|||
}
|
||||
else
|
||||
{
|
||||
const gint32 *p;
|
||||
|
||||
g_object_get (config, "pages", &p, NULL);
|
||||
|
||||
pages.pages = g_new (gint, pages.n_pages);
|
||||
|
||||
for (i = 0; i < pages.n_pages; i++)
|
||||
{
|
||||
if (p[i] >= doc_n_pages)
|
||||
if (page_numbers[i] >= doc_n_pages)
|
||||
{
|
||||
status = GIMP_PDB_EXECUTION_ERROR;
|
||||
g_set_error (&error, GIMP_PLUGIN_PDF_LOAD_ERROR, 0,
|
||||
|
@ -423,13 +417,13 @@ pdf_load (GimpProcedure *procedure,
|
|||
"PDF document '%1$s' has %3$d pages. Page %2$d is out of range.",
|
||||
doc_n_pages),
|
||||
gimp_file_get_utf8_name (file),
|
||||
p[i],
|
||||
page_numbers[i],
|
||||
doc_n_pages);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
pages.pages[i] = p[i];
|
||||
pages.pages[i] = page_numbers[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1148,12 +1142,12 @@ load_dialog (PopplerDocument *doc,
|
|||
|
||||
target = gimp_page_selector_get_target (GIMP_PAGE_SELECTOR (selector));
|
||||
g_object_set (config,
|
||||
"target", target,
|
||||
"target", target,
|
||||
NULL);
|
||||
|
||||
pages->pages =
|
||||
gimp_page_selector_get_selected_pages (GIMP_PAGE_SELECTOR (selector),
|
||||
&pages->n_pages);
|
||||
(gint *) &pages->n_pages);
|
||||
|
||||
/* select all if none selected */
|
||||
if (pages->n_pages == 0)
|
||||
|
@ -1162,7 +1156,7 @@ load_dialog (PopplerDocument *doc,
|
|||
|
||||
pages->pages =
|
||||
gimp_page_selector_get_selected_pages (GIMP_PAGE_SELECTOR (selector),
|
||||
&pages->n_pages);
|
||||
(gint *) &pages->n_pages);
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
|
|
|
@ -75,9 +75,9 @@ static gboolean ico_save_init (GimpImage *image,
|
|||
gint32 run_mode,
|
||||
IcoSaveInfo *info,
|
||||
gint n_hot_spot_x,
|
||||
gint32 *hot_spot_x,
|
||||
const gint32 *hot_spot_x,
|
||||
gint n_hot_spot_y,
|
||||
gint32 *hot_spot_y,
|
||||
const gint32 *hot_spot_y,
|
||||
GError **error);
|
||||
static GimpPDBStatusType
|
||||
shared_save_image (GFile *file,
|
||||
|
@ -86,10 +86,12 @@ static GimpPDBStatusType
|
|||
GimpProcedure *procedure,
|
||||
GimpProcedureConfig *config,
|
||||
gint32 run_mode,
|
||||
gint *n_hot_spot_x,
|
||||
gint32 **hot_spot_x,
|
||||
gint *n_hot_spot_y,
|
||||
gint32 **hot_spot_y,
|
||||
gsize *n_hot_spot_x,
|
||||
const gint32 *hot_spot_x,
|
||||
gint32 **new_hot_spot_x,
|
||||
gsize *n_hot_spot_y,
|
||||
const gint32 *hot_spot_y,
|
||||
gint32 **new_hot_spot_y,
|
||||
gint32 file_offset,
|
||||
gint icon_index,
|
||||
GError **error,
|
||||
|
@ -179,14 +181,14 @@ ico_write_int8 (FILE *fp,
|
|||
|
||||
|
||||
static gboolean
|
||||
ico_save_init (GimpImage *image,
|
||||
gint32 run_mode,
|
||||
IcoSaveInfo *info,
|
||||
gint n_hot_spot_x,
|
||||
gint32 *hot_spot_x,
|
||||
gint n_hot_spot_y,
|
||||
gint32 *hot_spot_y,
|
||||
GError **error)
|
||||
ico_save_init (GimpImage *image,
|
||||
gint32 run_mode,
|
||||
IcoSaveInfo *info,
|
||||
gint n_hot_spot_x,
|
||||
const gint32 *hot_spot_x,
|
||||
gint n_hot_spot_y,
|
||||
const gint32 *hot_spot_y,
|
||||
GError **error)
|
||||
{
|
||||
GList *iter;
|
||||
gint num_colors;
|
||||
|
@ -1200,7 +1202,7 @@ ico_export_image (GFile *file,
|
|||
|
||||
return shared_save_image (file, NULL, image, procedure,
|
||||
config, run_mode,
|
||||
0, NULL, 0, NULL,
|
||||
0, NULL, NULL, 0, NULL, NULL,
|
||||
0, 0, error, &info);
|
||||
}
|
||||
|
||||
|
@ -1210,10 +1212,12 @@ cur_export_image (GFile *file,
|
|||
GimpProcedure *procedure,
|
||||
GimpProcedureConfig *config,
|
||||
gint32 run_mode,
|
||||
gint *n_hot_spot_x,
|
||||
gint32 **hot_spot_x,
|
||||
gint *n_hot_spot_y,
|
||||
gint32 **hot_spot_y,
|
||||
gsize *n_hot_spot_x,
|
||||
const gint32 *hot_spot_x,
|
||||
gint32 **new_hot_spot_x,
|
||||
gsize *n_hot_spot_y,
|
||||
const gint32 *hot_spot_y,
|
||||
gint32 **new_hot_spot_y,
|
||||
GError **error)
|
||||
{
|
||||
IcoSaveInfo info;
|
||||
|
@ -1225,8 +1229,8 @@ cur_export_image (GFile *file,
|
|||
|
||||
return shared_save_image (file, NULL, image, procedure,
|
||||
config, run_mode,
|
||||
n_hot_spot_x, hot_spot_x,
|
||||
n_hot_spot_y, hot_spot_y,
|
||||
n_hot_spot_x, hot_spot_x, new_hot_spot_x,
|
||||
n_hot_spot_y, hot_spot_y, new_hot_spot_y,
|
||||
0, 0, error, &info);
|
||||
}
|
||||
|
||||
|
@ -1237,10 +1241,12 @@ ani_export_image (GFile *file,
|
|||
GimpProcedure *procedure,
|
||||
GimpProcedureConfig *config,
|
||||
gint32 run_mode,
|
||||
gint *n_hot_spot_x,
|
||||
gint32 **hot_spot_x,
|
||||
gint *n_hot_spot_y,
|
||||
gint32 **hot_spot_y,
|
||||
gsize *n_hot_spot_x,
|
||||
const gint32 *hot_spot_x,
|
||||
gint32 **new_hot_spot_x,
|
||||
gsize *n_hot_spot_y,
|
||||
const gint32 *hot_spot_y,
|
||||
gint32 **new_hot_spot_y,
|
||||
AniFileHeader *header,
|
||||
AniSaveInfo *ani_info,
|
||||
GError **error)
|
||||
|
@ -1258,9 +1264,9 @@ ani_export_image (GFile *file,
|
|||
IcoSaveInfo info;
|
||||
|
||||
if (! ico_save_init (image, run_mode, &info,
|
||||
*n_hot_spot_x, *hot_spot_x,
|
||||
*n_hot_spot_y, *hot_spot_y,
|
||||
error))
|
||||
*n_hot_spot_x, hot_spot_x,
|
||||
*n_hot_spot_y, hot_spot_y,
|
||||
error))
|
||||
{
|
||||
return GIMP_PDB_EXECUTION_ERROR;
|
||||
}
|
||||
|
@ -1439,8 +1445,8 @@ ani_export_image (GFile *file,
|
|||
offset = ftell (fp);
|
||||
status = shared_save_image (file, fp, image, procedure,
|
||||
config, run_mode,
|
||||
n_hot_spot_x, hot_spot_x,
|
||||
n_hot_spot_y, hot_spot_y,
|
||||
n_hot_spot_x, hot_spot_x, new_hot_spot_x,
|
||||
n_hot_spot_y, hot_spot_y, new_hot_spot_y,
|
||||
offset, i, error, &info);
|
||||
|
||||
if (status != GIMP_PDB_SUCCESS)
|
||||
|
@ -1515,10 +1521,12 @@ shared_save_image (GFile *file,
|
|||
GimpProcedure *procedure,
|
||||
GimpProcedureConfig *config,
|
||||
gint32 run_mode,
|
||||
gint *n_hot_spot_x,
|
||||
gint32 **hot_spot_x,
|
||||
gint *n_hot_spot_y,
|
||||
gint32 **hot_spot_y,
|
||||
gsize *n_hot_spot_x,
|
||||
const gint32 *hot_spot_x,
|
||||
gint32 **new_hot_spot_x,
|
||||
gsize *n_hot_spot_y,
|
||||
const gint32 *hot_spot_y,
|
||||
gint32 **new_hot_spot_y,
|
||||
gint32 file_offset,
|
||||
gint icon_index,
|
||||
GError **error,
|
||||
|
@ -1539,9 +1547,9 @@ shared_save_image (GFile *file,
|
|||
if (! fp_ani &&
|
||||
! ico_save_init (image, run_mode, info,
|
||||
n_hot_spot_x ? *n_hot_spot_x : 0,
|
||||
hot_spot_x ? *hot_spot_x : NULL,
|
||||
hot_spot_x,
|
||||
n_hot_spot_y ? *n_hot_spot_y : 0,
|
||||
hot_spot_y ? *hot_spot_y : NULL,
|
||||
hot_spot_y,
|
||||
error))
|
||||
{
|
||||
return GIMP_PDB_EXECUTION_ERROR;
|
||||
|
@ -1698,20 +1706,20 @@ shared_save_image (GFile *file,
|
|||
|
||||
if (! fp_ani)
|
||||
{
|
||||
if (hot_spot_x)
|
||||
if (new_hot_spot_x)
|
||||
{
|
||||
*hot_spot_x = info->hot_spot_x;
|
||||
*new_hot_spot_x = info->hot_spot_x;
|
||||
info->hot_spot_x = NULL;
|
||||
|
||||
*n_hot_spot_x = num_icons;
|
||||
}
|
||||
if (hot_spot_y)
|
||||
if (new_hot_spot_y)
|
||||
{
|
||||
*hot_spot_y = info->hot_spot_y;
|
||||
*new_hot_spot_y = info->hot_spot_y;
|
||||
info->hot_spot_y = NULL;
|
||||
|
||||
*n_hot_spot_y = num_icons;
|
||||
}
|
||||
if (n_hot_spot_x)
|
||||
*n_hot_spot_x = num_icons;
|
||||
if (n_hot_spot_y)
|
||||
*n_hot_spot_y = num_icons;
|
||||
}
|
||||
|
||||
/* If saving .ani file, don't clear until
|
||||
|
|
|
@ -34,10 +34,12 @@ GimpPDBStatusType cur_export_image (GFile *file,
|
|||
GimpProcedure *procedure,
|
||||
GimpProcedureConfig *config,
|
||||
gint32 run_mode,
|
||||
gint *n_hot_spot_x,
|
||||
gint32 **hot_spot_x,
|
||||
gint *n_hot_spot_y,
|
||||
gint32 **hot_spot_y,
|
||||
gsize *n_hot_spot_x,
|
||||
const gint32 *hot_spot_x,
|
||||
gint32 **new_hot_spot_x,
|
||||
gsize *n_hot_spot_y,
|
||||
const gint32 *hot_spot_y,
|
||||
gint32 **new_hot_spot_y,
|
||||
GError **error);
|
||||
|
||||
GimpPDBStatusType ani_export_image (GFile *file,
|
||||
|
@ -45,10 +47,12 @@ GimpPDBStatusType ani_export_image (GFile *file,
|
|||
GimpProcedure *procedure,
|
||||
GimpProcedureConfig *config,
|
||||
gint32 run_mode,
|
||||
gint *n_hot_spot_x,
|
||||
gint32 **hot_spot_x,
|
||||
gint *n_hot_spot_y,
|
||||
gint32 **hot_spot_y,
|
||||
gsize *n_hot_spot_x,
|
||||
const gint32 *hot_spot_x,
|
||||
gint32 **new_hot_spot_x,
|
||||
gsize *n_hot_spot_y,
|
||||
const gint32 *hot_spot_y,
|
||||
gint32 **new_hot_spot_y,
|
||||
AniFileHeader *header,
|
||||
AniSaveInfo *ani_info,
|
||||
GError **error);
|
||||
|
|
|
@ -340,21 +340,10 @@ ico_create_procedure (GimpPlugIn *plug_in,
|
|||
gimp_file_procedure_set_extensions (GIMP_FILE_PROCEDURE (procedure),
|
||||
"cur");
|
||||
|
||||
gimp_procedure_add_int_argument (procedure, "n-hot-spot-x",
|
||||
"Number of hot spot's X coordinates",
|
||||
"Number of hot spot's X coordinates",
|
||||
0, G_MAXINT, 0,
|
||||
G_PARAM_READWRITE);
|
||||
gimp_procedure_add_int32_array_argument (procedure, "hot-spot-x",
|
||||
"Hot spot X",
|
||||
"X coordinates of hot spot (one per layer)",
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
gimp_procedure_add_int_argument (procedure, "n-hot-spot-y",
|
||||
"Number of hot spot's Y coordinates",
|
||||
"Number of hot spot's Y coordinates",
|
||||
0, G_MAXINT, 0,
|
||||
G_PARAM_READWRITE);
|
||||
gimp_procedure_add_int32_array_argument (procedure, "hot-spot-y",
|
||||
"Hot spot Y",
|
||||
"Y coordinates of hot spot (one per layer)",
|
||||
|
@ -408,21 +397,10 @@ ico_create_procedure (GimpPlugIn *plug_in,
|
|||
0, G_MAXINT, 8,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
gimp_procedure_add_int_argument (procedure, "n-hot-spot-x",
|
||||
"Number of hot spot's X coordinates",
|
||||
"Number of hot spot's X coordinates",
|
||||
0, G_MAXINT, 0,
|
||||
G_PARAM_READWRITE);
|
||||
gimp_procedure_add_int32_array_argument (procedure, "hot-spot-x",
|
||||
"Hot spot X",
|
||||
"X coordinates of hot spot (one per layer)",
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
gimp_procedure_add_int_argument (procedure, "n-hot-spot-y",
|
||||
"Number of hot spot's Y coordinates",
|
||||
"Number of hot spot's Y coordinates",
|
||||
0, G_MAXINT, 0,
|
||||
G_PARAM_READWRITE);
|
||||
gimp_procedure_add_int32_array_argument (procedure, "hot-spot-y",
|
||||
"Hot spot Y",
|
||||
"Y coordinates of hot spot (one per layer)",
|
||||
|
@ -605,39 +583,40 @@ cur_export (GimpProcedure *procedure,
|
|||
{
|
||||
GimpPDBStatusType status;
|
||||
GError *error = NULL;
|
||||
gint32 *hot_spot_x = NULL;
|
||||
gint32 *hot_spot_y = NULL;
|
||||
gint n_hot_spot_x = 0;
|
||||
gint n_hot_spot_y = 0;
|
||||
GimpArray *x_array = NULL;
|
||||
GimpArray *y_array = NULL;
|
||||
const gint32 *hot_spot_x = NULL;
|
||||
const gint32 *hot_spot_y = NULL;
|
||||
gint32 *new_hot_spot_x = NULL;
|
||||
gint32 *new_hot_spot_y = NULL;
|
||||
gsize n_hot_spot_x = 0;
|
||||
gsize n_hot_spot_y = 0;
|
||||
|
||||
gegl_init (NULL, NULL);
|
||||
|
||||
g_object_get (config,
|
||||
"n-hot-spot-x", &n_hot_spot_x,
|
||||
"n-hot-spot-y", &n_hot_spot_y,
|
||||
"hot-spot-x", &hot_spot_x,
|
||||
"hot-spot-y", &hot_spot_y,
|
||||
"hot-spot-x", &x_array,
|
||||
"hot-spot-y", &y_array,
|
||||
NULL);
|
||||
|
||||
hot_spot_x = gimp_int32_array_get_values (x_array, &n_hot_spot_x);
|
||||
hot_spot_y = gimp_int32_array_get_values (y_array, &n_hot_spot_y);
|
||||
|
||||
status = cur_export_image (file, image, procedure, config, run_mode,
|
||||
&n_hot_spot_x, &hot_spot_x,
|
||||
&n_hot_spot_y, &hot_spot_y,
|
||||
&n_hot_spot_x, hot_spot_x, &new_hot_spot_x,
|
||||
&n_hot_spot_y, hot_spot_y, &new_hot_spot_y,
|
||||
&error);
|
||||
|
||||
if (status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
/* XXX: seems libgimpconfig is not able to serialize
|
||||
* GimpInt32Array args yet anyway. Still leave this here for now,
|
||||
* as reminder of missing feature when we see the warnings.
|
||||
*/
|
||||
gimp_int32_array_set_values (x_array, new_hot_spot_x, n_hot_spot_x, FALSE);
|
||||
gimp_int32_array_set_values (y_array, new_hot_spot_y, n_hot_spot_y, FALSE);
|
||||
g_object_set (config,
|
||||
"n-hot-spot-x", n_hot_spot_x,
|
||||
"n-hot-spot-y", n_hot_spot_y,
|
||||
/*"hot-spot-x", hot_spot_x,*/
|
||||
/*"hot-spot-y", hot_spot_y,*/
|
||||
"hot-spot-x", x_array,
|
||||
"hot-spot-y", y_array,
|
||||
NULL);
|
||||
g_free (hot_spot_x);
|
||||
g_free (hot_spot_y);
|
||||
g_free (new_hot_spot_x);
|
||||
g_free (new_hot_spot_y);
|
||||
}
|
||||
|
||||
return gimp_procedure_new_return_values (procedure, status, error);
|
||||
|
@ -654,14 +633,18 @@ ani_export (GimpProcedure *procedure,
|
|||
gpointer run_data)
|
||||
{
|
||||
GimpPDBStatusType status;
|
||||
GError *error = NULL;
|
||||
gchar *inam = NULL;
|
||||
gchar *iart = NULL;
|
||||
gint jif_rate = 0;
|
||||
gint32 *hot_spot_x = NULL;
|
||||
gint32 *hot_spot_y = NULL;
|
||||
gint n_hot_spot_x = 0;
|
||||
gint n_hot_spot_y = 0;
|
||||
GError *error = NULL;
|
||||
gchar *inam = NULL;
|
||||
gchar *iart = NULL;
|
||||
gint jif_rate = 0;
|
||||
GimpArray *x_array = NULL;
|
||||
GimpArray *y_array = NULL;
|
||||
const gint32 *hot_spot_x = NULL;
|
||||
const gint32 *hot_spot_y = NULL;
|
||||
gint32 *new_hot_spot_x = NULL;
|
||||
gint32 *new_hot_spot_y = NULL;
|
||||
gsize n_hot_spot_x = 0;
|
||||
gsize n_hot_spot_y = 0;
|
||||
AniFileHeader header;
|
||||
AniSaveInfo ani_info;
|
||||
|
||||
|
@ -671,10 +654,8 @@ ani_export (GimpProcedure *procedure,
|
|||
"cursor-name", &inam,
|
||||
"author-name", &iart,
|
||||
"default-delay", &jif_rate,
|
||||
"n-hot-spot-x", &n_hot_spot_x,
|
||||
"n-hot-spot-y", &n_hot_spot_y,
|
||||
"hot-spot-x", &hot_spot_x,
|
||||
"hot-spot-y", &hot_spot_y,
|
||||
"hot-spot-x", &x_array,
|
||||
"hot-spot-y", &y_array,
|
||||
NULL);
|
||||
|
||||
/* Jiffies (1/60th of a second) used if rate chunk not present. */
|
||||
|
@ -682,28 +663,27 @@ ani_export (GimpProcedure *procedure,
|
|||
ani_info.inam = inam;
|
||||
ani_info.iart = iart;
|
||||
|
||||
hot_spot_x = gimp_int32_array_get_values (x_array, &n_hot_spot_x);
|
||||
hot_spot_y = gimp_int32_array_get_values (y_array, &n_hot_spot_y);
|
||||
|
||||
status = ani_export_image (file, image, procedure, config, run_mode,
|
||||
&n_hot_spot_x, &hot_spot_x,
|
||||
&n_hot_spot_y, &hot_spot_y,
|
||||
&n_hot_spot_x, hot_spot_x, &new_hot_spot_x,
|
||||
&n_hot_spot_y, hot_spot_y, &new_hot_spot_y,
|
||||
&header, &ani_info, &error);
|
||||
|
||||
if (status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
/* XXX: seems libgimpconfig is not able to serialize
|
||||
* GimpInt32Array args yet anyway. Still leave this here for now,
|
||||
* as reminder of missing feature when we see the warnings.
|
||||
*/
|
||||
gimp_int32_array_set_values (x_array, new_hot_spot_x, n_hot_spot_x, FALSE);
|
||||
gimp_int32_array_set_values (y_array, new_hot_spot_y, n_hot_spot_y, FALSE);
|
||||
g_object_set (config,
|
||||
"cursor-name", NULL,
|
||||
"author-name", NULL,
|
||||
"default-delay", header.jif_rate,
|
||||
"n-hot-spot-x", n_hot_spot_x,
|
||||
"n-hot-spot-y", n_hot_spot_y,
|
||||
/*"hot-spot-x", hot_spot_x,*/
|
||||
/*"hot-spot-y", hot_spot_y,*/
|
||||
"hot-spot-x", x_array,
|
||||
"hot-spot-y", y_array,
|
||||
NULL);
|
||||
g_free (hot_spot_x);
|
||||
g_free (hot_spot_y);
|
||||
g_free (new_hot_spot_x);
|
||||
g_free (new_hot_spot_y);
|
||||
|
||||
g_free (inam);
|
||||
g_free (iart);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue