Commit 2d6f808f authored by Michael Natterer's avatar Michael Natterer 😴

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.
parent d303d8c7
......@@ -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 \
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
......
This diff is collapsed.
......@@ -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:
......
......@@ -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 \
......
......@@ -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);
......
......@@ -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;
......
......@@ -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>
......
......@@ -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;
......
/* 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.