home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / libgimp / gimpunit_pdb.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-08-25  |  10.5 KB  |  417 lines

  1. /* LIBGIMP - The GIMP Library
  2.  * Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
  3.  *
  4.  * gimpunit_pdb.c
  5.  *
  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 2 of the License, or (at your option) any later version.
  10.  *
  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.
  15.  *
  16.  * You should have received a copy of the GNU Lesser General Public
  17.  * License along with this library; if not, write to the
  18.  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19.  * Boston, MA 02111-1307, USA.
  20.  */
  21.  
  22. /* NOTE: This file is autogenerated by pdbgen.pl */
  23.  
  24. #include "gimp.h"
  25.  
  26. /**
  27.  * _gimp_unit_get_number_of_units:
  28.  *
  29.  * Returns the number of units.
  30.  *
  31.  * This procedure returns the number of defined units.
  32.  *
  33.  * Returns: The number of units.
  34.  */
  35. gint
  36. _gimp_unit_get_number_of_units (void)
  37. {
  38.   GimpParam *return_vals;
  39.   gint nreturn_vals;
  40.   gint num_units = GIMP_UNIT_END;
  41.  
  42.   return_vals = gimp_run_procedure ("gimp_unit_get_number_of_units",
  43.                     &nreturn_vals,
  44.                     GIMP_PDB_END);
  45.  
  46.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  47.     num_units = return_vals[1].data.d_int32;
  48.  
  49.   gimp_destroy_params (return_vals, nreturn_vals);
  50.  
  51.   return num_units;
  52. }
  53.  
  54. /**
  55.  * _gimp_unit_get_number_of_built_in_units:
  56.  *
  57.  * Returns the number of built-in units.
  58.  *
  59.  * This procedure returns the number of defined units built-in to the
  60.  * GIMP.
  61.  *
  62.  * Returns: The number of built-in units.
  63.  */
  64. gint
  65. _gimp_unit_get_number_of_built_in_units (void)
  66. {
  67.   GimpParam *return_vals;
  68.   gint nreturn_vals;
  69.   gint num_units = GIMP_UNIT_END;
  70.  
  71.   return_vals = gimp_run_procedure ("gimp_unit_get_number_of_built_in_units",
  72.                     &nreturn_vals,
  73.                     GIMP_PDB_END);
  74.  
  75.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  76.     num_units = return_vals[1].data.d_int32;
  77.  
  78.   gimp_destroy_params (return_vals, nreturn_vals);
  79.  
  80.   return num_units;
  81. }
  82.  
  83. /**
  84.  * _gimp_unit_new:
  85.  * @identifier: The new unit's identifier.
  86.  * @factor: The new unit's factor.
  87.  * @digits: The new unit's digits.
  88.  * @symbol: The new unit's symbol.
  89.  * @abbreviation: The new unit's abbreviation.
  90.  * @singular: The new unit's singular form.
  91.  * @plural: The new unit's plural form.
  92.  *
  93.  * Creates a new unit and returns it's integer ID.
  94.  *
  95.  * This procedure creates a new unit and returns it's integer ID. Note
  96.  * that the new unit will have it's deletion flag set to TRUE, so you
  97.  * will have to set it to FALSE with gimp_unit_set_deletion_flag to
  98.  * make it persistent.
  99.  *
  100.  * Returns: The new unit's ID.
  101.  */
  102. GimpUnit
  103. _gimp_unit_new (gchar   *identifier,
  104.         gdouble  factor,
  105.         gint     digits,
  106.         gchar   *symbol,
  107.         gchar   *abbreviation,
  108.         gchar   *singular,
  109.         gchar   *plural)
  110. {
  111.   GimpParam *return_vals;
  112.   gint nreturn_vals;
  113.   GimpUnit unit_id = GIMP_UNIT_INCH;
  114.  
  115.   return_vals = gimp_run_procedure ("gimp_unit_new",
  116.                     &nreturn_vals,
  117.                     GIMP_PDB_STRING, identifier,
  118.                     GIMP_PDB_FLOAT, factor,
  119.                     GIMP_PDB_INT32, digits,
  120.                     GIMP_PDB_STRING, symbol,
  121.                     GIMP_PDB_STRING, abbreviation,
  122.                     GIMP_PDB_STRING, singular,
  123.                     GIMP_PDB_STRING, plural,
  124.                     GIMP_PDB_END);
  125.  
  126.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  127.     unit_id = return_vals[1].data.d_unit;
  128.  
  129.   gimp_destroy_params (return_vals, nreturn_vals);
  130.  
  131.   return unit_id;
  132. }
  133.  
  134. /**
  135.  * _gimp_unit_get_deletion_flag:
  136.  * @unit_id: The unit's integer ID.
  137.  *
  138.  * Returns the deletion flag of the unit.
  139.  *
  140.  * This procedure returns the deletion flag of the unit. If this value
  141.  * is TRUE the unit's definition will not be saved in the user's unitrc
  142.  * file on gimp exit.
  143.  *
  144.  * Returns: The unit's deletion flag.
  145.  */
  146. gboolean
  147. _gimp_unit_get_deletion_flag (GimpUnit unit_id)
  148. {
  149.   GimpParam *return_vals;
  150.   gint nreturn_vals;
  151.   gboolean deletion_flag = FALSE;
  152.  
  153.   return_vals = gimp_run_procedure ("gimp_unit_get_deletion_flag",
  154.                     &nreturn_vals,
  155.                     GIMP_PDB_INT32, unit_id,
  156.                     GIMP_PDB_END);
  157.  
  158.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  159.     deletion_flag = return_vals[1].data.d_int32;
  160.  
  161.   gimp_destroy_params (return_vals, nreturn_vals);
  162.  
  163.   return deletion_flag;
  164. }
  165.  
  166. /**
  167.  * _gimp_unit_set_deletion_flag:
  168.  * @unit_id: The unit's integer ID.
  169.  * @deletion_flag: The new deletion flag of the unit.
  170.  *
  171.  * Sets the deletion flag of a unit.
  172.  *
  173.  * This procedure sets the unit's deletion flag. If the deletion flag
  174.  * of a unit is TRUE on gimp exit, this unit's definition will not be
  175.  * saved in the user's unitrc.
  176.  *
  177.  * Returns: TRUE on success.
  178.  */
  179. gboolean
  180. _gimp_unit_set_deletion_flag (GimpUnit unit_id,
  181.                   gboolean deletion_flag)
  182. {
  183.   GimpParam *return_vals;
  184.   gint nreturn_vals;
  185.   gboolean success = TRUE;
  186.  
  187.   return_vals = gimp_run_procedure ("gimp_unit_set_deletion_flag",
  188.                     &nreturn_vals,
  189.                     GIMP_PDB_INT32, unit_id,
  190.                     GIMP_PDB_INT32, deletion_flag,
  191.                     GIMP_PDB_END);
  192.  
  193.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  194.  
  195.   gimp_destroy_params (return_vals, nreturn_vals);
  196.  
  197.   return success;
  198. }
  199.  
  200. /**
  201.  * _gimp_unit_get_identifier:
  202.  * @unit_id: The unit's integer ID.
  203.  *
  204.  * Returns the textual identifier of the unit.
  205.  *
  206.  * This procedure returns the textual identifier of the unit. For
  207.  * built-in units it will be the english singular form of the unit's
  208.  * name. For user-defined units this should equal to the singular form.
  209.  *
  210.  * Returns: The unit's textual identifier.
  211.  */
  212. gchar *
  213. _gimp_unit_get_identifier (GimpUnit unit_id)
  214. {
  215.   GimpParam *return_vals;
  216.   gint nreturn_vals;
  217.   gchar *identifier = NULL;
  218.  
  219.   return_vals = gimp_run_procedure ("gimp_unit_get_identifier",
  220.                     &nreturn_vals,
  221.                     GIMP_PDB_INT32, unit_id,
  222.                     GIMP_PDB_END);
  223.  
  224.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  225.     identifier = g_strdup (return_vals[1].data.d_string);
  226.  
  227.   gimp_destroy_params (return_vals, nreturn_vals);
  228.  
  229.   return identifier;
  230. }
  231.  
  232. /**
  233.  * _gimp_unit_get_factor:
  234.  * @unit_id: The unit's integer ID.
  235.  *
  236.  * Returns the factor of the unit.
  237.  *
  238.  * This procedure returns the unit's factor which indicates how many
  239.  * units make up an inch. Note that asking for the factor of \"pixels\"
  240.  * will produce an error.
  241.  *
  242.  * Returns: The unit's factor.
  243.  */
  244. gdouble
  245. _gimp_unit_get_factor (GimpUnit unit_id)
  246. {
  247.   GimpParam *return_vals;
  248.   gint nreturn_vals;
  249.   gdouble factor = 0;
  250.  
  251.   return_vals = gimp_run_procedure ("gimp_unit_get_factor",
  252.                     &nreturn_vals,
  253.                     GIMP_PDB_INT32, unit_id,
  254.                     GIMP_PDB_END);
  255.  
  256.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  257.     factor = return_vals[1].data.d_float;
  258.  
  259.   gimp_destroy_params (return_vals, nreturn_vals);
  260.  
  261.   return factor;
  262. }
  263.  
  264. /**
  265.  * _gimp_unit_get_digits:
  266.  * @unit_id: The unit's integer ID.
  267.  *
  268.  * Returns the number of digits of the unit.
  269.  *
  270.  * This procedure returns the number of digits you should provide in
  271.  * input or output functions to get approximately the same accuracy as
  272.  * with two digits and inches. Note that asking for the digits of
  273.  * \"pixels\" will produce an error.
  274.  *
  275.  * Returns: The unit's number of digits.
  276.  */
  277. gint
  278. _gimp_unit_get_digits (GimpUnit unit_id)
  279. {
  280.   GimpParam *return_vals;
  281.   gint nreturn_vals;
  282.   gint digits = 0;
  283.  
  284.   return_vals = gimp_run_procedure ("gimp_unit_get_digits",
  285.                     &nreturn_vals,
  286.                     GIMP_PDB_INT32, unit_id,
  287.                     GIMP_PDB_END);
  288.  
  289.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  290.     digits = return_vals[1].data.d_int32;
  291.  
  292.   gimp_destroy_params (return_vals, nreturn_vals);
  293.  
  294.   return digits;
  295. }
  296.  
  297. /**
  298.  * _gimp_unit_get_symbol:
  299.  * @unit_id: The unit's integer ID.
  300.  *
  301.  * Returns the symbol of the unit.
  302.  *
  303.  * This procedure returns the symbol of the unit (\"''\" for inches).
  304.  *
  305.  * Returns: The unit's symbol.
  306.  */
  307. gchar *
  308. _gimp_unit_get_symbol (GimpUnit unit_id)
  309. {
  310.   GimpParam *return_vals;
  311.   gint nreturn_vals;
  312.   gchar *symbol = NULL;
  313.  
  314.   return_vals = gimp_run_procedure ("gimp_unit_get_symbol",
  315.                     &nreturn_vals,
  316.                     GIMP_PDB_INT32, unit_id,
  317.                     GIMP_PDB_END);
  318.  
  319.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  320.     symbol = g_strdup (return_vals[1].data.d_string);
  321.  
  322.   gimp_destroy_params (return_vals, nreturn_vals);
  323.  
  324.   return symbol;
  325. }
  326.  
  327. /**
  328.  * _gimp_unit_get_abbreviation:
  329.  * @unit_id: The unit's integer ID.
  330.  *
  331.  * Returns the abbreviation of the unit.
  332.  *
  333.  * This procedure returns the abbreviation of the unit (\"in\" for
  334.  * inches).
  335.  *
  336.  * Returns: The unit's abbreviation.
  337.  */
  338. gchar *
  339. _gimp_unit_get_abbreviation (GimpUnit unit_id)
  340. {
  341.   GimpParam *return_vals;
  342.   gint nreturn_vals;
  343.   gchar *abbreviation = NULL;
  344.  
  345.   return_vals = gimp_run_procedure ("gimp_unit_get_abbreviation",
  346.                     &nreturn_vals,
  347.                     GIMP_PDB_INT32, unit_id,
  348.                     GIMP_PDB_END);
  349.  
  350.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  351.     abbreviation = g_strdup (return_vals[1].data.d_string);
  352.  
  353.   gimp_destroy_params (return_vals, nreturn_vals);
  354.  
  355.   return abbreviation;
  356. }
  357.  
  358. /**
  359.  * _gimp_unit_get_singular:
  360.  * @unit_id: The unit's integer ID.
  361.  *
  362.  * Returns the singular form of the unit.
  363.  *
  364.  * This procedure returns the singular form of the unit.
  365.  *
  366.  * Returns: The unit's singular form.
  367.  */
  368. gchar *
  369. _gimp_unit_get_singular (GimpUnit unit_id)
  370. {
  371.   GimpParam *return_vals;
  372.   gint nreturn_vals;
  373.   gchar *singular = NULL;
  374.  
  375.   return_vals = gimp_run_procedure ("gimp_unit_get_singular",
  376.                     &nreturn_vals,
  377.                     GIMP_PDB_INT32, unit_id,
  378.                     GIMP_PDB_END);
  379.  
  380.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  381.     singular = g_strdup (return_vals[1].data.d_string);
  382.  
  383.   gimp_destroy_params (return_vals, nreturn_vals);
  384.  
  385.   return singular;
  386. }
  387.  
  388. /**
  389.  * _gimp_unit_get_plural:
  390.  * @unit_id: The unit's integer ID.
  391.  *
  392.  * Returns the plural form of the unit.
  393.  *
  394.  * This procedure returns the plural form of the unit.
  395.  *
  396.  * Returns: The unit's plural form.
  397.  */
  398. gchar *
  399. _gimp_unit_get_plural (GimpUnit unit_id)
  400. {
  401.   GimpParam *return_vals;
  402.   gint nreturn_vals;
  403.   gchar *plural = NULL;
  404.  
  405.   return_vals = gimp_run_procedure ("gimp_unit_get_plural",
  406.                     &nreturn_vals,
  407.                     GIMP_PDB_INT32, unit_id,
  408.                     GIMP_PDB_END);
  409.  
  410.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  411.     plural = g_strdup (return_vals[1].data.d_string);
  412.  
  413.   gimp_destroy_params (return_vals, nreturn_vals);
  414.  
  415.   return plural;
  416. }
  417.