unit-cmds.c 35.3 KB
Newer Older
1
/* GIMP - The GNU Image Manipulation Program
2
 * Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
Manish Singh's avatar
Manish Singh committed
3
 *
4
 * This program is free software: you can redistribute it and/or modify
Manish Singh's avatar
Manish Singh committed
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
Manish Singh's avatar
Manish Singh committed
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/>.
Manish Singh's avatar
Manish Singh committed
16 17
 */

18
/* NOTE: This file is auto-generated by pdbgen.pl. */
Manish Singh's avatar
Manish Singh committed
19

20 21
#include "config.h"

22
#include <gegl.h>
23

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

26 27
#include "libgimpbase/gimpbase.h"

28 29
#include "libgimpbase/gimpbase.h"

30
#include "pdb-types.h"
Manish Singh's avatar
Manish Singh committed
31

32
#include "core/gimpparamspecs.h"
33
#include "core/gimpunit.h"
34

35 36
#include "gimppdb.h"
#include "gimpprocedure.h"
37
#include "internal-procs.h"
38

Manish Singh's avatar
Manish Singh committed
39

40
static GimpValueArray *
41
unit_get_number_of_units_invoker (GimpProcedure         *procedure,
42 43 44 45 46
                                  Gimp                  *gimp,
                                  GimpContext           *context,
                                  GimpProgress          *progress,
                                  const GimpValueArray  *args,
                                  GError               **error)
Manish Singh's avatar
Manish Singh committed
47
{
48
  GimpValueArray *return_vals;
49
  gint32 num_units = 0;
50 51

  num_units = _gimp_unit_get_number_of_units (gimp);
Manish Singh's avatar
Manish Singh committed
52

53
  return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
54
  g_value_set_int (gimp_value_array_index (return_vals, 1), num_units);
Manish Singh's avatar
Manish Singh committed
55

56
  return return_vals;
Manish Singh's avatar
Manish Singh committed
57 58
}

59
static GimpValueArray *
60
unit_get_number_of_built_in_units_invoker (GimpProcedure         *procedure,
61 62 63 64 65
                                           Gimp                  *gimp,
                                           GimpContext           *context,
                                           GimpProgress          *progress,
                                           const GimpValueArray  *args,
                                           GError               **error)
66
{
67
  GimpValueArray *return_vals;
68
  gint32 num_units = 0;
69 70

  num_units = _gimp_unit_get_number_of_built_in_units (gimp);
71

72
  return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
73
  g_value_set_int (gimp_value_array_index (return_vals, 1), num_units);
74

75
  return return_vals;
76 77
}

78
static GimpValueArray *
79
unit_new_invoker (GimpProcedure         *procedure,
80 81 82 83 84
                  Gimp                  *gimp,
                  GimpContext           *context,
                  GimpProgress          *progress,
                  const GimpValueArray  *args,
                  GError               **error)
Manish Singh's avatar
Manish Singh committed
85 86
{
  gboolean success = TRUE;
87
  GimpValueArray *return_vals;
88
  const gchar *identifier;
Manish Singh's avatar
Manish Singh committed
89 90
  gdouble factor;
  gint32 digits;
91 92 93 94
  const gchar *symbol;
  const gchar *abbreviation;
  const gchar *singular;
  const gchar *plural;
95
  GimpUnit unit_id = 0;
Manish Singh's avatar
Manish Singh committed
96

97 98 99 100 101 102 103
  identifier = g_value_get_string (gimp_value_array_index (args, 0));
  factor = g_value_get_double (gimp_value_array_index (args, 1));
  digits = g_value_get_int (gimp_value_array_index (args, 2));
  symbol = g_value_get_string (gimp_value_array_index (args, 3));
  abbreviation = g_value_get_string (gimp_value_array_index (args, 4));
  singular = g_value_get_string (gimp_value_array_index (args, 5));
  plural = g_value_get_string (gimp_value_array_index (args, 6));
Manish Singh's avatar
Manish Singh committed
104 105

  if (success)
106
    {
107 108
      unit_id = _gimp_unit_new (gimp, identifier, factor, digits,
                                symbol, abbreviation, singular, plural);
109
    }
Manish Singh's avatar
Manish Singh committed
110

111 112
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
Manish Singh's avatar
Manish Singh committed
113 114

  if (success)
115
    g_value_set_int (gimp_value_array_index (return_vals, 1), unit_id);
Manish Singh's avatar
Manish Singh committed
116

117
  return return_vals;
Manish Singh's avatar
Manish Singh committed
118 119
}

120
static GimpValueArray *
121
unit_get_deletion_flag_invoker (GimpProcedure         *procedure,
122 123 124 125 126
                                Gimp                  *gimp,
                                GimpContext           *context,
                                GimpProgress          *progress,
                                const GimpValueArray  *args,
                                GError               **error)
Manish Singh's avatar
Manish Singh committed
127 128
{
  gboolean success = TRUE;
129
  GimpValueArray *return_vals;
130
  GimpUnit unit_id;
131
  gboolean deletion_flag = FALSE;
Manish Singh's avatar
Manish Singh committed
132

133
  unit_id = g_value_get_int (gimp_value_array_index (args, 0));
Manish Singh's avatar
Manish Singh committed
134

135 136 137 138 139
  if (success)
    {
      deletion_flag = _gimp_unit_get_deletion_flag (gimp, unit_id);
    }

140 141
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
Manish Singh's avatar
Manish Singh committed
142 143

  if (success)
144
    g_value_set_boolean (gimp_value_array_index (return_vals, 1), deletion_flag);
Manish Singh's avatar
Manish Singh committed
145

146
  return return_vals;
Manish Singh's avatar
Manish Singh committed
147 148
}

149
static GimpValueArray *
150
unit_set_deletion_flag_invoker (GimpProcedure         *procedure,
151 152 153 154 155
                                Gimp                  *gimp,
                                GimpContext           *context,
                                GimpProgress          *progress,
                                const GimpValueArray  *args,
                                GError               **error)
Manish Singh's avatar
Manish Singh committed
156 157
{
  gboolean success = TRUE;
158
  GimpUnit unit_id;
Manish Singh's avatar
Manish Singh committed
159 160
  gboolean deletion_flag;

161 162
  unit_id = g_value_get_int (gimp_value_array_index (args, 0));
  deletion_flag = g_value_get_boolean (gimp_value_array_index (args, 1));
Manish Singh's avatar
Manish Singh committed
163 164

  if (success)
165 166 167
    {
      _gimp_unit_set_deletion_flag (gimp, unit_id, deletion_flag);
    }
Manish Singh's avatar
Manish Singh committed
168

169 170
  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
Manish Singh's avatar
Manish Singh committed
171 172
}

173
static GimpValueArray *
174
unit_get_identifier_invoker (GimpProcedure         *procedure,
175 176 177 178 179
                             Gimp                  *gimp,
                             GimpContext           *context,
                             GimpProgress          *progress,
                             const GimpValueArray  *args,
                             GError               **error)
Manish Singh's avatar
Manish Singh committed
180 181
{
  gboolean success = TRUE;
182
  GimpValueArray *return_vals;
183
  GimpUnit unit_id;
184
  gchar *identifier = NULL;
Manish Singh's avatar
Manish Singh committed
185

186
  unit_id = g_value_get_int (gimp_value_array_index (args, 0));
Manish Singh's avatar
Manish Singh committed
187

188 189 190 191 192
  if (success)
    {
      identifier = g_strdup (_gimp_unit_get_identifier (gimp, unit_id));
    }

193 194
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
Manish Singh's avatar
Manish Singh committed
195 196

  if (success)
197
    g_value_take_string (gimp_value_array_index (return_vals, 1), identifier);
Manish Singh's avatar
Manish Singh committed
198

199
  return return_vals;
Manish Singh's avatar
Manish Singh committed
200 201
}

202
static GimpValueArray *
203
unit_get_factor_invoker (GimpProcedure         *procedure,
204 205 206 207 208
                         Gimp                  *gimp,
                         GimpContext           *context,
                         GimpProgress          *progress,
                         const GimpValueArray  *args,
                         GError               **error)
Manish Singh's avatar
Manish Singh committed
209 210
{
  gboolean success = TRUE;
211
  GimpValueArray *return_vals;
212
  GimpUnit unit_id;
213
  gdouble factor = 0.0;
Manish Singh's avatar
Manish Singh committed
214

215
  unit_id = g_value_get_int (gimp_value_array_index (args, 0));
Manish Singh's avatar
Manish Singh committed
216

217 218 219 220 221
  if (success)
    {
      factor = _gimp_unit_get_factor (gimp, unit_id);
    }

222 223
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
Manish Singh's avatar
Manish Singh committed
224 225

  if (success)
226
    g_value_set_double (gimp_value_array_index (return_vals, 1), factor);
Manish Singh's avatar
Manish Singh committed
227

228
  return return_vals;
Manish Singh's avatar
Manish Singh committed
229 230
}

