app: s/sprintf/g_snprintf/ in xcf_save_image()
[gimp.git] / libgimp / gimpunit_pdb.c
blobfff9e127b0c354378162f73506440348029ce24a
1 /* LIBGIMP - The GIMP Library
2 * Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
4 * gimpunit_pdb.c
6 * This library is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library. If not, see
18 * <https://www.gnu.org/licenses/>.
21 /* NOTE: This file is auto-generated by pdbgen.pl */
23 #include "config.h"
25 #include "gimp.h"
28 /**
29 * SECTION: gimpunit
30 * @title: gimpunit
31 * @short_description: Provides a collection of predefined units and functions for creating user-defined units.
33 * Provides a collection of predefined units and functions for creating
34 * user-defined units.
35 **/
38 /**
39 * _gimp_unit_get_number_of_units:
41 * Returns the number of units.
43 * This procedure returns the number of defined units.
45 * Returns: The number of units.
46 **/
47 gint
48 _gimp_unit_get_number_of_units (void)
50 GimpParam *return_vals;
51 gint nreturn_vals;
52 gint num_units = GIMP_UNIT_END;
54 return_vals = gimp_run_procedure ("gimp-unit-get-number-of-units",
55 &nreturn_vals,
56 GIMP_PDB_END);
58 if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
59 num_units = return_vals[1].data.d_int32;
61 gimp_destroy_params (return_vals, nreturn_vals);
63 return num_units;
66 /**
67 * _gimp_unit_get_number_of_built_in_units:
69 * Returns the number of built-in units.
71 * This procedure returns the number of defined units built-in to GIMP.
73 * Returns: The number of built-in units.
74 **/
75 gint
76 _gimp_unit_get_number_of_built_in_units (void)
78 GimpParam *return_vals;
79 gint nreturn_vals;
80 gint num_units = GIMP_UNIT_END;
82 return_vals = gimp_run_procedure ("gimp-unit-get-number-of-built-in-units",
83 &nreturn_vals,
84 GIMP_PDB_END);
86 if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
87 num_units = return_vals[1].data.d_int32;
89 gimp_destroy_params (return_vals, nreturn_vals);
91 return num_units;
94 /**
95 * _gimp_unit_new:
96 * @identifier: The new unit's identifier.
97 * @factor: The new unit's factor.
98 * @digits: The new unit's digits.
99 * @symbol: The new unit's symbol.
100 * @abbreviation: The new unit's abbreviation.
101 * @singular: The new unit's singular form.
102 * @plural: The new unit's plural form.
104 * Creates a new unit and returns it's integer ID.
106 * This procedure creates a new unit and returns it's integer ID. Note
107 * that the new unit will have it's deletion flag set to TRUE, so you
108 * will have to set it to FALSE with gimp_unit_set_deletion_flag() to
109 * make it persistent.
111 * Returns: The new unit's ID.
113 GimpUnit
114 _gimp_unit_new (const gchar *identifier,
115 gdouble factor,
116 gint digits,
117 const gchar *symbol,
118 const gchar *abbreviation,
119 const gchar *singular,
120 const gchar *plural)
122 GimpParam *return_vals;
123 gint nreturn_vals;
124 GimpUnit unit_id = GIMP_UNIT_INCH;
126 return_vals = gimp_run_procedure ("gimp-unit-new",
127 &nreturn_vals,
128 GIMP_PDB_STRING, identifier,
129 GIMP_PDB_FLOAT, factor,
130 GIMP_PDB_INT32, digits,
131 GIMP_PDB_STRING, symbol,
132 GIMP_PDB_STRING, abbreviation,
133 GIMP_PDB_STRING, singular,
134 GIMP_PDB_STRING, plural,
135 GIMP_PDB_END);
137 if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
138 unit_id = return_vals[1].data.d_unit;
140 gimp_destroy_params (return_vals, nreturn_vals);
142 return unit_id;
146 * _gimp_unit_get_deletion_flag:
147 * @unit_id: The unit's integer ID.
149 * Returns the deletion flag of the unit.
151 * This procedure returns the deletion flag of the unit. If this value
152 * is TRUE the unit's definition will not be saved in the user's unitrc
153 * file on gimp exit.
155 * Returns: The unit's deletion flag.
157 gboolean
158 _gimp_unit_get_deletion_flag (GimpUnit unit_id)
160 GimpParam *return_vals;
161 gint nreturn_vals;
162 gboolean deletion_flag = FALSE;
164 return_vals = gimp_run_procedure ("gimp-unit-get-deletion-flag",
165 &nreturn_vals,
166 GIMP_PDB_INT32, unit_id,
167 GIMP_PDB_END);
169 if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
170 deletion_flag = return_vals[1].data.d_int32;
172 gimp_destroy_params (return_vals, nreturn_vals);
174 return deletion_flag;
178 * _gimp_unit_set_deletion_flag:
179 * @unit_id: The unit's integer ID.
180 * @deletion_flag: The new deletion flag of the unit.
182 * Sets the deletion flag of a unit.
184 * This procedure sets the unit's deletion flag. If the deletion flag
185 * of a unit is TRUE on gimp exit, this unit's definition will not be
186 * saved in the user's unitrc.
188 * Returns: TRUE on success.
190 gboolean
191 _gimp_unit_set_deletion_flag (GimpUnit unit_id,
192 gboolean deletion_flag)
194 GimpParam *return_vals;
195 gint nreturn_vals;
196 gboolean success = TRUE;
198 return_vals = gimp_run_procedure ("gimp-unit-set-deletion-flag",
199 &nreturn_vals,
200 GIMP_PDB_INT32, unit_id,
201 GIMP_PDB_INT32, deletion_flag,
202 GIMP_PDB_END);
204 success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
206 gimp_destroy_params (return_vals, nreturn_vals);
208 return success;
212 * _gimp_unit_get_identifier:
213 * @unit_id: The unit's integer ID.
215 * Returns the textual identifier of the unit.
217 * This procedure returns the textual identifier of the unit. For
218 * built-in units it will be the english singular form of the unit's
219 * name. For user-defined units this should equal to the singular form.
221 * Returns: The unit's textual identifier.
223 gchar *
224 _gimp_unit_get_identifier (GimpUnit unit_id)
226 GimpParam *return_vals;
227 gint nreturn_vals;
228 gchar *identifier = NULL;
230 return_vals = gimp_run_procedure ("gimp-unit-get-identifier",
231 &nreturn_vals,
232 GIMP_PDB_INT32, unit_id,
233 GIMP_PDB_END);
235 if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
236 identifier = g_strdup (return_vals[1].data.d_string);
238 gimp_destroy_params (return_vals, nreturn_vals);
240 return identifier;
244 * _gimp_unit_get_factor:
245 * @unit_id: The unit's integer ID.
247 * Returns the factor of the unit.
249 * This procedure returns the unit's factor which indicates how many
250 * units make up an inch. Note that asking for the factor of \"pixels\"
251 * will produce an error.
253 * Returns: The unit's factor.
255 gdouble
256 _gimp_unit_get_factor (GimpUnit unit_id)
258 GimpParam *return_vals;
259 gint nreturn_vals;
260 gdouble factor = 0.0;
262 return_vals = gimp_run_procedure ("gimp-unit-get-factor",
263 &nreturn_vals,
264 GIMP_PDB_INT32, unit_id,
265 GIMP_PDB_END);
267 if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
268 factor = return_vals[1].data.d_float;
270 gimp_destroy_params (return_vals, nreturn_vals);
272 return factor;
276 * _gimp_unit_get_digits:
277 * @unit_id: The unit's integer ID.
279 * Returns the number of digits of the unit.
281 * This procedure returns the number of digits you should provide in
282 * input or output functions to get approximately the same accuracy as
283 * with two digits and inches. Note that asking for the digits of
284 * \"pixels\" will produce an error.
286 * Returns: The unit's number of digits.
288 gint
289 _gimp_unit_get_digits (GimpUnit unit_id)
291 GimpParam *return_vals;
292 gint nreturn_vals;
293 gint digits = 0;
295 return_vals = gimp_run_procedure ("gimp-unit-get-digits",
296 &nreturn_vals,
297 GIMP_PDB_INT32, unit_id,
298 GIMP_PDB_END);
300 if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
301 digits = return_vals[1].data.d_int32;
303 gimp_destroy_params (return_vals, nreturn_vals);
305 return digits;
309 * _gimp_unit_get_symbol:
310 * @unit_id: The unit's integer ID.
312 * Returns the symbol of the unit.
314 * This procedure returns the symbol of the unit (\"''\" for inches).
316 * Returns: The unit's symbol.
318 gchar *
319 _gimp_unit_get_symbol (GimpUnit unit_id)
321 GimpParam *return_vals;
322 gint nreturn_vals;
323 gchar *symbol = NULL;
325 return_vals = gimp_run_procedure ("gimp-unit-get-symbol",
326 &nreturn_vals,
327 GIMP_PDB_INT32, unit_id,
328 GIMP_PDB_END);
330 if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
331 symbol = g_strdup (return_vals[1].data.d_string);
333 gimp_destroy_params (return_vals, nreturn_vals);
335 return symbol;
339 * _gimp_unit_get_abbreviation:
340 * @unit_id: The unit's integer ID.
342 * Returns the abbreviation of the unit.
344 * This procedure returns the abbreviation of the unit (\"in\" for
345 * inches).
347 * Returns: The unit's abbreviation.
349 gchar *
350 _gimp_unit_get_abbreviation (GimpUnit unit_id)
352 GimpParam *return_vals;
353 gint nreturn_vals;
354 gchar *abbreviation = NULL;
356 return_vals = gimp_run_procedure ("gimp-unit-get-abbreviation",
357 &nreturn_vals,
358 GIMP_PDB_INT32, unit_id,
359 GIMP_PDB_END);
361 if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
362 abbreviation = g_strdup (return_vals[1].data.d_string);
364 gimp_destroy_params (return_vals, nreturn_vals);
366 return abbreviation;
370 * _gimp_unit_get_singular:
371 * @unit_id: The unit's integer ID.
373 * Returns the singular form of the unit.
375 * This procedure returns the singular form of the unit.
377 * Returns: The unit's singular form.
379 gchar *
380 _gimp_unit_get_singular (GimpUnit unit_id)
382 GimpParam *return_vals;
383 gint nreturn_vals;
384 gchar *singular = NULL;
386 return_vals = gimp_run_procedure ("gimp-unit-get-singular",
387 &nreturn_vals,
388 GIMP_PDB_INT32, unit_id,
389 GIMP_PDB_END);
391 if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
392 singular = g_strdup (return_vals[1].data.d_string);
394 gimp_destroy_params (return_vals, nreturn_vals);
396 return singular;
400 * _gimp_unit_get_plural:
401 * @unit_id: The unit's integer ID.
403 * Returns the plural form of the unit.
405 * This procedure returns the plural form of the unit.
407 * Returns: The unit's plural form.
409 gchar *
410 _gimp_unit_get_plural (GimpUnit unit_id)
412 GimpParam *return_vals;
413 gint nreturn_vals;
414 gchar *plural = NULL;
416 return_vals = gimp_run_procedure ("gimp-unit-get-plural",
417 &nreturn_vals,
418 GIMP_PDB_INT32, unit_id,
419 GIMP_PDB_END);
421 if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
422 plural = g_strdup (return_vals[1].data.d_string);
424 gimp_destroy_params (return_vals, nreturn_vals);
426 return plural;