Exemplo n.º 1
0
static GValueArray *
unit_get_singular_invoker (GimpProcedure      *procedure,
                           Gimp               *gimp,
                           GimpContext        *context,
                           GimpProgress       *progress,
                           const GValueArray  *args,
                           GError            **error)
{
  gboolean success = TRUE;
  GValueArray *return_vals;
  GimpUnit unit_id;
  gchar *singular = NULL;

  unit_id = g_value_get_int (&args->values[0]);

  if (success)
    {
      singular = g_strdup (_gimp_unit_get_singular (gimp, unit_id));
    }

  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_take_string (&return_vals->values[1], singular);

  return return_vals;
}
Exemplo n.º 2
0
static void
gimp_unit_def_init (GimpUnitDef *unit_def,
                    GimpUnit     unit)
{
  unit_def->factor       = _gimp_unit_get_factor (unit);
  unit_def->digits       = _gimp_unit_get_digits (unit);
  unit_def->identifier   = _gimp_unit_get_identifier (unit);
  unit_def->symbol       = _gimp_unit_get_symbol (unit);
  unit_def->abbreviation = _gimp_unit_get_abbreviation (unit);
  unit_def->singular     = _gimp_unit_get_singular (unit);
  unit_def->plural       = _gimp_unit_get_plural (unit);
}
Exemplo n.º 3
0
void
gimp_unitrc_save (Gimp *gimp)
{
  GimpConfigWriter *writer;
  GFile            *file;
  gint              i;
  GError           *error = NULL;

  g_return_if_fail (GIMP_IS_GIMP (gimp));

  file = gimp_directory_file ("unitrc", NULL);

  if (gimp->be_verbose)
    g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));

  writer =
    gimp_config_writer_new_gfile (file,
                                  TRUE,
                                  "GIMP units\n\n"
                                  "This file contains the user unit database. "
                                  "You can edit this list with the unit "
                                  "editor. You are not supposed to edit it "
                                  "manually, but of course you can do.\n"
                                  "This file will be entirely rewritten each "
                                  "time you exit.",
                                  NULL);

  g_object_unref (file);

  if (!writer)
    return;

  /*  save user defined units  */
  for (i = _gimp_unit_get_number_of_built_in_units (gimp);
       i < _gimp_unit_get_number_of_units (gimp);
       i++)
    {
      if (_gimp_unit_get_deletion_flag (gimp, i) == FALSE)
        {
          gchar buf[G_ASCII_DTOSTR_BUF_SIZE];

          gimp_config_writer_open (writer, "unit-info");
          gimp_config_writer_string (writer,
                                     _gimp_unit_get_identifier (gimp, i));

          gimp_config_writer_open (writer, "factor");
          gimp_config_writer_print (writer,
                                    g_ascii_formatd (buf, sizeof (buf), "%f",
                                                     _gimp_unit_get_factor (gimp, i)),
                                    -1);
          gimp_config_writer_close (writer);

          gimp_config_writer_open (writer, "digits");
          gimp_config_writer_printf (writer,
                                     "%d", _gimp_unit_get_digits (gimp, i));
          gimp_config_writer_close (writer);

          gimp_config_writer_open (writer, "symbol");
          gimp_config_writer_string (writer,
                                     _gimp_unit_get_symbol (gimp, i));
          gimp_config_writer_close (writer);

          gimp_config_writer_open (writer, "abbreviation");
          gimp_config_writer_string (writer,
                                     _gimp_unit_get_abbreviation (gimp, i));
          gimp_config_writer_close (writer);

          gimp_config_writer_open (writer, "singular");
          gimp_config_writer_string (writer,
                                     _gimp_unit_get_singular (gimp, i));
          gimp_config_writer_close (writer);

          gimp_config_writer_open (writer, "plural");
          gimp_config_writer_string (writer,
                                     _gimp_unit_get_plural (gimp, i));
          gimp_config_writer_close (writer);

          gimp_config_writer_close (writer);
        }
    }

  if (! gimp_config_writer_finish (writer, "end of units", &error))
    {
      gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
      g_clear_error (&error);
    }
}
Exemplo n.º 4
0
static const gchar *
gimp_units_unit_get_singular (GimpUnit unit)
{
  return _gimp_unit_get_singular (the_unit_gimp, unit);
}