231
static GimpValueArray *
232
unit_get_digits_invoker (GimpProcedure         *procedure,
233 234 235 236 237
                         Gimp                  *gimp,
                         GimpContext           *context,
                         GimpProgress          *progress,
                         const GimpValueArray  *args,
                         GError               **error)
Manish Singh's avatar
Manish Singh committed
238 239
{
  gboolean success = TRUE;
240
  GimpValueArray *return_vals;
241
  GimpUnit unit_id;
242
  gint32 digits = 0;
Manish Singh's avatar
Manish Singh committed
243

244
  unit_id = g_value_get_int (gimp_value_array_index (args, 0));
Manish Singh's avatar
Manish Singh committed
245

246 247 248 249 250
  if (success)
    {
      digits = _gimp_unit_get_digits (gimp, unit_id);
    }

251 252
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
Manish Singh's avatar
Manish Singh committed
253 254

  if (success)
255
    g_value_set_int (gimp_value_array_index (return_vals, 1), digits);
Manish Singh's avatar
Manish Singh committed
256

257
  return return_vals;
Manish Singh's avatar
Manish Singh committed
258 259
}

260
static GimpValueArray *
261
unit_get_symbol_invoker (GimpProcedure         *procedure,
262 263 264 265 266
                         Gimp                  *gimp,
                         GimpContext           *context,
                         GimpProgress          *progress,
                         const GimpValueArray  *args,
                         GError               **error)
Manish Singh's avatar
Manish Singh committed
267 268
{
  gboolean success = TRUE;
269
  GimpValueArray *return_vals;
270
  GimpUnit unit_id;
271
  gchar *symbol = NULL;
Manish Singh's avatar
Manish Singh committed
272

273
  unit_id = g_value_get_int (gimp_value_array_index (args, 0));
Manish Singh's avatar
Manish Singh committed
274

275 276 277 278 279
  if (success)
    {
      symbol = g_strdup (_gimp_unit_get_symbol (gimp, unit_id));
    }

280 281
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
Manish Singh's avatar
Manish Singh committed
282 283

  if (success)
284
    g_value_take_string (gimp_value_array_index (return_vals, 1), symbol);
Manish Singh's avatar
Manish Singh committed
285

286
  return return_vals;
Manish Singh's avatar
Manish Singh committed
287 288
}

289
static GimpValueArray *
290
unit_get_abbreviation_invoker (GimpProcedure         *procedure,
291 292 293 294 295
                               Gimp                  *gimp,
                               GimpContext           *context,
                               GimpProgress          *progress,
                               const GimpValueArray  *args,
                               GError               **error)
Manish Singh's avatar
Manish Singh committed
296 297
{
  gboolean success = TRUE;
298
  GimpValueArray *return_vals;
299
  GimpUnit unit_id;
300
  gchar *abbreviation = NULL;
Manish Singh's avatar
Manish Singh committed
301

302
  unit_id = g_value_get_int (gimp_value_array_index (args, 0));
Manish Singh's avatar
Manish Singh committed
303

304 305 306 307 308
  if (success)
    {
      abbreviation = g_strdup (_gimp_unit_get_abbreviation (gimp, unit_id));
    }

309 310
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
Manish Singh's avatar
Manish Singh committed
311 312

  if (success)
313
    g_value_take_string (gimp_value_array_index (return_vals, 1), abbreviation);
Manish Singh's avatar
Manish Singh committed
314

315
  return return_vals;
Manish Singh's avatar
Manish Singh committed
316 317
}

318
static GimpValueArray *
319
unit_get_singular_invoker (GimpProcedure         *procedure,
320 321 322 323 324
                           Gimp                  *gimp,
                           GimpContext           *context,
                           GimpProgress          *progress,
                           const GimpValueArray  *args,
                           GError               **error)
Manish Singh's avatar
Manish Singh committed
325 326
{
  gboolean success = TRUE;
327
  GimpValueArray *return_vals;
328
  GimpUnit unit_id;
329
  gchar *singular = NULL;
Manish Singh's avatar
Manish Singh committed
330

331
  unit_id = g_value_get_int (gimp_value_array_index (args, 0));
Manish Singh's avatar
Manish Singh committed
332

333 334 335 336 337
  if (success)
    {
      singular = g_strdup (_gimp_unit_get_singular (gimp, unit_id));
    }

338 339
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
Manish Singh's avatar
Manish Singh committed
340 341

  if (success)
342
    g_value_take_string (gimp_value_array_index (return_vals, 1), singular);
Manish Singh's avatar
Manish Singh committed
343

344
  return return_vals;
Manish Singh's avatar
Manish Singh committed
345 346
}

