There were a few changes from Michael left, that I didn't knew of.

--Sven
This commit is contained in:
Sven Neumann 1999-03-03 17:10:50 +00:00
parent ca41c2609a
commit 151c624be1
12 changed files with 191 additions and 393 deletions

View File

@ -1,3 +1,12 @@
Wed Mar 3 17:59:09 MET 1999 Sven Neumann <sven@gimp.org>
* gimprc.5.in
* gimprc.in
* libgimp/gimpunit.[ch]
* libgimp/gimpunitmenu.c : Seems that Michael had created some
more patches I didn't knew of.
This commit now should bring it all uptodate.
Wed Mar 3 15:39:01 MET 1999 Sven Neumann <sven@gimp.org> Wed Mar 3 15:39:01 MET 1999 Sven Neumann <sven@gimp.org>
* libgimp/gimpchainbutton.[ch]: that looks much better now * libgimp/gimpchainbutton.[ch]: that looks much better now

View File

@ -155,16 +155,18 @@
# (dont-show-rulers) # (dont-show-rulers)
# Default units # Default units
# Will be used for ruler & coordinate display # This is the default unit of a new image. It will appear in the
# The units can be one of: # File/New dialog and will be the unit for coordinate display when
# (inches centimeters points picas) plus those in your user units database # dot-for-dot is off.
# The default units can be one of:
# (inches millimeters points picas) plus those in your user units database
# The default is inches # The default is inches
(default-units inches) (default-units inches)
# Default Resolution units # Default Resolution units
# This is used to specify the resolution of a new image # This is used to specify the resolution of a new image
# The units for the resolution can be one of: # The units for the resolution can be one of:
# (inches centimeters points picas) plus those in your user units database # (inches millimeters points picas) plus those in your user units database
# The default is inches # The default is inches
(default-resolution-units inches) (default-resolution-units inches)

View File

@ -115,9 +115,11 @@ One of
.BR none ", " small ", " medium ", or " large ", " .BR none ", " small ", " medium ", or " large ", "
or an INT. small is 32x32, medium is 64x64, and large is 128x128. or an INT. small is 32x32, medium is 64x64, and large is 128x128.
.TP .TP
.I RULERUNIT .I UNIT
One of One of
.BR pixels ", " inches ", or " centimeters "." .BR inches ", " millimeters ", " picas ", or " points
or the identifier of one of the units you have defined in your user
units database.
.PP .PP
.SH PROPERTIES .SH PROPERTIES
Valid properties and their types: Valid properties and their types:
@ -341,14 +343,26 @@ Set the default image size in the File/New dialog.
.I default-image-type IMAGETYPE .I default-image-type IMAGETYPE
Set the default image type in the File/New dialog. Set the default image type in the File/New dialog.
.TP .TP
.I default-units UNIT
Set the default units for new images and for the File/New dialog.
This units will be used for coordinate display when not in dot-for-dot
mode. The default units can be one of inches , millimeters, points or
picas or the identifier of one of the units defined in your user units
database. The default is inches.
.TP
.I default-xresolution FLOAT .I default-xresolution FLOAT
Set the default image width resolution in the File/New dialog. Set the default horizontal resolution for new images and for the
File/New dialog. This value is always in dpi (dots per inch).
.TP .TP
.I default-yresolution FLOAT .I default-yresolution FLOAT
Set the default image height resolution in the File/New dialog. Set the default vertical resolution for new images and for the
File/New dialog. This value is always in dpi (dots per inch).
.TP .TP
.I default-resolution-units RULERUNIT .I default-resolution-units UNIT
Set the units the default-resolution settings are in. Set the units for the display of the default resolution in the
File/New dialog. The default resolution units can be one of inches,
millimeters, points or picas or the identifier of one of the units
defined in your user unit database. The default is inches.
.TP .TP
.I monitor-xresolution FLOAT .I monitor-xresolution FLOAT
Set the monitor's horizontal resolution, in dots per inch. If set to Set the monitor's horizontal resolution, in dots per inch. If set to

View File

