mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-04 01:43:24 +00:00
app, libgimp, pdb, plug-ins: add a few Script-fu wrapper of libgimp filter API.
In particular (gimp-drawable-filter-configure), (gimp-drawable-merge-filter) and (gimp-drawable-append-filter) are proper Script-fu methods. I had to rename the PDB procedures for the 2 latter because they were clashing with these wrapper. I had not realized that private PDB procedures are still visible by Script-fu. This is not so glop. :-/ Right now, it doesn't look so useful compared to the -new- one-liner variant procedures. But it will make sense when I will add aux input C procedure wrappers.
This commit is contained in:
parent
6480ba2ad6
commit
a6392ed84a
6 changed files with 392 additions and 219 deletions
|
@ -605,7 +605,7 @@ drawable_mask_intersect_invoker (GimpProcedure *procedure,
|
||||||
}
|
}
|
||||||
|
|
||||||
static GimpValueArray *
|
static GimpValueArray *
|
||||||
drawable_append_filter_invoker (GimpProcedure *procedure,
|
drawable_append_filter_private_invoker (GimpProcedure *procedure,
|
||||||
Gimp *gimp,
|
Gimp *gimp,
|
||||||
GimpContext *context,
|
GimpContext *context,
|
||||||
GimpProgress *progress,
|
GimpProgress *progress,
|
||||||
|
@ -666,7 +666,7 @@ drawable_append_filter_invoker (GimpProcedure *procedure,
|
||||||
}
|
}
|
||||||
|
|
||||||
static GimpValueArray *
|
static GimpValueArray *
|
||||||
drawable_merge_filter_invoker (GimpProcedure *procedure,
|
drawable_merge_filter_private_invoker (GimpProcedure *procedure,
|
||||||
Gimp *gimp,
|
Gimp *gimp,
|
||||||
GimpContext *context,
|
GimpContext *context,
|
||||||
GimpProgress *progress,
|
GimpProgress *progress,
|
||||||
|
@ -1711,16 +1711,17 @@ register_drawable_procs (GimpPDB *pdb)
|
||||||
g_object_unref (procedure);
|
g_object_unref (procedure);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* gimp-drawable-append-filter
|
* gimp-drawable-append-filter-private
|
||||||
*/
|
*/
|
||||||
procedure = gimp_procedure_new (drawable_append_filter_invoker);
|
procedure = gimp_procedure_new (drawable_append_filter_private_invoker);
|
||||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||||
"gimp-drawable-append-filter");
|
"gimp-drawable-append-filter-private");
|
||||||
gimp_procedure_set_static_help (procedure,
|
gimp_procedure_set_static_help (procedure,
|
||||||
"Append the specified effect to the top of the list of drawable effects.",
|
"Append the specified effect to the top of the list of drawable effects.",
|
||||||
"This procedure adds the specified drawable effect at the top of the effect list of @drawable.\n"
|
"This procedure adds the specified drawable effect at the top of the effect list of @drawable.\n"
|
||||||
"The @drawable argument must be the same as the one used when you created the effect with [ctor@Gimp.DrawableFilter.new].\n"
|
"The @drawable argument must be the same as the one used when you created the effect with [ctor@Gimp.DrawableFilter.new].\n"
|
||||||
"Some effects may be slower than others to render. In order to minimize processing time, it is preferred to customize the operation's arguments as received with [method@Gimp.DrawableFilter.get_config] then sync them to the application with [method@Gimp.DrawableFilter.update] before adding the effect.",
|
"Some effects may be slower than others to render. In order to minimize processing time, it is preferred to customize the operation's arguments as received with [method@Gimp.DrawableFilter.get_config] then sync them to the application with [method@Gimp.DrawableFilter.update] before adding the effect.\n"
|
||||||
|
"This function is private and should not be used. Use [method@Gimp.Drawable.append_filter] instead.",
|
||||||
NULL);
|
NULL);
|
||||||
gimp_procedure_set_static_attribution (procedure,
|
gimp_procedure_set_static_attribution (procedure,
|
||||||
"Jehan",
|
"Jehan",
|
||||||
|
@ -1742,16 +1743,17 @@ register_drawable_procs (GimpPDB *pdb)
|
||||||
g_object_unref (procedure);
|
g_object_unref (procedure);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* gimp-drawable-merge-filter
|
* gimp-drawable-merge-filter-private
|
||||||
*/
|
*/
|
||||||
procedure = gimp_procedure_new (drawable_merge_filter_invoker);
|
procedure = gimp_procedure_new (drawable_merge_filter_private_invoker);
|
||||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||||
"gimp-drawable-merge-filter");
|
"gimp-drawable-merge-filter-private");
|
||||||
gimp_procedure_set_static_help (procedure,
|
gimp_procedure_set_static_help (procedure,
|
||||||
"Apply the specified effect directly to the drawable.",
|
"Apply the specified effect directly to the drawable.",
|
||||||
"This procedure applies the specified drawable effect on @drawable and merge it (therefore before non-destructive effects are computed).\n"
|
"This procedure applies the specified drawable effect on @drawable and merge it (therefore before non-destructive effects are computed).\n"
|
||||||
"The @drawable argument must be the same as the one used when you created the effect with [ctor@Gimp.DrawableFilter.new].\n"
|
"The @drawable argument must be the same as the one used when you created the effect with [ctor@Gimp.DrawableFilter.new].\n"
|
||||||
"Once this is run, @filter is not valid anymore and you should not try to do anything with it. In particular, you must customize the operation's arguments as received with [method@Gimp.DrawableFilter.get_config] then sync them to the application with [method@Gimp.DrawableFilter.update] before merging the effect.",
|
"Once this is run, @filter is not valid anymore and you should not try to do anything with it. In particular, you must customize the operation's arguments as received with [method@Gimp.DrawableFilter.get_config] then sync them to the application with [method@Gimp.DrawableFilter.update] before merging the effect.\n"
|
||||||
|
"This function is private and should not be used. Use [method@Gimp.Drawable.merge_filter] instead.",
|
||||||
NULL);
|
NULL);
|
||||||
gimp_procedure_set_static_attribution (procedure,
|
gimp_procedure_set_static_attribution (procedure,
|
||||||
"Jehan",
|
"Jehan",
|
||||||
|
|
|
@ -461,7 +461,7 @@ gimp_drawable_append_filter (GimpDrawable *drawable,
|
||||||
g_return_if_fail (GIMP_IS_DRAWABLE_FILTER (filter));
|
g_return_if_fail (GIMP_IS_DRAWABLE_FILTER (filter));
|
||||||
|
|
||||||
gimp_drawable_filter_update (filter);
|
gimp_drawable_filter_update (filter);
|
||||||
_gimp_drawable_append_filter (drawable, filter);
|
_gimp_drawable_append_filter_private (drawable, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -491,7 +491,7 @@ gimp_drawable_merge_filter (GimpDrawable *drawable,
|
||||||
g_return_if_fail (GIMP_IS_DRAWABLE_FILTER (filter));
|
g_return_if_fail (GIMP_IS_DRAWABLE_FILTER (filter));
|
||||||
|
|
||||||
gimp_drawable_filter_update (filter);
|
gimp_drawable_filter_update (filter);
|
||||||
_gimp_drawable_merge_filter (drawable, filter);
|
_gimp_drawable_merge_filter_private (drawable, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -677,7 +677,7 @@ gimp_drawable_mask_intersect (GimpDrawable *drawable,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _gimp_drawable_append_filter:
|
* _gimp_drawable_append_filter_private:
|
||||||
* @drawable: The drawable.
|
* @drawable: The drawable.
|
||||||
* @filter: The drawable filter to append.
|
* @filter: The drawable filter to append.
|
||||||
*
|
*
|
||||||
|
@ -694,13 +694,15 @@ gimp_drawable_mask_intersect (GimpDrawable *drawable,
|
||||||
* [method@Gimp.DrawableFilter.get_config] then sync them to the
|
* [method@Gimp.DrawableFilter.get_config] then sync them to the
|
||||||
* application with [method@Gimp.DrawableFilter.update] before adding
|
* application with [method@Gimp.DrawableFilter.update] before adding
|
||||||
* the effect.
|
* the effect.
|
||||||
|
* This function is private and should not be used. Use
|
||||||
|
* [method@Gimp.Drawable.append_filter] instead.
|
||||||
*
|
*
|
||||||
* Returns: TRUE on success.
|
* Returns: TRUE on success.
|
||||||
*
|
*
|
||||||
* Since: 3.0
|
* Since: 3.0
|
||||||
**/
|
**/
|
||||||
gboolean
|
gboolean
|
||||||
_gimp_drawable_append_filter (GimpDrawable *drawable,
|
_gimp_drawable_append_filter_private (GimpDrawable *drawable,
|
||||||
GimpDrawableFilter *filter)
|
GimpDrawableFilter *filter)
|
||||||
{
|
{
|
||||||
GimpValueArray *args;
|
GimpValueArray *args;
|
||||||
|
@ -713,7 +715,7 @@ _gimp_drawable_append_filter (GimpDrawable *drawable,
|
||||||
G_TYPE_NONE);
|
G_TYPE_NONE);
|
||||||
|
|
||||||
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
||||||
"gimp-drawable-append-filter",
|
"gimp-drawable-append-filter-private",
|
||||||
args);
|
args);
|
||||||
gimp_value_array_unref (args);
|
gimp_value_array_unref (args);
|
||||||
|
|
||||||
|
@ -725,7 +727,7 @@ _gimp_drawable_append_filter (GimpDrawable *drawable,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _gimp_drawable_merge_filter:
|
* _gimp_drawable_merge_filter_private:
|
||||||
* @drawable: The drawable.
|
* @drawable: The drawable.
|
||||||
* @filter: The drawable filter to merge.
|
* @filter: The drawable filter to merge.
|
||||||
*
|
*
|
||||||
|
@ -742,13 +744,15 @@ _gimp_drawable_append_filter (GimpDrawable *drawable,
|
||||||
* [method@Gimp.DrawableFilter.get_config] then sync them to the
|
* [method@Gimp.DrawableFilter.get_config] then sync them to the
|
||||||
* application with [method@Gimp.DrawableFilter.update] before merging
|
* application with [method@Gimp.DrawableFilter.update] before merging
|
||||||
* the effect.
|
* the effect.
|
||||||
|
* This function is private and should not be used. Use
|
||||||
|
* [method@Gimp.Drawable.merge_filter] instead.
|
||||||
*
|
*
|
||||||
* Returns: TRUE on success.
|
* Returns: TRUE on success.
|
||||||
*
|
*
|
||||||
* Since: 3.0
|
* Since: 3.0
|
||||||
**/
|
**/
|
||||||
gboolean
|
gboolean
|
||||||
_gimp_drawable_merge_filter (GimpDrawable *drawable,
|
_gimp_drawable_merge_filter_private (GimpDrawable *drawable,
|
||||||
GimpDrawableFilter *filter)
|
GimpDrawableFilter *filter)
|
||||||
{
|
{
|
||||||
GimpValueArray *args;
|
GimpValueArray *args;
|
||||||
|
@ -761,7 +765,7 @@ _gimp_drawable_merge_filter (GimpDrawable *drawable,
|
||||||
G_TYPE_NONE);
|
G_TYPE_NONE);
|
||||||
|
|
||||||
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
||||||
"gimp-drawable-merge-filter",
|
"gimp-drawable-merge-filter-private",
|
||||||
args);
|
args);
|
||||||
gimp_value_array_unref (args);
|
gimp_value_array_unref (args);
|
||||||
|
|
||||||
|
|
|
@ -63,9 +63,9 @@ gboolean gimp_drawable_mask_intersect (GimpDrawable
|
||||||
gint *y,
|
gint *y,
|
||||||
gint *width,
|
gint *width,
|
||||||
gint *height);
|
gint *height);
|
||||||
G_GNUC_INTERNAL gboolean _gimp_drawable_append_filter (GimpDrawable *drawable,
|
G_GNUC_INTERNAL gboolean _gimp_drawable_append_filter_private (GimpDrawable *drawable,
|
||||||
GimpDrawableFilter *filter);
|
GimpDrawableFilter *filter);
|
||||||
G_GNUC_INTERNAL gboolean _gimp_drawable_merge_filter (GimpDrawable *drawable,
|
G_GNUC_INTERNAL gboolean _gimp_drawable_merge_filter_private (GimpDrawable *drawable,
|
||||||
GimpDrawableFilter *filter);
|
GimpDrawableFilter *filter);
|
||||||
GimpDrawableFilter** gimp_drawable_get_filters (GimpDrawable *drawable);
|
GimpDrawableFilter** gimp_drawable_get_filters (GimpDrawable *drawable);
|
||||||
gboolean gimp_drawable_merge_filters (GimpDrawable *drawable);
|
gboolean gimp_drawable_merge_filters (GimpDrawable *drawable);
|
||||||
|
|
|
@ -111,7 +111,7 @@ CODE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub drawable_append_filter {
|
sub drawable_append_filter_private {
|
||||||
$blurb = 'Append the specified effect to the top of the list of drawable effects.';
|
$blurb = 'Append the specified effect to the top of the list of drawable effects.';
|
||||||
|
|
||||||
$help = <<'HELP';
|
$help = <<'HELP';
|
||||||
|
@ -125,6 +125,9 @@ processing time, it is preferred to customize the operation's arguments
|
||||||
as received with [method@Gimp.DrawableFilter.get_config] then sync them
|
as received with [method@Gimp.DrawableFilter.get_config] then sync them
|
||||||
to the application with [method@Gimp.DrawableFilter.update] before
|
to the application with [method@Gimp.DrawableFilter.update] before
|
||||||
adding the effect.
|
adding the effect.
|
||||||
|
|
||||||
|
This function is private and should not be used. Use
|
||||||
|
[method@Gimp.Drawable.append_filter] instead.
|
||||||
HELP
|
HELP
|
||||||
|
|
||||||
&jehan_pdb_misc('2024', '3.0');
|
&jehan_pdb_misc('2024', '3.0');
|
||||||
|
@ -182,7 +185,7 @@ HELP
|
||||||
CODE
|
CODE
|
||||||
}
|
}
|
||||||
|
|
||||||
sub drawable_merge_filter {
|
sub drawable_merge_filter_private {
|
||||||
$blurb = 'Apply the specified effect directly to the drawable.';
|
$blurb = 'Apply the specified effect directly to the drawable.';
|
||||||
|
|
||||||
$help = <<'HELP';
|
$help = <<'HELP';
|
||||||
|
@ -197,6 +200,9 @@ do anything with it. In particular, you must customize the operation's
|
||||||
arguments as received with [method@Gimp.DrawableFilter.get_config] then
|
arguments as received with [method@Gimp.DrawableFilter.get_config] then
|
||||||
sync them to the application with [method@Gimp.DrawableFilter.update]
|
sync them to the application with [method@Gimp.DrawableFilter.update]
|
||||||
before merging the effect.
|
before merging the effect.
|
||||||
|
|
||||||
|
This function is private and should not be used. Use
|
||||||
|
[method@Gimp.Drawable.merge_filter] instead.
|
||||||
HELP
|
HELP
|
||||||
|
|
||||||
&jehan_pdb_misc('2024', '3.0');
|
&jehan_pdb_misc('2024', '3.0');
|
||||||
|
@ -1225,8 +1231,8 @@ CODE
|
||||||
drawable_get_offsets
|
drawable_get_offsets
|
||||||
drawable_mask_bounds
|
drawable_mask_bounds
|
||||||
drawable_mask_intersect
|
drawable_mask_intersect
|
||||||
drawable_append_filter
|
drawable_append_filter_private
|
||||||
drawable_merge_filter
|
drawable_merge_filter_private
|
||||||
drawable_get_filters
|
drawable_get_filters
|
||||||
drawable_merge_filters
|
drawable_merge_filters
|
||||||
drawable_merge_shadow
|
drawable_merge_shadow
|
||||||
|
|
|
@ -88,10 +88,16 @@ static pointer script_fu_marshal_drawable_create_filter (scheme
|
||||||
const gchar *proc_name,
|
const gchar *proc_name,
|
||||||
GimpDrawable **drawable,
|
GimpDrawable **drawable,
|
||||||
GimpDrawableFilter **filter);
|
GimpDrawableFilter **filter);
|
||||||
|
static pointer script_fu_marshal_drawable_filter_configure_call (scheme *sc,
|
||||||
|
pointer a);
|
||||||
static pointer script_fu_marshal_drawable_merge_filter_call (scheme *sc,
|
static pointer script_fu_marshal_drawable_merge_filter_call (scheme *sc,
|
||||||
pointer a);
|
pointer a);
|
||||||
static pointer script_fu_marshal_drawable_append_filter_call (scheme *sc,
|
static pointer script_fu_marshal_drawable_append_filter_call (scheme *sc,
|
||||||
pointer a);
|
pointer a);
|
||||||
|
static pointer script_fu_marshal_drawable_merge_new_filter_call (scheme *sc,
|
||||||
|
pointer a);
|
||||||
|
static pointer script_fu_marshal_drawable_append_new_filter_call (scheme *sc,
|
||||||
|
pointer a);
|
||||||
|
|
||||||
static pointer script_fu_register_call (scheme *sc,
|
static pointer script_fu_register_call (scheme *sc,
|
||||||
pointer a);
|
pointer a);
|
||||||
|
@ -562,8 +568,11 @@ ts_define_procedure (sc, "load-extension", scm_load_ext);
|
||||||
ts_define_procedure (sc, "-gimp-proc-db-call", script_fu_marshal_procedure_call_permissive);
|
ts_define_procedure (sc, "-gimp-proc-db-call", script_fu_marshal_procedure_call_permissive);
|
||||||
ts_define_procedure (sc, "--gimp-proc-db-call", script_fu_marshal_procedure_call_deprecated);
|
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-filter-configure", script_fu_marshal_drawable_filter_configure_call);
|
||||||
ts_define_procedure (sc, "gimp-drawable-append-new-filter", script_fu_marshal_drawable_append_filter_call);
|
ts_define_procedure (sc, "gimp-drawable-merge-filter", script_fu_marshal_drawable_merge_filter_call);
|
||||||
|
ts_define_procedure (sc, "gimp-drawable-append-filter", script_fu_marshal_drawable_append_filter_call);
|
||||||
|
ts_define_procedure (sc, "gimp-drawable-merge-new-filter", script_fu_marshal_drawable_merge_new_filter_call);
|
||||||
|
ts_define_procedure (sc, "gimp-drawable-append-new-filter", script_fu_marshal_drawable_append_new_filter_call);
|
||||||
|
|
||||||
/* Define each PDB procedure as a scheme func.
|
/* Define each PDB procedure as a scheme func.
|
||||||
* Each call passes through one of the wrapper funcs.
|
* Each call passes through one of the wrapper funcs.
|
||||||
|
@ -1583,6 +1592,74 @@ script_fu_marshal_procedure_call_deprecated (scheme *sc,
|
||||||
return script_fu_marshal_procedure_call (sc, a, TRUE, TRUE);
|
return script_fu_marshal_procedure_call (sc, a, TRUE, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static pointer
|
||||||
|
script_fu_marshal_drawable_filter_configure (scheme *sc,
|
||||||
|
pointer a,
|
||||||
|
const gchar *proc_name,
|
||||||
|
GimpDrawableFilter *filter)
|
||||||
|
{
|
||||||
|
pointer return_val = sc->NIL;
|
||||||
|
GimpLayerMode mode = GIMP_LAYER_MODE_REPLACE;
|
||||||
|
gdouble opacity = 1.0;
|
||||||
|
GimpDrawableFilterConfig *config;
|
||||||
|
gint arg_index;
|
||||||
|
gchar error_str[1024];
|
||||||
|
|
||||||
|
if (sc->vptr->list_length (sc, a) > 0)
|
||||||
|
{
|
||||||
|
mode = sc->vptr->ivalue (sc->vptr->pair_car (a));
|
||||||
|
a = sc->vptr->pair_cdr (a);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sc->vptr->list_length (sc, a) > 0)
|
||||||
|
{
|
||||||
|
opacity = sc->vptr->rvalue (sc->vptr->pair_car (a));
|
||||||
|
a = sc->vptr->pair_cdr (a);
|
||||||
|
}
|
||||||
|
gimp_drawable_filter_set_opacity (filter, opacity);
|
||||||
|
gimp_drawable_filter_set_blend_mode (filter, mode);
|
||||||
|
|
||||||
|
config = gimp_drawable_filter_get_config (filter);
|
||||||
|
arg_index = 3;
|
||||||
|
while (sc->vptr->list_length (sc, a) > 1)
|
||||||
|
{
|
||||||
|
gchar *argname;
|
||||||
|
GParamSpec *arg_spec;
|
||||||
|
GValue value = G_VALUE_INIT;
|
||||||
|
|
||||||
|
argname = g_strdup (sc->vptr->string_value (sc->vptr->pair_car (a)));
|
||||||
|
arg_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (config), argname);
|
||||||
|
if (arg_spec == NULL)
|
||||||
|
{
|
||||||
|
g_snprintf (error_str, sizeof (error_str),
|
||||||
|
"Invalid argument name: %s", argname);
|
||||||
|
g_free (argname);
|
||||||
|
gimp_drawable_filter_delete (filter);
|
||||||
|
return script_error (sc, error_str, 0);
|
||||||
|
}
|
||||||
|
g_value_init (&value, arg_spec->value_type);
|
||||||
|
a = sc->vptr->pair_cdr (a);
|
||||||
|
|
||||||
|
return_val = script_fu_marshal_arg_to_value (sc, a, proc_name, arg_index, arg_spec, &value);
|
||||||
|
|
||||||
|
if (return_val != sc->NIL)
|
||||||
|
{
|
||||||
|
g_value_unset (&value);
|
||||||
|
g_free (argname);
|
||||||
|
gimp_drawable_filter_delete (filter);
|
||||||
|
return return_val;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_set_property (G_OBJECT (config), argname, &value);
|
||||||
|
g_value_unset (&value);
|
||||||
|
|
||||||
|
a = sc->vptr->pair_cdr (a);
|
||||||
|
arg_index += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sc->NIL;
|
||||||
|
}
|
||||||
|
|
||||||
static pointer
|
static pointer
|
||||||
script_fu_marshal_drawable_create_filter (scheme *sc,
|
script_fu_marshal_drawable_create_filter (scheme *sc,
|
||||||
pointer a,
|
pointer a,
|
||||||
|
@ -1590,13 +1667,8 @@ script_fu_marshal_drawable_create_filter (scheme *sc,
|
||||||
GimpDrawable **drawable,
|
GimpDrawable **drawable,
|
||||||
GimpDrawableFilter **filter)
|
GimpDrawableFilter **filter)
|
||||||
{
|
{
|
||||||
pointer return_val = sc->NIL;
|
|
||||||
gchar *operation_name;
|
gchar *operation_name;
|
||||||
gchar *filter_name = NULL;
|
gchar *filter_name = NULL;
|
||||||
GimpLayerMode mode = GIMP_LAYER_MODE_REPLACE;
|
|
||||||
gdouble opacity = 1.0;
|
|
||||||
GimpDrawableFilterConfig *config;
|
|
||||||
gint arg_index;
|
|
||||||
gchar error_str[1024];
|
gchar error_str[1024];
|
||||||
|
|
||||||
if (sc->vptr->list_length (sc, a) < 2)
|
if (sc->vptr->list_length (sc, a) < 2)
|
||||||
|
@ -1605,7 +1677,7 @@ script_fu_marshal_drawable_create_filter (scheme *sc,
|
||||||
"Drawable Filter marshaller was called with missing arguments. "
|
"Drawable Filter marshaller was called with missing arguments. "
|
||||||
"The drawable ID, the GEGL operation, filter name, blend mode, opacity "
|
"The drawable ID, the GEGL operation, filter name, blend mode, opacity "
|
||||||
"and the arguments' names and values it requires (possibly none) must be specified: "
|
"and the arguments' names and values it requires (possibly none) must be specified: "
|
||||||
"(%s drawable op title mode arg1 val1 arg2 val2...)",
|
"(%s drawable op title mode opacity arg1 val1 arg2 val2...)",
|
||||||
proc_name);
|
proc_name);
|
||||||
return implementation_error (sc, error_str, 0);
|
return implementation_error (sc, error_str, 0);
|
||||||
}
|
}
|
||||||
|
@ -1615,7 +1687,7 @@ script_fu_marshal_drawable_create_filter (scheme *sc,
|
||||||
"Drawable Filter marshaller was called with an even number of arguments. "
|
"Drawable Filter marshaller was called with an even number of arguments. "
|
||||||
"The drawable ID, the GEGL operation, filter name, blend mode, opacity "
|
"The drawable ID, the GEGL operation, filter name, blend mode, opacity "
|
||||||
"and the arguments' names and values it requires (possibly none) must be specified: "
|
"and the arguments' names and values it requires (possibly none) must be specified: "
|
||||||
"(%s drawable op title mode arg1 val1 arg2 val2...)",
|
"(%s drawable op title mode opacity arg1 val1 arg2 val2...)",
|
||||||
proc_name);
|
proc_name);
|
||||||
return implementation_error (sc, error_str, 0);
|
return implementation_error (sc, error_str, 0);
|
||||||
}
|
}
|
||||||
|
@ -1652,18 +1724,6 @@ script_fu_marshal_drawable_create_filter (scheme *sc,
|
||||||
a = sc->vptr->pair_cdr (a);
|
a = sc->vptr->pair_cdr (a);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sc->vptr->list_length (sc, a) > 0)
|
|
||||||
{
|
|
||||||
mode = sc->vptr->ivalue (sc->vptr->pair_car (a));
|
|
||||||
a = sc->vptr->pair_cdr (a);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sc->vptr->list_length (sc, a) > 0)
|
|
||||||
{
|
|
||||||
opacity = sc->vptr->rvalue (sc->vptr->pair_car (a));
|
|
||||||
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);
|
g_free (filter_name);
|
||||||
|
|
||||||
|
@ -1676,52 +1736,153 @@ script_fu_marshal_drawable_create_filter (scheme *sc,
|
||||||
}
|
}
|
||||||
g_free (operation_name);
|
g_free (operation_name);
|
||||||
|
|
||||||
gimp_drawable_filter_set_opacity (*filter, opacity);
|
return script_fu_marshal_drawable_filter_configure (sc, a, proc_name, *filter);
|
||||||
gimp_drawable_filter_set_blend_mode (*filter, mode);
|
}
|
||||||
|
|
||||||
config = gimp_drawable_filter_get_config (*filter);
|
static pointer
|
||||||
arg_index = 5;
|
script_fu_marshal_drawable_filter_configure_call (scheme *sc,
|
||||||
while (sc->vptr->list_length (sc, a) > 1)
|
pointer a)
|
||||||
{
|
{
|
||||||
gchar *argname;
|
GimpDrawableFilter *filter = NULL;
|
||||||
GParamSpec *arg_spec;
|
const gchar *proc_name = "gimp-drawable-filter-configure";
|
||||||
GValue value = G_VALUE_INIT;
|
gchar error_str[1024];
|
||||||
|
|
||||||
argname = g_strdup (sc->vptr->string_value (sc->vptr->pair_car (a)));
|
if (sc->vptr->list_length (sc, a) < 3)
|
||||||
arg_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (config), argname);
|
|
||||||
if (arg_spec == NULL)
|
|
||||||
{
|
{
|
||||||
g_snprintf (error_str, sizeof (error_str),
|
g_snprintf (error_str, sizeof (error_str),
|
||||||
"Invalid argument name: %s", argname);
|
"Drawable Filter marshaller was called with missing arguments. "
|
||||||
g_free (argname);
|
"The filter ID, blend mode, opacity and the arguments' names "
|
||||||
gimp_drawable_filter_delete (*filter);
|
"and values it requires (possibly none) must be specified: "
|
||||||
|
"(%s mode opacity arg1 val1 arg2 val2...)",
|
||||||
|
proc_name);
|
||||||
|
return implementation_error (sc, error_str, 0);
|
||||||
|
}
|
||||||
|
else if (sc->vptr->list_length (sc, a) > 3 && 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 mode opacity 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
|
||||||
|
{
|
||||||
|
gint id;
|
||||||
|
|
||||||
|
id = sc->vptr->ivalue (sc->vptr->pair_car (a));
|
||||||
|
filter = gimp_drawable_filter_get_by_id (id);
|
||||||
|
|
||||||
|
if (filter == NULL || ! GIMP_IS_DRAWABLE_FILTER (filter))
|
||||||
|
{
|
||||||
|
g_snprintf (error_str, sizeof (error_str),
|
||||||
|
"Invalid Drawable Filter ID: %d", id);
|
||||||
return script_error (sc, error_str, 0);
|
return script_error (sc, error_str, 0);
|
||||||
}
|
}
|
||||||
g_value_init (&value, arg_spec->value_type);
|
|
||||||
a = sc->vptr->pair_cdr (a);
|
a = sc->vptr->pair_cdr (a);
|
||||||
|
}
|
||||||
|
|
||||||
return_val = script_fu_marshal_arg_to_value (sc, a, proc_name, arg_index, arg_spec, &value);
|
return script_fu_marshal_drawable_filter_configure (sc, a, proc_name, filter);
|
||||||
|
}
|
||||||
|
|
||||||
if (return_val != sc->NIL)
|
static pointer
|
||||||
|
script_fu_marshal_drawable_merge_filter_call (scheme *sc,
|
||||||
|
pointer a)
|
||||||
|
{
|
||||||
|
const gchar *proc_name = "gimp-drawable-merge-filter";
|
||||||
|
GimpItem *item;
|
||||||
|
GimpDrawableFilter *filter;
|
||||||
|
gint id;
|
||||||
|
gchar error_str[1024];
|
||||||
|
|
||||||
|
if (sc->vptr->list_length (sc, a) != 2)
|
||||||
{
|
{
|
||||||
g_value_unset (&value);
|
g_snprintf (error_str, sizeof (error_str),
|
||||||
g_free (argname);
|
"Drawable Filter marshaller was called with missing arguments. "
|
||||||
gimp_drawable_filter_delete (*filter);
|
"The drawable and filter IDs are required: "
|
||||||
return return_val;
|
"(%s mode opacity arg1 val1 arg2 val2...)",
|
||||||
|
proc_name);
|
||||||
|
|
||||||
|
return implementation_error (sc, error_str, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_set_property (G_OBJECT (config), argname, &value);
|
id = sc->vptr->ivalue (sc->vptr->pair_car (a));
|
||||||
g_value_unset (&value);
|
item = gimp_item_get_by_id (id);
|
||||||
|
if (item == NULL || ! GIMP_IS_DRAWABLE (item))
|
||||||
|
{
|
||||||
|
g_snprintf (error_str, sizeof (error_str),
|
||||||
|
"Invalid Drawable ID: %d", id);
|
||||||
|
return script_error (sc, error_str, 0);
|
||||||
|
}
|
||||||
a = sc->vptr->pair_cdr (a);
|
a = sc->vptr->pair_cdr (a);
|
||||||
arg_index += 2;
|
|
||||||
|
id = sc->vptr->ivalue (sc->vptr->pair_car (a));
|
||||||
|
filter = gimp_drawable_filter_get_by_id (id);
|
||||||
|
if (filter == NULL || ! GIMP_IS_DRAWABLE_FILTER (filter))
|
||||||
|
{
|
||||||
|
g_snprintf (error_str, sizeof (error_str),
|
||||||
|
"Invalid Drawable Filter ID: %d", id);
|
||||||
|
return script_error (sc, error_str, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gimp_drawable_merge_filter (GIMP_DRAWABLE (item), filter);
|
||||||
|
|
||||||
return sc->NIL;
|
return sc->NIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static pointer
|
static pointer
|
||||||
script_fu_marshal_drawable_merge_filter_call (scheme *sc,
|
script_fu_marshal_drawable_append_filter_call (scheme *sc,
|
||||||
|
pointer a)
|
||||||
|
{
|
||||||
|
const gchar *proc_name = "gimp-drawable-append-filter";
|
||||||
|
GimpItem *item;
|
||||||
|
GimpDrawableFilter *filter;
|
||||||
|
gint id;
|
||||||
|
gchar error_str[1024];
|
||||||
|
|
||||||
|
if (sc->vptr->list_length (sc, a) != 2)
|
||||||
|
{
|
||||||
|
g_snprintf (error_str, sizeof (error_str),
|
||||||
|
"Drawable Filter marshaller was called with missing arguments. "
|
||||||
|
"The drawable and filter IDs are required: "
|
||||||
|
"(%s mode opacity arg1 val1 arg2 val2...)",
|
||||||
|
proc_name);
|
||||||
|
|
||||||
|
return implementation_error (sc, error_str, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
id = sc->vptr->ivalue (sc->vptr->pair_car (a));
|
||||||
|
item = gimp_item_get_by_id (id);
|
||||||
|
if (item == NULL || ! GIMP_IS_DRAWABLE (item))
|
||||||
|
{
|
||||||
|
g_snprintf (error_str, sizeof (error_str),
|
||||||
|
"Invalid Drawable ID: %d", id);
|
||||||
|
return script_error (sc, error_str, 0);
|
||||||
|
}
|
||||||
|
a = sc->vptr->pair_cdr (a);
|
||||||
|
|
||||||
|
id = sc->vptr->ivalue (sc->vptr->pair_car (a));
|
||||||
|
filter = gimp_drawable_filter_get_by_id (id);
|
||||||
|
if (filter == NULL || ! GIMP_IS_DRAWABLE_FILTER (filter))
|
||||||
|
{
|
||||||
|
g_snprintf (error_str, sizeof (error_str),
|
||||||
|
"Invalid Drawable Filter ID: %d", id);
|
||||||
|
return script_error (sc, error_str, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
gimp_drawable_append_filter (GIMP_DRAWABLE (item), filter);
|
||||||
|
|
||||||
|
return sc->NIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static pointer
|
||||||
|
script_fu_marshal_drawable_merge_new_filter_call (scheme *sc,
|
||||||
pointer a)
|
pointer a)
|
||||||
{
|
{
|
||||||
GimpDrawable *drawable = NULL;
|
GimpDrawable *drawable = NULL;
|
||||||
|
@ -1740,7 +1901,7 @@ script_fu_marshal_drawable_merge_filter_call (scheme *sc,
|
||||||
}
|
}
|
||||||
|
|
||||||
static pointer
|
static pointer
|
||||||
script_fu_marshal_drawable_append_filter_call (scheme *sc,
|
script_fu_marshal_drawable_append_new_filter_call (scheme *sc,
|
||||||
pointer a)
|
pointer a)
|
||||||
{
|
{
|
||||||
GimpDrawable *drawable = NULL;
|
GimpDrawable *drawable = NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue