gimprc-cmds.c 19.6 KB
Newer Older
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 8 9 10 11 12 13 14
 * (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
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 17
 */

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

20 21
#include "config.h"

22
#include <string.h>
23

24
#include <gegl.h>
25

26
#include "libgimpbase/gimpbase.h"
27
#include "libgimpconfig/gimpconfig.h"
28 29
#include "libgimpmodule/gimpmodule.h"

30
#include "pdb-types.h"
31

32
#include "config/gimprc.h"
33
#include "core/gimp-utils.h"
34
#include "core/gimp.h"
35
#include "core/gimpparamspecs.h"
Sven Neumann's avatar
Sven Neumann committed
36
#include "core/gimptemplate.h"
37

38 39
#include "gimppdb.h"
#include "gimpprocedure.h"
40
#include "internal-procs.h"
41

42

43
static GValueArray *
44 45 46 47 48 49
gimprc_query_invoker (GimpProcedure      *procedure,
                      Gimp               *gimp,
                      GimpContext        *context,
                      GimpProgress       *progress,
                      const GValueArray  *args,
                      GError            **error)
50 51
{
  gboolean success = TRUE;
52
  GValueArray *return_vals;
53
  const gchar *token;
54
  gchar *value = NULL;
55

56
  token = g_value_get_string (&args->values[0]);
57

Manish Singh's avatar
Manish Singh committed
58 59
  if (success)
    {
60 61 62 63
      if (strlen (token))
        {
          /*  use edit_config because unknown tokens are set there  */
          value = gimp_rc_query (GIMP_RC (gimp->edit_config), token);
64

65 66 67 68 69
          if (! value)
            success = FALSE;
        }
      else
        success = FALSE;
Manish Singh's avatar
Manish Singh committed
70
    }
71

72 73
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
74 75

  if (success)
76
    g_value_take_string (&return_vals->values[1], value);
77

78
  return return_vals;
79 80
}

81
static GValueArray *
82 83 84 85 86 87
gimprc_set_invoker (GimpProcedure      *procedure,
                    Gimp               *gimp,
                    GimpContext        *context,
                    GimpProgress       *progress,
                    const GValueArray  *args,
                    GError            **error)
88 89
{
  gboolean success = TRUE;
90 91
  const gchar *token;
  const gchar *value;
92

93 94
  token = g_value_get_string (&args->values[0]);
  value = g_value_get_string (&args->values[1]);
95 96

  if (success)
97
    {
98 99 100 101 102 103 104
      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;
105
    }
106

107 108
  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
109 110
}

111
static GValueArray *
112 113 114 115 116 117
get_default_comment_invoker (GimpProcedure      *procedure,
                             Gimp               *gimp,
                             GimpContext        *context,
                             GimpProgress       *progress,
                             const GValueArray  *args,
                             GError            **error)
118
{
119
  GValueArray *return_vals;
120
  gchar *comment = NULL;
121

Sven Neumann's avatar
Sven Neumann committed
122
  comment = g_strdup (gimp->config->default_image->comment);
123

124
  return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
125
  g_value_take_string (&return_vals->values[1], comment);
126

127
  return return_vals;
128 129
}

130
static GValueArray *
131 132 133 134 135 136
get_default_unit_invoker (GimpProcedure      *procedure,
                          Gimp               *gimp,
                          GimpContext        *context,
                          GimpProgress       *progress,
                          const GValueArray  *args,
                          GError            **error)
137 138 139 140 141 142
{
  GValueArray *return_vals;
  GimpUnit unit_id = 0;

  unit_id = gimp_get_default_unit ();

143
  return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
144 145 146 147 148
  g_value_set_int (&return_vals->values[1], unit_id);

  return return_vals;
}

149
static GValueArray *
150 151 152 153 154 155
get_monitor_resolution_invoker (GimpProcedure      *procedure,
                                Gimp               *gimp,
                                GimpContext        *context,
                                GimpProgress       *progress,
                                const GValueArray  *args,
                                GError            **error)
156
{
157
  GValueArray *return_vals;
158 159
  gdouble xres = 0.0;
  gdouble yres = 0.0;
160

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

164
  return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
165

166 167
  g_value_set_double (&return_vals->values[1], xres);
  g_value_set_double (&return_vals->values[2], yres);
168

169
  return return_vals;
170 171
}

172
static GValueArray *
173 174 175 176 177 178
get_theme_dir_invoker (GimpProcedure      *procedure,
                       Gimp               *gimp,
                       GimpContext        *context,
                       GimpProgress       *progress,
                       const GValueArray  *args,
                       GError            **error)
179
{
180
  GValueArray *return_vals;
181
  gchar *theme_dir = NULL;
182 183 184

  theme_dir = g_strdup (gimp_get_theme_dir (gimp));

185
  return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
186
  g_value_take_string (&return_vals->values[1], theme_dir);
187

188
  return return_vals;
189 190
}

191
static GValueArray *
192 193 194 195 196 197
get_color_configuration_invoker (GimpProcedure      *procedure,
                                 Gimp               *gimp,
                                 GimpContext        *context,
                                 GimpProgress       *progress,
                                 const GValueArray  *args,
                                 GError            **error)
198
{
199
  GValueArray *return_vals;
200
  gchar *config = NULL;
201 202 203

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

204
  return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
205
  g_value_take_string (&return_vals->values[1], config);
206

207
  return return_vals;
208 209
}

210
static GValueArray *
211 212 213 214 215 216
get_module_load_inhibit_invoker (GimpProcedure      *procedure,
                                 Gimp               *gimp,
                                 GimpContext        *context,
                                 GimpProgress       *progress,
                                 const GValueArray  *args,
                                 GError            **error)
217
{
218
  GValueArray *return_vals;
219
  gchar *load_inhibit = NULL;
220 221 222

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

223
  return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
224
  g_value_take_string (&return_vals->values[1], load_inhibit);
225

226
  return return_vals;
227 228
}

229
void
230
register_gimprc_procs (GimpPDB *pdb)
231
{
232 233 234 235 236
  GimpProcedure *procedure;

  /*
   * gimp-gimprc-query
   */
237
  procedure = gimp_procedure_new (gimprc_query_invoker);
238 239
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-gimprc-query");
240 241 242
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-gimprc-query",
                                     "Queries the gimprc file parser for information on a specified token.",
243
                                     "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.",
244 245 246 247 248 249 250 251
                                     "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",
252
                                                       FALSE, FALSE, FALSE,
253 254 255 256 257 258
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_string ("value",
                                                           "value",
                                                           "The value associated with the queried token",
259
                                                           FALSE, FALSE, FALSE,
260 261
                                                           NULL,
                                                           GIMP_PARAM_READWRITE));
262
  gimp_pdb_register_procedure (pdb, procedure);
263
  g_object_unref (procedure);
264 265 266 267

  /*
   * gimp-gimprc-set
   */
268
  procedure = gimp_procedure_new (gimprc_set_invoker);
269 270
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-gimprc-set");
271 272 273
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-gimprc-set",
                                     "Sets a gimprc token to a value and saves it in the gimprc.",
274
                                     "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.",
275 276 277 278 279 280 281 282
                                     "Seth Burgess",
                                     "Seth Burgess",
                                     "1999",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("token",
                                                       "token",
                                                       "The token to add or modify",
283
                                                       FALSE, FALSE, FALSE,
284 285 286 287 288 289
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("value",
                                                       "value",
                                                       "The value to set the token to",
290
                                                       FALSE, FALSE, FALSE,
291 292
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
293
  gimp_pdb_register_procedure (pdb, procedure);
294
  g_object_unref (procedure);
295 296 297 298

  /*
   * gimp-get-default-comment
   */
299
  procedure = gimp_procedure_new (get_default_comment_invoker);
300 301
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-get-default-comment");
302 303 304 305 306 307 308 309 310 311 312
  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",
313
                                                           "Default image comment",
314
                                                           FALSE, FALSE, FALSE,
315 316
                                                           NULL,
                                                           GIMP_PARAM_READWRITE));
317
  gimp_pdb_register_procedure (pdb, procedure);
318
  g_object_unref (procedure);
319

320 321 322 323
  /*
   * gimp-get-default-unit
   */
  procedure = gimp_procedure_new (get_default_unit_invoker);
324 325
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-get-default-unit");
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344
  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);

