1 /* GIMP - The GNU Image Manipulation Program
2  * Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
16  */
17 
18 /* NOTE: This file is auto-generated by pdbgen.pl. */
19 
20 #include "config.h"
21 
22 #include <gegl.h>
23 
24 #include <gdk-pixbuf/gdk-pixbuf.h>
25 
26 #include "libgimpbase/gimpbase.h"
27 
28 #include "pdb-types.h"
29 
30 #include "core/gimpdrawable.h"
31 #include "core/gimpimage.h"
32 #include "core/gimplayer-floating-selection.h"
33 #include "core/gimplayer.h"
34 #include "core/gimpparamspecs.h"
35 
36 #include "gimppdb.h"
37 #include "gimppdberror.h"
38 #include "gimppdb-utils.h"
39 #include "gimpprocedure.h"
40 #include "internal-procs.h"
41 
42 #include "gimp-intl.h"
43 
44 
45 static GimpValueArray *
floating_sel_remove_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)46 floating_sel_remove_invoker (GimpProcedure         *procedure,
47                              Gimp                  *gimp,
48                              GimpContext           *context,
49                              GimpProgress          *progress,
50                              const GimpValueArray  *args,
51                              GError               **error)
52 {
53   gboolean success = TRUE;
54   GimpLayer *floating_sel;
55 
56   floating_sel = gimp_value_get_layer (gimp_value_array_index (args, 0), gimp);
57 
58   if (success)
59     {
60       if (gimp_layer_is_floating_sel (floating_sel))
61         {
62           gimp_image_remove_layer (gimp_item_get_image (GIMP_ITEM (floating_sel)),
63                                    floating_sel, TRUE, NULL);
64         }
65       else
66         {
67           g_set_error_literal (error, GIMP_PDB_ERROR,
68                                GIMP_PDB_ERROR_INVALID_ARGUMENT,
69                                _("Cannot remove this layer because "
70                                  "it is not a floating selection."));
71           success = FALSE;
72         }
73     }
74 
75   return gimp_procedure_get_return_values (procedure, success,
76                                            error ? *error : NULL);
77 }
78 
79 static GimpValueArray *
floating_sel_anchor_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)80 floating_sel_anchor_invoker (GimpProcedure         *procedure,
81                              Gimp                  *gimp,
82                              GimpContext           *context,
83                              GimpProgress          *progress,
84                              const GimpValueArray  *args,
85                              GError               **error)
86 {
87   gboolean success = TRUE;
88   GimpLayer *floating_sel;
89 
90   floating_sel = gimp_value_get_layer (gimp_value_array_index (args, 0), gimp);
91 
92   if (success)
93     {
94       if (gimp_layer_is_floating_sel (floating_sel))
95         {
96           floating_sel_anchor (floating_sel);
97         }
98       else
99         {
100           g_set_error_literal (error, GIMP_PDB_ERROR,
101                                GIMP_PDB_ERROR_INVALID_ARGUMENT,
102                                _("Cannot anchor this layer because "
103                                  "it is not a floating selection."));
104           success = FALSE;
105         }
106     }
107 
108   return gimp_procedure_get_return_values (procedure, success,
109                                            error ? *error : NULL);
110 }
111 
112 static GimpValueArray *
floating_sel_to_layer_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)113 floating_sel_to_layer_invoker (GimpProcedure         *procedure,
114                                Gimp                  *gimp,
115                                GimpContext           *context,
116                                GimpProgress          *progress,
117                                const GimpValueArray  *args,
118                                GError               **error)
119 {
120   gboolean success = TRUE;
121   GimpLayer *floating_sel;
122 
123   floating_sel = gimp_value_get_layer (gimp_value_array_index (args, 0), gimp);
124 
125   if (success)
126     {
127       if (gimp_layer_is_floating_sel (floating_sel))
128         {
129           success = floating_sel_to_layer (floating_sel, error);
130         }
131       else
132         {
133           g_set_error_literal (error, GIMP_PDB_ERROR,
134                                GIMP_PDB_ERROR_INVALID_ARGUMENT,
135                                _("Cannot convert this layer to a normal layer "
136                                  "because it is not a floating selection."));
137           success = FALSE;
138         }
139     }
140 
141   return gimp_procedure_get_return_values (procedure, success,
142                                            error ? *error : NULL);
143 }
144 
145 static GimpValueArray *
floating_sel_attach_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)146 floating_sel_attach_invoker (GimpProcedure         *procedure,
147                              Gimp                  *gimp,
148                              GimpContext           *context,
149                              GimpProgress          *progress,
150                              const GimpValueArray  *args,
151                              GError               **error)
152 {
153   gboolean success = TRUE;
154   GimpLayer *layer;
155   GimpDrawable *drawable;
156 
157   layer = gimp_value_get_layer (gimp_value_array_index (args, 0), gimp);
158   drawable = gimp_value_get_drawable (gimp_value_array_index (args, 1), gimp);
159 
160   if (success)
161     {
162       if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
163                                      GIMP_PDB_ITEM_CONTENT, error) &&
164           gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
165         floating_sel_attach (layer, drawable);
166       else
167         success = FALSE;
168     }
169 
170   return gimp_procedure_get_return_values (procedure, success,
171                                            error ? *error : NULL);
172 }
173 
174 static GimpValueArray *
floating_sel_rigor_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)175 floating_sel_rigor_invoker (GimpProcedure         *procedure,
176                             Gimp                  *gimp,
177                             GimpContext           *context,
178                             GimpProgress          *progress,
179                             const GimpValueArray  *args,
180                             GError               **error)
181 {
182   gboolean success = TRUE;
183   if (success)
184     {
185     }
186   return gimp_procedure_get_return_values (procedure, success,
187                                            error ? *error : NULL);
188 }
189 
190 static GimpValueArray *
floating_sel_relax_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)191 floating_sel_relax_invoker (GimpProcedure         *procedure,
192                             Gimp                  *gimp,
193                             GimpContext           *context,
194                             GimpProgress          *progress,
195                             const GimpValueArray  *args,
196                             GError               **error)
197 {
198   gboolean success = TRUE;
199   if (success)
200     {
201     }
202   return gimp_procedure_get_return_values (procedure, success,
203                                            error ? *error : NULL);
204 }
205 
206 void
register_floating_sel_procs(GimpPDB * pdb)207 register_floating_sel_procs (GimpPDB *pdb)
208 {
209   GimpProcedure *procedure;
210 
211   /*
212    * gimp-floating-sel-remove
213    */
214   procedure = gimp_procedure_new (floating_sel_remove_invoker);
215   gimp_object_set_static_name (GIMP_OBJECT (procedure),
216                                "gimp-floating-sel-remove");
217   gimp_procedure_set_static_strings (procedure,
218                                      "gimp-floating-sel-remove",
219                                      "Remove the specified floating selection from its associated drawable.",
220                                      "This procedure removes the floating selection completely, without any side effects. The associated drawable is then set to active.",
221                                      "Spencer Kimball & Peter Mattis",
222                                      "Spencer Kimball & Peter Mattis",
223                                      "1995-1996",
224                                      NULL);
225   gimp_procedure_add_argument (procedure,
226                                gimp_param_spec_layer_id ("floating-sel",
227                                                          "floating sel",
228                                                          "The floating selection",
229                                                          pdb->gimp, FALSE,
230                                                          GIMP_PARAM_READWRITE));
231   gimp_pdb_register_procedure (pdb, procedure);
232   g_object_unref (procedure);
233 
234   /*
235    * gimp-floating-sel-anchor
236    */
237   procedure = gimp_procedure_new (floating_sel_anchor_invoker);
238   gimp_object_set_static_name (GIMP_OBJECT (procedure),
239                                "gimp-floating-sel-anchor");
240   gimp_procedure_set_static_strings (procedure,
241                                      "gimp-floating-sel-anchor",
242                                      "Anchor the specified floating selection to its associated drawable.",
243                                      "This procedure anchors the floating selection to its associated drawable. This is similar to merging with a merge type of ClipToBottomLayer. The floating selection layer is no longer valid after this operation.",
244                                      "Spencer Kimball & Peter Mattis",
245                                      "Spencer Kimball & Peter Mattis",
246                                      "1995-1996",
247                                      NULL);
248   gimp_procedure_add_argument (procedure,
249                                gimp_param_spec_layer_id ("floating-sel",
250                                                          "floating sel",
251                                                          "The floating selection",
252                                                          pdb->gimp, FALSE,
253                                                          GIMP_PARAM_READWRITE));
254   gimp_pdb_register_procedure (pdb, procedure);
255   g_object_unref (procedure);
256 
257   /*
258    * gimp-floating-sel-to-layer
259    */
260   procedure = gimp_procedure_new (floating_sel_to_layer_invoker);
261   gimp_object_set_static_name (GIMP_OBJECT (procedure),
262                                "gimp-floating-sel-to-layer");
263   gimp_procedure_set_static_strings (procedure,
264                                      "gimp-floating-sel-to-layer",
265                                      "Transforms the specified floating selection into a layer.",
266                                      "This procedure transforms the specified floating selection into a layer with the same offsets and extents. The composited image will look precisely the same, but the floating selection layer will no longer be clipped to the extents of the drawable it was attached to. The floating selection will become the active layer. This procedure will not work if the floating selection has a different base type from the underlying image. This might be the case if the floating selection is above an auxiliary channel or a layer mask.",
267                                      "Spencer Kimball & Peter Mattis",
268                                      "Spencer Kimball & Peter Mattis",
269                                      "1995-1996",
270                                      NULL);
271   gimp_procedure_add_argument (procedure,
272                                gimp_param_spec_layer_id ("floating-sel",
273                                                          "floating sel",
274                                                          "The floating selection",
275                                                          pdb->gimp, FALSE,
276                                                          GIMP_PARAM_READWRITE));
277   gimp_pdb_register_procedure (pdb, procedure);
278   g_object_unref (procedure);
279 
280   /*
281    * gimp-floating-sel-attach
282    */
283   procedure = gimp_procedure_new (floating_sel_attach_invoker);
284   gimp_object_set_static_name (GIMP_OBJECT (procedure),
285                                "gimp-floating-sel-attach");
286   gimp_procedure_set_static_strings (procedure,
287                                      "gimp-floating-sel-attach",
288                                      "Attach the specified layer as floating to the specified drawable.",
289                                      "This procedure attaches the layer as floating selection to the drawable.",
290                                      "Spencer Kimball & Peter Mattis",
291                                      "Spencer Kimball & Peter Mattis",
292                                      "1995-1996",
293                                      NULL);
294   gimp_procedure_add_argument (procedure,
295                                gimp_param_spec_layer_id ("layer",
296                                                          "layer",
297                                                          "The layer (is attached as floating selection)",
298                                                          pdb->gimp, FALSE,
299                                                          GIMP_PARAM_READWRITE));
300   gimp_procedure_add_argument (procedure,
301                                gimp_param_spec_drawable_id ("drawable",
302                                                             "drawable",
303                                                             "The drawable (where to attach the floating selection)",
304                                                             pdb->gimp, FALSE,
305                                                             GIMP_PARAM_READWRITE));
306   gimp_pdb_register_procedure (pdb, procedure);
307   g_object_unref (procedure);
308 
309   /*
310    * gimp-floating-sel-rigor
311    */
312   procedure = gimp_procedure_new (floating_sel_rigor_invoker);
313   gimp_object_set_static_name (GIMP_OBJECT (procedure),
314                                "gimp-floating-sel-rigor");
315   gimp_procedure_set_static_strings (procedure,
316                                      "gimp-floating-sel-rigor",
317                                      "Deprecated: There is no replacement for this procedure.",
318                                      "Deprecated: There is no replacement for this procedure.",
319                                      "",
320                                      "",
321                                      "",
322                                      "NONE");
323   gimp_procedure_add_argument (procedure,
324                                gimp_param_spec_layer_id ("floating-sel",
325                                                          "floating sel",
326                                                          "The floating selection",
327                                                          pdb->gimp, FALSE,
328                                                          GIMP_PARAM_READWRITE));
329   gimp_procedure_add_argument (procedure,
330                                g_param_spec_boolean ("undo",
331                                                      "undo",
332                                                      "",
333                                                      FALSE,
334                                                      GIMP_PARAM_READWRITE));
335   gimp_pdb_register_procedure (pdb, procedure);
336   g_object_unref (procedure);
337 
338   /*
339    * gimp-floating-sel-relax
340    */
341   procedure = gimp_procedure_new (floating_sel_relax_invoker);
342   gimp_object_set_static_name (GIMP_OBJECT (procedure),
343                                "gimp-floating-sel-relax");
344   gimp_procedure_set_static_strings (procedure,
345                                      "gimp-floating-sel-relax",
346                                      "Deprecated: There is no replacement for this procedure.",
347                                      "Deprecated: There is no replacement for this procedure.",
348                                      "",
349                                      "",
350                                      "",
351                                      "NONE");
352   gimp_procedure_add_argument (procedure,
353                                gimp_param_spec_layer_id ("floating-sel",
354                                                          "floating sel",
355                                                          "The floating selection",
356                                                          pdb->gimp, FALSE,
357                                                          GIMP_PARAM_READWRITE));
358   gimp_procedure_add_argument (procedure,
359                                g_param_spec_boolean ("undo",
360                                                      "undo",
361                                                      "",
362                                                      FALSE,
363                                                      GIMP_PARAM_READWRITE));
364   gimp_pdb_register_procedure (pdb, procedure);
365   g_object_unref (procedure);
366 }
367