app, libgimp, pdb: passing GimpDrawableFilter across the wire.

A few functions were added, but the main one is
gimp_drawable_get_filters() to request the list of filters applied
non-destructively on a drawable. We can't do much with these for the
time being, but this will come.
WIP.
This commit is contained in:
Jehan 2024-11-25 04:38:39 +09:00
parent 1d7d3ab621
commit 08362d1e7b
31 changed files with 925 additions and 1 deletions

View File

@ -30,6 +30,7 @@
#include "gimpbrush.h"
#include "gimpcontext.h"
#include "gimpdisplay.h"
#include "gimpdrawablefilter.h"
#include "gimpgradient.h"
#include "gimpgrouplayer.h"
#include "gimpimage.h"

View File

@ -36,6 +36,7 @@
#include "config/gimpcoreconfig.h"
#include "core/gimp.h"
#include "core/gimpchannel-select.h"
#include "core/gimpcontainer.h"
#include "core/gimpdrawable-fill.h"
#include "core/gimpdrawable-filters.h"
#include "core/gimpdrawable-foreground-extract.h"
@ -43,7 +44,9 @@
#include "core/gimpdrawable-preview.h"
#include "core/gimpdrawable-shadow.h"
#include "core/gimpdrawable.h"
#include "core/gimpdrawablefilter.h"
#include "core/gimpimage.h"
#include "core/gimplist.h"
#include "core/gimpparamspecs.h"
#include "core/gimptempbuf.h"
#include "gegl/gimp-babl-compat.h"
@ -598,6 +601,46 @@ drawable_mask_intersect_invoker (GimpProcedure *procedure,
return return_vals;
}
static GimpValueArray *
drawable_get_filters_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpValueArray *return_vals;
GimpDrawable *drawable;
GimpDrawableFilter **filters = NULL;
drawable = g_value_get_object (gimp_value_array_index (args, 0));
if (success)
{
GimpContainer *container;
GList *iter;
gsize num_filters;
gint i;
container = gimp_drawable_get_filters (drawable);
num_filters = gimp_container_get_n_children (container);
filters = g_new0 (GimpDrawableFilter *, num_filters + 1);
iter = GIMP_LIST (container)->queue->head;
for (i = 0; i < num_filters; i++, iter = iter->next)
filters[i] = iter->data;
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_take_boxed (gimp_value_array_index (return_vals, 1), filters);
return return_vals;
}
static GimpValueArray *
drawable_merge_filters_invoker (GimpProcedure *procedure,
Gimp *gimp,
@ -1555,6 +1598,35 @@ register_drawable_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-drawable-get-filters
*/
procedure = gimp_procedure_new (drawable_get_filters_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-drawable-get-filters");
gimp_procedure_set_static_help (procedure,
"Returns the list of filters applied to the drawable.",
"This procedure returns the list of filters which are currently applied non-destructively to @drawable. The order of filters is from topmost to bottommost.",
NULL);
gimp_procedure_set_static_attribution (procedure,
"Jehan",
"Jehan",
"2024");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable ("drawable",
"drawable",
"The drawable",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_core_object_array ("filters",
"filters",
"The list of filters on the drawable.",
GIMP_TYPE_DRAWABLE_FILTER,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-drawable-merge-filters
*/

View File

@ -0,0 +1,102 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl. */
#include "config.h"
#include "stamp-pdbgen.h"
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libgimpbase/gimpbase.h"
#include "pdb-types.h"
#include "core/gimpdrawablefilter.h"
#include "core/gimpparamspecs.h"
#include "gimppdb.h"
#include "gimpprocedure.h"
#include "internal-procs.h"
static GimpValueArray *
drawable_filter_id_is_valid_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpValueArray *return_vals;
gint filter_id;
gboolean valid = FALSE;
filter_id = g_value_get_int (gimp_value_array_index (args, 0));
if (success)
{
valid = (gimp_drawable_filter_get_by_id (gimp, filter_id) != NULL);
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_boolean (gimp_value_array_index (return_vals, 1), valid);
return return_vals;
}
void
register_drawable_filter_procs (GimpPDB *pdb)
{
GimpProcedure *procedure;
/*
* gimp-drawable-filter-id-is-valid
*/
procedure = gimp_procedure_new (drawable_filter_id_is_valid_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-drawable-filter-id-is-valid");
gimp_procedure_set_static_help (procedure,
"Returns %TRUE if the drawable filter ID is valid.",
"This procedure checks if the given drawable filter ID is valid and refers to an existing filter.",
NULL);
gimp_procedure_set_static_attribution (procedure,
"Jehan",
"Jehan",
"2024");
gimp_procedure_add_argument (procedure,
g_param_spec_int ("filter-id",
"filter id",
"The filter ID to check",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_boolean ("valid",
"valid",
"Whether the filter ID is valid",
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

View File

@ -30,7 +30,7 @@
#include "internal-procs.h"
/* 718 procedures registered total */
/* 720 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)
@ -48,6 +48,7 @@ internal_procs_init (GimpPDB *pdb)
register_drawable_procs (pdb);
register_drawable_color_procs (pdb);
register_drawable_edit_procs (pdb);
register_drawable_filter_procs (pdb);
register_drawable_select_procs (pdb);
register_dynamics_procs (pdb);
register_edit_procs (pdb);

View File

@ -35,6 +35,7 @@ void register_display_procs (GimpPDB *pdb);
void register_drawable_procs (GimpPDB *pdb);
void register_drawable_color_procs (GimpPDB *pdb);
void register_drawable_edit_procs (GimpPDB *pdb);
void register_drawable_filter_procs (GimpPDB *pdb);
void register_drawable_select_procs (GimpPDB *pdb);
void register_dynamics_procs (GimpPDB *pdb);
void register_edit_procs (GimpPDB *pdb);

View File

@ -19,6 +19,7 @@ libappinternalprocs_sources = [
'drawable-cmds.c',
'drawable-color-cmds.c',
'drawable-edit-cmds.c',
'drawable-filter-cmds.c',
'drawable-select-cmds.c',
'dynamics-cmds.c',
'edit-cmds.c',

View File

@ -33,6 +33,7 @@
#include "core/gimp.h"
#include "core/gimpbrush.h"
#include "core/gimpdisplay.h"
#include "core/gimpdrawablefilter.h"
#include "core/gimpgradient.h"
#include "core/gimpgrouplayer.h"
#include "core/gimpimage.h"

View File

@ -445,6 +445,7 @@ gimp_main (GType plug_in_type,
GIMP_TYPE_LAYER_MASK, GIMP_TYPE_PARAM_LAYER_MASK,
GIMP_TYPE_SELECTION, GIMP_TYPE_PARAM_SELECTION,
GIMP_TYPE_PATH, GIMP_TYPE_PARAM_PATH,
GIMP_TYPE_DRAWABLE_FILTER, GIMP_TYPE_PARAM_DRAWABLE_FILTER,
GIMP_TYPE_BRUSH, GIMP_TYPE_PARAM_BRUSH,
GIMP_TYPE_FONT, GIMP_TYPE_PARAM_FONT,

View File

@ -211,11 +211,17 @@ EXPORTS
gimp_drawable_equalize
gimp_drawable_extract_component
gimp_drawable_fill
gimp_drawable_filter_get_by_id
gimp_drawable_filter_get_id
gimp_drawable_filter_get_type
gimp_drawable_filter_id_is_valid
gimp_drawable_filter_is_valid
gimp_drawable_foreground_extract
gimp_drawable_free_shadow
gimp_drawable_get_bpp
gimp_drawable_get_buffer
gimp_drawable_get_by_id
gimp_drawable_get_filters
gimp_drawable_get_format
gimp_drawable_get_height
gimp_drawable_get_offsets
@ -681,6 +687,7 @@ EXPORTS
gimp_param_brush_get_type
gimp_param_channel_get_type
gimp_param_display_get_type
gimp_param_drawable_filter_get_type
gimp_param_drawable_get_type
gimp_param_font_get_type
gimp_param_gradient_get_type
@ -698,6 +705,7 @@ EXPORTS
gimp_param_spec_channel
gimp_param_spec_display
gimp_param_spec_drawable
gimp_param_spec_drawable_filter
gimp_param_spec_font
gimp_param_spec_get_desc
gimp_param_spec_gradient

View File

@ -42,6 +42,7 @@
#include <libgimp/gimpchannel.h>
#include <libgimp/gimpdisplay.h>
#include <libgimp/gimpdrawable.h>
#include <libgimp/gimpdrawablefilter.h>
#include <libgimp/gimpexportoptions.h>
#include <libgimp/gimpexportprocedure.h>
#include <libgimp/gimpfont.h>

View File

@ -39,6 +39,7 @@
#include <libgimp/gimpdrawable_pdb.h>
#include <libgimp/gimpdrawablecolor_pdb.h>
#include <libgimp/gimpdrawableedit_pdb.h>
#include <libgimp/gimpdrawablefilter_pdb.h>
#include <libgimp/gimpdrawableselect_pdb.h>
#include <libgimp/gimpdynamics_pdb.h>
#include <libgimp/gimpedit_pdb.h>

View File

@ -676,6 +676,46 @@ gimp_drawable_mask_intersect (GimpDrawable *drawable,
return non_empty;
}
/**
* gimp_drawable_get_filters:
* @drawable: The drawable.
*
* Returns the list of filters applied to the drawable.
*
* This procedure returns the list of filters which are currently
* applied non-destructively to @drawable. The order of filters is from
* topmost to bottommost.
*
* Returns: (element-type GimpDrawableFilter) (array zero-terminated=1) (transfer container):
* The list of filters on the drawable.
* The returned value must be freed with g_free().
*
* Since: 3.0
**/
GimpDrawableFilter **
gimp_drawable_get_filters (GimpDrawable *drawable)
{
GimpValueArray *args;
GimpValueArray *return_vals;
GimpDrawableFilter **filters = NULL;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_DRAWABLE, drawable,
G_TYPE_NONE);
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-drawable-get-filters",
args);
gimp_value_array_unref (args);
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
filters = g_value_dup_boxed (gimp_value_array_index (return_vals, 1));
gimp_value_array_unref (return_vals);
return filters;
}
/**
* gimp_drawable_merge_filters:
* @drawable: The drawable.

View File

@ -63,6 +63,7 @@ gboolean gimp_drawable_mask_intersect (GimpDrawable
gint *y,
gint *width,
gint *height);
GimpDrawableFilter** gimp_drawable_get_filters (GimpDrawable *drawable);
gboolean gimp_drawable_merge_filters (GimpDrawable *drawable);
gboolean gimp_drawable_merge_shadow (GimpDrawable *drawable,
gboolean undo);

View File

@ -0,0 +1,184 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
*
* gimpdrawablefilter.c
* Copyright (C) 2024 Jehan
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gimp.h"
#include "libgimpbase/gimpwire.h" /* FIXME kill this include */
#include "gimpplugin-private.h"
enum
{
PROP_0,
PROP_ID,
N_PROPS
};
struct _GimpDrawableFilter
{
GObject parent_instance;
gint id;
};
static void gimp_drawable_filter_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_drawable_filter_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
G_DEFINE_TYPE (GimpDrawableFilter, gimp_drawable_filter, G_TYPE_OBJECT)
#define parent_class gimp_drawable_filter_parent_class
static GParamSpec *props[N_PROPS] = { NULL, };
static void
gimp_drawable_filter_class_init (GimpDrawableFilterClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->set_property = gimp_drawable_filter_set_property;
object_class->get_property = gimp_drawable_filter_get_property;
props[PROP_ID] =
g_param_spec_int ("id",
"The drawable_filter id",
"The drawable_filter id for internal use",
0, G_MAXINT32, 0,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_properties (object_class, N_PROPS, props);
}
static void
gimp_drawable_filter_init (GimpDrawableFilter *drawable_filter)
{
}
static void
gimp_drawable_filter_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpDrawableFilter *drawable_filter = GIMP_DRAWABLE_FILTER (object);
switch (property_id)
{
case PROP_ID:
drawable_filter->id = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_drawable_filter_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpDrawableFilter *drawable_filter = GIMP_DRAWABLE_FILTER (object);
switch (property_id)
{
case PROP_ID:
g_value_set_int (value, drawable_filter->id);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
/* Public API */
/**
* gimp_drawable_filter_get_id:
* @filter: The [class@Gimp.Drawable]'s filter.
*
* Returns: the drawable's filter ID.
*
* Since: 3.0
**/
gint32
gimp_drawable_filter_get_id (GimpDrawableFilter *filter)
{
return filter ? filter->id : -1;
}
/**
* gimp_drawable_filter_get_by_id:
* @filter_id: The %GimpDrawableFilter id.
*
* Returns: (nullable) (transfer none): a #GimpDrawableFilter for @filter_id or
* %NULL if @filter_id does not represent a valid drawable's filter.
* The object belongs to libgimp and you must not modify
* or unref it.
*
* Since: 3.0
**/
GimpDrawableFilter *
gimp_drawable_filter_get_by_id (gint32 filter_id)
{
if (filter_id > 0)
{
GimpPlugIn *plug_in = gimp_get_plug_in ();
return _gimp_plug_in_get_filter (plug_in, filter_id);
}
return NULL;
}
/**
* gimp_drawable_filter_is_valid:
* @filter: The drawable's filter to check.
*
* Returns TRUE if the @drawable_filter is valid.
*
* This procedure checks if the given filter is valid and refers to an
* existing %GimpDrawableFilter.
*
* Returns: Whether @drawable_filter is valid.
*
* Since: 3.0
**/
gboolean
gimp_drawable_filter_is_valid (GimpDrawableFilter *filter)
{
return gimp_drawable_filter_id_is_valid (gimp_drawable_filter_get_id (filter));
}

View File

@ -0,0 +1,47 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
*
* gimpdrawablefilter.h
* Copyright (C) 2024 Jehan
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#if !defined (__GIMP_H_INSIDE__) && !defined (GIMP_COMPILATION)
#error "Only <libgimp/gimp.h> can be included directly."
#endif
#ifndef __GIMP_DRAWABLE_FILTER_H__
#define __GIMP_DRAWABLE_FILTER_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
#define GIMP_TYPE_DRAWABLE_FILTER (gimp_drawable_filter_get_type ())
G_DECLARE_FINAL_TYPE (GimpDrawableFilter, gimp_drawable_filter, GIMP, DRAWABLE_FILTER, GObject)
gint32 gimp_drawable_filter_get_id (GimpDrawableFilter *filter);
GimpDrawableFilter * gimp_drawable_filter_get_by_id (gint32 filter_id);
gboolean gimp_drawable_filter_is_valid (GimpDrawableFilter *filter);
G_END_DECLS
#endif /* __GIMP_DRAWABLE_FILTER_H__ */

View File

@ -0,0 +1,74 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* gimpdrawablefilter_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "stamp-pdbgen.h"
#include "gimp.h"
/**
* SECTION: gimpdrawablefilter
* @title: gimpdrawablefilter
* @short_description: Operations on drawable filters.
*
* Operations on drawable filters: creation, editing.
**/
/**
* gimp_drawable_filter_id_is_valid:
* @filter_id: The filter ID to check.
*
* Returns %TRUE if the drawable filter ID is valid.
*
* This procedure checks if the given drawable filter ID is valid and
* refers to an existing filter.
*
* Returns: Whether the filter ID is valid.
*
* Since: 3.0
**/
gboolean
gimp_drawable_filter_id_is_valid (gint filter_id)
{
GimpValueArray *args;
GimpValueArray *return_vals;
gboolean valid = FALSE;
args = gimp_value_array_new_from_types (NULL,
G_TYPE_INT, filter_id,
G_TYPE_NONE);
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-drawable-filter-id-is-valid",
args);
gimp_value_array_unref (args);
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
valid = GIMP_VALUES_GET_BOOLEAN (return_vals, 1);
gimp_value_array_unref (return_vals);
return valid;
}

View File

@ -0,0 +1,40 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* gimpdrawablefilter_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__GIMP_H_INSIDE__) && !defined (GIMP_COMPILATION)
#error "Only <libgimp/gimp.h> can be included directly."
#endif
#ifndef __GIMP_DRAWABLE_FILTER_PDB_H__
#define __GIMP_DRAWABLE_FILTER_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gboolean gimp_drawable_filter_id_is_valid (gint filter_id);
G_END_DECLS
#endif /* __GIMP_DRAWABLE_FILTER_PDB_H__ */

View File

@ -637,6 +637,17 @@ get_item_by_id (gpointer gimp,
#endif
}
static GimpDrawableFilter *
get_filter_by_id (gpointer gimp,
gint id)
{
#ifdef LIBGIMP_COMPILATION
return gimp_drawable_filter_get_by_id (id);
#else
return gimp_drawable_filter_get_by_id (gimp, id);
#endif
}
static GimpDisplay *
get_display_by_id (gpointer gimp,
gint id)
@ -937,6 +948,10 @@ gimp_gp_param_to_value (gpointer gimp,
{
objects[i] = (GObject *) get_item_by_id (gimp, id);
}
else if (g_type_is_a (object_type, GIMP_TYPE_DRAWABLE_FILTER))
{
objects[i] = (GObject *) get_filter_by_id (gimp, id);
}
else if (g_type_is_a (object_type, GIMP_TYPE_DISPLAY))
{
objects[i] = (GObject *) get_display_by_id (gimp, id);
@ -960,6 +975,10 @@ gimp_gp_param_to_value (gpointer gimp,
{
g_value_set_object (value, get_item_by_id (gimp, param->data.d_int));
}
else if (GIMP_VALUE_HOLDS_DRAWABLE_FILTER (value))
{
g_value_set_object (value, get_filter_by_id (gimp, param->data.d_int));
}
else if (GIMP_VALUE_HOLDS_DISPLAY (value))
{
g_value_set_object (value, get_display_by_id (gimp, param->data.d_int));
@ -1390,6 +1409,10 @@ gimp_value_to_gp_param (const GValue *value,
{
element_type = GIMP_TYPE_ITEM;
}
else if (GIMP_IS_DRAWABLE_FILTER (array[i]))
{
element_type = GIMP_TYPE_DRAWABLE_FILTER;
}
else if (GIMP_IS_DISPLAY (array[i]))
{
element_type = GIMP_TYPE_DISPLAY;
@ -1431,6 +1454,11 @@ gimp_value_to_gp_param (const GValue *value,
param->data.d_id_array.data[i] =
gimp_item_get_id (GIMP_ITEM (array[i]));
}
else if (GIMP_IS_DRAWABLE_FILTER (array[i]))
{
param->data.d_id_array.data[i] =
gimp_drawable_filter_get_id (GIMP_DRAWABLE_FILTER (array[i]));
}
else if (GIMP_IS_DISPLAY (array[i]))
{
param->data.d_id_array.data[i] =
@ -1471,6 +1499,14 @@ gimp_value_to_gp_param (const GValue *value,
param->data.d_int = item ? gimp_item_get_id (item) : -1;
}
else if (GIMP_VALUE_HOLDS_DRAWABLE_FILTER (value))
{
GimpDrawableFilter *filter = g_value_get_object (value);
param->param_type = GP_PARAM_TYPE_INT;
param->data.d_int = filter ? gimp_drawable_filter_get_id (filter) : -1;
}
else if (GIMP_VALUE_HOLDS_DISPLAY (value))
{
GimpDisplay *display = g_value_get_object (value);

View File

@ -878,6 +878,86 @@ gimp_param_spec_path (const gchar *name,
}
/*
* GIMP_TYPE_PARAM_DRAWABLE_FILTER
*/
static void gimp_param_drawable_filter_class_init (GParamSpecClass *klass);
static void gimp_param_drawable_filter_init (GParamSpec *pspec);
GType
gimp_param_drawable_filter_get_type (void)
{
static GType type = 0;
if (! type)
{
const GTypeInfo info =
{
sizeof (GParamSpecClass),
NULL, NULL,
(GClassInitFunc) gimp_param_drawable_filter_class_init,
NULL, NULL,
sizeof (GimpParamSpecDrawableFilter),
0,
(GInstanceInitFunc) gimp_param_drawable_filter_init
};
type = g_type_register_static (G_TYPE_PARAM_OBJECT,
"GimpParamDrawableFilter", &info, 0);
}
return type;
}
static void
gimp_param_drawable_filter_class_init (GParamSpecClass *klass)
{
klass->value_type = GIMP_TYPE_DRAWABLE_FILTER;
}
static void
gimp_param_drawable_filter_init (GParamSpec *pspec)
{
}
/**
* gimp_param_spec_drawable_filter:
* @name: Canonical name of the property specified.
* @nick: Nick name of the property specified.
* @blurb: Description of the property specified.
* @none_ok: Whether no is a valid value.
* @flags: Flags for the property specified.
*
* Creates a new #GimpParamSpecDrawableFilter specifying a
* [type@DrawableFilter] property.
*
* See g_param_spec_internal() for details on property names.
*
* Returns: (transfer floating): The newly created #GimpParamSpecPath.
*
* Since: 3.0
**/
GParamSpec *
gimp_param_spec_drawable_filter (const gchar *name,
const gchar *nick,
const gchar *blurb,
gboolean none_ok,
GParamFlags flags)
{
GimpParamSpecDrawableFilter *fspec;
fspec = g_param_spec_internal (GIMP_TYPE_PARAM_DRAWABLE_FILTER,
name, nick, blurb, flags);
g_return_val_if_fail (fspec, NULL);
fspec->none_ok = none_ok ? TRUE : FALSE;
return G_PARAM_SPEC (fspec);
}
/*
* GIMP_TYPE_PARAM_DISPLAY
*/

View File

@ -240,6 +240,35 @@ GParamSpec * gimp_param_spec_path (const gchar *name,
GParamFlags flags);
/*
* GIMP_TYPE_PARAM_DRAWABLE_FILTER
*/
#define GIMP_VALUE_HOLDS_DRAWABLE_FILTER(value) (G_TYPE_CHECK_VALUE_TYPE ((value),\
GIMP_TYPE_DRAWABLE_FILTER))
#define GIMP_TYPE_PARAM_DRAWABLE_FILTER (gimp_param_drawable_filter_get_type ())
#define GIMP_PARAM_SPEC_DRAWABLE_FILTER(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), GIMP_TYPE_PARAM_DRAWABLE_FILTER, GimpParamSpecDrawableFilter))
#define GIMP_IS_PARAM_SPEC_DRAWABLE_FILTER(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), GIMP_TYPE_PARAM_DRAWABLE_FILTER))
typedef struct _GimpParamSpecDrawableFilter GimpParamSpecDrawableFilter;
struct _GimpParamSpecDrawableFilter
{
GParamSpecObject parent_instance;
gboolean none_ok;
};
GType gimp_param_drawable_filter_get_type (void) G_GNUC_CONST;
GParamSpec * gimp_param_spec_drawable_filter (const gchar *name,
const gchar *nick,
const gchar *blurb,
gboolean none_ok,
GParamFlags flags);
/*
* GIMP_TYPE_PARAM_DISPLAY
*/

View File

@ -53,6 +53,9 @@ G_GNUC_INTERNAL GimpImage * _gimp_plug_in_get_image (GimpPlugIn
gint32 image_id);
G_GNUC_INTERNAL GimpItem * _gimp_plug_in_get_item (GimpPlugIn *plug_in,
gint32 item_id);
G_GNUC_INTERNAL GimpDrawableFilter *
_gimp_plug_in_get_filter (GimpPlugIn *plug_in,
gint32 filter_id);
G_GNUC_INTERNAL GimpResource * _gimp_plug_in_get_resource (GimpPlugIn *plug_in,
gint32 resource_id);

View File

@ -155,6 +155,7 @@ typedef struct _GimpPlugInPrivate
GHashTable *displays;
GHashTable *images;
GHashTable *items;
GHashTable *filters;
GHashTable *resources;
} GimpPlugInPrivate;
@ -374,6 +375,7 @@ gimp_plug_in_finalize (GObject *object)
gimp_plug_in_destroy_proxies (plug_in, priv->displays, "display", TRUE);
gimp_plug_in_destroy_proxies (plug_in, priv->images, "image", TRUE);
gimp_plug_in_destroy_proxies (plug_in, priv->items, "item", TRUE);
gimp_plug_in_destroy_proxies (plug_in, priv->filters, "filters", TRUE);
gimp_plug_in_destroy_proxies (plug_in, priv->resources, "resource", TRUE);
gimp_plug_in_destroy_hashes (plug_in);
@ -1810,6 +1812,40 @@ _gimp_plug_in_get_item (GimpPlugIn *plug_in,
return item;
}
GimpDrawableFilter *
_gimp_plug_in_get_filter (GimpPlugIn *plug_in,
gint32 filter_id)
{
GimpPlugInPrivate *priv;
GimpDrawableFilter *filter = NULL;
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), NULL);
priv = gimp_plug_in_get_instance_private (plug_in);
if (G_UNLIKELY (! priv->filters))
priv->filters =
g_hash_table_new_full (g_direct_hash,
g_direct_equal,
NULL,
(GDestroyNotify) g_object_unref);
filter = g_hash_table_lookup (priv->filters, GINT_TO_POINTER (filter_id));
if (! filter)
{
filter = g_object_new (GIMP_TYPE_DRAWABLE_FILTER,
"id", filter_id,
NULL);
g_hash_table_insert (priv->filters,
GINT_TO_POINTER (filter_id),
filter);
}
return filter;
}
GimpResource *
_gimp_plug_in_get_resource (GimpPlugIn *plug_in,
gint32 resource_id)

View File

@ -373,6 +373,18 @@ G_BEGIN_DECLS
g_value_set_object (gimp_value_array_index (args, n), value)
/* Drawable Filter */
#define GIMP_VALUES_GET_DRAWABLE_FILTER(args, n) \
g_value_get_object (gimp_value_array_index (args, n))
#define GIMP_VALUES_GET_DRAWABLE_FILTER_ID(args, n) \
gimp_drawable_filter_get_id (g_value_get_object (gimp_value_array_index (args, n)))
#define GIMP_VALUES_SET_DRAWABLE_FILTER(args, n, value) \
g_value_set_object (gimp_value_array_index (args, n), value)
/* file */
#define GIMP_VALUES_GET_FILE(args, n) \

View File

@ -50,6 +50,7 @@ typedef struct _GimpLayerMask GimpLayerMask;
typedef struct _GimpSelection GimpSelection;
typedef struct _GimpTextLayer GimpTextLayer;
typedef struct _GimpPath GimpPath;
typedef struct _GimpDrawableFilter GimpDrawableFilter;
typedef struct _GimpDisplay GimpDisplay;

View File

@ -71,6 +71,7 @@ pdb_wrappers_sources = [
'gimpdrawable_pdb.c',
'gimpdrawablecolor_pdb.c',
'gimpdrawableedit_pdb.c',
'gimpdrawablefilter_pdb.c',
'gimpdrawableselect_pdb.c',
'gimpdynamics_pdb.c',
'gimpedit_pdb.c',
@ -128,6 +129,7 @@ pdb_wrappers_headers = [
'gimpdrawable_pdb.h',
'gimpdrawablecolor_pdb.h',
'gimpdrawableedit_pdb.h',
'gimpdrawablefilter_pdb.h',
'gimpdrawableselect_pdb.h',
'gimpdynamics_pdb.h',
'gimpedit_pdb.h',
@ -178,6 +180,7 @@ libgimp_sources_introspectable = [
'gimpchannel.c',
'gimpdisplay.c',
'gimpdrawable.c',
'gimpdrawablefilter.c',
'gimpexportoptions.c',
'gimpfileprocedure.c',
'gimpfont.c',
@ -239,6 +242,7 @@ libgimp_headers_introspectable = [
'gimpchannel.h',
'gimpdisplay.h',
'gimpdrawable.h',
'gimpdrawablefilter.h',
'gimpexportoptions.h',
'gimpfileprocedure.h',
'gimpfont.h',

View File

@ -431,6 +431,16 @@ gimp_param_spec_path ("$name",
"$blurb",
$none_ok,
$flags)
CODE
}
elsif ($pdbtype eq 'filter') {
$none_ok = exists $arg->{none_ok} ? 'TRUE' : 'FALSE';
$pspec = <<CODE;
gimp_param_spec_drawable_filter ("$name",
"$nick",
"$blurb",
$none_ok,
$flags)
CODE
}
elsif ($pdbtype eq 'display') {
@ -773,6 +783,15 @@ gimp_param_spec_core_object_array ("$name",
"$blurb",
GIMP_TYPE_PATH,
$flags)
CODE
}
elsif ($pdbtype eq 'filterarray') {
$pspec = <<CODE;
gimp_param_spec_core_object_array ("$name",
"$nick",
"$blurb",
GIMP_TYPE_DRAWABLE_FILTER,
$flags)
CODE
}
elsif ($pdbtype eq 'resourcearray') {

View File

@ -11,6 +11,7 @@
drawable
drawable_color
drawable_edit
drawable_filter
drawable_select
dynamics
edit

View File

@ -111,6 +111,46 @@ CODE
);
}
sub drawable_get_filters {
$blurb = 'Returns the list of filters applied to the drawable.';
$help = <<'HELP';
This procedure returns the list of filters which are currently applied non-destructively to @drawable.
The order of filters is from topmost to bottommost.
HELP
&jehan_pdb_misc('2024', '3.0');
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' }
);
@outargs = (
{ name => 'filters', type => 'filterarray',
desc => 'The list of filters on the drawable.' }
);
%invoke = (
code => <<'CODE'
{
GimpContainer *container;
GList *iter;
gsize num_filters;
gint i;
container = gimp_drawable_get_filters (drawable);
num_filters = gimp_container_get_n_children (container);
filters = g_new0 (GimpDrawableFilter *, num_filters + 1);
iter = GIMP_LIST (container)->queue->head;
for (i = 0; i < num_filters; i++, iter = iter->next)
filters[i] = iter->data;
}
CODE
);
}
sub drawable_merge_filters {
$blurb = 'Merge the layer effect filters to the specified drawable.';
@ -1024,10 +1064,13 @@ CODE
"gegl/gimp-babl.h"
"gegl/gimp-babl-compat.h"
"core/gimp.h"
"core/gimpcontainer.h"
"core/gimpchannel-select.h"
"core/gimpdrawablefilter.h"
"core/gimpdrawable-filters.h"
"core/gimpdrawable-offset.h"
"core/gimpimage.h"
"core/gimplist.h"
"core/gimptempbuf.h"
"gimppdb-utils.h"
"gimppdbcontext.h"
@ -1049,6 +1092,7 @@ CODE
drawable_get_offsets
drawable_mask_bounds
drawable_mask_intersect
drawable_get_filters
drawable_merge_filters
drawable_merge_shadow
drawable_free_shadow

View File

@ -0,0 +1,58 @@
# GIMP - The GNU Image Manipulation Program
# Copyright (C) 1995 Spencer Kimball and Peter Mattis
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
sub drawable_filter_id_is_valid {
$blurb = 'Returns %TRUE if the drawable filter ID is valid.';
$help = <<'HELP';
This procedure checks if the given drawable filter ID is valid and refers to an
existing filter.
HELP
&jehan_pdb_misc('2024', '3.0');
@inargs = (
{ name => 'filter_id', type => 'int32',
desc => 'The filter ID to check' }
);
@outargs = (
{ name => 'valid', type => 'boolean',
desc => 'Whether the filter ID is valid' }
);
%invoke = (
code => <<'CODE'
{
valid = (gimp_drawable_filter_get_by_id (gimp, filter_id) != NULL);
}
CODE
);
}
@headers = qw("core/gimpdrawablefilter.h");
@procs = qw(drawable_filter_id_is_valid);
%exports = (app => [@procs], lib => [@procs]);
$desc = 'Drawable Filter';
$doc_title = 'gimpdrawablefilter';
$doc_short_desc = 'Operations on drawable filters.';
$doc_long_desc = 'Operations on drawable filters: creation, editing.';
1;

View File

@ -12,6 +12,7 @@ pdb_names = [
'display',
'drawable_color',
'drawable_edit',
'drawable_filter',
'drawable_select',
'drawable',
'dynamics',

View File

@ -191,6 +191,18 @@ package Gimp::CodeGen::pdb;
set_value_func => 'g_value_set_boxed ($value, $var)',
take_value_func => 'g_value_take_boxed ($value, $var)' },
filterarray => { name => 'FILTERARRAY',
gtype => 'GIMP_TYPE_CORE_OBJECT_ARRAY',
type => 'GimpDrawableFilter **',
const_type => 'const GimpDrawableFilter **',
init_value => 'NULL',
in_annotate => '(element-type GimpDrawableFilter) (array zero-terminated=1)',
out_annotate => '(element-type GimpDrawableFilter) (array zero-terminated=1) (transfer container)',
get_value_func => '$var = g_value_get_boxed ($value)',
dup_value_func => '$var = g_value_dup_boxed (gimp_value_array_index ($value))',
set_value_func => 'g_value_set_boxed ($value, $var)',
take_value_func => 'g_value_take_boxed ($value, $var)' },
resourcearray => { name => 'RESOURCEARRAY',
gtype => 'GIMP_TYPE_CORE_OBJECT_ARRAY',
type => 'GimpResource **',
@ -419,6 +431,18 @@ package Gimp::CodeGen::pdb;
take_value_func => 'g_value_set_object ($value, $var)',
headers => [ qw("vectors/gimppath.h") ] },
filter => { name => 'DRAWABLE_FILTER',
gtype => 'GIMP_TYPE_DRAWABLE_FILTER',
type => 'GimpDrawableFilter *',
const_type => 'GimpDrawableFilter *',
init_value => 'NULL',
out_annotate => '(transfer none)',
get_value_func => '$var = g_value_get_object ($value)',
dup_value_func => '$var = GIMP_VALUES_GET_DRAWABLE_FILTER ($value)',
set_value_func => 'g_value_set_object ($value, $var)',
take_value_func => 'g_value_set_object ($value, $var)',
headers => [ qw("core/gimpdrawablefilter.h") ] },
file => { name => 'FILE',
gtype => 'G_TYPE_FILE',
type => 'GFile *',