gimp/libgimp/gimptextlayer.c
Jehan 957d76fd14 app, libgimp, pdb, plug-ins: PDB (gimp-layer-copy) made public.
Not sure what I had in mind with the class method copy() in libgimp
GimpLayer. The core duplicate code already takes care of returning an
object of the right type. Also the GimpTextLayer implementation was not
a perfect copy (only text, font and font size were copied). Now it is
because, again, core has all the duplication code necessary.

Finally this makes this function visible to PDB, hence Script-Fu, again.
2025-01-20 22:38:01 +01:00

76 lines
1.8 KiB
C

/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
*
* gimptextlayer.c
* Copyright (C) 2022 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"
struct _GimpTextLayer
{
GimpLayer parent_instance;
};
G_DEFINE_TYPE (GimpTextLayer, gimp_text_layer, GIMP_TYPE_LAYER)
#define parent_class gimp_text_layer_parent_class
static void
gimp_text_layer_class_init (GimpTextLayerClass *klass)
{
}
static void
gimp_text_layer_init (GimpTextLayer *layer)
{
}
/* Public API. */
/**
* gimp_text_layer_get_by_id:
* @layer_id: The layer id.
*
* Returns a #GimpTextLayer representing @layer_id. This function calls
* gimp_item_get_by_id() and returns the item if it is layer or %NULL
* otherwise.
*
* Returns: (nullable) (transfer none): a #GimpTextLayer for @layer_id or
* %NULL if @layer_id does not represent a valid layer. The
* object belongs to libgimp and you must not modify or unref
* it.
*
* Since: 3.0
**/
GimpTextLayer *
gimp_text_layer_get_by_id (gint32 layer_id)
{
GimpItem *item = gimp_item_get_by_id (layer_id);
if (GIMP_IS_TEXT_LAYER (item))
return (GimpTextLayer *) item;
return NULL;
}