File: gimprc_cmds.c

package info (click to toggle)
gimp 2.2.13-1etch4
  • links: PTS
  • area: main
  • in suites: etch
  • size: 94,832 kB
  • ctags: 47,113
  • sloc: ansic: 524,858; xml: 36,798; lisp: 9,870; sh: 9,409; makefile: 7,923; python: 2,674; perl: 2,589; yacc: 520; lex: 334
file content (368 lines) | stat: -rw-r--r-- 9,827 bytes parent folder | download | duplicates (3)
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
/* The GIMP -- an 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 2 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, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

/* NOTE: This file is autogenerated by pdbgen.pl. */

#include "config.h"

#include <string.h>

#include <glib-object.h>

#include "libgimpmodule/gimpmodule.h"

#include "pdb-types.h"
#include "procedural_db.h"

#include "config/gimpconfig.h"
#include "config/gimpcoreconfig.h"
#include "config/gimpdisplayconfig.h"
#include "config/gimprc.h"
#include "core/gimp.h"
#include "core/gimptemplate.h"

static ProcRecord gimprc_query_proc;
static ProcRecord gimprc_set_proc;
static ProcRecord get_default_comment_proc;
static ProcRecord get_monitor_resolution_proc;
static ProcRecord get_theme_dir_proc;
static ProcRecord get_module_load_inhibit_proc;

void
register_gimprc_procs (Gimp *gimp)
{
  procedural_db_register (gimp, &gimprc_query_proc);
  procedural_db_register (gimp, &gimprc_set_proc);
  procedural_db_register (gimp, &get_default_comment_proc);
  procedural_db_register (gimp, &get_monitor_resolution_proc);
  procedural_db_register (gimp, &get_theme_dir_proc);
  procedural_db_register (gimp, &get_module_load_inhibit_proc);
}

static Argument *
gimprc_query_invoker (Gimp         *gimp,
                      GimpContext  *context,
                      GimpProgress *progress,
                      Argument     *args)
{
  gboolean success = TRUE;
  Argument *return_args;
  gchar *token;
  gchar *value = NULL;

  token = (gchar *) args[0].value.pdb_pointer;
  if (token == NULL || !g_utf8_validate (token, -1, NULL))
    success = FALSE;

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

      success = (value != NULL);
    }

  return_args = procedural_db_return_args (&gimprc_query_proc, success);

  if (success)
    return_args[1].value.pdb_pointer = value;

  return return_args;
}

static ProcArg gimprc_query_inargs[] =
{
  {
    GIMP_PDB_STRING,
    "token",
    "The token to query for"
  }
};

static ProcArg gimprc_query_outargs[] =
{
  {
    GIMP_PDB_STRING,
    "value",
    "The value associated with the queried token"
  }
};

static ProcRecord gimprc_query_proc =
{
  "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 the 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_INTERNAL,
  1,
  gimprc_query_inargs,
  1,
  gimprc_query_outargs,
  { { gimprc_query_invoker } }
};

static Argument *
gimprc_set_invoker (Gimp         *gimp,
                    GimpContext  *context,
                    GimpProgress *progress,
                    Argument     *args)
{
  gboolean success = TRUE;
  gchar *token;
  gchar *value;

  token = (gchar *) args[0].value.pdb_pointer;
  if (token == NULL || !g_utf8_validate (token, -1, NULL))
    success = FALSE;

  value = (gchar *) args[1].value.pdb_pointer;
  if (value == NULL || !g_utf8_validate (value, -1, NULL))
    success = FALSE;

  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 procedural_db_return_args (&gimprc_set_proc, success);
}

static ProcArg gimprc_set_inargs[] =
{
  {
    GIMP_PDB_STRING,
    "token",
    "The token to add or modify"
  },
  {
    GIMP_PDB_STRING,
    "value",
    "The value to set the token to"
  }
};

static ProcRecord gimprc_set_proc =
{
  "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 the 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_INTERNAL,
  2,
  gimprc_set_inargs,
  0,
  NULL,
  { { gimprc_set_invoker } }
};

static Argument *
get_default_comment_invoker (Gimp         *gimp,
                             GimpContext  *context,
                             GimpProgress *progress,
                             Argument     *args)
{
  Argument *return_args;
  gchar *comment;

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

  return_args = procedural_db_return_args (&get_default_comment_proc, TRUE);
  return_args[1].value.pdb_pointer = comment;

  return return_args;
}

static ProcArg get_default_comment_outargs[] =
{
  {
    GIMP_PDB_STRING,
    "comment",
    "Default Image Comment"
  }
};

static ProcRecord get_default_comment_proc =
{
  "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_INTERNAL,
  0,
  NULL,
  1,
  get_default_comment_outargs,
  { { get_default_comment_invoker } }
};

static Argument *
get_monitor_resolution_invoker (Gimp         *gimp,
                                GimpContext  *context,
                                GimpProgress *progress,
                                Argument     *args)
{
  Argument *return_args;
  gdouble xres;
  gdouble yres;

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

  return_args = procedural_db_return_args (&get_monitor_resolution_proc, TRUE);

  return_args[1].value.pdb_float = xres;
  return_args[2].value.pdb_float = yres;

  return return_args;
}

static ProcArg get_monitor_resolution_outargs[] =
{
  {
    GIMP_PDB_FLOAT,
    "xres",
    "X resolution"
  },
  {
    GIMP_PDB_FLOAT,
    "yres",
    "Y resolution"
  }
};

static ProcRecord get_monitor_resolution_proc =
{
  "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_INTERNAL,
  0,
  NULL,
  2,
  get_monitor_resolution_outargs,
  { { get_monitor_resolution_invoker } }
};

static Argument *
get_theme_dir_invoker (Gimp         *gimp,
                       GimpContext  *context,
                       GimpProgress *progress,
                       Argument     *args)
{
  Argument *return_args;
  gchar *theme_dir;

  theme_dir = g_strdup (gimp_get_theme_dir (gimp));

  return_args = procedural_db_return_args (&get_theme_dir_proc, TRUE);
  return_args[1].value.pdb_pointer = theme_dir;

  return return_args;
}

static ProcArg get_theme_dir_outargs[] =
{
  {
    GIMP_PDB_STRING,
    "theme_dir",
    "The GUI theme dir"
  }
};

static ProcRecord get_theme_dir_proc =
{
  "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_INTERNAL,
  0,
  NULL,
  1,
  get_theme_dir_outargs,
  { { get_theme_dir_invoker } }
};

static Argument *
get_module_load_inhibit_invoker (Gimp         *gimp,
                                 GimpContext  *context,
                                 GimpProgress *progress,
                                 Argument     *args)
{
  Argument *return_args;
  gchar *load_inhibit;

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

  return_args = procedural_db_return_args (&get_module_load_inhibit_proc, TRUE);
  return_args[1].value.pdb_pointer = load_inhibit;

  return return_args;
}

static ProcArg get_module_load_inhibit_outargs[] =
{
  {
    GIMP_PDB_STRING,
    "load_inhibit",
    "The list of modules"
  }
};

static ProcRecord get_module_load_inhibit_proc =
{
  "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_INTERNAL,
  0,
  NULL,
  1,
  get_module_load_inhibit_outargs,
  { { get_module_load_inhibit_invoker } }
};