plug-ins: implement (gimp-drawable-append-new-filter) script-fu procedure.

This commit is contained in:
Jehan 2024-12-14 13:38:51 +01:00
parent dc91fe6ccd
commit 39df978c2c

View file

@ -53,58 +53,65 @@
#undef cons
static void ts_init_constants (scheme *sc,
GIRepository *repo);
static void ts_init_enums (scheme *sc,
GIRepository *repo,
const char *namespace);
static void ts_define_procedure (scheme *sc,
const gchar *symbol_name,
TsWrapperFunc func);
static void ts_init_procedures (scheme *sc,
gboolean register_scipts);
static void ts_load_init_and_compatibility_scripts (GList *paths);
static void ts_init_constants (scheme *sc,
GIRepository *repo);
static void ts_init_enums (scheme *sc,
GIRepository *repo,
const char *namespace);
static void ts_define_procedure (scheme *sc,
const gchar *symbol_name,
TsWrapperFunc func);
static void ts_init_procedures (scheme *sc,
gboolean register_scipts);
static void ts_load_init_and_compatibility_scripts (GList *paths);
static pointer script_fu_marshal_arg_to_value (scheme *sc,
pointer a,
const gchar *proc_name,
gint arg_index,
GParamSpec *arg_spec,
GValue *value);
static pointer script_fu_marshal_arg_to_value (scheme *sc,
pointer a,
const gchar *proc_name,
gint arg_index,
GParamSpec *arg_spec,
GValue *value);
static pointer script_fu_marshal_procedure_call (scheme *sc,
pointer a,
gboolean permissive,
gboolean deprecated);
static pointer script_fu_marshal_procedure_call_strict (scheme *sc,
pointer a);
static pointer script_fu_marshal_procedure_call_permissive (scheme *sc,
pointer a);
static pointer script_fu_marshal_procedure_call_deprecated (scheme *sc,
pointer a);
static pointer script_fu_marshal_procedure_call (scheme *sc,
pointer a,
gboolean permissive,
gboolean deprecated);
static pointer script_fu_marshal_procedure_call_strict (scheme *sc,
pointer a);
static pointer script_fu_marshal_procedure_call_permissive (scheme *sc,
pointer a);
static pointer script_fu_marshal_procedure_call_deprecated (scheme *sc,
pointer a);
static pointer script_fu_marshal_drawable_merge_filter_call (scheme *sc,
pointer a);
static pointer script_fu_marshal_drawable_create_filter (scheme *sc,
pointer a,
const gchar *proc_name,
GimpDrawable **drawable,
GimpDrawableFilter **filter);
static pointer script_fu_marshal_drawable_merge_filter_call (scheme *sc,
pointer a);
static pointer script_fu_marshal_drawable_append_filter_call (scheme *sc,
pointer a);
static pointer script_fu_register_call (scheme *sc,
pointer a);
static pointer script_fu_register_call_filter (scheme *sc,
pointer a);
static pointer script_fu_register_call_procedure (scheme *sc,
pointer a);
static pointer script_fu_menu_register_call (scheme *sc,
pointer a);
static pointer script_fu_use_v3_call (scheme *sc,
pointer a);
static pointer script_fu_use_v2_call (scheme *sc,
pointer a);
static pointer script_fu_quit_call (scheme *sc,
pointer a);
static pointer script_fu_nil_call (scheme *sc,
pointer a);
static pointer script_fu_register_call (scheme *sc,
pointer a);
static pointer script_fu_register_call_filter (scheme *sc,
pointer a);
static pointer script_fu_register_call_procedure (scheme *sc,
pointer a);
static pointer script_fu_menu_register_call (scheme *sc,
pointer a);
static pointer script_fu_use_v3_call (scheme *sc,
pointer a);
static pointer script_fu_use_v2_call (scheme *sc,
pointer a);
static pointer script_fu_quit_call (scheme *sc,
pointer a);
static pointer script_fu_nil_call (scheme *sc,
pointer a);
static gboolean ts_load_file (const gchar *dirname,
const gchar *basename);
static gboolean ts_load_file (const gchar *dirname,
const gchar *basename);
typedef struct
{
@ -556,6 +563,7 @@ ts_define_procedure (sc, "load-extension", scm_load_ext);
ts_define_procedure (sc, "--gimp-proc-db-call", script_fu_marshal_procedure_call_deprecated);
ts_define_procedure (sc, "gimp-drawable-merge-new-filter", script_fu_marshal_drawable_merge_filter_call);
ts_define_procedure (sc, "gimp-drawable-append-new-filter", script_fu_marshal_drawable_append_filter_call);
/* Define each PDB procedure as a scheme func.
* Each call passes through one of the wrapper funcs.
@ -1549,43 +1557,44 @@ script_fu_marshal_procedure_call_deprecated (scheme *sc,
}
static pointer
script_fu_marshal_drawable_merge_filter_call (scheme *sc,
pointer a)
script_fu_marshal_drawable_create_filter (scheme *sc,
pointer a,
const gchar *proc_name,
GimpDrawable **drawable,
GimpDrawableFilter **filter)
{
pointer return_val = sc->NIL;
const gchar *proc_name = "gimp-drawable-merge-new-filter";
GimpDrawable *drawable = NULL;
gchar *operation_name;
gchar *filter_name = NULL;
GimpLayerMode mode = GIMP_LAYER_MODE_REPLACE;
gdouble opacity = 1.0;
GimpDrawableFilter *filter;
GimpDrawableFilterConfig *config;
gint arg_index;
gchar error_str[1024];
g_debug ("In %s()", G_STRFUNC);
if (sc->vptr->list_length (sc, a) < 2)
/* Some ScriptFu function is calling this incorrectly. */
return implementation_error (sc,
"Drawable Filter marshaller was called with missing arguments. "
"The drawable ID, the GEGL operation, filter name, blend mode, opacity "
"and the arguments' names and values it requires (possibly none) must be specified: "
"(gimp-drawable-merge-new-filter drawable op title mode arg1 val1 arg2 val2...)",
0);
else if (sc->vptr->list_length (sc, a) > 5 && sc->vptr->list_length (sc, a) % 2 != 1)
return implementation_error (sc,
"Drawable Filter marshaller was called with an even number of arguments. "
"The drawable ID, the GEGL operation, filter name, blend mode, opacity "
"and the arguments' names and values it requires (possibly none) must be specified: "
"(gimp-drawable-merge-new-filter drawable op title mode arg1 val1 arg2 val2...)",
0);
if (! sc->vptr->is_number (sc->vptr->pair_car (a)))
{
return script_type_error (sc, "numeric", 0,
"gimp-drawable-merge-new-filter");
g_snprintf (error_str, sizeof (error_str),
"Drawable Filter marshaller was called with missing arguments. "
"The drawable ID, the GEGL operation, filter name, blend mode, opacity "
"and the arguments' names and values it requires (possibly none) must be specified: "
"(%s drawable op title mode arg1 val1 arg2 val2...)",
proc_name);
return implementation_error (sc, error_str, 0);
}
else if (sc->vptr->list_length (sc, a) > 5 && sc->vptr->list_length (sc, a) % 2 != 1)
{
g_snprintf (error_str, sizeof (error_str),
"Drawable Filter marshaller was called with an even number of arguments. "
"The drawable ID, the GEGL operation, filter name, blend mode, opacity "
"and the arguments' names and values it requires (possibly none) must be specified: "
"(%s drawable op title mode arg1 val1 arg2 val2...)",
proc_name);
return implementation_error (sc, error_str, 0);
}
else if (! sc->vptr->is_number (sc->vptr->pair_car (a)))
{
return script_type_error (sc, "numeric", 0, proc_name);
}
else
{
@ -1602,7 +1611,7 @@ script_fu_marshal_drawable_merge_filter_call (scheme *sc,
return script_error (sc, error_str, 0);
}
drawable = GIMP_DRAWABLE (item);
*drawable = GIMP_DRAWABLE (item);
}
a = sc->vptr->pair_cdr (a);
@ -1628,10 +1637,10 @@ script_fu_marshal_drawable_merge_filter_call (scheme *sc,
a = sc->vptr->pair_cdr (a);
}
filter = gimp_drawable_filter_new (drawable, operation_name, filter_name);
*filter = gimp_drawable_filter_new (*drawable, operation_name, filter_name);
g_free (filter_name);
if (filter == NULL)
if (*filter == NULL)
{
g_snprintf (error_str, sizeof (error_str),
"Unknown GEGL Operation: %s", operation_name);
@ -1640,10 +1649,10 @@ script_fu_marshal_drawable_merge_filter_call (scheme *sc,
}
g_free (operation_name);
gimp_drawable_filter_set_opacity (filter, opacity);
gimp_drawable_filter_set_blend_mode (filter, mode);
gimp_drawable_filter_set_opacity (*filter, opacity);
gimp_drawable_filter_set_blend_mode (*filter, mode);
config = gimp_drawable_filter_get_config (filter);
config = gimp_drawable_filter_get_config (*filter);
arg_index = 5;
while (sc->vptr->list_length (sc, a) > 1)
{
@ -1658,7 +1667,7 @@ script_fu_marshal_drawable_merge_filter_call (scheme *sc,
g_snprintf (error_str, sizeof (error_str),
"Invalid argument name: %s", argname);
g_free (argname);
gimp_drawable_filter_delete (filter);
gimp_drawable_filter_delete (*filter);
return script_error (sc, error_str, 0);
}
g_value_init (&value, arg_spec->value_type);
@ -1670,7 +1679,7 @@ script_fu_marshal_drawable_merge_filter_call (scheme *sc,
{
g_value_unset (&value);
g_free (argname);
gimp_drawable_filter_delete (filter);
gimp_drawable_filter_delete (*filter);
return return_val;
}
@ -1681,9 +1690,45 @@ script_fu_marshal_drawable_merge_filter_call (scheme *sc,
arg_index += 2;
}
return sc->NIL;
}
static pointer
script_fu_marshal_drawable_merge_filter_call (scheme *sc,
pointer a)
{
GimpDrawable *drawable = NULL;
GimpDrawableFilter *filter = NULL;
pointer return_val;
return_val = script_fu_marshal_drawable_create_filter (sc, a,
"gimp-drawable-merge-new-filter",
&drawable, &filter);
if (return_val != sc->NIL)
return return_val;
gimp_drawable_merge_filter (drawable, filter);
return return_val;
return sc->NIL;
}
static pointer
script_fu_marshal_drawable_append_filter_call (scheme *sc,
pointer a)
{
GimpDrawable *drawable = NULL;
GimpDrawableFilter *filter = NULL;
pointer return_val;
return_val = script_fu_marshal_drawable_create_filter (sc, a,
"gimp-drawable-append-new-filter",
&drawable, &filter);
if (return_val != sc->NIL)
return return_val;
gimp_drawable_append_filter (drawable, filter);
return sc->vptr->mk_integer (sc, gimp_drawable_filter_get_id (filter));
}
static pointer