summaryrefslogtreecommitdiffstats
path: root/app/pdb/gimprc-cmds.c
blob: 9f81868b312413eff858a01d099441b0d67640a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
/* GIMP - The GNU Image Manipulation Program
 * Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
 *
 * 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/>.
 */

/* NOTE: This file is auto-generated by pdbgen.pl. */

#include "config.h"

#include <string.h>

#include <gegl.h>

#include <gdk-pixbuf/gdk-pixbuf.h>

#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "libgimpmodule/gimpmodule.h"

#include "libgimpbase/gimpbase.h"

#include "pdb-types.h"

#include "config/gimprc.h"
#include "core/gimp-utils.h"
#include "core/gimp.h"
#include "core/gimpparamspecs.h"
#include "core/gimptemplate.h"

#include "gimppdb.h"
#include "gimpprocedure.h"
#include "internal-procs.h"


static GimpValueArray *
gimprc_query_invoker (GimpProcedure         *procedure,
                      Gimp                  *gimp,
                      GimpContext           *context,
                      GimpProgress          *progress,
                      const GimpValueArray  *args,
                      GError               **error)
{
  gboolean success = TRUE;
  GimpValueArray *return_vals;
  const gchar *token;
  gchar *value = NULL;

  token = g_value_get_string (gimp_value_array_index (args, 0));

  if (success)
    {
      if (strlen (token))
        {
          /*  use edit_config because unknown tokens are set there  */
          value = gimp_rc_query (GIMP_RC (gimp->edit_config), token);

          if (! value)
            success = FALSE;
        }
      else
        success = FALSE;
    }

  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_take_string (gimp_value_array_index (return_vals, 1), value);

  return return_vals;
}

static GimpValueArray *
gimprc_set_invoker (GimpProcedure         *procedure,
                    Gimp                  *gimp,
                    GimpContext           *context,
                    GimpProgress          *progress,
                    const GimpValueArray  *args,
                    GError               **error)
{
  gboolean success = TRUE;
  const gchar *token;
  const gchar *value;

  token = g_value_get_string (gimp_value_array_index (args, 0));
  value = g_value_get_string (gimp_value_array_index (args, 1));

  if (success)
    {
      if (strlen (token))
        {
          /*  use edit_config because that's the one that gets saved  */
          gimp_rc_set_unknown_token (GIMP_RC (gimp->edit_config), token, value);
        }
      else
        success = FALSE;
    }

  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static GimpValueArray *
get_default_comment_invoker (GimpProcedure         *procedure,
                             Gimp                  *gimp,
                             GimpContext           *context,
                             GimpProgress          *progress,
                             const GimpValueArray  *args,
                             GError               **error)
{
  GimpValueArray *return_vals;
  gchar *comment = NULL;

  comment = g_strdup (gimp_template_get_comment (gimp->config->default_image));

  return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
  g_value_take_string (gimp_value_array_index (return_vals, 1), comment);

  return return_vals;
}

static GimpValueArray *
get_default_unit_invoker (GimpProcedure         *procedure,
                          Gimp                  *gimp,
                          GimpContext           *context,
                          GimpProgress          *progress,
                          const GimpValueArray  *args,
                          GError               **error)
{
  GimpValueArray *return_vals;
  GimpUnit unit_id = 0;

  unit_id = gimp_get_default_unit ();

  return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
  g_value_set_int (gimp_value_array_index (return_vals, 1), unit_id);

  return return_vals;
}

static GimpValueArray *
get_monitor_resolution_invoker (GimpProcedure         *procedure,
                                Gimp                  *gimp,
                                GimpContext           *context,
                                GimpProgress          *progress,
                                const GimpValueArray  *args,
                                GError               **error)
{
  GimpValueArray *return_vals;
  gdouble xres = 0.0;
  gdouble yres = 0.0;

  xres = GIMP_DISPLAY_CONFIG (gimp->config)->monitor_xres;
  yres = GIMP_DISPLAY_CONFIG (gimp->config)->monitor_yres;

  return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);

  g_value_set_double (gimp_value_array_index (return_vals, 1), xres);
  g_value_set_double (gimp_value_array_index (return_vals, 2), yres);

  return return_vals;
}

static GimpValueArray *
get_theme_dir_invoker (GimpProcedure         *procedure,
                       Gimp                  *gimp,
                       GimpContext           *context,
                       GimpProgress          *progress,
                       const GimpValueArray  *args,
                       GError               **error)
{
  GimpValueArray *return_vals;
  gchar *theme_dir = NULL;

  GFile *file = gimp_get_theme_dir (gimp);

  if (file)
    theme_dir = g_file_get_path (file);

  return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
  g_value_take_string (gimp_value_array_index (return_vals, 1), theme_dir);

  return return_vals;
}

static GimpValueArray *
get_icon_theme_dir_invoker (GimpProcedure         *procedure,
                            Gimp                  *gimp,
                            GimpContext           *context,
                            GimpProgress          *progress,
                            const GimpValueArray  *args,
                            GError               **error)
{
  GimpValueArray *return_vals;
  gchar *icon_theme_dir = NULL;

  GFile *file = gimp_get_icon_theme_dir (gimp);

  if (file)
    icon_theme_dir = g_file_get_path (file);

  return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
  g_value_take_string (gimp_value_array_index (return_vals, 1), icon_theme_dir);

  return return_vals;
}

static GimpValueArray *
get_color_configuration_invoker (GimpProcedure         *procedure,
                                 Gimp                  *gimp,
                                 GimpContext           *context,
                                 GimpProgress          *progress,
                                 const GimpValueArray  *args,
                                 GError               **error)
{
  GimpValueArray *return_vals;
  gchar *config = NULL;

  config = gimp_config_serialize_to_string (GIMP_CONFIG (gimp->config->color_management), NULL);

  return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
  g_value_take_string (gimp_value_array_index (return_vals, 1), config);

  return return_vals;
}

static GimpValueArray *
get_module_load_inhibit_invoker (GimpProcedure         *procedure,
                                 Gimp                  *gimp,
                                 GimpContext           *context,
                                 GimpProgress          *progress,
                                 const GimpValueArray  *args,
                                 GError               **error)
{
  GimpValueArray *return_vals;
  gchar *load_inhibit = NULL;

  load_inhibit = g_strdup (gimp_module_db_get_load_inhibit (gimp->module_db));

  return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
  g_value_take_string (gimp_value_array_index (return_vals, 1), load_inhibit);

  return return_vals;
}