345 346 347
  /*
   * gimp-get-monitor-resolution
   */
348
  procedure = gimp_procedure_new (get_monitor_resolution_invoker);
349 350
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-get-monitor-resolution");
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370
  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));
371
  gimp_pdb_register_procedure (pdb, procedure);
372
  g_object_unref (procedure);
373 374 375 376

  /*
   * gimp-get-theme-dir
   */
377
  procedure = gimp_procedure_new (get_theme_dir_invoker);
378 379
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-get-theme-dir");
380 381 382 383 384 385 386 387 388 389 390 391
  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.",
                                     "Spencer Kimball & Peter Mattis",
                                     "Spencer Kimball & Peter Mattis",
                                     "1995-1996",
                                     NULL);
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_string ("theme-dir",
                                                           "theme dir",
                                                           "The GUI theme dir",
392
                                                           FALSE, FALSE, FALSE,
393 394
                                                           NULL,
                                                           GIMP_PARAM_READWRITE));
395
  gimp_pdb_register_procedure (pdb, procedure);
396
  g_object_unref (procedure);
397 398 399 400

  /*
   * gimp-get-color-configuration
   */
401
  procedure = gimp_procedure_new (get_color_configuration_invoker);
402 403
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-get-color-configuration");
404 405 406 407 408 409 410 411 412 413 414 415
  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",
416
                                                           FALSE, FALSE, FALSE,
417 418
                                                           NULL,
                                                           GIMP_PARAM_READWRITE));
419
  gimp_pdb_register_procedure (pdb, procedure);
420
  g_object_unref (procedure);
421 422 423 424

  /*
   * gimp-get-module-load-inhibit
   */
425
  procedure = gimp_procedure_new (get_module_load_inhibit_invoker);
426 427
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-get-module-load-inhibit");
428 429 430 431 432 433 434 435 436 437 438 439
  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",
440
                                                           FALSE, FALSE, FALSE,
441 442
                                                           NULL,
                                                           GIMP_PARAM_READWRITE));
443
  gimp_pdb_register_procedure (pdb, procedure);
444
  g_object_unref (procedure);
445
}