@ -115,9 +115,11 @@ One of
.BR none ", " small ", " medium ", or " large ", " .BR none ", " small ", " medium ", or " large ", "
or an INT. small is 32x32, medium is 64x64, and large is 128x128. or an INT. small is 32x32, medium is 64x64, and large is 128x128.
.TP .TP
.I RULERUNIT .I UNIT
One of One of
.BR pixels ", " inches ", or " centimeters "." .BR inches ", " millimeters ", " picas ", or " points
or the identifier of one of the units you have defined in your user
units database.
.PP .PP
.SH PROPERTIES .SH PROPERTIES
Valid properties and their types: Valid properties and their types:
@ -341,14 +343,26 @@ Set the default image size in the File/New dialog.
.I default-image-type IMAGETYPE .I default-image-type IMAGETYPE
Set the default image type in the File/New dialog. Set the default image type in the File/New dialog.
.TP .TP
.I default-units UNIT
Set the default units for new images and for the File/New dialog.
This units will be used for coordinate display when not in dot-for-dot
mode. The default units can be one of inches , millimeters, points or
picas or the identifier of one of the units defined in your user units
database. The default is inches.
.TP
.I default-xresolution FLOAT .I default-xresolution FLOAT
Set the default image width resolution in the File/New dialog. Set the default horizontal resolution for new images and for the
File/New dialog. This value is always in dpi (dots per inch).
.TP .TP
.I default-yresolution FLOAT .I default-yresolution FLOAT
Set the default image height resolution in the File/New dialog. Set the default vertical resolution for new images and for the
File/New dialog. This value is always in dpi (dots per inch).
.TP .TP
.I default-resolution-units RULERUNIT .I default-resolution-units UNIT
Set the units the default-resolution settings are in. Set the units for the display of the default resolution in the
File/New dialog. The default resolution units can be one of inches,
millimeters, points or picas or the identifier of one of the units
defined in your user unit database. The default is inches.
.TP .TP
.I monitor-xresolution FLOAT .I monitor-xresolution FLOAT
Set the monitor's horizontal resolution, in dots per inch. If set to Set the monitor's horizontal resolution, in dots per inch. If set to

View File

@ -155,16 +155,18 @@
# (dont-show-rulers) # (dont-show-rulers)
# Default units # Default units
# Will be used for ruler & coordinate display # This is the default unit of a new image. It will appear in the
# The units can be one of: # File/New dialog and will be the unit for coordinate display when
# (inches centimeters points picas) plus those in your user units database # dot-for-dot is off.
# The default units can be one of:
# (inches millimeters points picas) plus those in your user units database
# The default is inches # The default is inches
(default-units inches) (default-units inches)
# Default Resolution units # Default Resolution units
# This is used to specify the resolution of a new image # This is used to specify the resolution of a new image
# The units for the resolution can be one of: # The units for the resolution can be one of:
# (inches centimeters points picas) plus those in your user units database # (inches millimeters points picas) plus those in your user units database
# The default is inches # The default is inches
(default-resolution-units inches) (default-resolution-units inches)

View File

@ -40,7 +40,7 @@ static GimpUnitDef gimp_unit_defs[UNIT_END] =
/* standard units */ /* standard units */
{ FALSE, 1.0, 2, "inches", "''", "in", N_("inch"), N_("inches") }, { FALSE, 1.0, 2, "inches", "''", "in", N_("inch"), N_("inches") },
{ FALSE, 2.54, 2, "centimeters", "cm", "cm", N_("centimeter"), N_("centimeters") }, { FALSE, 25.4, 1, "millimeters", "mm", "mm", N_("millimeter"), N_("millimeters") },
/* professional units */ /* professional units */
{ FALSE, 72.0, 0, "points", "pt", "pt", N_("point"), N_("points") }, { FALSE, 72.0, 0, "points", "pt", "pt", N_("point"), N_("points") },
@ -53,10 +53,10 @@ static gint number_of_user_units = 0;
/* private functions */ /* private functions */
GimpUnitDef * static GimpUnitDef *
gimp_unit_get_user_unit (GUnit unit) gimp_unit_get_user_unit (GUnit unit)
{ {
return g_slist_nth_data (user_units, unit - UNIT_END + 1); return g_slist_nth_data (user_units, unit - UNIT_END);
} }
@ -76,24 +76,27 @@ gimp_unit_get_number_of_built_in_units (void)
GUnit GUnit
gimp_unit_new (void) gimp_unit_new (gchar *identifier,
gfloat factor,
gint digits,
gchar *symbol,
gchar *abbreviation,
gchar *singular,
gchar *plural)
{ {
GimpUnitDef *user_unit; GimpUnitDef *user_unit;
user_unit = g_malloc (sizeof (GimpUnitDef)); user_unit = g_malloc (sizeof (GimpUnitDef));
user_unit->delete_on_exit = TRUE; user_unit->delete_on_exit = TRUE;
user_unit->factor = 1.0; user_unit->factor = factor;
user_unit->digits = 2; user_unit->digits = digits;
user_unit->identifier = NULL; user_unit->identifier = g_strdup (identifier);
user_unit->symbol = NULL; user_unit->symbol = g_strdup (symbol);
user_unit->abbreviation = NULL; user_unit->abbreviation = g_strdup (abbreviation);
user_unit->singular = NULL; user_unit->singular = g_strdup (singular);
user_unit->plural = NULL; user_unit->plural = g_strdup (plural);
if (user_units == NULL) user_units = g_slist_append (user_units, user_unit);
user_units = g_slist_alloc ();
g_slist_append (user_units, user_unit);
number_of_user_units++; number_of_user_units++;
return UNIT_END + number_of_user_units - 1; return UNIT_END + number_of_user_units - 1;
@ -136,16 +139,6 @@ gimp_unit_get_factor (GUnit unit)
return gimp_unit_get_user_unit (unit)->factor; return gimp_unit_get_user_unit (unit)->factor;
} }
void
gimp_unit_set_factor (GUnit unit,
gfloat factor)
{
g_return_if_fail ( (unit >= UNIT_END) &&
(unit < (UNIT_END + number_of_user_units)));
gimp_unit_get_user_unit (unit)->factor = factor;
}
gint gint
gimp_unit_get_digits (GUnit unit) gimp_unit_get_digits (GUnit unit)
@ -160,16 +153,6 @@ gimp_unit_get_digits (GUnit unit)
return gimp_unit_get_user_unit (unit)->digits; return gimp_unit_get_user_unit (unit)->digits;
} }
void
gimp_unit_set_digits (GUnit unit,
gint digits)
{
g_return_if_fail ( (unit >= UNIT_END) &&
(unit < (UNIT_END + number_of_user_units)));
gimp_unit_get_user_unit (unit)->digits = digits;
}
const gchar * const gchar *
gimp_unit_get_identifier (GUnit unit) gimp_unit_get_identifier (GUnit unit)
@ -184,21 +167,6 @@ gimp_unit_get_identifier (GUnit unit)
return gimp_unit_get_user_unit (unit)->identifier; return gimp_unit_get_user_unit (unit)->identifier;
} }
void
gimp_unit_set_identifier (GUnit unit,
gchar *identifier)
{
GimpUnitDef *user_unit;
g_return_if_fail ( (unit >= UNIT_END) &&
(unit < (UNIT_END + number_of_user_units)));
user_unit = gimp_unit_get_user_unit (unit);
if (user_unit->identifier)
g_free (user_unit->identifier);
user_unit->identifier = g_strdup (identifier);
}
const gchar * const gchar *
gimp_unit_get_symbol (GUnit unit) gimp_unit_get_symbol (GUnit unit)
@ -213,21 +181,6 @@ gimp_unit_get_symbol (GUnit unit)
return gimp_unit_get_user_unit (unit)->symbol; return gimp_unit_get_user_unit (unit)->symbol;
} }
void
gimp_unit_set_symbol (GUnit unit,
gchar *symbol)
{
GimpUnitDef *user_unit;
g_return_if_fail ( (unit >= UNIT_END) &&
(unit < (UNIT_END + number_of_user_units)));
user_unit = gimp_unit_get_user_unit (unit);
if (user_unit->symbol)
g_free (user_unit->symbol);
user_unit->symbol = g_strdup (symbol);
}
const gchar * const gchar *
gimp_unit_get_abbreviation (GUnit unit) gimp_unit_get_abbreviation (GUnit unit)
@ -256,21 +209,6 @@ gimp_unit_get_singular (GUnit unit)
return gimp_unit_get_user_unit (unit)->singular; return gimp_unit_get_user_unit (unit)->singular;
} }
void
gimp_unit_set_singular (GUnit unit,
gchar *singular)
{
GimpUnitDef *user_unit;
g_return_if_fail ( (unit >= UNIT_END) &&
(unit < (UNIT_END + number_of_user_units)));
user_unit = gimp_unit_get_user_unit (unit);
if (user_unit->singular)
g_free (user_unit->singular);
user_unit->symbol = g_strdup (singular);
}
const gchar * const gchar *
gimp_unit_get_plural (GUnit unit) gimp_unit_get_plural (GUnit unit)
@ -284,18 +222,3 @@ gimp_unit_get_plural (GUnit unit)
return gimp_unit_get_user_unit (unit)->plural; return gimp_unit_get_user_unit (unit)->plural;
} }
void
gimp_unit_set_plural (GUnit unit,
gchar *plural)
{
GimpUnitDef *user_unit;
g_return_if_fail ( (unit >= UNIT_END) &&
(unit < (UNIT_END + number_of_user_units)));
user_unit = gimp_unit_get_user_unit (unit);
if (user_unit->plural)
g_free (user_unit->plural);
user_unit->symbol = g_strdup (plural);
}

View File

