pdb: add a new PDB group "item" and move lots of functions to it

The item groups has all the duplicated functionality from drawable
and vectors (name, visible, linked etc).

Hijack the unused GIMP_PDB_REGION and turn it into GIMP_PDB_ITEM;
change all protocol aware files accordingly and bump the protocol
version number. Change script-fu to handle the new type.
This commit is contained in:
Michael Natterer 2010-07-09 09:34:44 +02:00
parent d303d8c7c1
commit 2d6f808ff8
24 changed files with 2480 additions and 91 deletions

View File

@ -57,6 +57,7 @@ libappinternal_procs_a_SOURCES = \
guides-cmds.c \
help-cmds.c \
image-cmds.c \
item-cmds.c \
layer-cmds.c \
message-cmds.c \
misc-cmds.c \

View File

@ -108,7 +108,10 @@ gimp_pdb_compat_param_spec (Gimp *gimp,
G_PARAM_READWRITE);
break;
case GIMP_PDB_REGION:
case GIMP_PDB_ITEM:
pspec = gimp_param_spec_item_id (name, name, desc,
gimp, TRUE,
G_PARAM_READWRITE);
break;
case GIMP_PDB_DISPLAY:
@ -220,8 +223,8 @@ gimp_pdb_compat_arg_type_to_gtype (GimpPDBArgType type)
case GIMP_PDB_COLOR:
return GIMP_TYPE_RGB;
case GIMP_PDB_REGION:
break;
case GIMP_PDB_ITEM:
return GIMP_TYPE_ITEM_ID;
case GIMP_PDB_DISPLAY:
return GIMP_TYPE_DISPLAY_ID;

View File

@ -28,7 +28,7 @@
#include "internal-procs.h"
/* 602 procedures registered total */
/* 621 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)
@ -59,6 +59,7 @@ internal_procs_init (GimpPDB *pdb)
register_guides_procs (pdb);
register_help_procs (pdb);
register_image_procs (pdb);
register_item_procs (pdb);
register_layer_procs (pdb);
register_message_procs (pdb);
register_misc_procs (pdb);

View File

@ -48,6 +48,7 @@ void register_grid_procs (GimpPDB *pdb);
void register_guides_procs (GimpPDB *pdb);
void register_help_procs (GimpPDB *pdb);
void register_image_procs (GimpPDB *pdb);
void register_item_procs (GimpPDB *pdb);
void register_layer_procs (GimpPDB *pdb);
void register_message_procs (GimpPDB *pdb);
void register_misc_procs (GimpPDB *pdb);

1115
app/pdb/item-cmds.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -192,8 +192,8 @@ plug_in_params_to_args (GParamSpec **pspecs,
gimp_value_set_rgb (&value, &params[i].data.d_color);
break;
case GIMP_PDB_REGION:
g_message ("the \"region\" argument type is not supported");
case GIMP_PDB_ITEM:
g_value_set_int (&value, params[i].data.d_item);
break;
case GIMP_PDB_DISPLAY:
@ -353,8 +353,8 @@ plug_in_args_to_params (GValueArray *args,
gimp_value_get_rgb (value, &params[i].data.d_color);
break;
case GIMP_PDB_REGION:
g_message ("the \"region\" argument type is not supported");
case GIMP_PDB_ITEM:
params[i].data.d_item = g_value_get_int (value);
break;
case GIMP_PDB_DISPLAY:

View File

@ -92,6 +92,7 @@ PDB_WRAPPERS_C = \
gimpgrid_pdb.c \
gimphelp_pdb.c \
gimpimage_pdb.c \
gimpitem_pdb.c \
gimplayer_pdb.c \
gimpmessage_pdb.c \
gimpmisc_pdb.c \
@ -142,6 +143,7 @@ PDB_WRAPPERS_H = \
gimpguides_pdb.h \
gimphelp_pdb.h \
gimpimage_pdb.h \
gimpitem_pdb.h \
gimplayer_pdb.h \
gimpmessage_pdb.h \
gimpmisc_pdb.h \

View File

@ -750,6 +750,7 @@ gimp_run_procedure (const gchar *name,
case GIMP_PDB_INT32:
case GIMP_PDB_DISPLAY:
case GIMP_PDB_IMAGE:
case GIMP_PDB_ITEM:
case GIMP_PDB_LAYER:
case GIMP_PDB_CHANNEL:
case GIMP_PDB_DRAWABLE:
@ -792,8 +793,6 @@ gimp_run_procedure (const gchar *name,
case GIMP_PDB_PARASITE:
(void) va_arg (args, GimpParasite *);
break;
case GIMP_PDB_REGION:
break;
case GIMP_PDB_END:
break;
}
@ -848,7 +847,8 @@ gimp_run_procedure (const gchar *name,
case GIMP_PDB_COLOR:
params[i].data.d_color = *va_arg (args, GimpRGB *);
break;
case GIMP_PDB_REGION:
case GIMP_PDB_ITEM:
params[i].data.d_item = va_arg (args, gint32);
break;
case GIMP_PDB_DISPLAY:
params[i].data.d_display = va_arg (args, gint32);

View File

@ -127,9 +127,10 @@ union _GimpParamData
gchar **d_stringarray;
GimpRGB *d_colorarray;
GimpRGB d_color;
GimpParamRegion d_region;
GimpParamRegion d_region; /* deprecated */
gint32 d_display;
gint32 d_image;
gint32 d_item;
gint32 d_layer;
gint32 d_layer_mask;
gint32 d_channel;

