Commit 38b9b411 authored by Michael Natterer's avatar Michael Natterer 😴
Browse files

pdb: deprecate gimp-drawable-is-text-layer and add gimp-item-is-text-layer

parent c56f0568
......@@ -50,35 +50,6 @@
#include "gimp-intl.h"
static GValueArray *
drawable_is_text_layer_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
GimpDrawable *drawable;
gboolean text_layer = FALSE;
drawable = gimp_value_get_drawable (&args->values[0], gimp);
if (success)
{
text_layer = gimp_drawable_is_text_layer (drawable);
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_boolean (&return_vals->values[1], text_layer);
return return_vals;
}
static GValueArray *
drawable_type_invoker (GimpProcedure *procedure,
Gimp *gimp,
......@@ -948,35 +919,6 @@ register_drawable_procs (GimpPDB *pdb)
{
GimpProcedure *procedure;
/*
* gimp-drawable-is-text-layer
*/
procedure = gimp_procedure_new (drawable_is_text_layer_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-drawable-is-text-layer");
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-is-text-layer",
"Returns whether the drawable is a text layer.",
"This procedure returns TRUE if the specified drawable is a text layer.",
"Marcus Heese <heese@cip.ifi.lmu.de>",
"Marcus Heese",
"2008",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
"The drawable",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_boolean ("text-layer",
"text layer",
"TRUE if the drawable is a text layer, FALSE otherwise.",
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-drawable-type
*/
......
......@@ -428,6 +428,7 @@ gimp_pdb_compat_procs_register (GimpPDB *pdb,
/* deprecations since 2.6 */
{ "gimp-drawable-is-valid", "gimp-item-is-valid" },
{ "gimp-drawable-is-layer", "gimp-item-is-layer" },
{ "gimp-drawable-is-text-layer", "gimp-item-is-text-layer" },
{ "gimp-drawable-is-layer-mask", "gimp-item-is-layer-mask" },
{ "gimp-drawable-is-channel", "gimp-item-is-channel" },
{ "gimp-drawable-delete", "gimp-item-delete" },
......
......@@ -179,6 +179,36 @@ item_is_layer_invoker (GimpProcedure *procedure,
return return_vals;
}
static GValueArray *
item_is_text_layer_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
GimpItem *item;
gboolean text_layer = FALSE;
item = gimp_value_get_item (&args->values[0], gimp);
if (success)
{
text_layer = (GIMP_IS_DRAWABLE (item) &&
gimp_drawable_is_text_layer (GIMP_DRAWABLE (item)));
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_boolean (&return_vals->values[1], text_layer);
return return_vals;
}
static GValueArray *
item_is_channel_invoker (GimpProcedure *procedure,
Gimp *gimp,
......@@ -856,6 +886,35 @@ register_item_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-item-is-text-layer
*/
procedure = gimp_procedure_new (item_is_text_layer_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-item-is-text-layer");
gimp_procedure_set_static_strings (procedure,
"gimp-item-is-text-layer",
"Returns whether the item is a text layer.",
"This procedure returns TRUE if the specified item is a text layer.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_item_id ("item",
"item",
"The item",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_boolean ("text-layer",
"text layer",
"TRUE if the item is a text layer, FALSE otherwise.",
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-item-is-channel
*/
......
......@@ -446,6 +446,7 @@ EXPORTS
gimp_item_is_layer
gimp_item_is_layer_mask
gimp_item_is_selection
gimp_item_is_text_layer
gimp_item_is_valid
gimp_item_is_vectors
gimp_item_parasite_attach
......
......@@ -351,6 +351,22 @@ gimp_drawable_is_layer (gint32 drawable_ID)
return gimp_item_is_layer (drawable_ID);
}
/**
* gimp_drawable_is_text_layer:
* @drawable_ID: The drawable.
*
* Deprecated: Use gimp_item_is_text_layer() instead.
*
* Returns: TRUE if the drawable is a text layer, FALSE otherwise.
*
* Since: GIMP 2.6
*/
gboolean
gimp_drawable_is_text_layer (gint32 drawable_ID)
{
return gimp_item_is_text_layer (drawable_ID);
}
/**
* gimp_drawable_is_layer_mask:
* @drawable_ID: The drawable.
......
......@@ -71,6 +71,7 @@ guchar * gimp_drawable_get_sub_thumbnail_data (gint32 drawable_ID,
#ifndef GIMP_DISABLE_DEPRECATED
gboolean gimp_drawable_is_valid (gint32 drawable_ID);
gboolean gimp_drawable_is_layer (gint32 drawable_ID);
gboolean gimp_drawable_is_text_layer (gint32 drawable_ID);
gboolean gimp_drawable_is_layer_mask (gint32 drawable_ID);
gboolean gimp_drawable_is_channel (gint32 drawable_ID);
gboolean gimp_drawable_delete (gint32 drawable_ID);
......
......@@ -39,39 +39,6 @@
**/
/**
* gimp_drawable_is_text_layer:
* @drawable_ID: The drawable.
*
* Returns whether the drawable is a text layer.
*
* This procedure returns TRUE if the specified drawable is a text
* layer.
*
* Returns: TRUE if the drawable is a text layer, FALSE otherwise.
*
* Since: GIMP 2.6
*/
gboolean
gimp_drawable_is_text_layer (gint32 drawable_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean text_layer = FALSE;
return_vals = gimp_run_procedure ("gimp-drawable-is-text-layer",
&nreturn_vals,
GIMP_PDB_DRAWABLE, drawable_ID,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
text_layer = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return text_layer;
}
/**
* gimp_drawable_type:
* @drawable_ID: The drawable.
......
......@@ -28,7 +28,6 @@ G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gboolean gimp_drawable_is_text_layer (gint32 drawable_ID);
GimpImageType gimp_drawable_type (gint32 drawable_ID);
GimpImageType gimp_drawable_type_with_alpha (gint32 drawable_ID);
gboolean gimp_drawable_has_alpha (gint32 drawable_ID);
......
......@@ -200,6 +200,38 @@ gimp_item_is_layer (gint32 item_ID)
return layer;
}
/**
* gimp_item_is_text_layer:
* @item_ID: The item.
*
* Returns whether the item is a text layer.
*
* This procedure returns TRUE if the specified item is a text layer.
*
* Returns: TRUE if the item is a text layer, FALSE otherwise.
*
* Since: GIMP 2.8
*/
gboolean
gimp_item_is_text_layer (gint32 item_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean text_layer = FALSE;
return_vals = gimp_run_procedure ("gimp-item-is-text-layer",
&nreturn_vals,
GIMP_PDB_ITEM, item_ID,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
text_layer = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return text_layer;
}
/**
* gimp_item_is_channel:
* @item_ID: The item.
......
......@@ -33,6 +33,7 @@ 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_text_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);
......
......@@ -551,34 +551,6 @@ CODE
);
}
sub drawable_is_text_layer {
$blurb = 'Returns whether the drawable is a text layer.';
$help = <<'HELP';
This procedure returns TRUE if the specified drawable is a text layer.
HELP
&marcus_pdb_misc('2008', '2.6');
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' }
);
@outargs = (
{ name => 'text_layer', type => 'boolean',
desc => 'TRUE if the drawable is a text layer, FALSE otherwise.' }
);
%invoke = (
code => <<'CODE'
{
text_layer = gimp_drawable_is_text_layer (drawable);
}
CODE
);
}
sub drawable_get_pixel {
$blurb = 'Gets the value of the pixel at the specified coordinates.';
......@@ -973,8 +945,7 @@ CODE
"gimppdb-utils.h"
"gimp-intl.h");
@procs = qw(drawable_is_text_layer
drawable_type
@procs = qw(drawable_type
drawable_type_with_alpha
drawable_has_alpha
drawable_is_rgb
......
......@@ -165,6 +165,35 @@ CODE
);
}
sub item_is_text_layer {
$blurb = 'Returns whether the item is a text layer.';
$help = <<'HELP';
This procedure returns TRUE if the specified item is a text layer.
HELP
&mitch_pdb_misc('2010', '2.8');
@inargs = (
{ name => 'item', type => 'item',
desc => 'The item' }
);
@outargs = (
{ name => 'text_layer', type => 'boolean',
desc => 'TRUE if the item is a text layer, FALSE otherwise.' }
);
%invoke = (
code => <<'CODE'
{
text_layer = (GIMP_IS_DRAWABLE (item) &&
gimp_drawable_is_text_layer (GIMP_DRAWABLE (item)));
}
CODE
);
}
sub item_is_channel {
$blurb = 'Returns whether the item is a channel.';
......@@ -708,6 +737,7 @@ CODE
item_delete
item_is_drawable
item_is_layer
item_is_text_layer
item_is_channel
item_is_layer_mask
item_is_selection
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment