/* LIBPIKA - The PIKA Library * Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball * * pikaunit_pdb.c * * This library is free software: you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see * . */ /* NOTE: This file is auto-generated by pdbgen.pl */ #include "config.h" #include "stamp-pdbgen.h" #include "pika.h" #include "pikaunit_pdb.h" /** * _pika_unit_get_number_of_units: * * Returns the number of units. * * This procedure returns the number of defined units. * * Returns: The number of units. **/ gint _pika_unit_get_number_of_units (void) { PikaValueArray *args; PikaValueArray *return_vals; gint num_units = PIKA_UNIT_END; args = pika_value_array_new_from_types (NULL, G_TYPE_NONE); return_vals = _pika_pdb_run_procedure_array (pika_get_pdb (), "pika-unit-get-number-of-units", args); pika_value_array_unref (args); if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS) num_units = PIKA_VALUES_GET_INT (return_vals, 1); pika_value_array_unref (return_vals); return num_units; } /** * _pika_unit_get_number_of_built_in_units: * * Returns the number of built-in units. * * This procedure returns the number of defined units built-in to PIKA. * * Returns: The number of built-in units. **/ gint _pika_unit_get_number_of_built_in_units (void) { PikaValueArray *args; PikaValueArray *return_vals; gint num_units = PIKA_UNIT_END; args = pika_value_array_new_from_types (NULL, G_TYPE_NONE); return_vals = _pika_pdb_run_procedure_array (pika_get_pdb (), "pika-unit-get-number-of-built-in-units", args); pika_value_array_unref (args); if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS) num_units = PIKA_VALUES_GET_INT (return_vals, 1); pika_value_array_unref (return_vals); return num_units; } /** * _pika_unit_new: * @identifier: The new unit's identifier. * @factor: The new unit's factor. * @digits: The new unit's digits. * @symbol: The new unit's symbol. * @abbreviation: The new unit's abbreviation. * @singular: The new unit's singular form. * @plural: The new unit's plural form. * * Creates a new unit and returns it's integer ID. * * 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 pika_unit_set_deletion_flag() to * make it persistent. * * Returns: (transfer none): The new unit's ID. **/ PikaUnit _pika_unit_new (const gchar *identifier, gdouble factor, gint digits, const gchar *symbol, const gchar *abbreviation, const gchar *singular, const gchar *plural) { PikaValueArray *args; PikaValueArray *return_vals; PikaUnit unit_id = PIKA_UNIT_INCH; args = pika_value_array_new_from_types (NULL, G_TYPE_STRING, identifier, G_TYPE_DOUBLE, factor, G_TYPE_INT, digits, G_TYPE_STRING, symbol, G_TYPE_STRING, abbreviation, G_TYPE_STRING, singular, G_TYPE_STRING, plural, G_TYPE_NONE); return_vals = _pika_pdb_run_procedure_array (pika_get_pdb (), "pika-unit-new", args); pika_value_array_unref (args); if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS) unit_id = PIKA_VALUES_GET_INT (return_vals, 1); pika_value_array_unref (return_vals); return unit_id; } /** * _pika_unit_get_deletion_flag: * @unit_id: The unit's integer ID. * * 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 pika exit. * * Returns: The unit's deletion flag. **/ gboolean _pika_unit_get_deletion_flag (PikaUnit unit_id) { PikaValueArray *args; PikaValueArray *return_vals; gboolean deletion_flag = FALSE; args = pika_value_array_new_from_types (NULL, PIKA_TYPE_UNIT, unit_id, G_TYPE_NONE); return_vals = _pika_pdb_run_procedure_array (pika_get_pdb (), "pika-unit-get-deletion-flag", args); pika_value_array_unref (args); if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS) deletion_flag = PIKA_VALUES_GET_BOOLEAN (return_vals, 1); pika_value_array_unref (return_vals); return deletion_flag; } /** * _pika_unit_set_deletion_flag: * @unit_id: The unit's integer ID. * @deletion_flag: The new deletion flag of the unit. * * 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 pika exit, this unit's definition will not be * saved in the user's unitrc. * * Returns: TRUE on success. **/ gboolean _pika_unit_set_deletion_flag (PikaUnit unit_id, gboolean deletion_flag) { PikaValueArray *args; PikaValueArray *return_vals; gboolean success = TRUE; args = pika_value_array_new_from_types (NULL, PIKA_TYPE_UNIT, unit_id, G_TYPE_BOOLEAN, deletion_flag, G_TYPE_NONE); return_vals = _pika_pdb_run_procedure_array (pika_get_pdb (), "pika-unit-set-deletion-flag", args); pika_value_array_unref (args); success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS; pika_value_array_unref (return_vals); return success; } /** * _pika_unit_get_identifier: * @unit_id: The unit's integer ID. * * 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. * * Returns: (transfer full): The unit's textual identifier. * The returned value must be freed with g_free(). **/ gchar * _pika_unit_get_identifier (PikaUnit unit_id) { PikaValueArray *args; PikaValueArray *return_vals; gchar *identifier = NULL; args = pika_value_array_new_from_types (NULL, PIKA_TYPE_UNIT, unit_id, G_TYPE_NONE); return_vals = _pika_pdb_run_procedure_array (pika_get_pdb (), "pika-unit-get-identifier", args); pika_value_array_unref (args); if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS) identifier = PIKA_VALUES_DUP_STRING (return_vals, 1); pika_value_array_unref (return_vals); return identifier; } /** * _pika_unit_get_factor: * @unit_id: The unit's integer ID. * * 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. * * Returns: The unit's factor. **/ gdouble _pika_unit_get_factor (PikaUnit unit_id) { PikaValueArray *args; PikaValueArray *return_vals; gdouble factor = 0.0; args = pika_value_array_new_from_types (NULL, PIKA_TYPE_UNIT, unit_id, G_TYPE_NONE); return_vals = _pika_pdb_run_procedure_array (pika_get_pdb (), "pika-unit-get-factor", args); pika_value_array_unref (args); if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS) factor = PIKA_VALUES_GET_DOUBLE (return_vals, 1); pika_value_array_unref (return_vals); return factor; } /** * _pika_unit_get_digits: * @unit_id: The unit's integer ID. * * 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. * * Returns: The unit's number of digits. **/ gint _pika_unit_get_digits (PikaUnit unit_id) { PikaValueArray *args; PikaValueArray *return_vals; gint digits = 0; args = pika_value_array_new_from_types (NULL, PIKA_TYPE_UNIT, unit_id, G_TYPE_NONE); return_vals = _pika_pdb_run_procedure_array (pika_get_pdb (), "pika-unit-get-digits", args); pika_value_array_unref (args); if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS) digits = PIKA_VALUES_GET_INT (return_vals, 1); pika_value_array_unref (return_vals); return digits; } /** * _pika_unit_get_symbol: * @unit_id: The unit's integer ID. * * Returns the symbol of the unit. * * This procedure returns the symbol of the unit (\"''\" for inches). * * Returns: (transfer full): The unit's symbol. * The returned value must be freed with g_free(). **/ gchar * _pika_unit_get_symbol (PikaUnit unit_id) { PikaValueArray *args; PikaValueArray *return_vals; gchar *symbol = NULL; args = pika_value_array_new_from_types (NULL, PIKA_TYPE_UNIT, unit_id, G_TYPE_NONE); return_vals = _pika_pdb_run_procedure_array (pika_get_pdb (), "pika-unit-get-symbol", args); pika_value_array_unref (args); if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS) symbol = PIKA_VALUES_DUP_STRING (return_vals, 1); pika_value_array_unref (return_vals); return symbol; } /** * _pika_unit_get_abbreviation: * @unit_id: The unit's integer ID. * * Returns the abbreviation of the unit. * * This procedure returns the abbreviation of the unit (\"in\" for * inches). * * Returns: (transfer full): The unit's abbreviation. * The returned value must be freed with g_free(). **/ gchar * _pika_unit_get_abbreviation (PikaUnit unit_id) { PikaValueArray *args; PikaValueArray *return_vals; gchar *abbreviation = NULL; args = pika_value_array_new_from_types (NULL, PIKA_TYPE_UNIT, unit_id, G_TYPE_NONE); return_vals = _pika_pdb_run_procedure_array (pika_get_pdb (), "pika-unit-get-abbreviation", args); pika_value_array_unref (args); if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS) abbreviation = PIKA_VALUES_DUP_STRING (return_vals, 1); pika_value_array_unref (return_vals); return abbreviation; } /** * _pika_unit_get_singular: * @unit_id: The unit's integer ID. * * Returns the singular form of the unit. * * This procedure returns the singular form of the unit. * * Returns: (transfer full): The unit's singular form. * The returned value must be freed with g_free(). **/ gchar * _pika_unit_get_singular (PikaUnit unit_id) { PikaValueArray *args; PikaValueArray *return_vals; gchar *singular = NULL; args = pika_value_array_new_from_types (NULL, PIKA_TYPE_UNIT, unit_id, G_TYPE_NONE); return_vals = _pika_pdb_run_procedure_array (pika_get_pdb (), "pika-unit-get-singular", args); pika_value_array_unref (args); if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS) singular = PIKA_VALUES_DUP_STRING (return_vals, 1); pika_value_array_unref (return_vals); return singular; } /** * _pika_unit_get_plural: * @unit_id: The unit's integer ID. * * Returns the plural form of the unit. * * This procedure returns the plural form of the unit. * * Returns: (transfer full): The unit's plural form. * The returned value must be freed with g_free(). **/ gchar * _pika_unit_get_plural (PikaUnit unit_id) { PikaValueArray *args; PikaValueArray *return_vals; gchar *plural = NULL; args = pika_value_array_new_from_types (NULL, PIKA_TYPE_UNIT, unit_id, G_TYPE_NONE); return_vals = _pika_pdb_run_procedure_array (pika_get_pdb (), "pika-unit-get-plural", args); pika_value_array_unref (args); if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS) plural = PIKA_VALUES_DUP_STRING (return_vals, 1); pika_value_array_unref (return_vals); return plural; }