View File

@ -47,6 +47,7 @@
#include <libgimp/gimpguides_pdb.h>
#include <libgimp/gimphelp_pdb.h>
#include <libgimp/gimpimage_pdb.h>
#include <libgimp/gimpitem_pdb.h>
#include <libgimp/gimplayer_pdb.h>
#include <libgimp/gimpmessage_pdb.h>
#include <libgimp/gimpmisc_pdb.h>

View File

@ -24,15 +24,6 @@
G_BEGIN_DECLS
/**
* SECTION: gimpenums
* @title: gimpenums
* @short_description: Enums and definitions.
*
* Enums and definitions.
**/
#define GIMP_TYPE_BRUSH_APPLICATION_MODE (gimp_brush_application_mode_get_type ())
GType gimp_brush_application_mode_get_type (void) G_GNUC_CONST;

661
libgimp/gimpitem_pdb.c Normal file
View File

@ -0,0 +1,661 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* gimpitem_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
* <http://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "gimp.h"
/**
* SECTION: gimpitem
* @title: gimpitem
* @short_description: Functions to manipulate items.
*
* Functions to manipulate items.
**/
/**
* gimp_item_is_valid:
* @item_ID: The item to check.
*
* Returns TRUE if the item is valid.
*
* This procedure checks if the given item ID is valid and refers to an
* existing item.
*
* Returns: Whether the item ID is valid.
*
* Since: GIMP 2.8
*/
gboolean
gimp_item_is_valid (gint32 item_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean valid = FALSE;
return_vals = gimp_run_procedure ("gimp-item-is-valid",
&nreturn_vals,
GIMP_PDB_ITEM, item_ID,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
valid = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return valid;
}
/**
* gimp_item_get_image:
* @item_ID: The item.
*
* Returns the item's image.
*
* This procedure returns the item's image.
*
* Returns: The item's image.
*
* Since: GIMP 2.8
*/
gint32
gimp_item_get_image (gint32 item_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gint32 image_ID = -1;
return_vals = gimp_run_procedure ("gimp-item-get-image",
&nreturn_vals,
GIMP_PDB_ITEM, item_ID,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
image_ID = return_vals[1].data.d_image;
gimp_destroy_params (return_vals, nreturn_vals);
return image_ID;
}
/**
* gimp_item_delete:
* @item_ID: The item to delete.
*
* Delete a item.
*
* This procedure deletes the specified item. This must not be done if
* the image containing this item was already deleted or if the item
* was already removed from the image. The only case in which this
* procedure is useful is if you want to get rid of a item which has
* not yet been added to an image.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.8
*/
gboolean
gimp_item_delete (gint32 item_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-item-delete",
&nreturn_vals,
GIMP_PDB_ITEM, item_ID,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_item_is_drawable:
* @item_ID: The item.
*
* Returns whether the item is a drawable.
*
* This procedure returns TRUE if the specified item is a drawable.
*
* Returns: TRUE if the item is a drawable, FALSE otherwise.
*
* Since: GIMP 2.8
*/
gboolean
gimp_item_is_drawable (gint32 item_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean drawable = FALSE;
return_vals = gimp_run_procedure ("gimp-item-is-drawable",
&nreturn_vals,
GIMP_PDB_ITEM, item_ID,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
drawable = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return drawable;
}
/**
* gimp_item_is_layer:
* @item_ID: The item.
*
* Returns whether the item is a layer.
*
* This procedure returns TRUE if the specified item is a layer.
*
* Returns: TRUE if the item is a layer, FALSE otherwise.
*
* Since: GIMP 2.8
*/
gboolean
gimp_item_is_layer (gint32 item_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean layer = FALSE;
return_vals = gimp_run_procedure ("gimp-item-is-layer",
&nreturn_vals,
GIMP_PDB_ITEM, item_ID,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
layer = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return layer;
}
/**
* gimp_item_is_channel:
* @item_ID: The item.
*
* Returns whether the item is a channel.
*
* This procedure returns TRUE if the specified item is a channel.
*
* Returns: TRUE if the item is a channel, FALSE otherwise.
*
* Since: GIMP 2.8
*/
gboolean
gimp_item_is_channel (gint32 item_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean channel = FALSE;
return_vals = gimp_run_procedure ("gimp-item-is-channel",
&nreturn_vals,
GIMP_PDB_ITEM, item_ID,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
channel = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return channel;
}
/**
* gimp_item_is_layer_mask:
* @item_ID: The item.
*
* Returns whether the item is a layer mask.
*
* This procedure returns TRUE if the specified item is a layer mask.
*
* Returns: TRUE if the item is a layer mask, FALSE otherwise.
*
* Since: GIMP 2.8
*/
gboolean
gimp_item_is_layer_mask (gint32 item_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean layer_mask = FALSE;
return_vals = gimp_run_procedure ("gimp-item-is-layer-mask",
&nreturn_vals,
GIMP_PDB_ITEM, item_ID,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
layer_mask = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return layer_mask;
}
/**
* gimp_item_is_selection:
* @item_ID: The item.
*
* Returns whether the item is a selection.
*
* This procedure returns TRUE if the specified item is a selection.
*
* Returns: TRUE if the item is a selection, FALSE otherwise.
*
* Since: GIMP 2.8
*/
gboolean
gimp_item_is_selection (gint32 item_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean selection = FALSE;
return_vals = gimp_run_procedure ("gimp-item-is-selection",
&nreturn_vals,
GIMP_PDB_ITEM, item_ID,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
selection = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return selection;
}
/**
* gimp_item_is_vectors:
* @item_ID: The item.
*
* Returns whether the item is a vectors.
*
* This procedure returns TRUE if the specified item is a vectors.
*
* Returns: TRUE if the item is a vectors, FALSE otherwise.
*
* Since: GIMP 2.8
*/
gboolean
gimp_item_is_vectors (gint32 item_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean vectors = FALSE;
return_vals = gimp_run_procedure ("gimp-item-is-vectors",
&nreturn_vals,
GIMP_PDB_ITEM, item_ID,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
vectors = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return vectors;
}
/**
* gimp_item_get_name:
* @item_ID: The item.
*
* Get the name of the specified item.
*
* This procedure returns the specified item's name.
*
* Returns: The item name.
*
* Since: GIMP 2.8
*/
gchar *
gimp_item_get_name (gint32 item_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gchar *name = NULL;
return_vals = gimp_run_procedure ("gimp-item-get-name",
&nreturn_vals,
GIMP_PDB_ITEM, item_ID,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
name = g_strdup (return_vals[1].data.d_string);
gimp_destroy_params (return_vals, nreturn_vals);
return name;
}
/**
* gimp_item_set_name:
* @item_ID: The item.
* @name: The new item name.
*
* Set the name of the specified item.
*
* This procedure sets the specified item's name.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.8
*/
gboolean
gimp_item_set_name (gint32 item_ID,
const gchar *name)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-item-set-name",
&nreturn_vals,
GIMP_PDB_ITEM, item_ID,
GIMP_PDB_STRING, name,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_item_get_visible:
* @item_ID: The item.
*
* Get the visibility of the specified item.
*
* This procedure returns the specified item's visibility.
*
* Returns: The item visibility.
*
* Since: GIMP 2.8
*/
gboolean
gimp_item_get_visible (gint32 item_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean visible = FALSE;
return_vals = gimp_run_procedure ("gimp-item-get-visible",
&nreturn_vals,
GIMP_PDB_ITEM, item_ID,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
visible = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return visible;
}
/**
* gimp_item_set_visible:
* @item_ID: The item.
* @visible: The new item visibility.
*
* Set the visibility of the specified item.
*
* This procedure sets the specified item's visibility.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.8
*/
gboolean
gimp_item_set_visible (gint32 item_ID,
gboolean visible)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-item-set-visible",
&nreturn_vals,
GIMP_PDB_ITEM, item_ID,
GIMP_PDB_INT32, visible,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_item_get_linked:
* @item_ID: The item.
*
* Get the linked state of the specified item.
*
* This procedure returns the specified item's linked state.
*
* Returns: The item linked state (for moves).
*
* Since: GIMP 2.8
*/
gboolean
gimp_item_get_linked (gint32 item_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean linked = FALSE;
return_vals = gimp_run_procedure ("gimp-item-get-linked",
&nreturn_vals,
GIMP_PDB_ITEM, item_ID,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
linked = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return linked;
}
/**
* gimp_item_set_linked:
* @item_ID: The item.
* @linked: The new item linked state.
*
* Set the linked state of the specified item.
*
* This procedure sets the specified item's linked state.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.8
*/
gboolean
gimp_item_set_linked (gint32 item_ID,
gboolean linked)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-item-set-linked",
&nreturn_vals,
GIMP_PDB_ITEM, item_ID,
GIMP_PDB_INT32, linked,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_item_get_lock_content:
* @item_ID: The item.
*
* Get the 'lock content' state of the specified item.
*
* This procedure returns the specified item's lock content state.
*
* Returns: Whether the item's pixels are locked.
*
* Since: GIMP 2.8
*/
gboolean
gimp_item_get_lock_content (gint32 item_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean lock_content = FALSE;
return_vals = gimp_run_procedure ("gimp-item-get-lock-content",
&nreturn_vals,
GIMP_PDB_ITEM, item_ID,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
lock_content = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return lock_content;
}
/**
* gimp_item_set_lock_content:
* @item_ID: The item.
* @lock_content: The new item 'lock content' state.
*
* Set the 'lock content' state of the specified item.
*
* This procedure sets the specified item's lock content state.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.8
*/
gboolean
gimp_item_set_lock_content (gint32 item_ID,
gboolean lock_content)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-item-set-lock-content",
&nreturn_vals,
GIMP_PDB_ITEM, item_ID,
GIMP_PDB_INT32, lock_content,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_item_get_tattoo:
* @item_ID: The item.
*
* Get the tattoo of the specified item.
*
* This procedure returns the specified item's tattoo. A tattoo is a
* unique and permanent identifier attached to a item that can be used
* to uniquely identify a item within an image even between sessions.
*
* Returns: The item tattoo.
*
* Since: GIMP 2.8
*/
gint
gimp_item_get_tattoo (gint32 item_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gint tattoo = 0;
return_vals = gimp_run_procedure ("gimp-item-get-tattoo",
&nreturn_vals,
GIMP_PDB_ITEM, item_ID,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
tattoo = return_vals[1].data.d_tattoo;
gimp_destroy_params (return_vals, nreturn_vals);
return tattoo;
}
/**
* gimp_item_set_tattoo:
* @item_ID: The item.
* @tattoo: The new item tattoo.
*
* Set the tattoo of the specified item.
*
* This procedure sets the specified item's tattoo. A tattoo is a
* unique and permanent identifier attached to a item that can be used
* to uniquely identify a item within an image even between sessions.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.8
*/
gboolean
gimp_item_set_tattoo (gint32 item_ID,
gint tattoo)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-item-set-tattoo",
&nreturn_vals,
GIMP_PDB_ITEM, item_ID,
GIMP_PDB_INT32, tattoo,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}

59
libgimp/gimpitem_pdb.h Normal file
View File

@ -0,0 +1,59 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* gimpitem_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
* <http://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#ifndef __GIMP_ITEM_PDB_H__
#define __GIMP_ITEM_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gboolean gimp_item_is_valid (gint32 item_ID);
gint32 gimp_item_get_image (gint32 item_ID);
gboolean gimp_item_delete (gint32 item_ID);
gboolean gimp_item_is_drawable (gint32 item_ID);
gboolean gimp_item_is_layer (gint32 item_ID);
gboolean gimp_item_is_channel (gint32 item_ID);
gboolean gimp_item_is_layer_mask (gint32 item_ID);
gboolean gimp_item_is_selection (gint32 item_ID);
gboolean gimp_item_is_vectors (gint32 item_ID);
gchar* gimp_item_get_name (gint32 item_ID);
gboolean gimp_item_set_name (gint32 item_ID,
const gchar *name);
gboolean gimp_item_get_visible (gint32 item_ID);
gboolean gimp_item_set_visible (gint32 item_ID,
gboolean visible);
gboolean gimp_item_get_linked (gint32 item_ID);
gboolean gimp_item_set_linked (gint32 item_ID,
gboolean linked);
gboolean gimp_item_get_lock_content (gint32 item_ID);
gboolean gimp_item_set_lock_content (gint32 item_ID,
gboolean lock_content);
gint gimp_item_get_tattoo (gint32 item_ID);
gboolean gimp_item_set_tattoo (gint32 item_ID,
gint tattoo);
G_END_DECLS
#endif /* __GIMP_ITEM_PDB_H__ */

View File

@ -832,7 +832,7 @@ gimp_pdb_arg_type_get_type (void)
{ GIMP_PDB_FLOATARRAY, "GIMP_PDB_FLOATARRAY", "floatarray" },
{ GIMP_PDB_STRINGARRAY, "GIMP_PDB_STRINGARRAY", "stringarray" },
{ GIMP_PDB_COLOR, "GIMP_PDB_COLOR", "color" },
{ GIMP_PDB_REGION, "GIMP_PDB_REGION", "region" },
{ GIMP_PDB_ITEM, "GIMP_PDB_ITEM", "item" },
{ GIMP_PDB_DISPLAY, "GIMP_PDB_DISPLAY", "display" },
{ GIMP_PDB_IMAGE, "GIMP_PDB_IMAGE", "image" },
{ GIMP_PDB_LAYER, "GIMP_PDB_LAYER", "layer" },
@ -860,7 +860,7 @@ gimp_pdb_arg_type_get_type (void)
{ GIMP_PDB_FLOATARRAY, "GIMP_PDB_FLOATARRAY", NULL },
{ GIMP_PDB_STRINGARRAY, "GIMP_PDB_STRINGARRAY", NULL },
{ GIMP_PDB_COLOR, "GIMP_PDB_COLOR", NULL },
{ GIMP_PDB_REGION, "GIMP_PDB_REGION", NULL },
{ GIMP_PDB_ITEM, "GIMP_PDB_ITEM", NULL },
{ GIMP_PDB_DISPLAY, "GIMP_PDB_DISPLAY", NULL },
{ GIMP_PDB_IMAGE, "GIMP_PDB_IMAGE", NULL },
{ GIMP_PDB_LAYER, "GIMP_PDB_LAYER", NULL },

View File

@ -374,7 +374,7 @@ typedef enum
GIMP_PDB_FLOATARRAY,
GIMP_PDB_STRINGARRAY,
GIMP_PDB_COLOR,
GIMP_PDB_REGION,
GIMP_PDB_ITEM,
GIMP_PDB_DISPLAY,
GIMP_PDB_IMAGE,
GIMP_PDB_LAYER,
@ -389,7 +389,8 @@ typedef enum
/* the following aliases are deprecated */
GIMP_PDB_PATH = GIMP_PDB_VECTORS, /*< skip >*/
GIMP_PDB_BOUNDARY = GIMP_PDB_COLORARRAY /*< skip >*/
GIMP_PDB_BOUNDARY = GIMP_PDB_COLORARRAY, /*< skip >*/
GIMP_PDB_REGION = GIMP_PDB_ITEM /*< skip >*/
} GimpPDBArgType;

View File

@ -1435,7 +1435,11 @@ _gp_params_read (GIOChannel *channel,
goto cleanup;
break;
case GIMP_PDB_REGION:
case GIMP_PDB_ITEM:
if (! _gimp_wire_read_int32 (channel,
(guint32 *) &(*params)[i].data.d_item, 1,
user_data))
goto cleanup;
break;
case GIMP_PDB_DISPLAY:
@ -1658,7 +1662,11 @@ _gp_params_write (GIOChannel *channel,
return;
break;
case GIMP_PDB_REGION:
case GIMP_PDB_ITEM:
if (! _gimp_wire_write_int32 (channel,
(const guint32 *) &params[i].data.d_item, 1,
user_data))
return;
break;
case GIMP_PDB_DISPLAY:
@ -1772,7 +1780,7 @@ gp_params_destroy (GPParam *params,
case GIMP_PDB_INT8:
case GIMP_PDB_FLOAT:
case GIMP_PDB_COLOR:
case GIMP_PDB_REGION:
case GIMP_PDB_ITEM:
case GIMP_PDB_DISPLAY:
case GIMP_PDB_IMAGE:
case GIMP_PDB_LAYER:

View File

@ -26,7 +26,7 @@ G_BEGIN_DECLS
/* Increment every time the protocol changes
*/
#define GIMP_PROTOCOL_VERSION 0x0013
#define GIMP_PROTOCOL_VERSION 0x0014
enum
@ -127,9 +127,10 @@ struct _GPParam
gint32 y;
gint32 width;
gint32 height;
} d_region;
} d_region; /* deprecated */
gint32 d_display;
gint32 d_image;
gint32 d_item;
gint32 d_layer;
gint32 d_channel;
gint32 d_drawable;

View File

@ -745,6 +745,7 @@ script_fu_marshal_procedure_call (scheme *sc,
case GIMP_PDB_INT32:
case GIMP_PDB_DISPLAY:
case GIMP_PDB_IMAGE:
case GIMP_PDB_ITEM:
case GIMP_PDB_LAYER:
case GIMP_PDB_CHANNEL:
case GIMP_PDB_DRAWABLE:
@ -1173,36 +1174,6 @@ script_fu_marshal_procedure_call (scheme *sc,
}
break;
case GIMP_PDB_REGION:
if (! (sc->vptr->is_list (sc, sc->vptr->pair_car (a)) &&
sc->vptr->list_length (sc, sc->vptr->pair_car (a)) == 4))
success = FALSE;
if (success)
{
pointer region;
region = sc->vptr->pair_car (a);
args[i].data.d_region.x =
sc->vptr->ivalue (sc->vptr->pair_car (region));
region = sc->vptr->pair_cdr (region);
args[i].data.d_region.y =
sc->vptr->ivalue (sc->vptr->pair_car (region));
region = sc->vptr->pair_cdr (region);
args[i].data.d_region.width =
sc->vptr->ivalue (sc->vptr->pair_car (region));
region = sc->vptr->pair_cdr (region);
args[i].data.d_region.height =
sc->vptr->ivalue (sc->vptr->pair_car (region));
#if DEBUG_MARSHALL
g_printerr (" (%d %d %d %d)\n",
args[i].data.d_region.x,
args[i].data.d_region.y,
args[i].data.d_region.width,
args[i].data.d_region.height);
#endif
}
break;
case GIMP_PDB_PARASITE:
if (!sc->vptr->is_list (sc, sc->vptr->pair_car (a)) ||
sc->vptr->list_length (sc, sc->vptr->pair_car (a)) != 3)
@ -1385,6 +1356,7 @@ script_fu_marshal_procedure_call (scheme *sc,
case GIMP_PDB_INT32:
case GIMP_PDB_DISPLAY:
case GIMP_PDB_IMAGE:
case GIMP_PDB_ITEM:
case GIMP_PDB_LAYER:
case GIMP_PDB_CHANNEL:
case GIMP_PDB_DRAWABLE:
@ -1560,32 +1532,6 @@ script_fu_marshal_procedure_call (scheme *sc,
}
break;
case GIMP_PDB_REGION:
{
gint32 x, y, w, h;
pointer temp_val;
x = values[i + 1].data.d_region.x;
y = values[i + 1].data.d_region.y;
w = values[i + 1].data.d_region.width;
h = values[i + 1].data.d_region.height;
temp_val = sc->vptr->cons (sc,
sc->vptr->mk_integer (sc, x),
sc->vptr->cons (sc,
sc->vptr->mk_integer (sc, y),
sc->vptr->cons (sc,
sc->vptr->mk_integer (sc, w),
sc->vptr->cons (sc,
sc->vptr->mk_integer (sc, h),
sc->NIL))));
return_val = sc->vptr->cons (sc,
temp_val,
return_val);
break;
}
break;
case GIMP_PDB_PARASITE:
{
if (values[i + 1].data.d_parasite.name == NULL)
@ -1722,9 +1668,9 @@ script_fu_marshal_destroy_args (GimpParam *params,
break;
case GIMP_PDB_COLOR:
case GIMP_PDB_REGION:
case GIMP_PDB_DISPLAY:
case GIMP_PDB_IMAGE:
case GIMP_PDB_ITEM:
case GIMP_PDB_LAYER:
case GIMP_PDB_CHANNEL:
case GIMP_PDB_DRAWABLE:

View File

@ -26,6 +26,7 @@ pdb_sources = \
pdb/guides.pdb \
pdb/help.pdb \
pdb/image.pdb \
pdb/item.pdb \
pdb/layer.pdb \
pdb/message.pdb \
pdb/misc.pdb \

View File

@ -221,6 +221,16 @@ gimp_param_spec_image_id ("$name",
"$blurb",
pdb->gimp, $none_ok,
$flags)
CODE
}
elsif ($pdbtype eq 'item') {
$none_ok = exists $arg->{none_ok} ? 'TRUE' : 'FALSE';
$pspec = <<CODE;
gimp_param_spec_item_id ("$name",
"$nick",
"$blurb",
pdb->gimp, $none_ok,
$flags)
CODE
}
elsif ($pdbtype eq 'drawable') {

View File

@ -261,12 +261,12 @@ package Gimp::CodeGen::enums;
GIMP_PDB_FLOAT GIMP_PDB_STRING GIMP_PDB_INT32ARRAY
GIMP_PDB_INT16ARRAY GIMP_PDB_INT8ARRAY
GIMP_PDB_FLOATARRAY GIMP_PDB_STRINGARRAY
GIMP_PDB_COLOR GIMP_PDB_REGION GIMP_PDB_DISPLAY
GIMP_PDB_COLOR GIMP_PDB_ITEM GIMP_PDB_DISPLAY
GIMP_PDB_IMAGE GIMP_PDB_LAYER GIMP_PDB_CHANNEL
GIMP_PDB_DRAWABLE GIMP_PDB_SELECTION
GIMP_PDB_COLORARRAY GIMP_PDB_VECTORS
GIMP_PDB_PARASITE GIMP_PDB_STATUS GIMP_PDB_END
GIMP_PDB_PATH GIMP_PDB_BOUNDARY) ],
GIMP_PDB_PATH GIMP_PDB_BOUNDARY GIMP_PDB_REGION) ],
mapping => { GIMP_PDB_INT32 => '0',
GIMP_PDB_INT16 => '1',
GIMP_PDB_INT8 => '2',
@ -278,7 +278,7 @@ package Gimp::CodeGen::enums;
GIMP_PDB_FLOATARRAY => '8',
GIMP_PDB_STRINGARRAY => '9',
GIMP_PDB_COLOR => '10',
GIMP_PDB_REGION => '11',
GIMP_PDB_ITEM => '11',
GIMP_PDB_DISPLAY => '12',
GIMP_PDB_IMAGE => '13',
GIMP_PDB_LAYER => '14',
@ -291,7 +291,8 @@ package Gimp::CodeGen::enums;
GIMP_PDB_STATUS => '21',
GIMP_PDB_END => '22',
GIMP_PDB_PATH => 'GIMP_PDB_VECTORS',
GIMP_PDB_BOUNDARY => 'GIMP_PDB_COLORARRAY' }
GIMP_PDB_BOUNDARY => 'GIMP_PDB_COLORARRAY',
GIMP_PDB_REGION => 'GIMP_PDB_ITEM' }
},
GimpPDBErrorHandler =>
{ contig => 1,

View File

@ -24,6 +24,7 @@
guides
help
image
item
layer
message
misc

View File

@ -126,6 +126,15 @@ package Gimp::CodeGen::pdb;
set_value_func => 'gimp_value_set_image ($value, $var)',
headers => [ qw("core/gimpimage.h") ] },
item => { name => 'ITEM',
type => 'GimpItem *',
const_type => 'GimpItem *',
id => 1,
init_value => 'NULL',
get_value_func => '$var = gimp_value_get_item ($value, gimp)',
set_value_func => 'gimp_value_set_item ($value, $var)',
headers => [ qw("core/gimpitem.h") ] },
layer => { name => 'LAYER',
type => 'GimpLayer *',
const_type => 'GimpLayer *',

575
tools/pdbgen/pdb/item.pdb Normal file
View File

@ -0,0 +1,575 @@
# 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 <http://www.gnu.org/licenses/>.
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
sub item_is_valid {
$blurb = 'Returns TRUE if the item is valid.';
$help = <<'HELP';
This procedure checks if the given item ID is valid and refers to an
existing item.
HELP
&neo_pdb_misc('2007', '2.8');
@inargs = (
{ name => 'item', type => 'item', no_validate => 1,
desc => 'The item to check' }
);
@outargs = (
{ name => 'valid', type => 'boolean',
desc => 'Whether the item ID is valid' }
);
%invoke = (
code => <<'CODE'
{
valid = (GIMP_IS_ITEM (item) &&
! gimp_item_is_removed (GIMP_ITEM (item)));
}
CODE
);
}
sub item_get_image {
$blurb = "Returns the item's image.";
$help = "This procedure returns the item's image.";
&std_pdb_misc;
$since = '2.8';
@inargs = (
{ name => 'item', type => 'item',
desc => 'The item' }
);
@outargs = (
{ name => 'image', type => 'image',
desc => "The item's image" }
);
%invoke = (
code => <<'CODE'
{
image = gimp_item_get_image (GIMP_ITEM (item));
}
CODE
);
}
sub item_delete {
$blurb = 'Delete a item.';
$help = <<'HELP';
This procedure deletes the specified item. This must not be done if the
image containing this item was already deleted or if the item was
already removed from the image. The only case in which this procedure is
useful is if you want to get rid of a item which has not yet been
added to an image.
HELP
&std_pdb_misc;
$since = '2.8';
@inargs = (
{ name => 'item', type => 'item',
desc => 'The item to delete' }
);
%invoke = (
code => <<'CODE'
{
if (g_object_is_floating (item))
{
g_object_ref_sink (item);
g_object_unref (item);
}
else
success = FALSE;
}
CODE
);
}
sub item_is_drawable {
$blurb = 'Returns whether the item is a drawable.';
$help = <<HELP;
This procedure returns TRUE if the specified item is a drawable.
HELP
&std_pdb_misc;
$since = '2.8';
@inargs = (
{ name => 'item', type => 'item',
desc => 'The item' }
);
@outargs = (
{ name => 'drawable', type => 'boolean',
desc => 'TRUE if the item is a drawable, FALSE otherwise' }
);
%invoke = (
code => <<'CODE'
{
drawable = GIMP_IS_DRAWABLE (item);
}
CODE
);
}
sub item_is_layer {
$blurb = 'Returns whether the item is a layer.';
$help = <<HELP;
This procedure returns TRUE if the specified item is a layer.
HELP
&std_pdb_misc;
$since = '2.8';
@inargs = (
{ name => 'item', type => 'item',
desc => 'The item' }
);
@outargs = (
{ name => 'layer', type => 'boolean',
desc => 'TRUE if the item is a layer, FALSE otherwise' }
);
%invoke = (
code => <<'CODE'
{
layer = GIMP_IS_LAYER (item);
}
CODE
);
}
sub item_is_channel {
$blurb = 'Returns whether the item is a channel.';
$help = <<HELP;
This procedure returns TRUE if the specified item is a channel.
HELP
&std_pdb_misc;
$since = '2.8';
@inargs = (
{ name => 'item', type => 'item',
desc => 'The item' }
);
@outargs = (
{ name => 'channel', type => 'boolean',
desc => 'TRUE if the item is a channel, FALSE otherwise' }
);
%invoke = (
code => <<'CODE'
{
channel = GIMP_IS_CHANNEL (item);
}
CODE
);
}
sub item_is_layer_mask {
$blurb = 'Returns whether the item is a layer mask.';
$help = <<HELP;
This procedure returns TRUE if the specified item is a layer mask.
HELP
&std_pdb_misc;
$since = '2.8';
@inargs = (
{ name => 'item', type => 'item',
desc => 'The item' }
);
@outargs = (
{ name => 'layer_mask', type => 'boolean',
desc => 'TRUE if the item is a layer mask, FALSE otherwise' }
);
%invoke = (
code => <<'CODE'
{
layer_mask = GIMP_IS_LAYER_MASK (item);
}
CODE
);
}
sub item_is_selection {
$blurb = 'Returns whether the item is a selection.';
$help = <<HELP;
This procedure returns TRUE if the specified item is a selection.
HELP
&std_pdb_misc;
$since = '2.8';
@inargs = (
{ name => 'item', type => 'item',
desc => 'The item' }
);
@outargs = (
{ name => 'selection', type => 'boolean',
desc => 'TRUE if the item is a selection, FALSE otherwise' }
);
%invoke = (
code => <<'CODE'
{
selection = GIMP_IS_SELECTION (item);
}
CODE
);
}
sub item_is_vectors {
$blurb = 'Returns whether the item is a vectors.';
$help = <<HELP;
This procedure returns TRUE if the specified item is a vectors.
HELP
&std_pdb_misc;
$since = '2.8';
@inargs = (
{ name => 'item', type => 'item',
desc => 'The item' }
);
@outargs = (
{ name => 'vectors', type => 'boolean',
desc => 'TRUE if the item is a vectors, FALSE otherwise' }
);
%invoke = (
code => <<'CODE'
{
vectors = GIMP_IS_VECTORS (item);
}
CODE
);
}
sub item_get_name {
$blurb = "Get the name of the specified item.";
$help = "This procedure returns the specified item's name.";
&std_pdb_misc;
$since = '2.8';
@inargs = (
{ name => 'item', type => 'item',
desc => 'The item' }
);
@outargs = (
{ name => 'name', type => 'string',
desc => "The item name" }
);
%invoke = (
code => <<'CODE'
{
name = g_strdup (gimp_object_get_name (item));
}
CODE
);
}
sub item_set_name {
$blurb = "Set the name of the specified item.";
$help = "This procedure sets the specified item's name.";
&std_pdb_misc;
$since = '2.8';
@inargs = (
{ name => 'item', type => 'item',
desc => 'The item' },
{ name => 'name', type => 'string',
desc => "The new item name" }
);
%invoke = (
code => <<'CODE'
{
success = gimp_item_rename (GIMP_ITEM (item), name, error);
}
CODE
);
}
sub item_get_visible {
$blurb = "Get the visibility of the specified item.";
$help = "This procedure returns the specified item's visibility.";
&std_pdb_misc;
$since = '2.8';
@inargs = (
{ name => 'item', type => 'item',
desc => 'The item' }
);
@outargs = (
{ name => 'visible', type => 'boolean',
desc => "The item visibility" }
);
%invoke = (
code => <<'CODE'
{
visible = gimp_item_get_visible (GIMP_ITEM (item));
}
CODE
);
}
sub item_set_visible {
$blurb = "Set the visibility of the specified item.";
$help = "This procedure sets the specified item's visibility.";
&std_pdb_misc;
$since = '2.8';
@inargs = (
{ name => 'item', type => 'item',
desc => 'The item' },
{ name => 'visible', type => 'boolean',
desc => "The new item visibility" }
);
%invoke = (
code => <<'CODE'
{
gimp_item_set_visible (GIMP_ITEM (item), visible, TRUE);
}
CODE
);
}
sub item_get_linked {
$blurb = "Get the linked state of the specified item.";
$help = "This procedure returns the specified item's linked state.";
&wolfgang_pdb_misc('1998', '2.8');
@inargs = (
{ name => 'item', type => 'item',
desc => 'The item' }
);
@outargs = (
{ name => 'linked', type => 'boolean',
desc => "The item linked state (for moves)" }
);
%invoke = (
code => <<'CODE'
{
linked = gimp_item_get_linked (GIMP_ITEM (item));
}
CODE
);
}
sub item_set_linked {
$blurb = "Set the linked state of the specified item.";
$help = "This procedure sets the specified item's linked state.";
&wolfgang_pdb_misc('1998', '2.8');
@inargs = (
{ name => 'item', type => 'item',
desc => 'The item' },
{ name => 'linked', type => 'boolean',
desc => "The new item linked state" }
);
%invoke = (
code => <<'CODE'
{
gimp_item_set_linked (GIMP_ITEM (item), linked, TRUE);
}
CODE
);
}
sub item_get_lock_content {
$blurb = "Get the 'lock content' state of the specified item.";
$help = "This procedure returns the specified item's lock content state.";
&mitch_pdb_misc('2009', '2.8');
@inargs = (
{ name => 'item', type => 'item',
desc => 'The item' }
);
@outargs = (
{ name => 'lock_content', type => 'boolean',
desc => "Whether the item's pixels are locked" }
);
%invoke = (
code => <<'CODE'
{
lock_content = gimp_item_get_lock_content (GIMP_ITEM (item));
}
CODE
);
}
sub item_set_lock_content {
$blurb = "Set the 'lock content' state of the specified item.";
$help = "This procedure sets the specified item's lock content state.";
&mitch_pdb_misc('2009', '2.8');
@inargs = (
{ name => 'item', type => 'item',
desc => 'The item' },
{ name => 'lock_content', type => 'boolean',
desc => "The new item 'lock content' state" }
);
%invoke = (
code => <<'CODE'
{
if (gimp_item_can_lock_content (GIMP_ITEM (item)))
gimp_item_set_lock_content (GIMP_ITEM (item), lock_content, TRUE);
else
success = FALSE;
}
CODE
);
}
sub item_get_tattoo {
$blurb = "Get the tattoo of the specified item.";
$help = <<'HELP';
This procedure returns the specified item's tattoo. A tattoo is a
unique and permanent identifier attached to a item that can be
used to uniquely identify a item within an image even between
sessions.
HELP
&jay_pdb_misc('1998', '2.8');
@inargs = (
{ name => 'item', type => 'item',
desc => 'The item' }
);
@outargs = (
{ name => 'tattoo', type => 'tattoo',
desc => "The item tattoo" }
);
%invoke = (
code => <<'CODE'
{
tattoo = gimp_item_get_tattoo (GIMP_ITEM (item));
}
CODE
);
}
sub item_set_tattoo {
$blurb = "Set the tattoo of the specified item.";
$help = <<'HELP';
This procedure sets the specified item's tattoo. A tattoo is a
unique and permanent identifier attached to a item that can be
used to uniquely identify a item within an image even between
sessions.
HELP
&jay_pdb_misc('1998', '2.8');
@inargs = (
{ name => 'item', type => 'item',
desc => 'The item' },
{ name => 'tattoo', type => 'tattoo',
desc => "The new item tattoo" }
);
%invoke = (
code => <<'CODE'
{
gimp_item_set_tattoo (GIMP_ITEM (item), tattoo);
}
CODE
);
}
@headers = qw("core/gimplayermask.h"
"core/gimpselection.h"
"text/gimptextlayer.h"
"vectors/gimpvectors.h"
"gimppdb-utils.h"
"gimp-intl.h");
@procs = qw(item_is_valid
item_get_image
item_delete
item_is_drawable
item_is_layer
item_is_channel
item_is_layer_mask
item_is_selection
item_is_vectors
item_get_name item_set_name
item_get_visible item_set_visible
item_get_linked item_set_linked
item_get_lock_content item_set_lock_content
item_get_tattoo item_set_tattoo);
%exports = (app => [@procs], lib => [@procs]);
$desc = 'Item procedures';
$doc_title = 'gimpitem';
$doc_short_desc = 'Functions to manipulate items.';
$doc_long_desc = 'Functions to manipulate items.';
1;