@ -39,7 +39,7 @@ typedef enum
{ {
UNIT_PIXEL = 0, UNIT_PIXEL = 0,
UNIT_INCH = 1, UNIT_INCH = 1,
UNIT_CM = 2, UNIT_MM = 2,
UNIT_POINT = 3, UNIT_POINT = 3,
UNIT_PICA = 4, UNIT_PICA = 4,
UNIT_END /* never use UNIT_END but gimp_unit_get_number_of_units() instead */ UNIT_END /* never use UNIT_END but gimp_unit_get_number_of_units() instead */
@ -49,62 +49,55 @@ typedef enum
gint gimp_unit_get_number_of_units (void); gint gimp_unit_get_number_of_units (void);
gint gimp_unit_get_number_of_built_in_units (void); gint gimp_unit_get_number_of_built_in_units (void);
/* create a new, empty user unit and returns it's ID /* Create a new user unit and returns it's ID.
*/
GUnit gimp_unit_new (void);
/* the following functions fall back to inch (not pixel, as pixel is not
* a 'real' unit) if the value passed is out of range
* *
* trying to change built-in units will be ignored * Note that a new unit is always created with it's deletion flag
* set to TRUE. You will have to set it to FALSE after creation to make
* the unit definition persistant.
*/
GUnit gimp_unit_new (gchar *identifier,
gfloat factor,
gint digits,
gchar *symbol,
gchar *abbreviation,
gchar *singular,
gchar *plural);
/* The following functions fall back to inch (not pixel, as pixel is not
* a 'real' unit) if the value passed is out of range.
*
* Trying to change the deletion flag of built-in units will be ignored.
*/ */
/* if the deletion flag for a unit is TRUE on GIMP exit, this unit /* If the deletion flag for a unit is TRUE on GIMP exit, this unit
* will not be saved in the user units database * will not be saved in the user units database.
*/ */
guint gimp_unit_get_deletion_flag (GUnit unit); guint gimp_unit_get_deletion_flag (GUnit unit);
void gimp_unit_set_deletion_flag (GUnit unit, void gimp_unit_set_deletion_flag (GUnit unit,
guint deletion_flag); guint deletion_flag);
/* the meaning of 'factor' is: /* This one is an untranslated string for gimprc */
const gchar * gimp_unit_get_identifier (GUnit unit);
/* The meaning of 'factor' is:
* distance_in_units == ( factor * distance_in_inches ) * distance_in_units == ( factor * distance_in_inches )
* *
* returns 0 for unit == UNIT_PIXEL as we don't have resolution info here * Returns 0 for unit == UNIT_PIXEL as we don't have resolution info here
*/ */
gfloat gimp_unit_get_factor (GUnit unit); gfloat gimp_unit_get_factor (GUnit unit);
void gimp_unit_set_factor (GUnit unit,
gfloat factor);
/* the following function gives a hint how many digits a spinbutton /* The following function gives a hint how many digits a spinbutton
* should provide to get approximately the accuracy of an inch-spinbutton * should provide to get approximately the accuracy of an inch-spinbutton
* with two digits. * with two digits.
* *
* returns 0 for unit == UNIT_PIXEL as we don't have resolution info here * Returns 0 for unit == UNIT_PIXEL as we don't have resolution info here.
*/ */
gint gimp_unit_get_digits (GUnit unit); gint gimp_unit_get_digits (GUnit unit);
void gimp_unit_set_digits (GUnit unit,
gint digits);
/* this one is an untranslated string for gimprc */
const gchar * gimp_unit_get_identifier (GUnit unit);
void gimp_unit_set_identifier (GUnit unit,
gchar *identifier);
const gchar * gimp_unit_get_symbol (GUnit unit); const gchar * gimp_unit_get_symbol (GUnit unit);
void gimp_unit_set_symbol (GUnit unit,
gchar *symbol);
const gchar * gimp_unit_get_abbreviation (GUnit unit); const gchar * gimp_unit_get_abbreviation (GUnit unit);
void gimp_unit_set_abbreviation (GUnit unit,
gchar *abbreviation);
const gchar * gimp_unit_get_singular (GUnit unit); const gchar * gimp_unit_get_singular (GUnit unit);
void gimp_unit_set_singular (GUnit unit,
gchar *singular);
const gchar * gimp_unit_get_plural (GUnit unit); const gchar * gimp_unit_get_plural (GUnit unit);
void gimp_unit_set_plural (GUnit unit,
gchar *plural);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -40,7 +40,7 @@ static GimpUnitDef gimp_unit_defs[UNIT_END] =
/* standard units */ /* standard units */
{ FALSE, 1.0, 2, "inches", "''", "in", N_("inch"), N_("inches") }, { FALSE, 1.0, 2, "inches", "''", "in", N_("inch"), N_("inches") },
{ FALSE, 2.54, 2, "centimeters", "cm", "cm", N_("centimeter"), N_("centimeters") }, { FALSE, 25.4, 1, "millimeters", "mm", "mm", N_("millimeter"), N_("millimeters") },
/* professional units */ /* professional units */
{ FALSE, 72.0, 0, "points", "pt", "pt", N_("point"), N_("points") }, { FALSE, 72.0, 0, "points", "pt", "pt", N_("point"), N_("points") },
@ -53,10 +53,10 @@ static gint number_of_user_units = 0;
/* private functions */ /* private functions */
GimpUnitDef * static GimpUnitDef *
gimp_unit_get_user_unit (GUnit unit) gimp_unit_get_user_unit (GUnit unit)
{ {
return g_slist_nth_data (user_units, unit - UNIT_END + 1); return g_slist_nth_data (user_units, unit - UNIT_END);
} }
@ -76,24 +76,27 @@ gimp_unit_get_number_of_built_in_units (void)
GUnit GUnit
gimp_unit_new (void) gimp_unit_new (gchar *identifier,
gfloat factor,
gint digits,
gchar *symbol,
gchar *abbreviation,
gchar *singular,
gchar *plural)
{ {
GimpUnitDef *user_unit; GimpUnitDef *user_unit;
user_unit = g_malloc (sizeof (GimpUnitDef)); user_unit = g_malloc (sizeof (GimpUnitDef));
user_unit->delete_on_exit = TRUE; user_unit->delete_on_exit = TRUE;
user_unit->factor = 1.0; user_unit->factor = factor;
user_unit->digits = 2; user_unit->digits = digits;
user_unit->identifier = NULL; user_unit->identifier = g_strdup (identifier);
user_unit->symbol = NULL; user_unit->symbol = g_strdup (symbol);
user_unit->abbreviation = NULL; user_unit->abbreviation = g_strdup (abbreviation);
user_unit->singular = NULL; user_unit->singular = g_strdup (singular);
user_unit->plural = NULL; user_unit->plural = g_strdup (plural);
if (user_units == NULL) user_units = g_slist_append (user_units, user_unit);
user_units = g_slist_alloc ();
g_slist_append (user_units, user_unit);
number_of_user_units++; number_of_user_units++;
return UNIT_END + number_of_user_units - 1; return UNIT_END + number_of_user_units - 1;
@ -136,16 +139,6 @@ gimp_unit_get_factor (GUnit unit)
return gimp_unit_get_user_unit (unit)->factor; return gimp_unit_get_user_unit (unit)->factor;
} }
void
gimp_unit_set_factor (GUnit unit,
gfloat factor)
{
g_return_if_fail ( (unit >= UNIT_END) &&
(unit < (UNIT_END + number_of_user_units)));
gimp_unit_get_user_unit (unit)->factor = factor;
}
gint gint
gimp_unit_get_digits (GUnit unit) gimp_unit_get_digits (GUnit unit)
@ -160,16 +153,6 @@ gimp_unit_get_digits (GUnit unit)
return gimp_unit_get_user_unit (unit)->digits; return gimp_unit_get_user_unit (unit)->digits;
} }
void
gimp_unit_set_digits (GUnit unit,
gint digits)
{
g_return_if_fail ( (unit >= UNIT_END) &&
(unit < (UNIT_END + number_of_user_units)));
gimp_unit_get_user_unit (unit)->digits = digits;
}
const gchar * const gchar *
gimp_unit_get_identifier (GUnit unit) gimp_unit_get_identifier (GUnit unit)
@ -184,21 +167,6 @@ gimp_unit_get_identifier (GUnit unit)
return gimp_unit_get_user_unit (unit)->identifier; return gimp_unit_get_user_unit (unit)->identifier;
} }
void
gimp_unit_set_identifier (GUnit unit,
gchar *identifier)
{
GimpUnitDef *user_unit;
g_return_if_fail ( (unit >= UNIT_END) &&
(unit < (UNIT_END + number_of_user_units)));
user_unit = gimp_unit_get_user_unit (unit);
if (user_unit->identifier)
g_free (user_unit->identifier);
user_unit->identifier = g_strdup (identifier);
}
const gchar * const gchar *
gimp_unit_get_symbol (GUnit unit) gimp_unit_get_symbol (GUnit unit)
@ -213,21 +181,6 @@ gimp_unit_get_symbol (GUnit unit)
return gimp_unit_get_user_unit (unit)->symbol; return gimp_unit_get_user_unit (unit)->symbol;
} }
void
gimp_unit_set_symbol (GUnit unit,
gchar *symbol)
{
GimpUnitDef *user_unit;
g_return_if_fail ( (unit >= UNIT_END) &&
(unit < (UNIT_END + number_of_user_units)));
user_unit = gimp_unit_get_user_unit (unit);
if (user_unit->symbol)
g_free (user_unit->symbol);
user_unit->symbol = g_strdup (symbol);
}
const gchar * const gchar *
gimp_unit_get_abbreviation (GUnit unit) gimp_unit_get_abbreviation (GUnit unit)
@ -256,21 +209,6 @@ gimp_unit_get_singular (GUnit unit)
return gimp_unit_get_user_unit (unit)->singular; return gimp_unit_get_user_unit (unit)->singular;
} }
void
gimp_unit_set_singular (GUnit unit,
gchar *singular)
{
GimpUnitDef *user_unit;
g_return_if_fail ( (unit >= UNIT_END) &&
(unit < (UNIT_END + number_of_user_units)));
user_unit = gimp_unit_get_user_unit (unit);
if (user_unit->singular)
g_free (user_unit->singular);
user_unit->symbol = g_strdup (singular);
}
const gchar * const gchar *
gimp_unit_get_plural (GUnit unit) gimp_unit_get_plural (GUnit unit)
@ -284,18 +222,3 @@ gimp_unit_get_plural (GUnit unit)
return gimp_unit_get_user_unit (unit)->plural; return gimp_unit_get_user_unit (unit)->plural;
} }
void
gimp_unit_set_plural (GUnit unit,
gchar *plural)
{
GimpUnitDef *user_unit;
g_return_if_fail ( (unit >= UNIT_END) &&
(unit < (UNIT_END + number_of_user_units)));
user_unit = gimp_unit_get_user_unit (unit);
if (user_unit->plural)
g_free (user_unit->plural);
user_unit->symbol = g_strdup (plural);
}