347
static GimpValueArray *
348
unit_get_plural_invoker (GimpProcedure         *procedure,
349 350 351 352 353
                         Gimp                  *gimp,
                         GimpContext           *context,
                         GimpProgress          *progress,
                         const GimpValueArray  *args,
                         GError               **error)
Manish Singh's avatar
Manish Singh committed
354 355
{
  gboolean success = TRUE;
356
  GimpValueArray *return_vals;
357
  GimpUnit unit_id;
358
  gchar *plural = NULL;
Manish Singh's avatar
Manish Singh committed
359

360
  unit_id = g_value_get_int (gimp_value_array_index (args, 0));
Manish Singh's avatar
Manish Singh committed
361

362 363 364 365 366
  if (success)
    {
      plural = g_strdup (_gimp_unit_get_plural (gimp, unit_id));
    }

367 368
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
Manish Singh's avatar
Manish Singh committed
369 370

  if (success)
371
    g_value_take_string (gimp_value_array_index (return_vals, 1), plural);
Manish Singh's avatar
Manish Singh committed
372

373
  return return_vals;
Manish Singh's avatar
Manish Singh committed
374 375
}

376
void
377
register_unit_procs (GimpPDB *pdb)
Manish Singh's avatar
Manish Singh committed
378
{
379 380 381 382 383
  GimpProcedure *procedure;

  /*
   * gimp-unit-get-number-of-units
   */
384
  procedure = gimp_procedure_new (unit_get_number_of_units_invoker);
385 386
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-unit-get-number-of-units");
387 388 389 390 391 392 393 394 395 396 397 398 399 400
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-unit-get-number-of-units",
                                     "Returns the number of units.",
                                     "This procedure returns the number of defined units.",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "1999",
                                     NULL);
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_int32 ("num-units",
                                                          "num units",
                                                          "The number of units",
                                                          G_MININT32, G_MAXINT32, 0,
                                                          GIMP_PARAM_READWRITE));
401
  gimp_pdb_register_procedure (pdb, procedure);
402
  g_object_unref (procedure);
403 404 405 406

  /*
   * gimp-unit-get-number-of-built-in-units
   */
407
  procedure = gimp_procedure_new (unit_get_number_of_built_in_units_invoker);
408 409
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-unit-get-number-of-built-in-units");
410 411 412
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-unit-get-number-of-built-in-units",
                                     "Returns the number of built-in units.",
413
                                     "This procedure returns the number of defined units built-in to GIMP.",
414 415 416 417 418 419 420 421 422 423
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "1999",
                                     NULL);
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_int32 ("num-units",
                                                          "num units",
                                                          "The number of built-in units",
                                                          G_MININT32, G_MAXINT32, 0,
                                                          GIMP_PARAM_READWRITE));
424
  gimp_pdb_register_procedure (pdb, procedure);
425
  g_object_unref (procedure);
426 427 428 429

  /*
   * gimp-unit-new
   */
430
  procedure = gimp_procedure_new (unit_new_invoker);
431 432
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-unit-new");
433 434 435
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-unit-new",
                                     "Creates a new unit and returns it's integer ID.",
436
                                     "This procedure creates a new unit and returns it's integer ID. Note that the new unit will have it's deletion flag set to TRUE, so you will have to set it to FALSE with 'gimp-unit-set-deletion-flag' to make it persistent.",
