ScriptFu: refactor script-fu-command
No functional changes. Extract methods to be in common with script_fu_fu_regular_proc i.e. to run a GimpProcedure instead of GimpImageProcedure
This commit is contained in:

committed by
Lloyd Konneker

parent
0a2b64352c
commit
a96211fcb7
@ -82,30 +82,20 @@ script_fu_run_command (const gchar *command,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Wrap a run_command in error handler.
|
||||||
|
* Returns the result of running the command.
|
||||||
/* Interpret a script that defines a GimpImageProcedure.
|
* The result is a PDB call result whose only value is the success.
|
||||||
*
|
* Since no SF command returns more values i.e. scripts return type void.
|
||||||
* Similar to v2 code in script-fu-interface.c, except:
|
|
||||||
* 1) builds a command from a GValueArray from a GimpConfig,
|
|
||||||
* instead of from local array of SFArg.
|
|
||||||
* 2) adds actual args image, drawable, etc. for GimpImageProcedure
|
|
||||||
*/
|
*/
|
||||||
GimpValueArray *
|
static GimpValueArray *
|
||||||
script_fu_interpret_image_proc (GimpProcedure *procedure,
|
sf_wrap_run_command (GimpProcedure *procedure,
|
||||||
SFScript *script,
|
SFScript *script,
|
||||||
GimpImage *image,
|
gchar *command)
|
||||||
guint n_drawables,
|
|
||||||
GimpDrawable **drawables,
|
|
||||||
GimpProcedureConfig *config)
|
|
||||||
{
|
{
|
||||||
gchar *command;
|
|
||||||
GimpValueArray *result = NULL;
|
GimpValueArray *result = NULL;
|
||||||
gboolean interpretation_result;
|
gboolean interpretation_result;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
command = script_fu_script_get_command_for_image_proc (script, image, n_drawables, drawables, config);
|
|
||||||
|
|
||||||
/* Take responsibility for handling errors from the scripts further calls to PDB.
|
/* Take responsibility for handling errors from the scripts further calls to PDB.
|
||||||
* ScriptFu does not show an error dialog, but forwards errors back to GIMP.
|
* ScriptFu does not show an error dialog, but forwards errors back to GIMP.
|
||||||
* This only tells GIMP that ScriptFu itself will forward GimpPDBStatus errors from
|
* This only tells GIMP that ScriptFu itself will forward GimpPDBStatus errors from
|
||||||
@ -117,7 +107,7 @@ script_fu_interpret_image_proc (GimpProcedure *procedure,
|
|||||||
GIMP_PDB_ERROR_HANDLER_PLUGIN);
|
GIMP_PDB_ERROR_HANDLER_PLUGIN);
|
||||||
|
|
||||||
interpretation_result = script_fu_run_command (command, &error);
|
interpretation_result = script_fu_run_command (command, &error);
|
||||||
g_free (command);
|
|
||||||
if (! interpretation_result)
|
if (! interpretation_result)
|
||||||
{
|
{
|
||||||
/* This is to the console.
|
/* This is to the console.
|
||||||
@ -145,3 +135,27 @@ script_fu_interpret_image_proc (GimpProcedure *procedure,
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Interpret a script that defines a GimpImageProcedure.
|
||||||
|
*
|
||||||
|
* Similar to v2 code in script-fu-interface.c, except:
|
||||||
|
* 1) builds a command from a GValueArray from a GimpConfig,
|
||||||
|
* instead of from local array of SFArg.
|
||||||
|
* 2) adds actual args image, drawable, etc. for GimpImageProcedure
|
||||||
|
*/
|
||||||
|
GimpValueArray *
|
||||||
|
script_fu_interpret_image_proc (GimpProcedure *procedure,
|
||||||
|
SFScript *script,
|
||||||
|
GimpImage *image,
|
||||||
|
guint n_drawables,
|
||||||
|
GimpDrawable **drawables,
|
||||||
|
GimpProcedureConfig *config)
|
||||||
|
{
|
||||||
|
gchar *command;
|
||||||
|
GimpValueArray *result = NULL;
|
||||||
|
|
||||||
|
command = script_fu_script_get_command_for_image_proc (script, image, n_drawables, drawables, config);
|
||||||
|
result = sf_wrap_run_command (procedure, script, command);
|
||||||
|
g_free (command);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user