View File

@ -40,7 +40,7 @@ static GimpUnitDef gimp_unit_defs[UNIT_END] =
/* standard units */ /* standard units */
{ FALSE, 1.0, 2, "inches", "''", "in", N_("inch"), N_("inches") }, { FALSE, 1.0, 2, "inches", "''", "in", N_("inch"), N_("inches") },
{ FALSE, 2.54, 2, "centimeters", "cm", "cm", N_("centimeter"), N_("centimeters") }, { FALSE, 25.4, 1, "millimeters", "mm", "mm", N_("millimeter"), N_("millimeters") },
/* professional units */ /* professional units */
{ FALSE, 72.0, 0, "points", "pt", "pt", N_("point"), N_("points") }, { FALSE, 72.0, 0, "points", "pt", "pt", N_("point"), N_("points") },
@ -53,10 +53,10 @@ static gint number_of_user_units = 0;
/* private functions */ /* private functions */
GimpUnitDef * static GimpUnitDef *
gimp_unit_get_user_unit (GUnit unit) gimp_unit_get_user_unit (GUnit unit)
{ {
return g_slist_nth_data (user_units, unit - UNIT_END + 1); return g_slist_nth_data (user_units, unit - UNIT_END);
} }
@ -76,24 +76,27 @@ gimp_unit_get_number_of_built_in_units (void)
GUnit GUnit
gimp_unit_new (void) gimp_unit_new (gchar *identifier,
gfloat factor,
gint digits,
gchar *symbol,
gchar *abbreviation,
gchar *singular,
gchar *plural)
{ {
GimpUnitDef *user_unit; GimpUnitDef *user_unit;
user_unit = g_malloc (sizeof (GimpUnitDef)); user_unit = g_malloc (sizeof (GimpUnitDef));
user_unit->delete_on_exit = TRUE; user_unit->delete_on_exit = TRUE;
user_unit->factor = 1.0; user_unit->factor = factor;
user_unit->digits = 2; user_unit->digits = digits;
user_unit->identifier = NULL; user_unit->identifier = g_strdup (identifier);
user_unit->symbol = NULL; user_unit->symbol = g_strdup (symbol);
user_unit->abbreviation = NULL; user_unit->abbreviation = g_strdup (abbreviation);
user_unit->singular = NULL; user_unit->singular = g_strdup (singular);
user_unit->plural = NULL; user_unit->plural = g_strdup (plural);
if (user_units == NULL) user_units = g_slist_append (user_units, user_unit);
user_units = g_slist_alloc ();
g_slist_append (user_units, user_unit);
number_of_user_units++; number_of_user_units++;
return UNIT_END + number_of_user_units - 1; return UNIT_END + number_of_user_units - 1;
@ -136,16 +139,6 @@ gimp_unit_get_factor (GUnit unit)
return gimp_unit_get_user_unit (unit)->factor; return gimp_unit_get_user_unit (unit)->factor;
} }
void
gimp_unit_set_factor (GUnit unit,
gfloat factor)
{
g_return_if_fail ( (unit >= UNIT_END) &&
(unit < (UNIT_END + number_of_user_units)));
gimp_unit_get_user_unit (unit)->factor = factor;
}
gint gint
gimp_unit_get_digits (GUnit unit) gimp_unit_get_digits (GUnit unit)
@ -160,16 +153,6 @@ gimp_unit_get_digits (GUnit unit)
return gimp_unit_get_user_unit (unit)->digits; return gimp_unit_get_user_unit (unit)->digits;
} }
void
gimp_unit_set_digits (GUnit unit,
gint digits)
{
g_return_if_fail ( (unit >= UNIT_END) &&
(unit < (UNIT_END + number_of_user_units)));
gimp_unit_get_user_unit (unit)->digits = digits;
}
const gchar * const gchar *
gimp_unit_get_identifier (GUnit unit) gimp_unit_get_identifier (GUnit unit)
@ -184,21 +167,6 @@ gimp_unit_get_identifier (GUnit unit)
return gimp_unit_get_user_unit (unit)->identifier; return gimp_unit_get_user_unit (unit)->identifier;
} }
void
gimp_unit_set_identifier (GUnit unit,
gchar *identifier)
{
GimpUnitDef *user_unit;
g_return_if_fail ( (unit >= UNIT_END) &&
(unit < (UNIT_END + number_of_user_units)));
user_unit = gimp_unit_get_user_unit (unit);
if (user_unit->identifier)
g_free (user_unit->identifier);
user_unit->identifier = g_strdup (identifier);
}
const gchar * const gchar *
gimp_unit_get_symbol (GUnit unit) gimp_unit_get_symbol (GUnit unit)
@ -213,21 +181,6 @@ gimp_unit_get_symbol (GUnit unit)
return gimp_unit_get_user_unit (unit)->symbol; return gimp_unit_get_user_unit (unit)->symbol;
} }
void
gimp_unit_set_symbol (GUnit unit,
gchar *symbol)
{
GimpUnitDef *user_unit;
g_return_if_fail ( (unit >= UNIT_END) &&
(unit < (UNIT_END + number_of_user_units)));
user_unit = gimp_unit_get_user_unit (unit);
if (user_unit->symbol)
g_free (user_unit->symbol);
user_unit->symbol = g_strdup (symbol);
}
const gchar * const gchar *
gimp_unit_get_abbreviation (GUnit unit) gimp_unit_get_abbreviation (GUnit unit)
@ -256,21 +209,6 @@ gimp_unit_get_singular (GUnit unit)
return gimp_unit_get_user_unit (unit)->singular; return gimp_unit_get_user_unit (unit)->singular;
} }
void
gimp_unit_set_singular (GUnit unit,
gchar *singular)
{
GimpUnitDef *user_unit;
g_return_if_fail ( (unit >= UNIT_END) &&
(unit < (UNIT_END + number_of_user_units)));
user_unit = gimp_unit_get_user_unit (unit);
if (user_unit->singular)
g_free (user_unit->singular);
user_unit->symbol = g_strdup (singular);
}
const gchar * const gchar *
gimp_unit_get_plural (GUnit unit) gimp_unit_get_plural (GUnit unit)
@ -284,18 +222,3 @@ gimp_unit_get_plural (GUnit unit)
return gimp_unit_get_user_unit (unit)->plural; return gimp_unit_get_user_unit (unit)->plural;
} }
void
gimp_unit_set_plural (GUnit unit,
gchar *plural)
{
GimpUnitDef *user_unit;
g_return_if_fail ( (unit >= UNIT_END) &&
(unit < (UNIT_END + number_of_user_units)));
user_unit = gimp_unit_get_user_unit (unit);
if (user_unit->plural)
g_free (user_unit->plural);
user_unit->symbol = g_strdup (plural);
}