void
register_gimprc_procs (GimpPDB *pdb)
{
  GimpProcedure *procedure;

  /*
   * gimp-gimprc-query
   */
  procedure = gimp_procedure_new (gimprc_query_invoker);
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-gimprc-query");
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-gimprc-query",
                                     "Queries the gimprc file parser for information on a specified token.",
                                     "This procedure is used to locate additional information contained in the gimprc file considered extraneous to the operation of GIMP. Plug-ins that need configuration information can expect it will be stored in the user gimprc file and can use this procedure to retrieve it. This query procedure will return the value associated with the specified token. This corresponds _only_ to entries with the format: (<token> <value>). The value must be a string. Entries not corresponding to this format will cause warnings to be issued on gimprc parsing and will not be queryable.",
                                     "Spencer Kimball & Peter Mattis",
                                     "Spencer Kimball & Peter Mattis",
                                     "1997",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("token",
                                                       "token",
                                                       "The token to query for",
                                                       FALSE, FALSE, FALSE,
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_string ("value",
                                                           "value",
                                                           "The value associated with the queried token",
                                                           FALSE, FALSE, FALSE,
                                                           NULL,
                                                           GIMP_PARAM_READWRITE));
  gimp_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * gimp-gimprc-set
   */
  procedure = gimp_procedure_new (gimprc_set_invoker);
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-gimprc-set");
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-gimprc-set",
                                     "Sets a gimprc token to a value and saves it in the gimprc.",
                                     "This procedure is used to add or change additional information in the gimprc file that is considered extraneous to the operation of GIMP. Plug-ins that need configuration information can use this function to store it, and 'gimp-gimprc-query' to retrieve it. This will accept _only_ string values in UTF-8 encoding.",
                                     "Seth Burgess",
                                     "Seth Burgess",
                                     "1999",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("token",
                                                       "token",
                                                       "The token to add or modify",
                                                       FALSE, FALSE, FALSE,
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("value",
                                                       "value",
                                                       "The value to set the token to",
                                                       FALSE, FALSE, FALSE,
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * gimp-get-default-comment
   */
  procedure = gimp_procedure_new (get_default_comment_invoker);
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-get-default-comment");
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-get-default-comment",
                                     "Get the default image comment as specified in the Preferences.",
                                     "Returns a copy of the default image comment.",
                                     "Spencer Kimball & Peter Mattis",
                                     "Spencer Kimball & Peter Mattis",
                                     "1995-1996",
                                     NULL);
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_string ("comment",
                                                           "comment",
                                                           "Default image comment",
                                                           FALSE, FALSE, FALSE,
                                                           NULL,
                                                           GIMP_PARAM_READWRITE));
  gimp_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * gimp-get-default-unit
   */
  procedure = gimp_procedure_new (get_default_unit_invoker);
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-get-default-unit");
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-get-default-unit",
                                     "Get the default unit (taken from the user's locale).",
                                     "Returns the default unit's integer ID.",
                                     "Spencer Kimball & Peter Mattis",
                                     "Spencer Kimball & Peter Mattis",
                                     "1995-1996",
                                     NULL);
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_unit ("unit-id",
                                                         "unit id",
                                                         "Default unit",
                                                         TRUE,
                                                         FALSE,
                                                         GIMP_UNIT_PIXEL,
                                                         GIMP_PARAM_READWRITE));
  gimp_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * gimp-get-monitor-resolution
   */
  procedure = gimp_procedure_new (get_monitor_resolution_invoker);
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-get-monitor-resolution");
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-get-monitor-resolution",
                                     "Get the monitor resolution as specified in the Preferences.",
                                     "Returns the resolution of the monitor in pixels/inch. This value is taken from the Preferences (or the windowing system if this is set in the Preferences) and there's no guarantee for the value to be reasonable.",
                                     "Spencer Kimball & Peter Mattis",
                                     "Spencer Kimball & Peter Mattis",
                                     "1995-1996",
                                     NULL);
  gimp_procedure_add_return_value (procedure,
                                   g_param_spec_double ("xres",
                                                        "xres",
                                                        "X resolution",
                                                        -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                        GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   g_param_spec_double ("yres",
                                                        "yres",
                                                        "Y resolution",
                                                        -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                        GIMP_PARAM_READWRITE));
  gimp_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * gimp-get-theme-dir
   */
  procedure = gimp_procedure_new (get_theme_dir_invoker);
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-get-theme-dir");
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-get-theme-dir",
                                     "Get the directory of the current GUI theme.",
                                     "Returns a copy of the current GUI theme dir.\n"
                                     "\n"
                                     "Deprecated: There is no replacement for this procedure.",
                                     "Spencer Kimball & Peter Mattis",
                                     "Spencer Kimball & Peter Mattis",
                                     "1995-1996",
                                     "NONE");
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_string ("theme-dir",
                                                           "theme dir",
                                                           "The GUI theme dir",
                                                           FALSE, FALSE, FALSE,
                                                           NULL,
                                                           GIMP_PARAM_READWRITE));
  gimp_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * gimp-get-icon-theme-dir
   */
  procedure = gimp_procedure_new (get_icon_theme_dir_invoker);
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-get-icon-theme-dir");
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-get-icon-theme-dir",
                                     "Get the directory of the current icon theme.",
                                     "Returns a copy of the current icon theme dir.\n"
                                     "\n"
                                     "Deprecated: There is no replacement for this procedure.",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "2015",
                                     "NONE");
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_string ("icon-theme-dir",
                                                           "icon theme dir",
                                                           "The icon theme dir",
                                                           FALSE, FALSE, FALSE,
                                                           NULL,
                                                           GIMP_PARAM_READWRITE));
  gimp_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * gimp-get-color-configuration
   */
  procedure = gimp_procedure_new (get_color_configuration_invoker);
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-get-color-configuration");
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-get-color-configuration",
                                     "Get a serialized version of the color management configuration.",
                                     "Returns a string that can be deserialized into a GimpColorConfig object representing the current color management configuration.",
                                     "Sven Neumann <sven@gimp.org>",
                                     "Sven Neumann",
                                     "2005",
                                     NULL);
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_string ("config",
                                                           "config",
                                                           "Serialized color management configuration",
                                                           FALSE, FALSE, FALSE,
                                                           NULL,
                                                           GIMP_PARAM_READWRITE));
  gimp_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * gimp-get-module-load-inhibit
   */
  procedure = gimp_procedure_new (get_module_load_inhibit_invoker);
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-get-module-load-inhibit");
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-get-module-load-inhibit",
                                     "Get the list of modules which should not be loaded.",
                                     "Returns a copy of the list of modules which should not be loaded.",
                                     "Spencer Kimball & Peter Mattis",
                                     "Spencer Kimball & Peter Mattis",
                                     "1995-1996",
                                     NULL);
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_string ("load-inhibit",
                                                           "load inhibit",
                                                           "The list of modules",
                                                           FALSE, FALSE, FALSE,
                                                           NULL,
                                                           GIMP_PARAM_READWRITE));
  gimp_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);
}