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 "libgimpbase/gimpbase.h"
29
30 #include "pdb-types.h"
31
32 #include "core/gimp-parasites.h"
33 #include "core/gimp-utils.h"
34 #include "core/gimp.h"
35 #include "core/gimpparamspecs.h"
36
37 #include "gimppdb.h"
38 #include "gimpprocedure.h"
39 #include "internal-procs.h"
40
41
42 static GimpValueArray *
version_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)43 version_invoker (GimpProcedure *procedure,
44 Gimp *gimp,
45 GimpContext *context,
46 GimpProgress *progress,
47 const GimpValueArray *args,
48 GError **error)
49 {
50 GimpValueArray *return_vals;
51 gchar *version = NULL;
52
53 version = g_strdup (GIMP_VERSION);
54
55 return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
56 g_value_take_string (gimp_value_array_index (return_vals, 1), version);
57
58 return return_vals;
59 }
60
61 static GimpValueArray *
getpid_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)62 getpid_invoker (GimpProcedure *procedure,
63 Gimp *gimp,
64 GimpContext *context,
65 GimpProgress *progress,
66 const GimpValueArray *args,
67 GError **error)
68 {
69 GimpValueArray *return_vals;
70 gint32 pid = 0;
71
72 pid = gimp_get_pid ();
73
74 return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
75 g_value_set_int (gimp_value_array_index (return_vals, 1), pid);
76
77 return return_vals;
78 }
79
80 static GimpValueArray *
quit_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)81 quit_invoker (GimpProcedure *procedure,
82 Gimp *gimp,
83 GimpContext *context,
84 GimpProgress *progress,
85 const GimpValueArray *args,
86 GError **error)
87 {
88 gboolean success = TRUE;
89 gboolean force;
90
91 force = g_value_get_boolean (gimp_value_array_index (args, 0));
92
93 if (success)
94 {
95 gimp_exit (gimp, force);
96 }
97
98 return gimp_procedure_get_return_values (procedure, success,
99 error ? *error : NULL);
100 }
101
102 static GimpValueArray *
attach_parasite_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)103 attach_parasite_invoker (GimpProcedure *procedure,
104 Gimp *gimp,
105 GimpContext *context,
106 GimpProgress *progress,
107 const GimpValueArray *args,
108 GError **error)
109 {
110 gboolean success = TRUE;
111 const GimpParasite *parasite;
112
113 parasite = g_value_get_boxed (gimp_value_array_index (args, 0));
114
115 if (success)
116 {
117 if (gimp_parasite_validate (gimp, parasite, error))
118 gimp_parasite_attach (gimp, parasite);
119 else
120 success = FALSE;
121 }
122
123 return gimp_procedure_get_return_values (procedure, success,
124 error ? *error : NULL);
125 }
126
127 static GimpValueArray *
detach_parasite_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)128 detach_parasite_invoker (GimpProcedure *procedure,
129 Gimp *gimp,
130 GimpContext *context,
131 GimpProgress *progress,
132 const GimpValueArray *args,
133 GError **error)
134 {
135 gboolean success = TRUE;
136 const gchar *name;
137
138 name = g_value_get_string (gimp_value_array_index (args, 0));
139
140 if (success)
141 {
142 gimp_parasite_detach (gimp, name);
143 }
144
145 return gimp_procedure_get_return_values (procedure, success,
146 error ? *error : NULL);
147 }
148
149 static GimpValueArray *
get_parasite_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)150 get_parasite_invoker (GimpProcedure *procedure,
151 Gimp *gimp,
152 GimpContext *context,
153 GimpProgress *progress,
154 const GimpValueArray *args,
155 GError **error)
156 {
157 gboolean success = TRUE;
158 GimpValueArray *return_vals;
159 const gchar *name;
160 GimpParasite *parasite = NULL;
161
162 name = g_value_get_string (gimp_value_array_index (args, 0));
163
164 if (success)
165 {
166 parasite = gimp_parasite_copy (gimp_parasite_find (gimp, name));
167
168 if (! parasite)
169 success = FALSE;
170 }
171
172 return_vals = gimp_procedure_get_return_values (procedure, success,
173 error ? *error : NULL);
174
175 if (success)
176 g_value_take_boxed (gimp_value_array_index (return_vals, 1), parasite);
177
178 return return_vals;
179 }
180
181 static GimpValueArray *
get_parasite_list_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)182 get_parasite_list_invoker (GimpProcedure *procedure,
183 Gimp *gimp,
184 GimpContext *context,
185 GimpProgress *progress,
186 const GimpValueArray *args,
187 GError **error)
188 {
189 GimpValueArray *return_vals;
190 gint32 num_parasites = 0;
191 gchar **parasites = NULL;
192
193 parasites = gimp_parasite_list (gimp, &num_parasites);
194
195 return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
196
197 g_value_set_int (gimp_value_array_index (return_vals, 1), num_parasites);
198 gimp_value_take_stringarray (gimp_value_array_index (return_vals, 2), parasites, num_parasites);
199
200 return return_vals;
201 }
202
203 static GimpValueArray *
temp_name_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)204 temp_name_invoker (GimpProcedure *procedure,
205 Gimp *gimp,
206 GimpContext *context,
207 GimpProgress *progress,
208 const GimpValueArray *args,
209 GError **error)
210 {
211 gboolean success = TRUE;
212 GimpValueArray *return_vals;
213 const gchar *extension;
214 gchar *name = NULL;
215
216 extension = g_value_get_string (gimp_value_array_index (args, 0));
217
218 if (success)
219 {
220 GFile *file = gimp_get_temp_file (gimp, extension);
221
222 name = g_file_get_path (file);
223
224 g_object_unref (file);
225 }
226
227 return_vals = gimp_procedure_get_return_values (procedure, success,
228 error ? *error : NULL);
229
230 if (success)
231 g_value_take_string (gimp_value_array_index (return_vals, 1), name);
232
233 return return_vals;
234 }
235
236 void
register_gimp_procs(GimpPDB * pdb)237 register_gimp_procs (GimpPDB *pdb)
238 {
239 GimpProcedure *procedure;
240
241 /*
242 * gimp-version
243 */
244 procedure = gimp_procedure_new (version_invoker);
245 gimp_object_set_static_name (GIMP_OBJECT (procedure),
246 "gimp-version");
247 gimp_procedure_set_static_strings (procedure,
248 "gimp-version",
249 "Returns the host GIMP version.",
250 "This procedure returns the version number of the currently running GIMP.",
251 "Manish Singh",
252 "Manish Singh",
253 "1999",
254 NULL);
255 gimp_procedure_add_return_value (procedure,
256 gimp_param_spec_string ("version",
257 "version",
258 "GIMP version number",
259 FALSE, FALSE, FALSE,
260 NULL,
261 GIMP_PARAM_READWRITE));
262 gimp_pdb_register_procedure (pdb, procedure);
263 g_object_unref (procedure);
264
265 /*
266 * gimp-getpid
267 */
268 procedure = gimp_procedure_new (getpid_invoker);
269 gimp_object_set_static_name (GIMP_OBJECT (procedure),
270 "gimp-getpid");
271 gimp_procedure_set_static_strings (procedure,
272 "gimp-getpid",
273 "Returns the PID of the host GIMP process.",
274 "This procedure returns the process ID of the currently running GIMP.",
275 "Michael Natterer <mitch@gimp.org>",
276 "Michael Natterer",
277 "2005",
278 NULL);
279 gimp_procedure_add_return_value (procedure,
280 gimp_param_spec_int32 ("pid",
281 "pid",
282 "The PID",
283 G_MININT32, G_MAXINT32, 0,
284 GIMP_PARAM_READWRITE));
285 gimp_pdb_register_procedure (pdb, procedure);
286 g_object_unref (procedure);
287
288 /*
289 * gimp-quit
290 */
291 procedure = gimp_procedure_new (quit_invoker);
292 gimp_object_set_static_name (GIMP_OBJECT (procedure),
293 "gimp-quit");
294 gimp_procedure_set_static_strings (procedure,
295 "gimp-quit",
296 "Causes GIMP to exit gracefully.",
297 "If there are unsaved images in an interactive GIMP session, the user will be asked for confirmation. If force is TRUE, the application is quit without querying the user to save any dirty images.",
298 "Spencer Kimball & Peter Mattis",
299 "Spencer Kimball & Peter Mattis",
300 "1995-1996",
301 NULL);
302 gimp_procedure_add_argument (procedure,
303 g_param_spec_boolean ("force",
304 "force",
305 "Force GIMP to quit without asking",
306 FALSE,
307 GIMP_PARAM_READWRITE));
308 gimp_pdb_register_procedure (pdb, procedure);
309 g_object_unref (procedure);
310
311 /*
312 * gimp-attach-parasite
313 */
314 procedure = gimp_procedure_new (attach_parasite_invoker);
315 gimp_object_set_static_name (GIMP_OBJECT (procedure),
316 "gimp-attach-parasite");
317 gimp_procedure_set_static_strings (procedure,
318 "gimp-attach-parasite",
319 "Add a global parasite.",
320 "This procedure attaches a global parasite. It has no return values.",
321 "Jay Cox",
322 "Jay Cox",
323 "1998",
324 NULL);
325 gimp_procedure_add_argument (procedure,
326 gimp_param_spec_parasite ("parasite",
327 "parasite",
328 "The parasite to attach",
329 GIMP_PARAM_READWRITE));
330 gimp_pdb_register_procedure (pdb, procedure);
331 g_object_unref (procedure);
332
333 /*
334 * gimp-detach-parasite
335 */
336 procedure = gimp_procedure_new (detach_parasite_invoker);
337 gimp_object_set_static_name (GIMP_OBJECT (procedure),
338 "gimp-detach-parasite");
339 gimp_procedure_set_static_strings (procedure,
340 "gimp-detach-parasite",
341 "Removes a global parasite.",
342 "This procedure detaches a global parasite from. It has no return values.",
343 "Jay Cox",
344 "Jay Cox",
345 "1998",
346 NULL);
347 gimp_procedure_add_argument (procedure,
348 gimp_param_spec_string ("name",
349 "name",
350 "The name of the parasite to detach.",
351 FALSE, FALSE, FALSE,
352 NULL,
353 GIMP_PARAM_READWRITE));
354 gimp_pdb_register_procedure (pdb, procedure);
355 g_object_unref (procedure);
356
357 /*
358 * gimp-get-parasite
359 */
360 procedure = gimp_procedure_new (get_parasite_invoker);
361 gimp_object_set_static_name (GIMP_OBJECT (procedure),
362 "gimp-get-parasite");
363 gimp_procedure_set_static_strings (procedure,
364 "gimp-get-parasite",
365 "Look up a global parasite.",
366 "Finds and returns the global parasite that was previously attached.",
367 "Jay Cox",
368 "Jay Cox",
369 "1998",
370 NULL);
371 gimp_procedure_add_argument (procedure,
372 gimp_param_spec_string ("name",
373 "name",
374 "The name of the parasite to find",
375 FALSE, FALSE, FALSE,
376 NULL,
377 GIMP_PARAM_READWRITE));
378 gimp_procedure_add_return_value (procedure,
379 gimp_param_spec_parasite ("parasite",
380 "parasite",
381 "The found parasite",
382 GIMP_PARAM_READWRITE));
383 gimp_pdb_register_procedure (pdb, procedure);
384 g_object_unref (procedure);
385
386 /*
387 * gimp-get-parasite-list
388 */
389 procedure = gimp_procedure_new (get_parasite_list_invoker);
390 gimp_object_set_static_name (GIMP_OBJECT (procedure),
391 "gimp-get-parasite-list");
392 gimp_procedure_set_static_strings (procedure,
393 "gimp-get-parasite-list",
394 "List all parasites.",
395 "Returns a list of all currently attached global parasites.",
396 "Marc Lehmann",
397 "Marc Lehmann",
398 "1999",
399 NULL);
400 gimp_procedure_add_return_value (procedure,
401 gimp_param_spec_int32 ("num-parasites",
402 "num parasites",
403 "The number of attached parasites",
404 0, G_MAXINT32, 0,
405 GIMP_PARAM_READWRITE));
406 gimp_procedure_add_return_value (procedure,
407 gimp_param_spec_string_array ("parasites",
408 "parasites",
409 "The names of currently attached parasites",
410 GIMP_PARAM_READWRITE));
411 gimp_pdb_register_procedure (pdb, procedure);
412 g_object_unref (procedure);
413
414 /*
415 * gimp-temp-name
416 */
417 procedure = gimp_procedure_new (temp_name_invoker);
418 gimp_object_set_static_name (GIMP_OBJECT (procedure),
419 "gimp-temp-name");
420 gimp_procedure_set_static_strings (procedure,
421 "gimp-temp-name",
422 "Generates a unique filename.",
423 "Generates a unique filename using the temp path supplied in the user's gimprc.",
424 "Josh MacDonald",
425 "Josh MacDonald",
426 "1997",
427 NULL);
428 gimp_procedure_add_argument (procedure,
429 gimp_param_spec_string ("extension",
430 "extension",
431 "The extension the file will have",
432 TRUE, TRUE, FALSE,
433 NULL,
434 GIMP_PARAM_READWRITE));
435 gimp_procedure_add_return_value (procedure,
436 gimp_param_spec_string ("name",
437 "name",
438 "The new temp filename",
439 FALSE, FALSE, FALSE,
440 NULL,
441 GIMP_PARAM_READWRITE));
442 gimp_pdb_register_procedure (pdb, procedure);
443 g_object_unref (procedure);
444 }
445