View File

@ -112,7 +112,7 @@ gimp_unit_menu_new (gchar *format,
unit = gum->start; unit = gum->start;
menu = gtk_menu_new(); menu = gtk_menu_new();
for (u = gum->start; u < gimp_unit_get_number_of_units(); u++) for (u = gum->start; u < gimp_unit_get_number_of_built_in_units(); u++)
{ {
menuitem = menuitem =
gtk_menu_item_new_with_label (gimp_unit_menu_build_string(format, u) ); gtk_menu_item_new_with_label (gimp_unit_menu_build_string(format, u) );
@ -169,7 +169,8 @@ print (char *buf, int len, int start, const char *fmt, ...)
return printed; return printed;
} }
static const gchar* gimp_unit_menu_build_string (gchar *format, GUnit unit) static const gchar*
gimp_unit_menu_build_string (gchar *format, GUnit unit)
{ {
#define BUFFER_LEN 64 #define BUFFER_LEN 64

View File

@ -39,7 +39,7 @@ typedef enum
{ {
UNIT_PIXEL = 0, UNIT_PIXEL = 0,
UNIT_INCH = 1, UNIT_INCH = 1,
UNIT_CM = 2, UNIT_MM = 2,
UNIT_POINT = 3, UNIT_POINT = 3,
UNIT_PICA = 4, UNIT_PICA = 4,
UNIT_END /* never use UNIT_END but gimp_unit_get_number_of_units() instead */ UNIT_END /* never use UNIT_END but gimp_unit_get_number_of_units() instead */
@ -49,62 +49,55 @@ typedef enum
gint gimp_unit_get_number_of_units (void); gint gimp_unit_get_number_of_units (void);
gint gimp_unit_get_number_of_built_in_units (void); gint gimp_unit_get_number_of_built_in_units (void);
/* create a new, empty user unit and returns it's ID /* Create a new user unit and returns it's ID.
*/
GUnit gimp_unit_new (void);
/* the following functions fall back to inch (not pixel, as pixel is not
* a 'real' unit) if the value passed is out of range
* *
* trying to change built-in units will be ignored * Note that a new unit is always created with it's deletion flag
* set to TRUE. You will have to set it to FALSE after creation to make
* the unit definition persistant.
*/
GUnit gimp_unit_new (gchar *identifier,
gfloat factor,
gint digits,
gchar *symbol,
gchar *abbreviation,
gchar *singular,
gchar *plural);
/* The following functions fall back to inch (not pixel, as pixel is not
* a 'real' unit) if the value passed is out of range.
*
* Trying to change the deletion flag of built-in units will be ignored.
*/ */
/* if the deletion flag for a unit is TRUE on GIMP exit, this unit /* If the deletion flag for a unit is TRUE on GIMP exit, this unit
* will not be saved in the user units database * will not be saved in the user units database.
*/ */
guint gimp_unit_get_deletion_flag (GUnit unit); guint gimp_unit_get_deletion_flag (GUnit unit);
void gimp_unit_set_deletion_flag (GUnit unit, void gimp_unit_set_deletion_flag (GUnit unit,
guint deletion_flag); guint deletion_flag);
/* the meaning of 'factor' is: /* This one is an untranslated string for gimprc */
const gchar * gimp_unit_get_identifier (GUnit unit);
/* The meaning of 'factor' is:
* distance_in_units == ( factor * distance_in_inches ) * distance_in_units == ( factor * distance_in_inches )
* *
* returns 0 for unit == UNIT_PIXEL as we don't have resolution info here * Returns 0 for unit == UNIT_PIXEL as we don't have resolution info here
*/ */
gfloat gimp_unit_get_factor (GUnit unit); gfloat gimp_unit_get_factor (GUnit unit);
void gimp_unit_set_factor (GUnit unit,
gfloat factor);
/* the following function gives a hint how many digits a spinbutton /* The following function gives a hint how many digits a spinbutton
* should provide to get approximately the accuracy of an inch-spinbutton * should provide to get approximately the accuracy of an inch-spinbutton
* with two digits. * with two digits.
* *
* returns 0 for unit == UNIT_PIXEL as we don't have resolution info here * Returns 0 for unit == UNIT_PIXEL as we don't have resolution info here.
*/ */
gint gimp_unit_get_digits (GUnit unit); gint gimp_unit_get_digits (GUnit unit);
void gimp_unit_set_digits (GUnit unit,
gint digits);
/* this one is an untranslated string for gimprc */
const gchar * gimp_unit_get_identifier (GUnit unit);
void gimp_unit_set_identifier (GUnit unit,
gchar *identifier);
const gchar * gimp_unit_get_symbol (GUnit unit); const gchar * gimp_unit_get_symbol (GUnit unit);
void gimp_unit_set_symbol (GUnit unit,
gchar *symbol);
const gchar * gimp_unit_get_abbreviation (GUnit unit); const gchar * gimp_unit_get_abbreviation (GUnit unit);
void gimp_unit_set_abbreviation (GUnit unit,
gchar *abbreviation);
const gchar * gimp_unit_get_singular (GUnit unit); const gchar * gimp_unit_get_singular (GUnit unit);
void gimp_unit_set_singular (GUnit unit,
gchar *singular);
const gchar * gimp_unit_get_plural (GUnit unit); const gchar * gimp_unit_get_plural (GUnit unit);
void gimp_unit_set_plural (GUnit unit,
gchar *plural);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -112,7 +112,7 @@ gimp_unit_menu_new (gchar *format,
unit = gum->start; unit = gum->start;
menu = gtk_menu_new(); menu = gtk_menu_new();
for (u = gum->start; u < gimp_unit_get_number_of_units(); u++) for (u = gum->start; u < gimp_unit_get_number_of_built_in_units(); u++)
{ {
menuitem = menuitem =
gtk_menu_item_new_with_label (gimp_unit_menu_build_string(format, u) ); gtk_menu_item_new_with_label (gimp_unit_menu_build_string(format, u) );
@ -169,7 +169,8 @@ print (char *buf, int len, int start, const char *fmt, ...)
return printed; return printed;
} }
static const gchar* gimp_unit_menu_build_string (gchar *format, GUnit unit) static const gchar*
gimp_unit_menu_build_string (gchar *format, GUnit unit)
{ {
#define BUFFER_LEN 64 #define BUFFER_LEN 64