mirror of https://github.com/GNOME/gimp.git
Issue #434: remove broken plural support for GimpUnit.
Rather than trying to implement full i18n plural support, we just remove this failed attempt from the past. The fact is that to get proper support, we'd basically need to reimplement a Gettext-like plural definition syntax within our API, then ask people to write down this plural definition for their language, then to write every plural form… all this for custom units which only them will ever see! Moreover code investigation shows that the singular form was simply never used, and the plural form was always used (whatever the actual unit value displayed). As for the "identifier", this was a text which was never shown anywhere (except in the unit editor) and for all built-in units, as well as default unitrc units, it was equivalent to the English plural value. So we now just have a unique name which is the "long label" to be used everywhere in the GUI, and abbreviation will be basically the "short label". That's it. No useless (or worse, not actually usable because it was not generic internationalization) values anymore!
This commit is contained in:
parent
a9af5509ab
commit
2a00a9e60a
|
@ -93,8 +93,8 @@ enum
|
||||||
UNIT_DIGITS,
|
UNIT_DIGITS,
|
||||||
UNIT_SYMBOL,
|
UNIT_SYMBOL,
|
||||||
UNIT_ABBREV,
|
UNIT_ABBREV,
|
||||||
UNIT_SINGULAR,
|
UNIT_SINGULAR, /* Obsoleted in GIMP 3.0. */
|
||||||
UNIT_PLURAL
|
UNIT_PLURAL /* Obsoleted in GIMP 3.0. */
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -236,7 +236,7 @@ gimp_unitrc_save (Gimp *gimp)
|
||||||
|
|
||||||
gimp_config_writer_open (writer, "unit-info");
|
gimp_config_writer_open (writer, "unit-info");
|
||||||
gimp_config_writer_string (writer,
|
gimp_config_writer_string (writer,
|
||||||
gimp_unit_get_identifier (unit));
|
gimp_unit_get_name (unit));
|
||||||
|
|
||||||
gimp_config_writer_open (writer, "factor");
|
gimp_config_writer_open (writer, "factor");
|
||||||
gimp_config_writer_print (writer,
|
gimp_config_writer_print (writer,
|
||||||
|
@ -260,16 +260,6 @@ gimp_unitrc_save (Gimp *gimp)
|
||||||
gimp_unit_get_abbreviation (unit));
|
gimp_unit_get_abbreviation (unit));
|
||||||
gimp_config_writer_close (writer);
|
gimp_config_writer_close (writer);
|
||||||
|
|
||||||
gimp_config_writer_open (writer, "singular");
|
|
||||||
gimp_config_writer_string (writer,
|
|
||||||
gimp_unit_get_singular (unit));
|
|
||||||
gimp_config_writer_close (writer);
|
|
||||||
|
|
||||||
gimp_config_writer_open (writer, "plural");
|
|
||||||
gimp_config_writer_string (writer,
|
|
||||||
gimp_unit_get_plural (unit));
|
|
||||||
gimp_config_writer_close (writer);
|
|
||||||
|
|
||||||
gimp_config_writer_close (writer);
|
gimp_config_writer_close (writer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,7 +278,7 @@ static GTokenType
|
||||||
gimp_unitrc_unit_info_deserialize (GScanner *scanner,
|
gimp_unitrc_unit_info_deserialize (GScanner *scanner,
|
||||||
Gimp *gimp)
|
Gimp *gimp)
|
||||||
{
|
{
|
||||||
gchar *identifier = NULL;
|
gchar *name = NULL;
|
||||||
gdouble factor = 1.0;
|
gdouble factor = 1.0;
|
||||||
gint digits = 2.0;
|
gint digits = 2.0;
|
||||||
gchar *symbol = NULL;
|
gchar *symbol = NULL;
|
||||||
|
@ -297,7 +287,7 @@ gimp_unitrc_unit_info_deserialize (GScanner *scanner,
|
||||||
gchar *plural = NULL;
|
gchar *plural = NULL;
|
||||||
GTokenType token;
|
GTokenType token;
|
||||||
|
|
||||||
if (! gimp_scanner_parse_string (scanner, &identifier))
|
if (! gimp_scanner_parse_string (scanner, &name))
|
||||||
return G_TOKEN_STRING;
|
return G_TOKEN_STRING;
|
||||||
|
|
||||||
token = G_TOKEN_LEFT_PAREN;
|
token = G_TOKEN_LEFT_PAREN;
|
||||||
|
@ -340,6 +330,11 @@ gimp_unitrc_unit_info_deserialize (GScanner *scanner,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UNIT_SINGULAR:
|
case UNIT_SINGULAR:
|
||||||
|
/* UNIT_SINGULAR and UNIT_PLURAL are deprecated. We still
|
||||||
|
* support reading them if they exist to stay backward
|
||||||
|
* compatible with older unitrc, in which case, we use
|
||||||
|
* UNIT_PLURAL on behalf of the name.
|
||||||
|
*/
|
||||||
token = G_TOKEN_STRING;
|
token = G_TOKEN_STRING;
|
||||||
if (! gimp_scanner_parse_string (scanner, &singular))
|
if (! gimp_scanner_parse_string (scanner, &singular))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -373,9 +368,8 @@ gimp_unitrc_unit_info_deserialize (GScanner *scanner,
|
||||||
if (g_scanner_peek_next_token (scanner) == token)
|
if (g_scanner_peek_next_token (scanner) == token)
|
||||||
{
|
{
|
||||||
GimpUnit *unit = _gimp_unit_new (gimp,
|
GimpUnit *unit = _gimp_unit_new (gimp,
|
||||||
identifier, factor, digits,
|
plural && strlen (plural) > 0 ? plural : name,
|
||||||
symbol, abbreviation,
|
factor, digits, symbol, abbreviation);
|
||||||
singular, plural);
|
|
||||||
|
|
||||||
/* make the unit definition persistent */
|
/* make the unit definition persistent */
|
||||||
gimp_unit_set_deletion_flag (unit, FALSE);
|
gimp_unit_set_deletion_flag (unit, FALSE);
|
||||||
|
@ -384,7 +378,7 @@ gimp_unitrc_unit_info_deserialize (GScanner *scanner,
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
|
||||||
g_free (identifier);
|
g_free (name);
|
||||||
g_free (symbol);
|
g_free (symbol);
|
||||||
g_free (abbreviation);
|
g_free (abbreviation);
|
||||||
g_free (singular);
|
g_free (singular);
|
||||||
|
|
|
@ -3071,6 +3071,11 @@ gimp_image_get_xcf_version (GimpImage *image,
|
||||||
version = MAX (16, version);
|
version = MAX (16, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Note: user unit storage was changed in XCF 21, but we can still
|
||||||
|
* easily save older XCF (we use the unit name for both singular and
|
||||||
|
* plural forms). Therefore we don't bump the XCF version unecessarily
|
||||||
|
* and don't add any test.
|
||||||
|
*/
|
||||||
|
|
||||||
#undef ADD_REASON
|
#undef ADD_REASON
|
||||||
|
|
||||||
|
|
|
@ -40,13 +40,11 @@
|
||||||
|
|
||||||
GimpUnit *
|
GimpUnit *
|
||||||
_gimp_unit_new (Gimp *gimp,
|
_gimp_unit_new (Gimp *gimp,
|
||||||
const gchar *identifier,
|
const gchar *name,
|
||||||
gdouble factor,
|
gdouble factor,
|
||||||
gint digits,
|
gint digits,
|
||||||
const gchar *symbol,
|
const gchar *symbol,
|
||||||
const gchar *abbreviation,
|
const gchar *abbreviation)
|
||||||
const gchar *singular,
|
|
||||||
const gchar *plural)
|
|
||||||
{
|
{
|
||||||
GimpUnit *unit;
|
GimpUnit *unit;
|
||||||
gint unit_id;
|
gint unit_id;
|
||||||
|
@ -54,13 +52,11 @@ _gimp_unit_new (Gimp *gimp,
|
||||||
unit_id = GIMP_UNIT_END + g_list_length (gimp->user_units);
|
unit_id = GIMP_UNIT_END + g_list_length (gimp->user_units);
|
||||||
unit = g_object_new (GIMP_TYPE_UNIT,
|
unit = g_object_new (GIMP_TYPE_UNIT,
|
||||||
"id", unit_id,
|
"id", unit_id,
|
||||||
"name", identifier,
|
"name", name,
|
||||||
"factor", factor,
|
"factor", factor,
|
||||||
"digits", digits,
|
"digits", digits,
|
||||||
"symbol", symbol,
|
"symbol", symbol,
|
||||||
"abbreviation", abbreviation,
|
"abbreviation", abbreviation,
|
||||||
"singular", singular,
|
|
||||||
"plural", plural,
|
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
gimp->user_units = g_list_append (gimp->user_units, unit);
|
gimp->user_units = g_list_append (gimp->user_units, unit);
|
||||||
|
|
|
@ -20,13 +20,11 @@
|
||||||
|
|
||||||
|
|
||||||
GimpUnit * _gimp_unit_new (Gimp *gimp,
|
GimpUnit * _gimp_unit_new (Gimp *gimp,
|
||||||
const gchar *identifier,
|
const gchar *name,
|
||||||
gdouble factor,
|
gdouble factor,
|
||||||
gint digits,
|
gint digits,
|
||||||
const gchar *symbol,
|
const gchar *symbol,
|
||||||
const gchar *abbreviation,
|
const gchar *abbreviation);
|
||||||
const gchar *singular,
|
|
||||||
const gchar *plural);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __APP_GIMP_UNIT_H__ */
|
#endif /* __APP_GIMP_UNIT_H__ */
|
||||||
|
|
|
@ -163,7 +163,7 @@ print_size_dialog_new (GimpImage *image,
|
||||||
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (height), TRUE);
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (height), TRUE);
|
||||||
gtk_entry_set_width_chars (GTK_ENTRY (height), SB_WIDTH);
|
gtk_entry_set_width_chars (GTK_ENTRY (height), SB_WIDTH);
|
||||||
|
|
||||||
entry = gimp_size_entry_new (0, gimp_get_default_unit (), "%p",
|
entry = gimp_size_entry_new (0, gimp_get_default_unit (), "%n",
|
||||||
FALSE, FALSE, FALSE, SB_WIDTH,
|
FALSE, FALSE, FALSE, SB_WIDTH,
|
||||||
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
||||||
private->size_entry = GIMP_SIZE_ENTRY (entry);
|
private->size_entry = GIMP_SIZE_ENTRY (entry);
|
||||||
|
|
|
@ -388,7 +388,7 @@ resize_dialog_new (GimpViewable *viewable,
|
||||||
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
||||||
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), SB_WIDTH);
|
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), SB_WIDTH);
|
||||||
|
|
||||||
private->offset = entry = gimp_size_entry_new (1, unit, "%p",
|
private->offset = entry = gimp_size_entry_new (1, unit, "%n",
|
||||||
TRUE, FALSE, FALSE, SB_WIDTH,
|
TRUE, FALSE, FALSE, SB_WIDTH,
|
||||||
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
||||||
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (entry),
|
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (entry),
|
||||||
|
|
|
@ -137,7 +137,7 @@ resolution_calibrate_dialog (GtkWidget *resolution_entry,
|
||||||
gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (resolution_entry), 1);
|
gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (resolution_entry), 1);
|
||||||
|
|
||||||
calibrate_entry =
|
calibrate_entry =
|
||||||
gimp_coordinates_new (gimp_unit_inch (), "%p",
|
gimp_coordinates_new (gimp_unit_inch (), "%n",
|
||||||
FALSE, FALSE, 10,
|
FALSE, FALSE, 10,
|
||||||
GIMP_SIZE_ENTRY_UPDATE_SIZE,
|
GIMP_SIZE_ENTRY_UPDATE_SIZE,
|
||||||
FALSE,
|
FALSE,
|
||||||
|
|
|
@ -6,7 +6,7 @@ EXPORTS
|
||||||
_gimp_unit_get_deletion_flag
|
_gimp_unit_get_deletion_flag
|
||||||
_gimp_unit_get_digits
|
_gimp_unit_get_digits
|
||||||
_gimp_unit_get_factor
|
_gimp_unit_get_factor
|
||||||
_gimp_unit_get_identifier
|
_gimp_unit_get_name
|
||||||
_gimp_unit_get_number_of_units
|
_gimp_unit_get_number_of_units
|
||||||
_gimp_unit_get_plural
|
_gimp_unit_get_plural
|
||||||
_gimp_unit_get_singular
|
_gimp_unit_get_singular
|
||||||
|
|
|
@ -50,27 +50,23 @@ unit_new_invoker (GimpProcedure *procedure,
|
||||||
{
|
{
|
||||||
gboolean success = TRUE;
|
gboolean success = TRUE;
|
||||||
GimpValueArray *return_vals;
|
GimpValueArray *return_vals;
|
||||||
const gchar *identifier;
|
const gchar *name;
|
||||||
gdouble factor;
|
gdouble factor;
|
||||||
gint digits;
|
gint digits;
|
||||||
const gchar *symbol;
|
const gchar *symbol;
|
||||||
const gchar *abbreviation;
|
const gchar *abbreviation;
|
||||||
const gchar *singular;
|
|
||||||
const gchar *plural;
|
|
||||||
GimpUnit *unit = NULL;
|
GimpUnit *unit = NULL;
|
||||||
|
|
||||||
identifier = g_value_get_string (gimp_value_array_index (args, 0));
|
name = g_value_get_string (gimp_value_array_index (args, 0));
|
||||||
factor = g_value_get_double (gimp_value_array_index (args, 1));
|
factor = g_value_get_double (gimp_value_array_index (args, 1));
|
||||||
digits = g_value_get_int (gimp_value_array_index (args, 2));
|
digits = g_value_get_int (gimp_value_array_index (args, 2));
|
||||||
symbol = g_value_get_string (gimp_value_array_index (args, 3));
|
symbol = g_value_get_string (gimp_value_array_index (args, 3));
|
||||||
abbreviation = g_value_get_string (gimp_value_array_index (args, 4));
|
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));
|
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
unit = _gimp_unit_new (gimp, identifier, factor, digits,
|
unit = _gimp_unit_new (gimp, name, factor, digits,
|
||||||
symbol, abbreviation, singular, plural);
|
symbol, abbreviation);
|
||||||
}
|
}
|
||||||
|
|
||||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||||
|
@ -93,13 +89,11 @@ unit_get_data_invoker (GimpProcedure *procedure,
|
||||||
gboolean success = TRUE;
|
gboolean success = TRUE;
|
||||||
GimpValueArray *return_vals;
|
GimpValueArray *return_vals;
|
||||||
gint unit_id;
|
gint unit_id;
|
||||||
gchar *identifier = NULL;
|
gchar *name = NULL;
|
||||||
gdouble factor = 0.0;
|
gdouble factor = 0.0;
|
||||||
gint digits = 0;
|
gint digits = 0;
|
||||||
gchar *symbol = NULL;
|
gchar *symbol = NULL;
|
||||||
gchar *abbreviation = NULL;
|
gchar *abbreviation = NULL;
|
||||||
gchar *singular = NULL;
|
|
||||||
gchar *plural = NULL;
|
|
||||||
|
|
||||||
unit_id = g_value_get_int (gimp_value_array_index (args, 0));
|
unit_id = g_value_get_int (gimp_value_array_index (args, 0));
|
||||||
|
|
||||||
|
@ -111,13 +105,11 @@ unit_get_data_invoker (GimpProcedure *procedure,
|
||||||
|
|
||||||
if (unit != NULL)
|
if (unit != NULL)
|
||||||
{
|
{
|
||||||
identifier = g_strdup (gimp_unit_get_identifier (unit));
|
name = g_strdup (gimp_unit_get_name (unit));
|
||||||
factor = gimp_unit_get_factor (unit);
|
factor = gimp_unit_get_factor (unit);
|
||||||
digits = gimp_unit_get_digits (unit);
|
digits = gimp_unit_get_digits (unit);
|
||||||
symbol = g_strdup (gimp_unit_get_symbol (unit));
|
symbol = g_strdup (gimp_unit_get_symbol (unit));
|
||||||
abbreviation = g_strdup (gimp_unit_get_abbreviation (unit));
|
abbreviation = g_strdup (gimp_unit_get_abbreviation (unit));
|
||||||
singular = g_strdup (gimp_unit_get_singular (unit));
|
|
||||||
plural = g_strdup (gimp_unit_get_plural (unit));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,13 +119,11 @@ unit_get_data_invoker (GimpProcedure *procedure,
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
g_value_take_string (gimp_value_array_index (return_vals, 1), identifier);
|
g_value_take_string (gimp_value_array_index (return_vals, 1), name);
|
||||||
g_value_set_double (gimp_value_array_index (return_vals, 2), factor);
|
g_value_set_double (gimp_value_array_index (return_vals, 2), factor);
|
||||||
g_value_set_int (gimp_value_array_index (return_vals, 3), digits);
|
g_value_set_int (gimp_value_array_index (return_vals, 3), digits);
|
||||||
g_value_take_string (gimp_value_array_index (return_vals, 4), symbol);
|
g_value_take_string (gimp_value_array_index (return_vals, 4), symbol);
|
||||||
g_value_take_string (gimp_value_array_index (return_vals, 5), abbreviation);
|
g_value_take_string (gimp_value_array_index (return_vals, 5), abbreviation);
|
||||||
g_value_take_string (gimp_value_array_index (return_vals, 6), singular);
|
|
||||||
g_value_take_string (gimp_value_array_index (return_vals, 7), plural);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return return_vals;
|
return return_vals;
|
||||||
|
@ -212,9 +202,9 @@ register_unit_procs (GimpPDB *pdb)
|
||||||
"Michael Natterer",
|
"Michael Natterer",
|
||||||
"1999");
|
"1999");
|
||||||
gimp_procedure_add_argument (procedure,
|
gimp_procedure_add_argument (procedure,
|
||||||
gimp_param_spec_string ("identifier",
|
gimp_param_spec_string ("name",
|
||||||
"identifier",
|
"name",
|
||||||
"The new unit's identifier",
|
"The new unit's name",
|
||||||
FALSE, FALSE, TRUE,
|
FALSE, FALSE, TRUE,
|
||||||
NULL,
|
NULL,
|
||||||
GIMP_PARAM_READWRITE));
|
GIMP_PARAM_READWRITE));
|
||||||
|
@ -244,20 +234,6 @@ register_unit_procs (GimpPDB *pdb)
|
||||||
FALSE, FALSE, TRUE,
|
FALSE, FALSE, TRUE,
|
||||||
NULL,
|
NULL,
|
||||||
GIMP_PARAM_READWRITE));
|
GIMP_PARAM_READWRITE));
|
||||||
gimp_procedure_add_argument (procedure,
|
|
||||||
gimp_param_spec_string ("singular",
|
|
||||||
"singular",
|
|
||||||
"The new unit's singular form",
|
|
||||||
FALSE, FALSE, TRUE,
|
|
||||||
NULL,
|
|
||||||
GIMP_PARAM_READWRITE));
|
|
||||||
gimp_procedure_add_argument (procedure,
|
|
||||||
gimp_param_spec_string ("plural",
|
|
||||||
"plural",
|
|
||||||
"The new unit's plural form",
|
|
||||||
FALSE, FALSE, TRUE,
|
|
||||||
NULL,
|
|
||||||
GIMP_PARAM_READWRITE));
|
|
||||||
gimp_procedure_add_return_value (procedure,
|
gimp_procedure_add_return_value (procedure,
|
||||||
gimp_param_spec_unit ("unit",
|
gimp_param_spec_unit ("unit",
|
||||||
"unit",
|
"unit",
|
||||||
|
@ -290,9 +266,9 @@ register_unit_procs (GimpPDB *pdb)
|
||||||
G_MININT32, G_MAXINT32, 0,
|
G_MININT32, G_MAXINT32, 0,
|
||||||
GIMP_PARAM_READWRITE));
|
GIMP_PARAM_READWRITE));
|
||||||
gimp_procedure_add_return_value (procedure,
|
gimp_procedure_add_return_value (procedure,
|
||||||
gimp_param_spec_string ("identifier",
|
gimp_param_spec_string ("name",
|
||||||
"identifier",
|
"name",
|
||||||
"The unit's textual identifier",
|
"The unit's name",
|
||||||
FALSE, FALSE, FALSE,
|
FALSE, FALSE, FALSE,
|
||||||
NULL,
|
NULL,
|
||||||
GIMP_PARAM_READWRITE));
|
GIMP_PARAM_READWRITE));
|
||||||
|
@ -322,20 +298,6 @@ register_unit_procs (GimpPDB *pdb)
|
||||||
FALSE, FALSE, FALSE,
|
FALSE, FALSE, FALSE,
|
||||||
NULL,
|
NULL,
|
||||||
GIMP_PARAM_READWRITE));
|
GIMP_PARAM_READWRITE));
|
||||||
gimp_procedure_add_return_value (procedure,
|
|
||||||
gimp_param_spec_string ("singular",
|
|
||||||
"singular",
|
|
||||||
"The unit's singular form",
|
|
||||||
FALSE, FALSE, FALSE,
|
|
||||||
NULL,
|
|
||||||
GIMP_PARAM_READWRITE));
|
|
||||||
gimp_procedure_add_return_value (procedure,
|
|
||||||
gimp_param_spec_string ("plural",
|
|
||||||
"plural",
|
|
||||||
"The unit's plural form",
|
|
||||||
FALSE, FALSE, FALSE,
|
|
||||||
NULL,
|
|
||||||
GIMP_PARAM_READWRITE));
|
|
||||||
gimp_pdb_register_procedure (pdb, procedure);
|
gimp_pdb_register_procedure (pdb, procedure);
|
||||||
g_object_unref (procedure);
|
g_object_unref (procedure);
|
||||||
|
|
||||||
|
|
|
@ -623,7 +623,7 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *measure,
|
||||||
g_snprintf (format, sizeof (format),
|
g_snprintf (format, sizeof (format),
|
||||||
"%%.%df %s, %%.2f\302\260 (%%.%df × %%.%df)",
|
"%%.%df %s, %%.2f\302\260 (%%.%df × %%.%df)",
|
||||||
unit_distance_digits,
|
unit_distance_digits,
|
||||||
gimp_unit_get_plural (shell->unit),
|
gimp_unit_get_name (shell->unit),
|
||||||
unit_width_digits,
|
unit_width_digits,
|
||||||
unit_height_digits);
|
unit_height_digits);
|
||||||
|
|
||||||
|
@ -648,7 +648,7 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *measure,
|
||||||
gtk_label_set_text (GTK_LABEL (measure->distance_label[1]), buf);
|
gtk_label_set_text (GTK_LABEL (measure->distance_label[1]), buf);
|
||||||
|
|
||||||
gtk_label_set_text (GTK_LABEL (measure->unit_label[0]),
|
gtk_label_set_text (GTK_LABEL (measure->unit_label[0]),
|
||||||
gimp_unit_get_plural (shell->unit));
|
gimp_unit_get_name (shell->unit));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -685,7 +685,7 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *measure,
|
||||||
gtk_label_set_text (GTK_LABEL (measure->width_label[1]), buf);
|
gtk_label_set_text (GTK_LABEL (measure->width_label[1]), buf);
|
||||||
|
|
||||||
gtk_label_set_text (GTK_LABEL (measure->unit_label[2]),
|
gtk_label_set_text (GTK_LABEL (measure->unit_label[2]),
|
||||||
gimp_unit_get_plural (shell->unit));
|
gimp_unit_get_name (shell->unit));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -705,7 +705,7 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *measure,
|
||||||
gtk_label_set_text (GTK_LABEL (measure->height_label[1]), buf);
|
gtk_label_set_text (GTK_LABEL (measure->height_label[1]), buf);
|
||||||
|
|
||||||
gtk_label_set_text (GTK_LABEL (measure->unit_label[3]),
|
gtk_label_set_text (GTK_LABEL (measure->unit_label[3]),
|
||||||
gimp_unit_get_plural (shell->unit));
|
gimp_unit_get_name (shell->unit));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -804,7 +804,7 @@ gimp_text_options_gui (GimpToolOptions *tool_options)
|
||||||
gtk_widget_show (grid);
|
gtk_widget_show (grid);
|
||||||
|
|
||||||
entry = gimp_prop_size_entry_new (config,
|
entry = gimp_prop_size_entry_new (config,
|
||||||
"font-size", FALSE, "font-size-unit", "%p",
|
"font-size", FALSE, "font-size-unit", "%n",
|
||||||
GIMP_SIZE_ENTRY_UPDATE_SIZE, 72.0);
|
GIMP_SIZE_ENTRY_UPDATE_SIZE, 72.0);
|
||||||
gimp_grid_attach_aligned (GTK_GRID (grid), 0, row++,
|
gimp_grid_attach_aligned (GTK_GRID (grid), 0, row++,
|
||||||
_("Size:"), 0.0, 0.5,
|
_("Size:"), 0.0, 0.5,
|
||||||
|
|
|
@ -448,7 +448,7 @@ gimp_image_prop_view_update (GimpImagePropView *view)
|
||||||
g_snprintf (format_buf, sizeof (format_buf), "%%.%df × %%.%df %s",
|
g_snprintf (format_buf, sizeof (format_buf), "%%.%df × %%.%df %s",
|
||||||
gimp_unit_get_scaled_digits (unit, xres),
|
gimp_unit_get_scaled_digits (unit, xres),
|
||||||
gimp_unit_get_scaled_digits (unit, yres),
|
gimp_unit_get_scaled_digits (unit, yres),
|
||||||
gimp_unit_get_plural (unit));
|
gimp_unit_get_name (unit));
|
||||||
g_snprintf (buf, sizeof (buf), format_buf,
|
g_snprintf (buf, sizeof (buf), format_buf,
|
||||||
gimp_pixels_to_units (gimp_image_get_width (image), unit, xres),
|
gimp_pixels_to_units (gimp_image_get_width (image), unit, xres),
|
||||||
gimp_pixels_to_units (gimp_image_get_height (image), unit, yres));
|
gimp_pixels_to_units (gimp_image_get_height (image), unit, yres));
|
||||||
|
|
|
@ -183,7 +183,7 @@ gimp_size_box_constructed (GObject *object)
|
||||||
gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (hbox);
|
gtk_widget_show (hbox);
|
||||||
|
|
||||||
entry = gimp_coordinates_new (box->unit, "%p",
|
entry = gimp_coordinates_new (box->unit, "%n",
|
||||||
TRUE, TRUE, SB_WIDTH,
|
TRUE, TRUE, SB_WIDTH,
|
||||||
GIMP_SIZE_ENTRY_UPDATE_SIZE,
|
GIMP_SIZE_ENTRY_UPDATE_SIZE,
|
||||||
TRUE, TRUE,
|
TRUE, TRUE,
|
||||||
|
|
|
@ -224,7 +224,7 @@ gimp_template_editor_constructed (GObject *object)
|
||||||
|
|
||||||
private->size_se = gimp_size_entry_new (0,
|
private->size_se = gimp_size_entry_new (0,
|
||||||
gimp_template_get_unit (template),
|
gimp_template_get_unit (template),
|
||||||
_("%p"),
|
_("%n"),
|
||||||
TRUE, FALSE, FALSE, SB_WIDTH,
|
TRUE, FALSE, FALSE, SB_WIDTH,
|
||||||
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
||||||
|
|
||||||
|
@ -359,7 +359,7 @@ gimp_template_editor_constructed (GObject *object)
|
||||||
private->resolution_se =
|
private->resolution_se =
|
||||||
gimp_size_entry_new (0,
|
gimp_size_entry_new (0,
|
||||||
gimp_template_get_resolution_unit (template),
|
gimp_template_get_resolution_unit (template),
|
||||||
_("pixels/%s"),
|
_("pixels/%a"),
|
||||||
FALSE, FALSE, FALSE, SB_WIDTH,
|
FALSE, FALSE, FALSE, SB_WIDTH,
|
||||||
GIMP_SIZE_ENTRY_UPDATE_RESOLUTION);
|
GIMP_SIZE_ENTRY_UPDATE_RESOLUTION);
|
||||||
|
|
||||||
|
|
|
@ -1455,30 +1455,36 @@ xcf_load_image_props (XcfInfo *info,
|
||||||
|
|
||||||
case PROP_USER_UNIT:
|
case PROP_USER_UNIT:
|
||||||
{
|
{
|
||||||
gchar *unit_strings[5];
|
gchar *unit_strings[5] = { 0 };
|
||||||
float factor;
|
float factor;
|
||||||
guint32 digits;
|
guint32 digits;
|
||||||
GimpUnit *unit;
|
GimpUnit *unit;
|
||||||
GList *iter;
|
GList *iter;
|
||||||
|
gint n_fields = 3;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
xcf_read_float (info, &factor, 1);
|
xcf_read_float (info, &factor, 1);
|
||||||
xcf_read_int32 (info, &digits, 1);
|
xcf_read_int32 (info, &digits, 1);
|
||||||
xcf_read_string (info, unit_strings, 5);
|
|
||||||
|
|
||||||
for (i = 0; i < 5; i++)
|
/* Depending on XCF version, read more or less strings. */
|
||||||
|
if (info->file_version < 21)
|
||||||
|
n_fields = 5;
|
||||||
|
xcf_read_string (info, unit_strings, n_fields);
|
||||||
|
|
||||||
|
for (i = 0; i < n_fields; i++)
|
||||||
if (unit_strings[i] == NULL)
|
if (unit_strings[i] == NULL)
|
||||||
unit_strings[i] = g_strdup ("");
|
unit_strings[i] = g_strdup ("");
|
||||||
|
|
||||||
for (iter = info->gimp->user_units; iter; iter = iter->next)
|
for (iter = info->gimp->user_units; iter; iter = iter->next)
|
||||||
{
|
{
|
||||||
unit = iter->data;
|
unit = iter->data;
|
||||||
/* if the factor and the identifier match some unit
|
/* if the factor and the name match some unit in unitrc,
|
||||||
* in unitrc, use the unitrc unit
|
* use the unitrc unit
|
||||||
*/
|
*/
|
||||||
if ((ABS (gimp_unit_get_factor (unit) - factor) < 1e-5) &&
|
if (ABS (gimp_unit_get_factor (unit) - factor) < 1e-5 &&
|
||||||
(strcmp (unit_strings[0],
|
(strcmp (unit_strings[0], gimp_unit_get_name (unit)) == 0 ||
|
||||||
gimp_unit_get_identifier (unit)) == 0))
|
(info->file_version < 21 &&
|
||||||
|
strcmp (unit_strings[4], gimp_unit_get_name (unit)) == 0)))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1489,17 +1495,15 @@ xcf_load_image_props (XcfInfo *info,
|
||||||
* flag.
|
* flag.
|
||||||
*/
|
*/
|
||||||
unit = _gimp_unit_new (info->gimp,
|
unit = _gimp_unit_new (info->gimp,
|
||||||
unit_strings[0],
|
unit_strings[4] && strlen (unit_strings[4]) > 0 ? unit_strings[4] : unit_strings[0],
|
||||||
(gdouble) factor,
|
(gdouble) factor,
|
||||||
digits,
|
digits,
|
||||||
unit_strings[1],
|
unit_strings[1],
|
||||||
unit_strings[2],
|
unit_strings[2]);
|
||||||
unit_strings[3],
|
|
||||||
unit_strings[4]);
|
|
||||||
|
|
||||||
gimp_image_set_unit (image, unit);
|
gimp_image_set_unit (image, unit);
|
||||||
|
|
||||||
for (i = 0; i < 5; i++)
|
for (i = 0; i < n_fields; i++)
|
||||||
g_free (unit_strings[i]);
|
g_free (unit_strings[i]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1588,28 +1588,37 @@ xcf_save_prop (XcfInfo *info,
|
||||||
guint32 digits;
|
guint32 digits;
|
||||||
|
|
||||||
/* write the entire unit definition */
|
/* write the entire unit definition */
|
||||||
unit_strings[0] = gimp_unit_get_identifier (unit);
|
unit_strings[0] = gimp_unit_get_name (unit);
|
||||||
factor = gimp_unit_get_factor (unit);
|
factor = gimp_unit_get_factor (unit);
|
||||||
digits = gimp_unit_get_digits (unit);
|
digits = gimp_unit_get_digits (unit);
|
||||||
unit_strings[1] = gimp_unit_get_symbol (unit);
|
unit_strings[1] = gimp_unit_get_symbol (unit);
|
||||||
unit_strings[2] = gimp_unit_get_abbreviation (unit);
|
unit_strings[2] = gimp_unit_get_abbreviation (unit);
|
||||||
unit_strings[3] = gimp_unit_get_singular (unit);
|
/* Singular and plural forms were deprecated in XCF 21. Just use
|
||||||
unit_strings[4] = gimp_unit_get_plural (unit);
|
* the unit name as bogus (yet reasonable) replacements.
|
||||||
|
*/
|
||||||
|
unit_strings[3] = gimp_unit_get_name (unit);
|
||||||
|
unit_strings[4] = gimp_unit_get_name (unit);
|
||||||
|
|
||||||
size =
|
size =
|
||||||
2 * 4 +
|
2 * 4 +
|
||||||
strlen (unit_strings[0]) ? strlen (unit_strings[0]) + 5 : 4 +
|
strlen (unit_strings[0]) ? strlen (unit_strings[0]) + 5 : 4 +
|
||||||
strlen (unit_strings[1]) ? strlen (unit_strings[1]) + 5 : 4 +
|
strlen (unit_strings[1]) ? strlen (unit_strings[1]) + 5 : 4 +
|
||||||
strlen (unit_strings[2]) ? strlen (unit_strings[2]) + 5 : 4 +
|
strlen (unit_strings[2]) ? strlen (unit_strings[2]) + 5 : 4;
|
||||||
strlen (unit_strings[3]) ? strlen (unit_strings[3]) + 5 : 4 +
|
|
||||||
strlen (unit_strings[4]) ? strlen (unit_strings[4]) + 5 : 4;
|
if (info->file_version < 21)
|
||||||
|
size +=
|
||||||
|
strlen (unit_strings[3]) ? strlen (unit_strings[3]) + 5 : 4 +
|
||||||
|
strlen (unit_strings[4]) ? strlen (unit_strings[4]) + 5 : 4;
|
||||||
|
|
||||||
xcf_write_prop_type_check_error (info, prop_type, va_end (args));
|
xcf_write_prop_type_check_error (info, prop_type, va_end (args));
|
||||||
xcf_write_int32_check_error (info, &size, 1, va_end (args));
|
xcf_write_int32_check_error (info, &size, 1, va_end (args));
|
||||||
|
|
||||||
xcf_write_float_check_error (info, &factor, 1, va_end (args));
|
xcf_write_float_check_error (info, &factor, 1, va_end (args));
|
||||||
xcf_write_int32_check_error (info, &digits, 1, va_end (args));
|
xcf_write_int32_check_error (info, &digits, 1, va_end (args));
|
||||||
xcf_write_string_check_error (info, (gchar **) unit_strings, 5, va_end (args));
|
if (info->file_version < 21)
|
||||||
|
xcf_write_string_check_error (info, (gchar **) unit_strings, 5, va_end (args));
|
||||||
|
else
|
||||||
|
xcf_write_string_check_error (info, (gchar **) unit_strings, 3, va_end (args));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,7 @@ static GimpXcfLoaderFunc * const xcf_loaders[] =
|
||||||
xcf_load_image, /* version 18 */
|
xcf_load_image, /* version 18 */
|
||||||
xcf_load_image, /* version 19 */
|
xcf_load_image, /* version 19 */
|
||||||
xcf_load_image, /* version 20 */
|
xcf_load_image, /* version 20 */
|
||||||
|
xcf_load_image, /* version 21 */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -661,7 +661,7 @@ gimp_resolution_entry_format_label (GimpResolutionEntry *entry,
|
||||||
gimp_unit_get_digits (entry->unit));
|
gimp_unit_get_digits (entry->unit));
|
||||||
gchar *text = g_strdup_printf (format,
|
gchar *text = g_strdup_printf (format,
|
||||||
size_inch * gimp_unit_get_factor (entry->unit),
|
size_inch * gimp_unit_get_factor (entry->unit),
|
||||||
gimp_unit_get_plural (entry->unit));
|
gimp_unit_get_name (entry->unit));
|
||||||
g_free (format);
|
g_free (format);
|
||||||
|
|
||||||
gtk_label_set_text (GTK_LABEL (label), text);
|
gtk_label_set_text (GTK_LABEL (label), text);
|
||||||
|
|
|
@ -39,13 +39,11 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gimp_unit_new:
|
* gimp_unit_new:
|
||||||
* @identifier: The new unit's identifier.
|
* @name: The new unit's name.
|
||||||
* @factor: The new unit's factor.
|
* @factor: The new unit's factor.
|
||||||
* @digits: The new unit's digits.
|
* @digits: The new unit's digits.
|
||||||
* @symbol: The new unit's symbol.
|
* @symbol: The new unit's symbol.
|
||||||
* @abbreviation: The new unit's abbreviation.
|
* @abbreviation: The new unit's abbreviation.
|
||||||
* @singular: The new unit's singular form.
|
|
||||||
* @plural: The new unit's plural form.
|
|
||||||
*
|
*
|
||||||
* Creates a new unit.
|
* Creates a new unit.
|
||||||
*
|
*
|
||||||
|
@ -57,26 +55,22 @@
|
||||||
* Returns: (transfer none): The new unit.
|
* Returns: (transfer none): The new unit.
|
||||||
**/
|
**/
|
||||||
GimpUnit *
|
GimpUnit *
|
||||||
gimp_unit_new (const gchar *identifier,
|
gimp_unit_new (const gchar *name,
|
||||||
gdouble factor,
|
gdouble factor,
|
||||||
gint digits,
|
gint digits,
|
||||||
const gchar *symbol,
|
const gchar *symbol,
|
||||||
const gchar *abbreviation,
|
const gchar *abbreviation)
|
||||||
const gchar *singular,
|
|
||||||
const gchar *plural)
|
|
||||||
{
|
{
|
||||||
GimpValueArray *args;
|
GimpValueArray *args;
|
||||||
GimpValueArray *return_vals;
|
GimpValueArray *return_vals;
|
||||||
GimpUnit *unit = NULL;
|
GimpUnit *unit = NULL;
|
||||||
|
|
||||||
args = gimp_value_array_new_from_types (NULL,
|
args = gimp_value_array_new_from_types (NULL,
|
||||||
G_TYPE_STRING, identifier,
|
G_TYPE_STRING, name,
|
||||||
G_TYPE_DOUBLE, factor,
|
G_TYPE_DOUBLE, factor,
|
||||||
G_TYPE_INT, digits,
|
G_TYPE_INT, digits,
|
||||||
G_TYPE_STRING, symbol,
|
G_TYPE_STRING, symbol,
|
||||||
G_TYPE_STRING, abbreviation,
|
G_TYPE_STRING, abbreviation,
|
||||||
G_TYPE_STRING, singular,
|
|
||||||
G_TYPE_STRING, plural,
|
|
||||||
G_TYPE_NONE);
|
G_TYPE_NONE);
|
||||||
|
|
||||||
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
||||||
|
@ -99,8 +93,6 @@ gimp_unit_new (const gchar *identifier,
|
||||||
* @digits: (out): The unit's number of digits.
|
* @digits: (out): The unit's number of digits.
|
||||||
* @symbol: (out) (transfer full): The unit's symbol.
|
* @symbol: (out) (transfer full): The unit's symbol.
|
||||||
* @abbreviation: (out) (transfer full): The unit's abbreviation.
|
* @abbreviation: (out) (transfer full): The unit's abbreviation.
|
||||||
* @singular: (out) (transfer full): The unit's singular form.
|
|
||||||
* @plural: (out) (transfer full): The unit's plural form.
|
|
||||||
*
|
*
|
||||||
* Returns the various data pertaining to a given unit ID.
|
* Returns the various data pertaining to a given unit ID.
|
||||||
*
|
*
|
||||||
|
@ -109,7 +101,7 @@ gimp_unit_new (const gchar *identifier,
|
||||||
* programming error to use it directly, in particular for any of the
|
* programming error to use it directly, in particular for any of the
|
||||||
* built-in units.
|
* built-in units.
|
||||||
*
|
*
|
||||||
* Returns: (transfer full): The unit's textual identifier.
|
* Returns: (transfer full): The unit's name.
|
||||||
* The returned value must be freed with g_free().
|
* The returned value must be freed with g_free().
|
||||||
**/
|
**/
|
||||||
gchar *
|
gchar *
|
||||||
|
@ -117,13 +109,11 @@ _gimp_unit_get_data (gint unit_id,
|
||||||
gdouble *factor,
|
gdouble *factor,
|
||||||
gint *digits,
|
gint *digits,
|
||||||
gchar **symbol,
|
gchar **symbol,
|
||||||
gchar **abbreviation,
|
gchar **abbreviation)
|
||||||
gchar **singular,
|
|
||||||
gchar **plural)
|
|
||||||
{
|
{
|
||||||
GimpValueArray *args;
|
GimpValueArray *args;
|
||||||
GimpValueArray *return_vals;
|
GimpValueArray *return_vals;
|
||||||
gchar *identifier = NULL;
|
gchar *name = NULL;
|
||||||
|
|
||||||
args = gimp_value_array_new_from_types (NULL,
|
args = gimp_value_array_new_from_types (NULL,
|
||||||
G_TYPE_INT, unit_id,
|
G_TYPE_INT, unit_id,
|
||||||
|
@ -136,18 +126,16 @@ _gimp_unit_get_data (gint unit_id,
|
||||||
|
|
||||||
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
|
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
|
||||||
{
|
{
|
||||||
identifier = GIMP_VALUES_DUP_STRING (return_vals, 1);
|
name = GIMP_VALUES_DUP_STRING (return_vals, 1);
|
||||||
*factor = GIMP_VALUES_GET_DOUBLE (return_vals, 2);
|
*factor = GIMP_VALUES_GET_DOUBLE (return_vals, 2);
|
||||||
*digits = GIMP_VALUES_GET_INT (return_vals, 3);
|
*digits = GIMP_VALUES_GET_INT (return_vals, 3);
|
||||||
*symbol = GIMP_VALUES_DUP_STRING (return_vals, 4);
|
*symbol = GIMP_VALUES_DUP_STRING (return_vals, 4);
|
||||||
*abbreviation = GIMP_VALUES_DUP_STRING (return_vals, 5);
|
*abbreviation = GIMP_VALUES_DUP_STRING (return_vals, 5);
|
||||||
*singular = GIMP_VALUES_DUP_STRING (return_vals, 6);
|
|
||||||
*plural = GIMP_VALUES_DUP_STRING (return_vals, 7);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_value_array_unref (return_vals);
|
gimp_value_array_unref (return_vals);
|
||||||
|
|
||||||
return identifier;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -32,20 +32,16 @@ G_BEGIN_DECLS
|
||||||
/* For information look into the C source or the html documentation */
|
/* For information look into the C source or the html documentation */
|
||||||
|
|
||||||
|
|
||||||
GimpUnit* gimp_unit_new (const gchar *identifier,
|
GimpUnit* gimp_unit_new (const gchar *name,
|
||||||
gdouble factor,
|
gdouble factor,
|
||||||
gint digits,
|
gint digits,
|
||||||
const gchar *symbol,
|
const gchar *symbol,
|
||||||
const gchar *abbreviation,
|
const gchar *abbreviation);
|
||||||
const gchar *singular,
|
|
||||||
const gchar *plural);
|
|
||||||
G_GNUC_INTERNAL gchar* _gimp_unit_get_data (gint unit_id,
|
G_GNUC_INTERNAL gchar* _gimp_unit_get_data (gint unit_id,
|
||||||
gdouble *factor,
|
gdouble *factor,
|
||||||
gint *digits,
|
gint *digits,
|
||||||
gchar **symbol,
|
gchar **symbol,
|
||||||
gchar **abbreviation,
|
gchar **abbreviation);
|
||||||
gchar **singular,
|
|
||||||
gchar **plural);
|
|
||||||
G_GNUC_INTERNAL gboolean _gimp_unit_get_deletion_flag (GimpUnit *unit);
|
G_GNUC_INTERNAL gboolean _gimp_unit_get_deletion_flag (GimpUnit *unit);
|
||||||
G_GNUC_INTERNAL gboolean _gimp_unit_set_deletion_flag (GimpUnit *unit,
|
G_GNUC_INTERNAL gboolean _gimp_unit_set_deletion_flag (GimpUnit *unit,
|
||||||
gboolean deletion_flag);
|
gboolean deletion_flag);
|
||||||
|
|
|
@ -4,7 +4,7 @@ typedef struct
|
||||||
{
|
{
|
||||||
gdouble factor;
|
gdouble factor;
|
||||||
gint digits;
|
gint digits;
|
||||||
gchar *identifier;
|
gchar *name;
|
||||||
gchar *symbol;
|
gchar *symbol;
|
||||||
gchar *abbreviation;
|
gchar *abbreviation;
|
||||||
} GimpUnitDef;
|
} GimpUnitDef;
|
||||||
|
@ -57,7 +57,7 @@ gimp_c_test_run (GimpProcedure *procedure,
|
||||||
unit = gimp_unit_get_by_id (i);
|
unit = gimp_unit_get_by_id (i);
|
||||||
|
|
||||||
GIMP_TEST_END(GIMP_IS_UNIT (unit) &&
|
GIMP_TEST_END(GIMP_IS_UNIT (unit) &&
|
||||||
g_strcmp0 (gimp_unit_get_identifier (unit), _gimp_unit_defs[i].identifier) == 0 &&
|
g_strcmp0 (gimp_unit_get_name (unit), _gimp_unit_defs[i].name) == 0 &&
|
||||||
g_strcmp0 (gimp_unit_get_symbol (unit), _gimp_unit_defs[i].symbol) == 0 &&
|
g_strcmp0 (gimp_unit_get_symbol (unit), _gimp_unit_defs[i].symbol) == 0 &&
|
||||||
g_strcmp0 (gimp_unit_get_abbreviation (unit), _gimp_unit_defs[i].abbreviation) == 0 &&
|
g_strcmp0 (gimp_unit_get_abbreviation (unit), _gimp_unit_defs[i].abbreviation) == 0 &&
|
||||||
gimp_unit_get_factor (unit) == _gimp_unit_defs[i].factor &&
|
gimp_unit_get_factor (unit) == _gimp_unit_defs[i].factor &&
|
||||||
|
@ -78,9 +78,7 @@ gimp_c_test_run (GimpProcedure *procedure,
|
||||||
GIMP_TEST_END(n_user_units == N_DEFAULT_USER_UNITS);
|
GIMP_TEST_END(n_user_units == N_DEFAULT_USER_UNITS);
|
||||||
|
|
||||||
GIMP_TEST_START("gimp_unit_new()");
|
GIMP_TEST_START("gimp_unit_new()");
|
||||||
unit2 = gimp_unit_new ("identifier", 2.0, 1,
|
unit2 = gimp_unit_new ("name", 2.0, 1, "symbol", "abbreviation");
|
||||||
"symbol", "abbreviation",
|
|
||||||
"singular", "plural");
|
|
||||||
GIMP_TEST_END(GIMP_IS_UNIT (unit2));
|
GIMP_TEST_END(GIMP_IS_UNIT (unit2));
|
||||||
|
|
||||||
GIMP_TEST_START("Verifying the new user unit's ID");
|
GIMP_TEST_START("Verifying the new user unit's ID");
|
||||||
|
|
|
@ -35,9 +35,7 @@ struct _GimpUnitVtable
|
||||||
gdouble *factor,
|
gdouble *factor,
|
||||||
gint *digits,
|
gint *digits,
|
||||||
gchar **symbol,
|
gchar **symbol,
|
||||||
gchar **abbreviation,
|
gchar **abbreviation);
|
||||||
gchar **singular,
|
|
||||||
gchar **plural);
|
|
||||||
|
|
||||||
/* These methods MUST only be set on app, not in libgimp. */
|
/* These methods MUST only be set on app, not in libgimp. */
|
||||||
GimpUnit * (* get_user_unit) (gint unit_id);
|
GimpUnit * (* get_user_unit) (gint unit_id);
|
||||||
|
|
|
@ -205,10 +205,8 @@ EXPORTS
|
||||||
gimp_unit_get_digits
|
gimp_unit_get_digits
|
||||||
gimp_unit_get_factor
|
gimp_unit_get_factor
|
||||||
gimp_unit_get_id
|
gimp_unit_get_id
|
||||||
gimp_unit_get_identifier
|
gimp_unit_get_name
|
||||||
gimp_unit_get_plural
|
|
||||||
gimp_unit_get_scaled_digits
|
gimp_unit_get_scaled_digits
|
||||||
gimp_unit_get_singular
|
|
||||||
gimp_unit_get_symbol
|
gimp_unit_get_symbol
|
||||||
gimp_unit_get_type
|
gimp_unit_get_type
|
||||||
gimp_unit_inch
|
gimp_unit_inch
|
||||||
|
|
|
@ -45,21 +45,8 @@ enum
|
||||||
PROP_DIGITS,
|
PROP_DIGITS,
|
||||||
PROP_SYMBOL,
|
PROP_SYMBOL,
|
||||||
PROP_ABBREVIATION,
|
PROP_ABBREVIATION,
|
||||||
PROP_SINGULAR,
|
|
||||||
PROP_PLURAL,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
gdouble factor;
|
|
||||||
gint digits;
|
|
||||||
gchar *identifier;
|
|
||||||
gchar *symbol;
|
|
||||||
gchar *abbreviation;
|
|
||||||
gchar *singular;
|
|
||||||
gchar *plural;
|
|
||||||
} GimpUnitDef;
|
|
||||||
|
|
||||||
struct _GimpUnit
|
struct _GimpUnit
|
||||||
{
|
{
|
||||||
GObject parent_instance;
|
GObject parent_instance;
|
||||||
|
@ -72,40 +59,63 @@ struct _GimpUnit
|
||||||
gint digits;
|
gint digits;
|
||||||
gchar *symbol;
|
gchar *symbol;
|
||||||
gchar *abbreviation;
|
gchar *abbreviation;
|
||||||
gchar *singular;
|
|
||||||
gchar *plural;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
gdouble factor;
|
||||||
|
gint digits;
|
||||||
|
gchar *identifier;
|
||||||
|
gchar *symbol;
|
||||||
|
gchar *abbreviation;
|
||||||
|
} GimpUnitDef;
|
||||||
|
|
||||||
/* these are the built-in units
|
/* these are the built-in units
|
||||||
*/
|
*/
|
||||||
static const GimpUnitDef _gimp_unit_defs[GIMP_UNIT_END] =
|
static const GimpUnitDef _gimp_unit_defs[GIMP_UNIT_END] =
|
||||||
{
|
{
|
||||||
/* pseudo unit */
|
/* pseudo unit */
|
||||||
{ 0.0, 0, "pixels", "px", "px",
|
{
|
||||||
NC_("unit-singular", "pixel"), NC_("unit-plural", "pixels") },
|
0.0, 0,
|
||||||
|
NC_("unit-plural", "pixels"),
|
||||||
|
"px", "px",
|
||||||
|
},
|
||||||
|
|
||||||
/* standard units */
|
/* standard units */
|
||||||
{ 1.0, 2, "inches", "''", "in",
|
{
|
||||||
NC_("unit-singular", "inch"), NC_("unit-plural", "inches") },
|
1.0, 2,
|
||||||
|
NC_("unit-plural", "inches"),
|
||||||
|
"''", "in",
|
||||||
|
},
|
||||||
|
|
||||||
{ 25.4, 1, "millimeters", "mm", "mm",
|
{
|
||||||
NC_("unit-singular", "millimeter"), NC_("unit-plural", "millimeters") },
|
25.4, 1,
|
||||||
|
NC_("unit-plural", "millimeters"),
|
||||||
|
"mm", "mm",
|
||||||
|
},
|
||||||
|
|
||||||
/* professional units */
|
/* professional units */
|
||||||
{ 72.0, 0, "points", "pt", "pt",
|
{
|
||||||
NC_("unit-singular", "point"), NC_("unit-plural", "points") },
|
72.0, 0,
|
||||||
|
NC_("unit-plural", "points"),
|
||||||
|
"pt", "pt",
|
||||||
|
},
|
||||||
|
|
||||||
{ 6.0, 1, "picas", "pc", "pc",
|
{
|
||||||
NC_("unit-singular", "pica"), NC_("unit-plural", "picas") }
|
6.0, 1,
|
||||||
|
NC_("unit-plural", "picas"),
|
||||||
|
"pc", "pc",
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* not a unit at all but kept here to have the strings in one place
|
/* not a unit at all but kept here to have the strings in one place
|
||||||
*/
|
*/
|
||||||
static const GimpUnitDef _gimp_unit_percent_def =
|
static const GimpUnitDef _gimp_unit_percent_def =
|
||||||
{
|
{
|
||||||
0.0, 0, "percent", "%", "%",
|
0.0, 0,
|
||||||
NC_("singular", "percent"), NC_("plural", "percent")
|
NC_("unit-plural", "percent"),
|
||||||
|
"%", "%",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -174,16 +184,6 @@ gimp_unit_class_init (GimpUnitClass *klass)
|
||||||
NULL,
|
NULL,
|
||||||
GIMP_PARAM_READWRITE |
|
GIMP_PARAM_READWRITE |
|
||||||
G_PARAM_CONSTRUCT_ONLY));
|
G_PARAM_CONSTRUCT_ONLY));
|
||||||
g_object_class_install_property (object_class, PROP_SINGULAR,
|
|
||||||
g_param_spec_string ("singular", NULL, NULL,
|
|
||||||
NULL,
|
|
||||||
GIMP_PARAM_READWRITE |
|
|
||||||
G_PARAM_CONSTRUCT_ONLY));
|
|
||||||
g_object_class_install_property (object_class, PROP_PLURAL,
|
|
||||||
g_param_spec_string ("plural", NULL, NULL,
|
|
||||||
NULL,
|
|
||||||
GIMP_PARAM_READWRITE |
|
|
||||||
G_PARAM_CONSTRUCT_ONLY));
|
|
||||||
|
|
||||||
/*klass->id_table = gimp_id_table_new ();*/
|
/*klass->id_table = gimp_id_table_new ();*/
|
||||||
}
|
}
|
||||||
|
@ -194,8 +194,6 @@ gimp_unit_init (GimpUnit *unit)
|
||||||
unit->name = NULL;
|
unit->name = NULL;
|
||||||
unit->symbol = NULL;
|
unit->symbol = NULL;
|
||||||
unit->abbreviation = NULL;
|
unit->abbreviation = NULL;
|
||||||
unit->singular = NULL;
|
|
||||||
unit->plural = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -212,8 +210,6 @@ gimp_unit_finalize (GObject *object)
|
||||||
g_free (unit->name);
|
g_free (unit->name);
|
||||||
g_free (unit->symbol);
|
g_free (unit->symbol);
|
||||||
g_free (unit->abbreviation);
|
g_free (unit->abbreviation);
|
||||||
g_free (unit->singular);
|
|
||||||
g_free (unit->plural);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
@ -246,12 +242,6 @@ gimp_unit_set_property (GObject *object,
|
||||||
case PROP_ABBREVIATION:
|
case PROP_ABBREVIATION:
|
||||||
unit->abbreviation = g_value_dup_string (value);
|
unit->abbreviation = g_value_dup_string (value);
|
||||||
break;
|
break;
|
||||||
case PROP_SINGULAR:
|
|
||||||
unit->singular = g_value_dup_string (value);
|
|
||||||
break;
|
|
||||||
case PROP_PLURAL:
|
|
||||||
unit->plural = g_value_dup_string (value);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
|
@ -287,12 +277,6 @@ gimp_unit_get_property (GObject *object,
|
||||||
case PROP_ABBREVIATION:
|
case PROP_ABBREVIATION:
|
||||||
g_value_set_string (value, unit->abbreviation);
|
g_value_set_string (value, unit->abbreviation);
|
||||||
break;
|
break;
|
||||||
case PROP_SINGULAR:
|
|
||||||
g_value_set_string (value, unit->singular);
|
|
||||||
break;
|
|
||||||
case PROP_PLURAL:
|
|
||||||
g_value_set_string (value, unit->plural);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
|
@ -323,15 +307,19 @@ gimp_unit_get_id (GimpUnit *unit)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gimp_unit_get_identifier:
|
* gimp_unit_get_name:
|
||||||
* @unit: The unit you want to know the identifier of.
|
* @unit: The unit you want to know the name of.
|
||||||
*
|
*
|
||||||
* This is an untranslated string which must not be changed or freed.
|
* This function returns the usual name of the unit (e.g. "inches").
|
||||||
|
* It can be used as the long label for the unit in the interface.
|
||||||
|
* For short labels, use [method@Unit.get_abbreviation].
|
||||||
*
|
*
|
||||||
* Returns: The unit's identifier.
|
* NOTE: This string must not be changed or freed.
|
||||||
|
*
|
||||||
|
* Returns: The unit's name.
|
||||||
**/
|
**/
|
||||||
const gchar *
|
const gchar *
|
||||||
gimp_unit_get_identifier (GimpUnit *unit)
|
gimp_unit_get_name (GimpUnit *unit)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (GIMP_IS_UNIT (unit), NULL);
|
g_return_val_if_fail (GIMP_IS_UNIT (unit), NULL);
|
||||||
|
|
||||||
|
@ -435,8 +423,10 @@ gimp_unit_get_symbol (GimpUnit *unit)
|
||||||
* gimp_unit_get_abbreviation:
|
* gimp_unit_get_abbreviation:
|
||||||
* @unit: The unit you want to know the abbreviation of.
|
* @unit: The unit you want to know the abbreviation of.
|
||||||
*
|
*
|
||||||
* For built-in units, this function returns the abbreviation
|
* This function returns the abbreviation of the unit (e.g. "in" for
|
||||||
* of the unit (e.g. "in" for inches).
|
* inches).
|
||||||
|
* It can be used as a short label for the unit in the interface.
|
||||||
|
* For long labels, use [method@Unit.get_name].
|
||||||
*
|
*
|
||||||
* NOTE: This string must not be changed or freed.
|
* NOTE: This string must not be changed or freed.
|
||||||
*
|
*
|
||||||
|
@ -450,44 +440,6 @@ gimp_unit_get_abbreviation (GimpUnit *unit)
|
||||||
return unit->abbreviation;
|
return unit->abbreviation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* gimp_unit_get_singular:
|
|
||||||
* @unit: The unit you want to know the singular form of.
|
|
||||||
*
|
|
||||||
* For built-in units, this function returns the singular form of the
|
|
||||||
* unit's name.
|
|
||||||
*
|
|
||||||
* NOTE: This string must not be changed or freed.
|
|
||||||
*
|
|
||||||
* Returns: The unit's singular form.
|
|
||||||
**/
|
|
||||||
const gchar *
|
|
||||||
gimp_unit_get_singular (GimpUnit *unit)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (GIMP_IS_UNIT (unit), NULL);
|
|
||||||
|
|
||||||
return unit->singular;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gimp_unit_get_plural:
|
|
||||||
* @unit: The unit you want to know the plural form of.
|
|
||||||
*
|
|
||||||
* For built-in units, this function returns the plural form of the
|
|
||||||
* unit's name.
|
|
||||||
*
|
|
||||||
* NOTE: This string must not be changed or freed.
|
|
||||||
*
|
|
||||||
* Returns: The unit's plural form.
|
|
||||||
**/
|
|
||||||
const gchar *
|
|
||||||
gimp_unit_get_plural (GimpUnit *unit)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (GIMP_IS_UNIT (unit), NULL);
|
|
||||||
|
|
||||||
return unit->plural;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gimp_unit_get_deletion_flag:
|
* gimp_unit_get_deletion_flag:
|
||||||
* @unit: The unit you want to know the @deletion_flag of.
|
* @unit: The unit you want to know the @deletion_flag of.
|
||||||
|
@ -579,8 +531,6 @@ gimp_unit_get_by_id (gint unit_id)
|
||||||
"digits", def.digits,
|
"digits", def.digits,
|
||||||
"symbol", def.symbol,
|
"symbol", def.symbol,
|
||||||
"abbreviation", def.abbreviation,
|
"abbreviation", def.abbreviation,
|
||||||
"singular", def.singular,
|
|
||||||
"plural", def.plural,
|
|
||||||
NULL);
|
NULL);
|
||||||
unit->delete_on_exit = FALSE;
|
unit->delete_on_exit = FALSE;
|
||||||
}
|
}
|
||||||
|
@ -593,8 +543,6 @@ gimp_unit_get_by_id (gint unit_id)
|
||||||
"digits", _gimp_unit_percent_def.digits,
|
"digits", _gimp_unit_percent_def.digits,
|
||||||
"symbol", _gimp_unit_percent_def.symbol,
|
"symbol", _gimp_unit_percent_def.symbol,
|
||||||
"abbreviation", _gimp_unit_percent_def.abbreviation,
|
"abbreviation", _gimp_unit_percent_def.abbreviation,
|
||||||
"singular", _gimp_unit_percent_def.singular,
|
|
||||||
"plural", _gimp_unit_percent_def.plural,
|
|
||||||
NULL);
|
NULL);
|
||||||
unit->delete_on_exit = FALSE;
|
unit->delete_on_exit = FALSE;
|
||||||
}
|
}
|
||||||
|
@ -609,16 +557,12 @@ gimp_unit_get_by_id (gint unit_id)
|
||||||
gint digits;
|
gint digits;
|
||||||
gchar *symbol = NULL;
|
gchar *symbol = NULL;
|
||||||
gchar *abbreviation = NULL;
|
gchar *abbreviation = NULL;
|
||||||
gchar *singular = NULL;
|
|
||||||
gchar *plural = NULL;
|
|
||||||
|
|
||||||
identifier = _gimp_unit_vtable.get_data (unit_id,
|
identifier = _gimp_unit_vtable.get_data (unit_id,
|
||||||
&factor,
|
&factor,
|
||||||
&digits,
|
&digits,
|
||||||
&symbol,
|
&symbol,
|
||||||
&abbreviation,
|
&abbreviation);
|
||||||
&singular,
|
|
||||||
&plural);
|
|
||||||
|
|
||||||
if (identifier != NULL)
|
if (identifier != NULL)
|
||||||
unit = g_object_new (GIMP_TYPE_UNIT,
|
unit = g_object_new (GIMP_TYPE_UNIT,
|
||||||
|
@ -628,15 +572,11 @@ gimp_unit_get_by_id (gint unit_id)
|
||||||
"digits", digits,
|
"digits", digits,
|
||||||
"symbol", symbol,
|
"symbol", symbol,
|
||||||
"abbreviation", abbreviation,
|
"abbreviation", abbreviation,
|
||||||
"singular", singular,
|
|
||||||
"plural", plural,
|
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_free (identifier);
|
g_free (identifier);
|
||||||
g_free (symbol);
|
g_free (symbol);
|
||||||
g_free (abbreviation);
|
g_free (abbreviation);
|
||||||
g_free (singular);
|
|
||||||
g_free (plural);
|
|
||||||
}
|
}
|
||||||
else if (_gimp_unit_vtable.get_user_unit != NULL)
|
else if (_gimp_unit_vtable.get_user_unit != NULL)
|
||||||
{
|
{
|
||||||
|
@ -826,39 +766,14 @@ gimp_unit_is_metric (GimpUnit *unit)
|
||||||
*
|
*
|
||||||
* The @format string supports the following percent expansions:
|
* The @format string supports the following percent expansions:
|
||||||
*
|
*
|
||||||
* <informaltable pgwide="1" frame="none" role="enum">
|
* * `%n`: Name (long label)
|
||||||
* <tgroup cols="2"><colspec colwidth="1*"/><colspec colwidth="8*"/>
|
* * `%a`: Abbreviation (short label)
|
||||||
* <tbody>
|
* * `%%`: Literal percent
|
||||||
* <row>
|
* * `%f`: Factor (how many units make up an inch)
|
||||||
* <entry>% f</entry>
|
* * `%y`: Symbol (e.g. `''` for `GIMP_UNIT_INCH`)
|
||||||
* <entry>Factor (how many units make up an inch)</entry>
|
|
||||||
* </row>
|
|
||||||
* <row>
|
|
||||||
* <entry>% y</entry>
|
|
||||||
* <entry>Symbol (e.g. "''" for GIMP_UNIT_INCH)</entry>
|
|
||||||
* </row>
|
|
||||||
* <row>
|
|
||||||
* <entry>% a</entry>
|
|
||||||
* <entry>Abbreviation</entry>
|
|
||||||
* </row>
|
|
||||||
* <row>
|
|
||||||
* <entry>% s</entry>
|
|
||||||
* <entry>Singular</entry>
|
|
||||||
* </row>
|
|
||||||
* <row>
|
|
||||||
* <entry>% p</entry>
|
|
||||||
* <entry>Plural</entry>
|
|
||||||
* </row>
|
|
||||||
* <row>
|
|
||||||
* <entry>%%</entry>
|
|
||||||
* <entry>Literal percent</entry>
|
|
||||||
* </row>
|
|
||||||
* </tbody>
|
|
||||||
* </tgroup>
|
|
||||||
* </informaltable>
|
|
||||||
*
|
*
|
||||||
* Returns: A newly allocated string with above percent expressions
|
* Returns: (transfer full): A newly allocated string with above percent
|
||||||
* replaced with the resp. strings for @unit.
|
* expressions replaced with the resp. strings for @unit.
|
||||||
*
|
*
|
||||||
* Since: 2.8
|
* Since: 2.8
|
||||||
**/
|
**/
|
||||||
|
@ -904,14 +819,9 @@ gimp_unit_format_string (const gchar *format,
|
||||||
gimp_unit_get_abbreviation (unit));
|
gimp_unit_get_abbreviation (unit));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's': /* singular */
|
case 'n': /* full name */
|
||||||
i += print (buffer, sizeof (buffer), i, "%s",
|
i += print (buffer, sizeof (buffer), i, "%s",
|
||||||
gimp_unit_get_singular (unit));
|
gimp_unit_get_name (unit));
|
||||||
break;
|
|
||||||
|
|
||||||
case 'p': /* plural */
|
|
||||||
i += print (buffer, sizeof (buffer), i, "%s",
|
|
||||||
gimp_unit_get_plural (unit));
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -43,15 +43,13 @@ G_DECLARE_FINAL_TYPE (GimpUnit, gimp_unit, GIMP, UNIT, GObject)
|
||||||
|
|
||||||
gint32 gimp_unit_get_id (GimpUnit *unit);
|
gint32 gimp_unit_get_id (GimpUnit *unit);
|
||||||
|
|
||||||
const gchar * gimp_unit_get_identifier (GimpUnit *unit);
|
const gchar * gimp_unit_get_name (GimpUnit *unit);
|
||||||
gdouble gimp_unit_get_factor (GimpUnit *unit);
|
gdouble gimp_unit_get_factor (GimpUnit *unit);
|
||||||
gint gimp_unit_get_digits (GimpUnit *unit);
|
gint gimp_unit_get_digits (GimpUnit *unit);
|
||||||
gint gimp_unit_get_scaled_digits (GimpUnit *unit,
|
gint gimp_unit_get_scaled_digits (GimpUnit *unit,
|
||||||
gdouble resolution);
|
gdouble resolution);
|
||||||
const gchar * gimp_unit_get_symbol (GimpUnit *unit);
|
const gchar * gimp_unit_get_symbol (GimpUnit *unit);
|
||||||
const gchar * gimp_unit_get_abbreviation (GimpUnit *unit);
|
const gchar * gimp_unit_get_abbreviation (GimpUnit *unit);
|
||||||
const gchar * gimp_unit_get_singular (GimpUnit *unit);
|
|
||||||
const gchar * gimp_unit_get_plural (GimpUnit *unit);
|
|
||||||
|
|
||||||
gboolean gimp_unit_get_deletion_flag (GimpUnit *unit);
|
gboolean gimp_unit_get_deletion_flag (GimpUnit *unit);
|
||||||
void gimp_unit_set_deletion_flag (GimpUnit *unit,
|
void gimp_unit_set_deletion_flag (GimpUnit *unit,
|
||||||
|
|
|
@ -887,7 +887,7 @@ gimp_config_get_unit_from_identifier (const gchar *identifier)
|
||||||
unit = gimp_unit_get_by_id (GIMP_UNIT_PIXEL);
|
unit = gimp_unit_get_by_id (GIMP_UNIT_PIXEL);
|
||||||
for (gint i = GIMP_UNIT_PIXEL; unit; i++)
|
for (gint i = GIMP_UNIT_PIXEL; unit; i++)
|
||||||
{
|
{
|
||||||
if (g_strcmp0 (identifier, gimp_unit_get_identifier (unit)) == 0)
|
if (g_strcmp0 (identifier, gimp_unit_get_name (unit)) == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
unit = gimp_unit_get_by_id (i);
|
unit = gimp_unit_get_by_id (i);
|
||||||
|
|
|
@ -377,7 +377,7 @@ gimp_config_serialize_property (GimpConfig *config,
|
||||||
gimp_config_writer_open (writer, param_spec->name);
|
gimp_config_writer_open (writer, param_spec->name);
|
||||||
|
|
||||||
if (unit)
|
if (unit)
|
||||||
gimp_config_writer_printf (writer, "%s", gimp_unit_get_identifier (unit));
|
gimp_config_writer_printf (writer, "%s", gimp_unit_get_name (unit));
|
||||||
else
|
else
|
||||||
gimp_config_writer_printf (writer, "%s", "NULL");
|
gimp_config_writer_printf (writer, "%s", "NULL");
|
||||||
|
|
||||||
|
|
|
@ -484,7 +484,7 @@ gimp_query_size_box (const gchar *title,
|
||||||
if (! query_box)
|
if (! query_box)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
sizeentry = gimp_size_entry_new (1, unit, "%p", TRUE, FALSE, FALSE, 12,
|
sizeentry = gimp_size_entry_new (1, unit, "%n", TRUE, FALSE, FALSE, 12,
|
||||||
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
||||||
if (dot_for_dot)
|
if (dot_for_dot)
|
||||||
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), gimp_unit_pixel ());
|
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), gimp_unit_pixel ());
|
||||||
|
|
|
@ -407,12 +407,7 @@ gimp_size_entry_new (gint number_of_fields,
|
||||||
gchar *short_format = g_strdup (unit_format);
|
gchar *short_format = g_strdup (unit_format);
|
||||||
gchar *p;
|
gchar *p;
|
||||||
|
|
||||||
p = strstr (short_format, "%s");
|
while ((p = strstr (short_format, "%n")))
|
||||||
if (p)
|
|
||||||
strcpy (p, "%a");
|
|
||||||
|
|
||||||
p = strstr (short_format, "%p");
|
|
||||||
if (p)
|
|
||||||
strcpy (p, "%a");
|
strcpy (p, "%a");
|
||||||
|
|
||||||
g_object_set (store,
|
g_object_set (store,
|
||||||
|
|
|
@ -128,8 +128,6 @@ static GType column_types[GIMP_UNIT_STORE_UNIT_COLUMNS] =
|
||||||
G_TYPE_STRING,
|
G_TYPE_STRING,
|
||||||
G_TYPE_STRING,
|
G_TYPE_STRING,
|
||||||
G_TYPE_STRING,
|
G_TYPE_STRING,
|
||||||
G_TYPE_STRING,
|
|
||||||
G_TYPE_STRING
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -191,7 +189,7 @@ gimp_unit_store_init (GimpUnitStore *store)
|
||||||
private->has_pixels = TRUE;
|
private->has_pixels = TRUE;
|
||||||
private->has_percent = FALSE;
|
private->has_percent = FALSE;
|
||||||
private->short_format = g_strdup ("%a");
|
private->short_format = g_strdup ("%a");
|
||||||
private->long_format = g_strdup ("%p");
|
private->long_format = g_strdup ("%n");
|
||||||
private->synced_ID = 0;
|
private->synced_ID = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,8 +440,8 @@ gimp_unit_store_tree_model_get_value (GtkTreeModel *tree_model,
|
||||||
case GIMP_UNIT_STORE_UNIT_DIGITS:
|
case GIMP_UNIT_STORE_UNIT_DIGITS:
|
||||||
g_value_set_int (value, gimp_unit_get_digits (unit));
|
g_value_set_int (value, gimp_unit_get_digits (unit));
|
||||||
break;
|
break;
|
||||||
case GIMP_UNIT_STORE_UNIT_IDENTIFIER:
|
case GIMP_UNIT_STORE_UNIT_NAME:
|
||||||
g_value_set_static_string (value, gimp_unit_get_identifier (unit));
|
g_value_set_static_string (value, gimp_unit_get_name (unit));
|
||||||
break;
|
break;
|
||||||
case GIMP_UNIT_STORE_UNIT_SYMBOL:
|
case GIMP_UNIT_STORE_UNIT_SYMBOL:
|
||||||
g_value_set_static_string (value, gimp_unit_get_symbol (unit));
|
g_value_set_static_string (value, gimp_unit_get_symbol (unit));
|
||||||
|
@ -451,12 +449,6 @@ gimp_unit_store_tree_model_get_value (GtkTreeModel *tree_model,
|
||||||
case GIMP_UNIT_STORE_UNIT_ABBREVIATION:
|
case GIMP_UNIT_STORE_UNIT_ABBREVIATION:
|
||||||
g_value_set_static_string (value, gimp_unit_get_abbreviation (unit));
|
g_value_set_static_string (value, gimp_unit_get_abbreviation (unit));
|
||||||
break;
|
break;
|
||||||
case GIMP_UNIT_STORE_UNIT_SINGULAR:
|
|
||||||
g_value_set_static_string (value, gimp_unit_get_singular (unit));
|
|
||||||
break;
|
|
||||||
case GIMP_UNIT_STORE_UNIT_PLURAL:
|
|
||||||
g_value_set_static_string (value, gimp_unit_get_plural (unit));
|
|
||||||
break;
|
|
||||||
case GIMP_UNIT_STORE_UNIT_SHORT_FORMAT:
|
case GIMP_UNIT_STORE_UNIT_SHORT_FORMAT:
|
||||||
g_value_take_string (value,
|
g_value_take_string (value,
|
||||||
gimp_unit_format_string (private->short_format,
|
gimp_unit_format_string (private->short_format,
|
||||||
|
|
|
@ -34,11 +34,9 @@ enum
|
||||||
GIMP_UNIT_STORE_UNIT,
|
GIMP_UNIT_STORE_UNIT,
|
||||||
GIMP_UNIT_STORE_UNIT_FACTOR,
|
GIMP_UNIT_STORE_UNIT_FACTOR,
|
||||||
GIMP_UNIT_STORE_UNIT_DIGITS,
|
GIMP_UNIT_STORE_UNIT_DIGITS,
|
||||||
GIMP_UNIT_STORE_UNIT_IDENTIFIER,
|
GIMP_UNIT_STORE_UNIT_NAME,
|
||||||
GIMP_UNIT_STORE_UNIT_SYMBOL,
|
GIMP_UNIT_STORE_UNIT_SYMBOL,
|
||||||
GIMP_UNIT_STORE_UNIT_ABBREVIATION,
|
GIMP_UNIT_STORE_UNIT_ABBREVIATION,
|
||||||
GIMP_UNIT_STORE_UNIT_SINGULAR,
|
|
||||||
GIMP_UNIT_STORE_UNIT_PLURAL,
|
|
||||||
GIMP_UNIT_STORE_UNIT_SHORT_FORMAT,
|
GIMP_UNIT_STORE_UNIT_SHORT_FORMAT,
|
||||||
GIMP_UNIT_STORE_UNIT_LONG_FORMAT,
|
GIMP_UNIT_STORE_UNIT_LONG_FORMAT,
|
||||||
GIMP_UNIT_STORE_UNIT_COLUMNS,
|
GIMP_UNIT_STORE_UNIT_COLUMNS,
|
||||||
|
|
|
@ -35,8 +35,8 @@ HELP
|
||||||
);
|
);
|
||||||
|
|
||||||
@outargs = (
|
@outargs = (
|
||||||
{ name => 'identifier', type => 'string',
|
{ name => 'name', type => 'string',
|
||||||
desc => "The unit's textual identifier" },
|
desc => "The unit's name" },
|
||||||
{ name => 'factor', type => 'float',
|
{ name => 'factor', type => 'float',
|
||||||
desc => "The unit's factor" },
|
desc => "The unit's factor" },
|
||||||
{ name => 'digits', type => 'int32',
|
{ name => 'digits', type => 'int32',
|
||||||
|
@ -45,10 +45,6 @@ HELP
|
||||||
desc => "The unit's symbol" },
|
desc => "The unit's symbol" },
|
||||||
{ name => 'abbreviation', type => 'string',
|
{ name => 'abbreviation', type => 'string',
|
||||||
desc => "The unit's abbreviation" },
|
desc => "The unit's abbreviation" },
|
||||||
{ name => 'singular', type => 'string',
|
|
||||||
desc => "The unit's singular form" },
|
|
||||||
{ name => 'plural', type => 'string',
|
|
||||||
desc => "The unit's plural form" }
|
|
||||||
);
|
);
|
||||||
|
|
||||||
%invoke = (
|
%invoke = (
|
||||||
|
@ -60,13 +56,11 @@ HELP
|
||||||
|
|
||||||
if (unit != NULL)
|
if (unit != NULL)
|
||||||
{
|
{
|
||||||
identifier = g_strdup (gimp_unit_get_identifier (unit));
|
name = g_strdup (gimp_unit_get_name (unit));
|
||||||
factor = gimp_unit_get_factor (unit);
|
factor = gimp_unit_get_factor (unit);
|
||||||
digits = gimp_unit_get_digits (unit);
|
digits = gimp_unit_get_digits (unit);
|
||||||
symbol = g_strdup (gimp_unit_get_symbol (unit));
|
symbol = g_strdup (gimp_unit_get_symbol (unit));
|
||||||
abbreviation = g_strdup (gimp_unit_get_abbreviation (unit));
|
abbreviation = g_strdup (gimp_unit_get_abbreviation (unit));
|
||||||
singular = g_strdup (gimp_unit_get_singular (unit));
|
|
||||||
plural = g_strdup (gimp_unit_get_plural (unit));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,8 +80,8 @@ HELP
|
||||||
&mitch_pdb_misc('1999');
|
&mitch_pdb_misc('1999');
|
||||||
|
|
||||||
@inargs = (
|
@inargs = (
|
||||||
{ name => 'identifier', type => 'string', non_empty => 1,
|
{ name => 'name', type => 'string', non_empty => 1,
|
||||||
desc => "The new unit's identifier" },
|
desc => "The new unit's name" },
|
||||||
{ name => 'factor', type => 'float',
|
{ name => 'factor', type => 'float',
|
||||||
desc => "The new unit's factor" },
|
desc => "The new unit's factor" },
|
||||||
{ name => 'digits', type => 'int32',
|
{ name => 'digits', type => 'int32',
|
||||||
|
@ -96,10 +90,6 @@ HELP
|
||||||
desc => "The new unit's symbol" },
|
desc => "The new unit's symbol" },
|
||||||
{ name => 'abbreviation', type => 'string', non_empty => 1,
|
{ name => 'abbreviation', type => 'string', non_empty => 1,
|
||||||
desc => "The new unit's abbreviation" },
|
desc => "The new unit's abbreviation" },
|
||||||
{ name => 'singular', type => 'string', non_empty => 1,
|
|
||||||
desc => "The new unit's singular form" },
|
|
||||||
{ name => 'plural', type => 'string', non_empty => 1,
|
|
||||||
desc => "The new unit's plural form" }
|
|
||||||
);
|
);
|
||||||
|
|
||||||
@outargs = (
|
@outargs = (
|
||||||
|
@ -110,8 +100,8 @@ HELP
|
||||||
%invoke = (
|
%invoke = (
|
||||||
code => <<'CODE'
|
code => <<'CODE'
|
||||||
{
|
{
|
||||||
unit = _gimp_unit_new (gimp, identifier, factor, digits,
|
unit = _gimp_unit_new (gimp, name, factor, digits,
|
||||||
symbol, abbreviation, singular, plural);
|
symbol, abbreviation);
|
||||||
}
|
}
|
||||||
CODE
|
CODE
|
||||||
);
|
);
|
||||||
|
|
|
@ -36,13 +36,11 @@
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
SAVE,
|
SAVE,
|
||||||
IDENTIFIER,
|
NAME,
|
||||||
FACTOR,
|
FACTOR,
|
||||||
DIGITS,
|
DIGITS,
|
||||||
SYMBOL,
|
SYMBOL,
|
||||||
ABBREVIATION,
|
ABBREVIATION,
|
||||||
SINGULAR,
|
|
||||||
PLURAL,
|
|
||||||
UNIT,
|
UNIT,
|
||||||
USER_UNIT,
|
USER_UNIT,
|
||||||
NUM_COLUMNS
|
NUM_COLUMNS
|
||||||
|
@ -113,8 +111,8 @@ static const UnitColumn columns[] =
|
||||||
{
|
{
|
||||||
{ N_("Saved"), N_("A unit definition will only be saved before "
|
{ N_("Saved"), N_("A unit definition will only be saved before "
|
||||||
"GIMP exits if this column is checked.") },
|
"GIMP exits if this column is checked.") },
|
||||||
{ N_("ID"), N_("This string will be used to identify a "
|
{ N_("Name"), N_("The name to be used to identify this unit in "
|
||||||
"unit in GIMP's configuration files.") },
|
"the graphical interface") },
|
||||||
{ N_("Factor"), N_("How many units make up an inch.") },
|
{ N_("Factor"), N_("How many units make up an inch.") },
|
||||||
{ N_("Digits"), N_("This field is a hint for numerical input "
|
{ N_("Digits"), N_("This field is a hint for numerical input "
|
||||||
"fields. It specifies how many decimal digits "
|
"fields. It specifies how many decimal digits "
|
||||||
|
@ -126,8 +124,6 @@ static const UnitColumn columns[] =
|
||||||
"if doesn't have a symbol.") },
|
"if doesn't have a symbol.") },
|
||||||
{ N_("Abbreviation"), N_("The unit's abbreviation (e.g. \"cm\" for "
|
{ N_("Abbreviation"), N_("The unit's abbreviation (e.g. \"cm\" for "
|
||||||
"centimeters).") },
|
"centimeters).") },
|
||||||
{ N_("Singular"), N_("The unit's singular form.") },
|
|
||||||
{ N_("Plural"), N_("The unit's plural form.") }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static GActionEntry ACTIONS[] =
|
static GActionEntry ACTIONS[] =
|
||||||
|
@ -211,13 +207,11 @@ on_app_activate (GApplication *gapp, gpointer user_data)
|
||||||
|
|
||||||
list_store = gtk_list_store_new (NUM_COLUMNS,
|
list_store = gtk_list_store_new (NUM_COLUMNS,
|
||||||
G_TYPE_BOOLEAN, /* SAVE */
|
G_TYPE_BOOLEAN, /* SAVE */
|
||||||
G_TYPE_STRING, /* IDENTIFIER */
|
G_TYPE_STRING, /* NAME */
|
||||||
G_TYPE_DOUBLE, /* FACTOR */
|
G_TYPE_DOUBLE, /* FACTOR */
|
||||||
G_TYPE_INT, /* DIGITS */
|
G_TYPE_INT, /* DIGITS */
|
||||||
G_TYPE_STRING, /* SYMBOL */
|
G_TYPE_STRING, /* SYMBOL */
|
||||||
G_TYPE_STRING, /* ABBREVIATION */
|
G_TYPE_STRING, /* ABBREVIATION */
|
||||||
G_TYPE_STRING, /* SINGULAR */
|
|
||||||
G_TYPE_STRING, /* PLURAL */
|
|
||||||
G_TYPE_OBJECT, /* UNIT */
|
G_TYPE_OBJECT, /* UNIT */
|
||||||
G_TYPE_BOOLEAN); /* USER_UNIT */
|
G_TYPE_BOOLEAN); /* USER_UNIT */
|
||||||
|
|
||||||
|
@ -418,13 +412,11 @@ new_unit_dialog (GtkWindow *main_window,
|
||||||
GtkWidget *entry;
|
GtkWidget *entry;
|
||||||
GtkWidget *spinbutton;
|
GtkWidget *spinbutton;
|
||||||
|
|
||||||
GtkWidget *identifier_entry;
|
GtkWidget *name_entry;
|
||||||
GtkAdjustment *factor_adj;
|
GtkAdjustment *factor_adj;
|
||||||
GtkAdjustment *digits_adj;
|
GtkAdjustment *digits_adj;
|
||||||
GtkWidget *symbol_entry;
|
GtkWidget *symbol_entry;
|
||||||
GtkWidget *abbreviation_entry;
|
GtkWidget *abbreviation_entry;
|
||||||
GtkWidget *singular_entry;
|
|
||||||
GtkWidget *plural_entry;
|
|
||||||
|
|
||||||
GimpUnit *unit = NULL;
|
GimpUnit *unit = NULL;
|
||||||
|
|
||||||
|
@ -450,17 +442,17 @@ new_unit_dialog (GtkWindow *main_window,
|
||||||
grid, FALSE, FALSE, 0);
|
grid, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (grid);
|
gtk_widget_show (grid);
|
||||||
|
|
||||||
entry = identifier_entry = gtk_entry_new ();
|
entry = name_entry = gtk_entry_new ();
|
||||||
if (template != gimp_unit_pixel ())
|
if (template != gimp_unit_pixel ())
|
||||||
{
|
{
|
||||||
gtk_entry_set_text (GTK_ENTRY (entry),
|
gtk_entry_set_text (GTK_ENTRY (entry),
|
||||||
gimp_unit_get_identifier (template));
|
gimp_unit_get_name (template));
|
||||||
}
|
}
|
||||||
gimp_grid_attach_aligned (GTK_GRID (grid), 0, 0,
|
gimp_grid_attach_aligned (GTK_GRID (grid), 0, 0,
|
||||||
_("_ID:"), 0.0, 0.5,
|
_("_ID:"), 0.0, 0.5,
|
||||||
entry, 1);
|
entry, 1);
|
||||||
|
|
||||||
gimp_help_set_help_data (entry, gettext (columns[IDENTIFIER].help), NULL);
|
gimp_help_set_help_data (entry, gettext (columns[NAME].help), NULL);
|
||||||
|
|
||||||
factor_adj = gtk_adjustment_new ((template != gimp_unit_pixel ()) ?
|
factor_adj = gtk_adjustment_new ((template != gimp_unit_pixel ()) ?
|
||||||
gimp_unit_get_factor (template) : 1.0,
|
gimp_unit_get_factor (template) : 1.0,
|
||||||
|
@ -509,64 +501,32 @@ new_unit_dialog (GtkWindow *main_window,
|
||||||
|
|
||||||
gimp_help_set_help_data (entry, gettext (columns[ABBREVIATION].help), NULL);
|
gimp_help_set_help_data (entry, gettext (columns[ABBREVIATION].help), NULL);
|
||||||
|
|
||||||
entry = singular_entry = gtk_entry_new ();
|
|
||||||
if (template != gimp_unit_pixel ())
|
|
||||||
{
|
|
||||||
gtk_entry_set_text (GTK_ENTRY (entry),
|
|
||||||
gimp_unit_get_singular (template));
|
|
||||||
}
|
|
||||||
gimp_grid_attach_aligned (GTK_GRID (grid), 0, 5,
|
|
||||||
_("Si_ngular:"), 0.0, 0.5,
|
|
||||||
entry, 1);
|
|
||||||
|
|
||||||
gimp_help_set_help_data (entry, gettext (columns[SINGULAR].help), NULL);
|
|
||||||
|
|
||||||
entry = plural_entry = gtk_entry_new ();
|
|
||||||
if (template != gimp_unit_pixel ())
|
|
||||||
{
|
|
||||||
gtk_entry_set_text (GTK_ENTRY (entry),
|
|
||||||
gimp_unit_get_plural (template));
|
|
||||||
}
|
|
||||||
gimp_grid_attach_aligned (GTK_GRID (grid), 0, 6,
|
|
||||||
_("_Plural:"), 0.0, 0.5,
|
|
||||||
entry, 1);
|
|
||||||
|
|
||||||
gimp_help_set_help_data (entry, gettext (columns[PLURAL].help), NULL);
|
|
||||||
|
|
||||||
gtk_widget_show (dialog);
|
gtk_widget_show (dialog);
|
||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
gchar *identifier;
|
gchar *name;
|
||||||
gdouble factor;
|
gdouble factor;
|
||||||
gint digits;
|
gint digits;
|
||||||
gchar *symbol;
|
gchar *symbol;
|
||||||
gchar *abbreviation;
|
gchar *abbreviation;
|
||||||
gchar *singular;
|
|
||||||
gchar *plural;
|
|
||||||
|
|
||||||
if (gimp_dialog_run (GIMP_DIALOG (dialog)) != GTK_RESPONSE_OK)
|
if (gimp_dialog_run (GIMP_DIALOG (dialog)) != GTK_RESPONSE_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
identifier = g_strdup (gtk_entry_get_text (GTK_ENTRY (identifier_entry)));
|
name = g_strdup (gtk_entry_get_text (GTK_ENTRY (name_entry)));
|
||||||
factor = gtk_adjustment_get_value (factor_adj);
|
factor = gtk_adjustment_get_value (factor_adj);
|
||||||
digits = gtk_adjustment_get_value (digits_adj);
|
digits = gtk_adjustment_get_value (digits_adj);
|
||||||
symbol = g_strdup (gtk_entry_get_text (GTK_ENTRY (symbol_entry)));
|
symbol = g_strdup (gtk_entry_get_text (GTK_ENTRY (symbol_entry)));
|
||||||
abbreviation = g_strdup (gtk_entry_get_text (GTK_ENTRY (abbreviation_entry)));
|
abbreviation = g_strdup (gtk_entry_get_text (GTK_ENTRY (abbreviation_entry)));
|
||||||
singular = g_strdup (gtk_entry_get_text (GTK_ENTRY (singular_entry)));
|
|
||||||
plural = g_strdup (gtk_entry_get_text (GTK_ENTRY (plural_entry)));
|
|
||||||
|
|
||||||
identifier = g_strstrip (identifier);
|
name = g_strstrip (name);
|
||||||
symbol = g_strstrip (symbol);
|
symbol = g_strstrip (symbol);
|
||||||
abbreviation = g_strstrip (abbreviation);
|
abbreviation = g_strstrip (abbreviation);
|
||||||
singular = g_strstrip (singular);
|
|
||||||
plural = g_strstrip (plural);
|
|
||||||
|
|
||||||
if (! strlen (identifier) ||
|
if (! strlen (name) ||
|
||||||
! strlen (symbol) ||
|
! strlen (symbol) ||
|
||||||
! strlen (abbreviation) ||
|
! strlen (abbreviation))
|
||||||
! strlen (singular) ||
|
|
||||||
! strlen (plural))
|
|
||||||
{
|
{
|
||||||
GtkWidget *msg = gtk_message_dialog_new (GTK_WINDOW (dialog), 0,
|
GtkWidget *msg = gtk_message_dialog_new (GTK_WINDOW (dialog), 0,
|
||||||
GTK_MESSAGE_ERROR,
|
GTK_MESSAGE_ERROR,
|
||||||
|
@ -581,15 +541,11 @@ new_unit_dialog (GtkWindow *main_window,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
unit = gimp_unit_new (identifier,
|
unit = gimp_unit_new (name, factor, digits, symbol, abbreviation);
|
||||||
factor, digits,
|
|
||||||
symbol, abbreviation, singular, plural);
|
|
||||||
|
|
||||||
g_free (identifier);
|
g_free (name);
|
||||||
g_free (symbol);
|
g_free (symbol);
|
||||||
g_free (abbreviation);
|
g_free (abbreviation);
|
||||||
g_free (singular);
|
|
||||||
g_free (plural);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -738,13 +694,11 @@ unit_list_init (GtkTreeView *tv)
|
||||||
gtk_list_store_append (list_store, &iter);
|
gtk_list_store_append (list_store, &iter);
|
||||||
gtk_list_store_set (list_store, &iter,
|
gtk_list_store_set (list_store, &iter,
|
||||||
SAVE, ! gimp_unit_get_deletion_flag (unit),
|
SAVE, ! gimp_unit_get_deletion_flag (unit),
|
||||||
IDENTIFIER, gimp_unit_get_identifier (unit),
|
NAME, gimp_unit_get_name (unit),
|
||||||
FACTOR, gimp_unit_get_factor (unit),
|
FACTOR, gimp_unit_get_factor (unit),
|
||||||
DIGITS, gimp_unit_get_digits (unit),
|
DIGITS, gimp_unit_get_digits (unit),
|
||||||
SYMBOL, gimp_unit_get_symbol (unit),
|
SYMBOL, gimp_unit_get_symbol (unit),
|
||||||
ABBREVIATION, gimp_unit_get_abbreviation (unit),
|
ABBREVIATION, gimp_unit_get_abbreviation (unit),
|
||||||
SINGULAR, gimp_unit_get_singular (unit),
|
|
||||||
PLURAL, gimp_unit_get_plural (unit),
|
|
||||||
UNIT, unit,
|
UNIT, unit,
|
||||||
USER_UNIT, ! gimp_unit_is_built_in (unit),
|
USER_UNIT, ! gimp_unit_is_built_in (unit),
|
||||||
-1);
|
-1);
|
||||||
|
|
|
@ -262,7 +262,7 @@ print_size_frame (PrintData *data,
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (hbox);
|
gtk_widget_show (hbox);
|
||||||
|
|
||||||
entry = gimp_size_entry_new (1, data->unit, "%p",
|
entry = gimp_size_entry_new (1, data->unit, "%n",
|
||||||
FALSE, FALSE, FALSE, SB_WIDTH,
|
FALSE, FALSE, FALSE, SB_WIDTH,
|
||||||
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);
|
||||||
|
@ -874,7 +874,7 @@ print_size_info_set_page_setup (PrintSizeInfo *info)
|
||||||
format = g_strdup_printf ("%%.%df x %%.%df %s",
|
format = g_strdup_printf ("%%.%df x %%.%df %s",
|
||||||
gimp_unit_get_digits (data->unit),
|
gimp_unit_get_digits (data->unit),
|
||||||
gimp_unit_get_digits (data->unit),
|
gimp_unit_get_digits (data->unit),
|
||||||
gimp_unit_get_plural (data->unit));
|
gimp_unit_get_name (data->unit));
|
||||||
text = g_strdup_printf (format, page_width, page_height);
|
text = g_strdup_printf (format, page_width, page_height);
|
||||||
g_free (format);
|
g_free (format);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue