55
55
struct _GimpLoadProcedurePrivate
56
56
{
57
57
GimpRunLoadFunc run_func ;
58
- GimpRunLoadFunc2 run_func2 ;
59
58
gpointer run_data ;
60
59
GDestroyNotify run_data_destroy ;
61
60
@@ -177,12 +176,18 @@ static GimpValueArray *
177
176
gimp_load_procedure_run (GimpProcedure * procedure ,
178
177
const GimpValueArray * args )
179
178
{
180
- GimpLoadProcedure * load_proc = GIMP_LOAD_PROCEDURE (procedure );
181
- GimpValueArray * remaining ;
182
- GimpValueArray * return_values ;
183
- GimpRunMode run_mode ;
184
- GFile * file ;
185
- gint i ;
179
+ GimpLoadProcedure * load_proc = GIMP_LOAD_PROCEDURE (procedure );
180
+ GimpValueArray * remaining ;
181
+ GimpValueArray * return_values ;
182
+ GimpProcedureConfig * config ;
183
+ GimpImage * image = NULL ;
184
+ GimpMetadata * metadata = NULL ;
185
+ gchar * mimetype = NULL ;
186
+ GimpMetadataLoadFlags flags = GIMP_METADATA_LOAD_ALL ;
187
+ GimpPDBStatusType status = GIMP_PDB_EXECUTION_ERROR ;
188
+ GimpRunMode run_mode ;
189
+ GFile * file ;
190
+ gint i ;
186
191
187
192
run_mode = GIMP_VALUES_GET_ENUM (args , 0 );
188
193
file = GIMP_VALUES_GET_FILE (args , 1 );
@@ -196,103 +201,85 @@ gimp_load_procedure_run (GimpProcedure *procedure,
196
201
gimp_value_array_append (remaining , value );
197
202
}
198
203
199
- if (load_proc -> priv -> run_func2 )
200
- {
201
- GimpProcedureConfig * config ;
202
- GimpImage * image = NULL ;
203
- GimpMetadata * metadata = NULL ;
204
- gchar * mimetype = NULL ;
205
- GimpMetadataLoadFlags flags = GIMP_METADATA_LOAD_ALL ;
206
- GimpPDBStatusType status = GIMP_PDB_EXECUTION_ERROR ;
207
-
208
- config = gimp_procedure_create_config (procedure );
209
- mimetype = (gchar * ) gimp_file_procedure_get_mime_types (GIMP_FILE_PROCEDURE (procedure ));
204
+ config = gimp_procedure_create_config (procedure );
205
+ mimetype = (gchar * ) gimp_file_procedure_get_mime_types (GIMP_FILE_PROCEDURE (procedure ));
210
206
211
- if (mimetype != NULL )
212
- {
213
- char * delim ;
214
-
215
- mimetype = g_strdup (mimetype );
216
- mimetype = g_strstrip (mimetype );
217
- delim = strstr (mimetype , "," );
218
- if (delim )
219
- * delim = '\0' ;
220
- /* Though docs only writes about the list being comma-separated, our
221
- * code apparently also split by spaces.
222
- */
223
- delim = strstr (mimetype , " " );
224
- if (delim )
225
- * delim = '\0' ;
226
- delim = strstr (mimetype , "\t" );
227
- if (delim )
228
- * delim = '\0' ;
229
-
230
- metadata = gimp_metadata_load_from_file (file , NULL );
231
- g_free (mimetype );
232
- }
233
- else
234
- {
235
- flags = GIMP_METADATA_LOAD_NONE ;
236
- }
207
+ if (mimetype != NULL )
208
+ {
209
+ char * delim ;
210
+
211
+ mimetype = g_strdup (mimetype );
212
+ mimetype = g_strstrip (mimetype );
213
+ delim = strstr (mimetype , "," );
214
+ if (delim )
215
+ * delim = '\0' ;
216
+ /* Though docs only writes about the list being comma-separated, our
217
+ * code apparently also split by spaces.
218
+ */
219
+ delim = strstr (mimetype , " " );
220
+ if (delim )
221
+ * delim = '\0' ;
222
+ delim = strstr (mimetype , "\t" );
223
+ if (delim )
224
+ * delim = '\0' ;
225
+
226
+ metadata = gimp_metadata_load_from_file (file , NULL );
227
+ g_free (mimetype );
228
+ }
229
+ else
230
+ {
231
+ flags = GIMP_METADATA_LOAD_NONE ;
232
+ }
237
233
238
- if (metadata == NULL )
239
- metadata = gimp_metadata_new ();
234
+ if (metadata == NULL )
235
+ metadata = gimp_metadata_new ();
240
236
241
- return_values = load_proc -> priv -> run_func2 (procedure ,
242
- run_mode ,
243
- file ,
244
- metadata , & flags ,
245
- config ,
246
- load_proc -> priv -> run_data );
237
+ return_values = load_proc -> priv -> run_func (procedure ,
238
+ run_mode ,
239
+ file ,
240
+ metadata , & flags ,
241
+ config ,
242
+ load_proc -> priv -> run_data );
247
243
248
- if (return_values != NULL &&
249
- gimp_value_array_length (return_values ) > 0 &&
250
- G_VALUE_HOLDS_ENUM (gimp_value_array_index (return_values , 0 )))
251
- status = GIMP_VALUES_GET_ENUM (return_values , 0 );
244
+ if (return_values != NULL &&
245
+ gimp_value_array_length (return_values ) > 0 &&
246
+ G_VALUE_HOLDS_ENUM (gimp_value_array_index (return_values , 0 )))
247
+ status = GIMP_VALUES_GET_ENUM (return_values , 0 );
252
248
253
- gimp_procedure_config_end_run (config , status );
249
+ gimp_procedure_config_end_run (config , status );
254
250
255
- if (status == GIMP_PDB_SUCCESS )
251
+ if (status == GIMP_PDB_SUCCESS )
252
+ {
253
+ if (gimp_value_array_length (return_values ) < 2 ||
254
+ ! GIMP_VALUE_HOLDS_IMAGE (gimp_value_array_index (return_values , 1 )))
256
255
{
257
- if (gimp_value_array_length (return_values ) < 2 ||
258
- ! GIMP_VALUE_HOLDS_IMAGE (gimp_value_array_index (return_values , 1 )))
259
- {
260
- GError * error = NULL ;
261
-
262
- status = GIMP_PDB_EXECUTION_ERROR ;
263
- g_set_error (& error , GIMP_PLUG_IN_ERROR , 0 ,
264
- _ ("This file loading plug-in returned SUCCESS as a status without an image. "
265
- "This is a bug in the plug-in code. Contact the plug-in developer." ));
266
- gimp_value_array_unref (return_values );
267
- return_values = gimp_procedure_new_return_values (procedure , status , error );
268
- }
269
- else
270
- {
271
- image = GIMP_VALUES_GET_IMAGE (return_values , 1 );
272
- }
256
+ GError * error = NULL ;
257
+
258
+ status = GIMP_PDB_EXECUTION_ERROR ;
259
+ g_set_error (& error , GIMP_PLUG_IN_ERROR , 0 ,
260
+ _ ("This file loading plug-in returned SUCCESS as a status without an image. "
261
+ "This is a bug in the plug-in code. Contact the plug-in developer." ));
262
+ gimp_value_array_unref (return_values );
263
+ return_values = gimp_procedure_new_return_values (procedure , status , error );
273
264
}
265
+ else
266
+ {
267
+ image = GIMP_VALUES_GET_IMAGE (return_values , 1 );
268
+ }
269
+ }
274
270
275
- if (image != NULL && metadata != NULL && flags != GIMP_METADATA_LOAD_NONE )
276
- gimp_image_metadata_load_finish (image , NULL , metadata , flags );
277
-
278
- /* This is debug printing to help plug-in developers figure out best
279
- * practices.
280
- */
281
- if (G_OBJECT (config )-> ref_count > 1 )
282
- g_printerr ("%s: ERROR: the GimpSaveProcedureConfig object was refed "
283
- "by plug-in, it MUST NOT do that!\n" , G_STRFUNC );
271
+ if (image != NULL && metadata != NULL && flags != GIMP_METADATA_LOAD_NONE )
272
+ gimp_image_metadata_load_finish (image , NULL , metadata , flags );
284
273
285
- g_object_unref (config );
286
- }
287
- else
288
- {
289
- return_values = load_proc -> priv -> run_func (procedure ,
290
- run_mode ,
291
- file ,
292
- remaining ,
293
- load_proc -> priv -> run_data );
294
- }
274
+ /* This is debug printing to help plug-in developers figure out best
275
+ * practices.
276
+ */
277
+ if (G_OBJECT (config )-> ref_count > 1 )
278
+ g_printerr ("%s: ERROR: the GimpSaveProcedureConfig object was refed "
279
+ "by plug-in, it MUST NOT do that!\n" , G_STRFUNC );
295
280
281
+ g_object_unref (config );
282
+ g_clear_object (& metadata );
296
283
gimp_value_array_unref (remaining );
297
284
298
285
return return_values ;
@@ -369,53 +356,6 @@ gimp_load_procedure_new (GimpPlugIn *plug_in,
369
356
return GIMP_PROCEDURE (procedure );
370
357
}
371
358
372
- /**
373
- * gimp_load_procedure_new2:
374
- * @plug_in: a #GimpPlugIn.
375
- * @name: the new procedure's name.
376
- * @proc_type: the new procedure's #GimpPDBProcType.
377
- * @run_func: the run function for the new procedure.
378
- * @run_data: user data passed to @run_func.
379
- * @run_data_destroy: (nullable): free function for @run_data, or %NULL.
380
- *
381
- * Creates a new load procedure named @name which will call @run_func
382
- * when invoked.
383
- *
384
- * See gimp_procedure_new() for information about @proc_type.
385
- *
386
- * Returns: (transfer full): a new #GimpProcedure.
387
- *
388
- * Since: 3.0
389
- **/
390
- GimpProcedure *
391
- gimp_load_procedure_new2 (GimpPlugIn * plug_in ,
392
- const gchar * name ,
393
- GimpPDBProcType proc_type ,
394
- GimpRunLoadFunc2 run_func ,
395
- gpointer run_data ,
396
- GDestroyNotify run_data_destroy )
397
- {
398
- GimpLoadProcedure * procedure ;
399
-
400
- g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in ), NULL );
401
- g_return_val_if_fail (gimp_is_canonical_identifier (name ), NULL );
402
- g_return_val_if_fail (proc_type != GIMP_PDB_PROC_TYPE_INTERNAL , NULL );
403
- g_return_val_if_fail (proc_type != GIMP_PDB_PROC_TYPE_EXTENSION , NULL );
404
- g_return_val_if_fail (run_func != NULL , NULL );
405
-
406
- procedure = g_object_new (GIMP_TYPE_LOAD_PROCEDURE ,
407
- "plug-in" , plug_in ,
408
- "name" , name ,
409
- "procedure-type" , proc_type ,
410
- NULL );
411
-
412
- procedure -> priv -> run_func2 = run_func ;
413
- procedure -> priv -> run_data = run_data ;
414
- procedure -> priv -> run_data_destroy = run_data_destroy ;
415
-
416
- return GIMP_PROCEDURE (procedure );
417
- }
418
-
419
359
/**
420
360
* gimp_load_procedure_set_handles_raw:
421
361
* @procedure: A load procedure object.
0 commit comments