437 438 439 440 441 442 443 444
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "1999",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("identifier",
                                                       "identifier",
                                                       "The new unit's identifier",
445
                                                       FALSE, FALSE, TRUE,
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_double ("factor",
                                                    "factor",
                                                    "The new unit's factor",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_int32 ("digits",
                                                      "digits",
                                                      "The new unit's digits",
                                                      G_MININT32, G_MAXINT32, 0,
                                                      GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("symbol",
                                                       "symbol",
                                                       "The new unit's symbol",
464
                                                       FALSE, FALSE, TRUE,
465 466 467 468 469 470
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("abbreviation",
                                                       "abbreviation",
                                                       "The new unit's abbreviation",
471
                                                       FALSE, FALSE, TRUE,
472 473 474 475 476 477
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("singular",
                                                       "singular",
                                                       "The new unit's singular form",
478
                                                       FALSE, FALSE, TRUE,
479 480 481 482 483 484
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("plural",
                                                       "plural",
                                                       "The new unit's plural form",
485
                                                       FALSE, FALSE, TRUE,
486 487 488 489 490 491 492 493 494 495
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_unit ("unit-id",
                                                         "unit id",
                                                         "The new unit's ID",
                                                         TRUE,
                                                         FALSE,
                                                         GIMP_UNIT_PIXEL,
                                                         GIMP_PARAM_READWRITE));
496
  gimp_pdb_register_procedure (pdb, procedure);
497
  g_object_unref (procedure);
498 499 500 501

  /*
   * gimp-unit-get-deletion-flag
   */
502
  procedure = gimp_procedure_new (unit_get_deletion_flag_invoker);
503 504
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-unit-get-deletion-flag");
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-unit-get-deletion-flag",
                                     "Returns the deletion flag of the unit.",
                                     "This procedure returns the deletion flag of the unit. If this value is TRUE the unit's definition will not be saved in the user's unitrc file on gimp exit.",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "1999",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_unit ("unit-id",
                                                     "unit id",
                                                     "The unit's integer ID",
                                                     TRUE,
                                                     FALSE,
                                                     GIMP_UNIT_PIXEL,
                                                     GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   g_param_spec_boolean ("deletion-flag",
                                                         "deletion flag",
                                                         "The unit's deletion flag",
                                                         FALSE,
                                                         GIMP_PARAM_READWRITE));
527
  gimp_pdb_register_procedure (pdb, procedure);
528
  g_object_unref (procedure);
529 530 531 532

  /*
   * gimp-unit-set-deletion-flag
   */
533
  procedure = gimp_procedure_new (unit_set_deletion_flag_invoker);
534 535
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-unit-set-deletion-flag");
536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-unit-set-deletion-flag",
                                     "Sets the deletion flag of a unit.",
                                     "This procedure sets the unit's deletion flag. If the deletion flag of a unit is TRUE on gimp exit, this unit's definition will not be saved in the user's unitrc.",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "1999",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_unit ("unit-id",
                                                     "unit id",
                                                     "The unit's integer ID",
                                                     TRUE,
                                                     FALSE,
                                                     GIMP_UNIT_PIXEL,
                                                     GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_boolean ("deletion-flag",
                                                     "deletion flag",
                                                     "The new deletion flag of the unit",
                                                     FALSE,
                                                     GIMP_PARAM_READWRITE));
558
  gimp_pdb_register_procedure (pdb, procedure);
559
  g_object_unref (procedure);
560 561 562 563

  /*
   * gimp-unit-get-identifier
   */
564
  procedure = gimp_procedure_new (unit_get_identifier_invoker);
565 566
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-unit-get-identifier");
567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-unit-get-identifier",
                                     "Returns the textual identifier of the unit.",
                                     "This procedure returns the textual identifier of the unit. For built-in units it will be the english singular form of the unit's name. For user-defined units this should equal to the singular form.",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "1999",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_unit ("unit-id",
                                                     "unit id",
                                                     "The unit's integer ID",
                                                     TRUE,
                                                     FALSE,
                                                     GIMP_UNIT_PIXEL,
                                                     GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_string ("identifier",
                                                           "identifier",
                                                           "The unit's textual identifier",
587
                                                           FALSE, FALSE, FALSE,
588 589
                                                           NULL,
                                                           GIMP_PARAM_READWRITE));
590
  gimp_pdb_register_procedure (pdb, procedure);
591
  g_object_unref (procedure);
592 593 594 595

  /*
   * gimp-unit-get-factor
   */
596
  procedure = gimp_procedure_new (unit_get_factor_invoker);
597 598
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-unit-get-factor");
599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-unit-get-factor",
                                     "Returns the factor of the unit.",
                                     "This procedure returns the unit's factor which indicates how many units make up an inch. Note that asking for the factor of \"pixels\" will produce an error.",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "1999",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_unit ("unit-id",
                                                     "unit id",
                                                     "The unit's integer ID",
                                                     TRUE,
                                                     FALSE,
                                                     GIMP_UNIT_PIXEL,
                                                     GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   g_param_spec_double ("factor",
                                                        "factor",
                                                        "The unit's factor",
                                                        -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                        GIMP_PARAM_READWRITE));
621
  gimp_pdb_register_procedure (pdb, procedure);
622
  g_object_unref (procedure);
623 624 625 626

  /*
   * gimp-unit-get-digits
   */
627
  procedure = gimp_procedure_new (unit_get_digits_invoker);
628 629
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-unit-get-digits");
630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-unit-get-digits",
                                     "Returns the number of digits of the unit.",
                                     "This procedure returns the number of digits you should provide in input or output functions to get approximately the same accuracy as with two digits and inches. Note that asking for the digits of \"pixels\" will produce an error.",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "1999",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_unit ("unit-id",
                                                     "unit id",
                                                     "The unit's integer ID",
                                                     TRUE,
                                                     FALSE,
                                                     GIMP_UNIT_PIXEL,
                                                     GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_int32 ("digits",
                                                          "digits",
                                                          "The unit's number of digits",
                                                          G_MININT32, G_MAXINT32, 0,
                                                          GIMP_PARAM_READWRITE));
652
  gimp_pdb_register_procedure (pdb, procedure);
653
  g_object_unref (procedure);
654 655 656 657

  /*
   * gimp-unit-get-symbol
   */
658
  procedure = gimp_procedure_new (unit_get_symbol_invoker);
659 660
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-unit-get-symbol");
661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-unit-get-symbol",
                                     "Returns the symbol of the unit.",
                                     "This procedure returns the symbol of the unit (\"''\" for inches).",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "1999",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_unit ("unit-id",
                                                     "unit id",
                                                     "The unit's integer ID",
                                                     TRUE,
                                                     FALSE,
                                                     GIMP_UNIT_PIXEL,
                                                     GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_string ("symbol",
                                                           "symbol",
                                                           "The unit's symbol",
681
                                                           FALSE, FALSE, FALSE,
682 683
                                                           NULL,
                                                           GIMP_PARAM_READWRITE));
684
  gimp_pdb_register_procedure (pdb, procedure);
685
  g_object_unref (procedure);
686 687 688 689

  /*
   * gimp-unit-get-abbreviation
   */
690
  procedure = gimp_procedure_new (unit_get_abbreviation_invoker);
691 692
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-unit-get-abbreviation");
693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-unit-get-abbreviation",
                                     "Returns the abbreviation of the unit.",
                                     "This procedure returns the abbreviation of the unit (\"in\" for inches).",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "1999",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_unit ("unit-id",
                                                     "unit id",
                                                     "The unit's integer ID",
                                                     TRUE,
                                                     FALSE,
                                                     GIMP_UNIT_PIXEL,
                                                     GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_string ("abbreviation",
                                                           "abbreviation",
                                                           "The unit's abbreviation",
713
                                                           FALSE, FALSE, FALSE,
714 715
                                                           NULL,
                                                           GIMP_PARAM_READWRITE));
716
  gimp_pdb_register_procedure (pdb, procedure);
717
  g_object_unref (procedure);
718 719 720 721

  /*
   * gimp-unit-get-singular
   */
722
  procedure = gimp_procedure_new (unit_get_singular_invoker);
723 724
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-unit-get-singular");
725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-unit-get-singular",
                                     "Returns the singular form of the unit.",
                                     "This procedure returns the singular form of the unit.",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "1999",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_unit ("unit-id",
                                                     "unit id",
                                                     "The unit's integer ID",
                                                     TRUE,
                                                     FALSE,
                                                     GIMP_UNIT_PIXEL,
                                                     GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_string ("singular",
                                                           "singular",
                                                           "The unit's singular form",
745
                                                           FALSE, FALSE, FALSE,
746 747
                                                           NULL,
                                                           GIMP_PARAM_READWRITE));
748
  gimp_pdb_register_procedure (pdb, procedure);
749
  g_object_unref (procedure);
750 751 752 753

  /*
   * gimp-unit-get-plural
   */
754
  procedure = gimp_procedure_new (unit_get_plural_invoker);
755 756
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-unit-get-plural");
757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-unit-get-plural",
                                     "Returns the plural form of the unit.",
                                     "This procedure returns the plural form of the unit.",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "1999",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_unit ("unit-id",
                                                     "unit id",
                                                     "The unit's integer ID",
                                                     TRUE,
                                                     FALSE,
                                                     GIMP_UNIT_PIXEL,
                                                     GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_string ("plural",
                                                           "plural",
                                                           "The unit's plural form",
777
                                                           FALSE, FALSE, FALSE,
778 779
                                                           NULL,
                                                           GIMP_PARAM_READWRITE));
780
  gimp_pdb_register_procedure (pdb, procedure);
781
  g_object_unref (procedure);
782
}