mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-10-06 01:12:40 +02:00
app, libgimp, pdb: add GimpLinkLayer base API.
Still more to be done, but this is the basic, working API.
This commit is contained in:
10
pdb/app.pl
10
pdb/app.pl
@@ -391,6 +391,16 @@ gimp_param_spec_vector_layer ("$name",
|
||||
"$blurb",
|
||||
$none_ok,
|
||||
$flags)
|
||||
CODE
|
||||
}
|
||||
elsif ($pdbtype eq 'link_layer') {
|
||||
$none_ok = exists $arg->{none_ok} ? 'TRUE' : 'FALSE';
|
||||
$pspec = <<CODE;
|
||||
gimp_param_spec_link_layer ("$name",
|
||||
"$nick",
|
||||
"$blurb",
|
||||
$none_ok,
|
||||
$flags)
|
||||
CODE
|
||||
}
|
||||
elsif ($pdbtype eq 'layer') {
|
||||
|
@@ -1,18 +1,18 @@
|
||||
# This file is autogenerated
|
||||
@groups = qw(
|
||||
brush
|
||||
brush_select
|
||||
brush
|
||||
brushes
|
||||
buffer
|
||||
channel
|
||||
context
|
||||
debug
|
||||
display
|
||||
drawable
|
||||
drawable_color
|
||||
drawable_edit
|
||||
drawable_filter
|
||||
drawable_select
|
||||
drawable
|
||||
dynamics
|
||||
edit
|
||||
file
|
||||
@@ -22,12 +22,11 @@
|
||||
fonts
|
||||
gimp
|
||||
gimprc
|
||||
gradient
|
||||
gradient_select
|
||||
gradient
|
||||
gradients
|
||||
group_layer
|
||||
help
|
||||
image
|
||||
image_autocrop
|
||||
image_color_profile
|
||||
image_convert
|
||||
@@ -37,17 +36,19 @@
|
||||
image_select
|
||||
image_transform
|
||||
image_undo
|
||||
item
|
||||
image
|
||||
item_transform
|
||||
item
|
||||
layer
|
||||
link_layer
|
||||
message
|
||||
paint_tools
|
||||
palette
|
||||
palette_select
|
||||
palette
|
||||
palettes
|
||||
path
|
||||
pattern
|
||||
pattern_select
|
||||
pattern
|
||||
patterns
|
||||
pdb
|
||||
plug_in
|
||||
|
@@ -248,6 +248,42 @@ CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub item_id_is_link_layer {
|
||||
$blurb = 'Returns whether the item ID is a link layer.';
|
||||
|
||||
$help = <<'HELP';
|
||||
This procedure returns %TRUE if the specified item ID is a link layer.
|
||||
|
||||
|
||||
*Note*: in most use cases, you should not use this function. See
|
||||
[func@Gimp.Item.id_is_layer] for a discussion on alternatives.
|
||||
HELP
|
||||
|
||||
&jehan_pdb_misc('2025', '3.2');
|
||||
|
||||
@inargs = (
|
||||
{ name => 'item_id', type => 'int32',
|
||||
desc => 'The item ID' }
|
||||
);
|
||||
|
||||
@outargs = (
|
||||
{ name => 'text_layer', type => 'boolean',
|
||||
desc => 'TRUE if the item is a text layer, FALSE otherwise.' }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
GimpItem *item = gimp_item_get_by_id (gimp, item_id);
|
||||
|
||||
text_layer = (GIMP_IS_LAYER (item) &&
|
||||
! gimp_item_is_removed (item) &&
|
||||
gimp_item_is_link_layer (item));
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub item_id_is_channel {
|
||||
$blurb = 'Returns whether the item ID is a channel.';
|
||||
|
||||
@@ -1090,6 +1126,7 @@ CODE
|
||||
|
||||
@headers = qw("core/gimpgrouplayer.h"
|
||||
"core/gimplayermask.h"
|
||||
"core/gimplinklayer.h"
|
||||
"core/gimplist.h"
|
||||
"core/gimpselection.h"
|
||||
"path/gimppath.h"
|
||||
@@ -1105,6 +1142,7 @@ CODE
|
||||
item_id_is_text_layer
|
||||
item_id_is_vector_layer
|
||||
item_id_is_group_layer
|
||||
item_id_is_link_layer
|
||||
item_id_is_channel
|
||||
item_id_is_layer_mask
|
||||
item_id_is_path
|
||||
|
225
pdb/groups/link_layer.pdb
Normal file
225
pdb/groups/link_layer.pdb
Normal file
@@ -0,0 +1,225 @@
|
||||
# GIMP - The GNU Image Manipulation Program
|
||||
# Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
|
||||
# New Link Layer PDB API
|
||||
# Copyright (C) 2025 Jehan
|
||||
|
||||
# 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 link_layer_new {
|
||||
$blurb = 'Creates a new link layer.';
|
||||
|
||||
$help = <<'HELP';
|
||||
This procedure creates a link layer monitoring the specified @file.
|
||||
|
||||
|
||||
The new layer still needs to be added to the image as this is not
|
||||
automatic. Add the new layer with the [method@Image.insert_layer]
|
||||
method.
|
||||
|
||||
|
||||
The arguments are kept as simple as necessary for the basic case. All
|
||||
link attributes, however, can be modified with the appropriate
|
||||
`gimp_link_layer_set_*()` procedures.
|
||||
HELP
|
||||
|
||||
&jehan_pdb_misc('2025', '3.2');
|
||||
|
||||
@inargs = (
|
||||
{ name => 'image', type => 'image',
|
||||
desc => 'The image' },
|
||||
{ name => 'file', type => 'file',
|
||||
desc => 'The file this link layer will monitor' }
|
||||
);
|
||||
|
||||
@outargs = (
|
||||
{ name => 'layer', type => 'link_layer',
|
||||
desc => 'The new link layer. The object belongs to libgimp and you should not free it.' }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
if (file == NULL)
|
||||
{
|
||||
g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT,
|
||||
_("Failed to create link layer"));
|
||||
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
GimpLink *link;
|
||||
|
||||
link = gimp_link_new (gimp, file, 0, 0, TRUE, NULL, error);
|
||||
|
||||
if (link == NULL)
|
||||
{
|
||||
success = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
layer = GIMP_LINK_LAYER (gimp_link_layer_new (image, link));
|
||||
|
||||
if (! layer)
|
||||
{
|
||||
g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT,
|
||||
_("Failed to create link layer"));
|
||||
|
||||
success = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
g_clear_object (&link);
|
||||
}
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub link_layer_discard {
|
||||
$blurb = 'Discard the link layer information.';
|
||||
|
||||
$help = <<'HELP';
|
||||
Discards the link information. This makes the layer behave like a normal layer.
|
||||
HELP
|
||||
|
||||
&jehan_pdb_misc('2025', '3.2');
|
||||
|
||||
@inargs = (
|
||||
{ name => 'layer', type => 'link_layer',
|
||||
desc => 'The link layer' }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimp_link_layer_discard (layer);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub link_layer_monitor {
|
||||
$blurb = 'Retrieve the link layer information.';
|
||||
|
||||
$help = <<'HELP';
|
||||
Retrieve the link information. This makes the layer behave like a link
|
||||
layer after the link information has been discarded.
|
||||
|
||||
Since the source file will be monitored again, it may change the layer's render.
|
||||
HELP
|
||||
|
||||
&jehan_pdb_misc('2025', '3.2');
|
||||
|
||||
@inargs = (
|
||||
{ name => 'layer', type => 'link_layer',
|
||||
desc => 'The link layer' }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimp_link_layer_monitor (layer);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub link_layer_get_file {
|
||||
$blurb = 'Get the monitored file.';
|
||||
|
||||
$help = <<'HELP';
|
||||
This procedure returns the file which is being monitored.
|
||||
HELP
|
||||
|
||||
&jehan_pdb_misc('2025', '3.2');
|
||||
|
||||
@inargs = (
|
||||
{ name => 'layer', type => 'link_layer',
|
||||
desc => 'The link layer' }
|
||||
);
|
||||
|
||||
@outargs = (
|
||||
{ name => 'file', type => 'file',
|
||||
desc => 'The monitored file' }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
file = gimp_link_get_file (gimp_link_layer_get_link (layer), NULL, NULL);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub link_layer_set_file {
|
||||
$blurb = 'Set the monitored file.';
|
||||
|
||||
$help = <<'HELP';
|
||||
This procedure sets the file to be monitored.
|
||||
It may change the layer's render.
|
||||
HELP
|
||||
|
||||
&jehan_pdb_misc('2025', '3.2');
|
||||
|
||||
@inargs = (
|
||||
{ name => 'layer', type => 'link_layer',
|
||||
desc => 'The link layer' },
|
||||
{ name => 'file', type => 'file',
|
||||
desc => 'The file to monitor' }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
GimpLink *link = gimp_link_new (gimp, file, 0, 0, TRUE, NULL, error);
|
||||
|
||||
if (link)
|
||||
{
|
||||
gimp_link_layer_set_link (layer, link, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
g_clear_object (&link);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
@headers = qw("core/gimplink.h"
|
||||
"core/gimplinklayer.h"
|
||||
"gimppdberror.h"
|
||||
"gimp-intl.h");
|
||||
|
||||
@procs = qw(link_layer_new
|
||||
link_layer_discard
|
||||
link_layer_monitor
|
||||
link_layer_get_file
|
||||
link_layer_set_file);
|
||||
|
||||
%exports = (app => [@procs], lib => [@procs]);
|
||||
|
||||
$desc = 'Link layer procedures';
|
||||
$doc_title = 'gimplinklayer';
|
||||
$doc_short_desc = 'Functions for querying and manipulating link layers.';
|
||||
$doc_long_desc = 'Functions for querying and manipulating link layers.';
|
||||
|
||||
1;
|
@@ -42,6 +42,7 @@ pdb_names = [
|
||||
'item_transform',
|
||||
'item',
|
||||
'layer',
|
||||
'link_layer',
|
||||
'message',
|
||||
'paint_tools',
|
||||
'palette_select',
|
||||
|
12
pdb/pdb.pl
12
pdb/pdb.pl
@@ -383,6 +383,18 @@ package Gimp::CodeGen::pdb;
|
||||
take_value_func => 'g_value_set_object ($value, $var)',
|
||||
headers => [ qw("path/gimpvectorlayer.h") ] },
|
||||
|
||||
link_layer => { name => 'LINK_LAYER',
|
||||
gtype => 'GIMP_TYPE_LINK_LAYER',
|
||||
type => 'GimpLinkLayer *',
|
||||
const_type => 'GimpLinkLayer *',
|
||||
init_value => 'NULL',
|
||||
out_annotate => '(transfer none)',
|
||||
get_value_func => '$var = g_value_get_object ($value)',
|
||||
dup_value_func => '$var = GIMP_VALUES_GET_LINK_LAYER ($value)',
|
||||
set_value_func => 'g_value_set_object ($value, $var)',
|
||||
take_value_func => 'g_value_set_object ($value, $var)',
|
||||
headers => [ qw("core/gimplinklayer.h") ] },
|
||||
|
||||
group_layer => { name => 'GROUP_LAYER',
|
||||
gtype => 'GIMP_TYPE_GROUP_LAYER',
|
||||
type => 'GimpGroupLayer *',
|
||||
|
Reference in New Issue
Block a user