From ab6c609ce1eeb2877136a12c4772d778e7baa7a2 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Tue, 12 Oct 2004 21:28:53 +0000 Subject: [PATCH] renamed struct member "unit" to "resolution_unit". 2004-10-12 Sven Neumann * app/core/gimpimage.[ch]: renamed struct member "unit" to "resolution_unit". * app/actions/image-commands.c * app/core/gimp-edit.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-undo-push.c * app/dialogs/info-window.c * app/vectors/gimpvectors-export.c * app/widgets/gimptoolbox-dnd.c: * app/xcf/xcf-load.c * app/xcf/xcf-save.c: changed accordingly. Use gimp_image_get_unit() where appropriate. * app/core/gimptemplate.c (gimp_template_set_from_image): fixed unit handling. Don't touch the template unit, it is used as the initial display unit. This will need further changes... --- ChangeLog | 20 ++++++++++++++++++++ app/actions/image-commands.c | 8 ++++---- app/core/gimp-edit.c | 3 ++- app/core/gimpimage-duplicate.c | 8 ++++---- app/core/gimpimage-undo-push.c | 14 +++++++------- app/core/gimpimage.c | 14 +++++++------- app/core/gimpimage.h | 2 +- app/core/gimptemplate.c | 4 +--- app/dialogs/info-window.c | 6 +++--- app/vectors/gimpvectors-export.c | 2 +- app/widgets/gimptoolbox-dnd.c | 3 ++- app/xcf/xcf-load.c | 4 ++-- app/xcf/xcf-save.c | 11 +++++------ 13 files changed, 59 insertions(+), 40 deletions(-) diff --git a/ChangeLog b/ChangeLog index 39b393f1a9..d167b02d09 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2004-10-12 Sven Neumann + + * app/core/gimpimage.[ch]: renamed struct member "unit" to + "resolution_unit". + + * app/actions/image-commands.c + * app/core/gimp-edit.c + * app/core/gimpimage-duplicate.c + * app/core/gimpimage-undo-push.c + * app/dialogs/info-window.c + * app/vectors/gimpvectors-export.c + * app/widgets/gimptoolbox-dnd.c: + * app/xcf/xcf-load.c + * app/xcf/xcf-save.c: changed accordingly. Use gimp_image_get_unit() + where appropriate. + + * app/core/gimptemplate.c (gimp_template_set_from_image): fixed + unit handling. Don't touch the template unit, it is used as the + initial display unit. This will need further changes... + 2004-10-12 Michael Natterer * app/widgets/gimpwidgets-utils.c (gimp_enum_radio_frame_add): diff --git a/app/actions/image-commands.c b/app/actions/image-commands.c index a765fd2c6e..15c2910a39 100644 --- a/app/actions/image-commands.c +++ b/app/actions/image-commands.c @@ -614,10 +614,10 @@ image_scale_implement (ImageResizeOptions *options) { GimpImage *gimage = options->gimage; - if (options->dialog->resolution_x == gimage->xresolution && - options->dialog->resolution_y == gimage->yresolution && - options->dialog->unit == gimage->unit && - options->dialog->width == gimage->width && + if (options->dialog->resolution_x == gimage->xresolution && + options->dialog->resolution_y == gimage->yresolution && + options->dialog->unit == gimage->resolution_unit && + options->dialog->width == gimage->width && options->dialog->height == gimage->height) return; diff --git a/app/core/gimp-edit.c b/app/core/gimp-edit.c index 1e1c2d2b3c..6e2d139b74 100644 --- a/app/core/gimp-edit.c +++ b/app/core/gimp-edit.c @@ -241,7 +241,8 @@ gimp_edit_paste_as_new (Gimp *gimp, { gimp_image_set_resolution (gimage, invoke->xresolution, invoke->yresolution); - gimp_image_set_unit (gimage, invoke->unit); + gimp_image_set_unit (gimage, + gimp_image_get_unit (invoke)); } layer = gimp_layer_new_from_tiles (paste->tiles, diff --git a/app/core/gimpimage-duplicate.c b/app/core/gimpimage-duplicate.c index 7a9adab6af..b15695fa4a 100644 --- a/app/core/gimpimage-duplicate.c +++ b/app/core/gimpimage-duplicate.c @@ -74,10 +74,10 @@ gimp_image_duplicate (GimpImage *gimage) gimp_image_get_colormap_size (gimage), FALSE); - /* Copy resolution and unit information */ - new_gimage->xresolution = gimage->xresolution; - new_gimage->yresolution = gimage->yresolution; - new_gimage->unit = gimage->unit; + /* Copy resolution information */ + new_gimage->xresolution = gimage->xresolution; + new_gimage->yresolution = gimage->yresolution; + new_gimage->resolution_unit = gimage->resolution_unit; /* Copy floating layer */ floating_layer = gimp_image_floating_sel (gimage); diff --git a/app/core/gimpimage-undo-push.c b/app/core/gimpimage-undo-push.c index 3471f39eb9..f0406ee221 100644 --- a/app/core/gimpimage-undo-push.c +++ b/app/core/gimpimage-undo-push.c @@ -221,9 +221,9 @@ typedef struct _ResolutionUndo ResolutionUndo; struct _ResolutionUndo { - gdouble xres; - gdouble yres; - GimpUnit unit; + gdouble xres; + gdouble yres; + GimpUnit unit; }; static gboolean undo_pop_image_resolution (GimpUndo *undo, @@ -253,7 +253,7 @@ gimp_image_undo_push_image_resolution (GimpImage *gimage, ru->xres = gimage->xresolution; ru->yres = gimage->yresolution; - ru->unit = gimage->unit; + ru->unit = gimage->resolution_unit; return TRUE; } @@ -286,12 +286,12 @@ undo_pop_image_resolution (GimpUndo *undo, accum->resolution_changed = TRUE; } - if (ru->unit != undo->gimage->unit) + if (ru->unit != undo->gimage->resolution_unit) { GimpUnit unit; - unit = undo->gimage->unit; - undo->gimage->unit = ru->unit; + unit = undo->gimage->resolution_unit; + undo->gimage->resolution_unit = ru->unit; ru->unit = unit; accum->unit_changed = TRUE; diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c index 9555c0812e..4d00642d82 100644 --- a/app/core/gimpimage.c +++ b/app/core/gimpimage.c @@ -511,7 +511,7 @@ gimp_image_init (GimpImage *gimage) gimage->height = 0; gimage->xresolution = 1.0; gimage->yresolution = 1.0; - gimage->unit = GIMP_UNIT_INCH; + gimage->resolution_unit = GIMP_UNIT_INCH; gimage->base_type = GIMP_RGB; gimage->cmap = NULL; @@ -637,9 +637,9 @@ gimp_image_constructor (GType type, GINT_TO_POINTER (gimage->ID), gimage); - gimage->xresolution = config->default_image->xresolution; - gimage->yresolution = config->default_image->yresolution; - gimage->unit = config->default_image->resolution_unit; + gimage->xresolution = config->default_image->xresolution; + gimage->yresolution = config->default_image->yresolution; + gimage->resolution_unit = config->default_image->resolution_unit; gimage->grid = gimp_config_duplicate (GIMP_CONFIG (config->default_grid)); @@ -1391,12 +1391,12 @@ gimp_image_set_unit (GimpImage *gimage, g_return_if_fail (GIMP_IS_IMAGE (gimage)); g_return_if_fail (unit > GIMP_UNIT_PIXEL); - if (gimage->unit != unit) + if (gimage->resolution_unit != unit) { gimp_image_undo_push_image_resolution (gimage, _("Change Image Unit")); - gimage->unit = unit; + gimage->resolution_unit = unit; gimp_image_unit_changed (gimage); } } @@ -1406,7 +1406,7 @@ gimp_image_get_unit (const GimpImage *gimage) { g_return_val_if_fail (GIMP_IS_IMAGE (gimage), GIMP_UNIT_INCH); - return gimage->unit; + return gimage->resolution_unit; } void diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h index 6fe51c2aa8..f7b6d548f4 100644 --- a/app/core/gimpimage.h +++ b/app/core/gimpimage.h @@ -108,7 +108,7 @@ struct _GimpImage gint width, height; /* width and height attributes */ gdouble xresolution; /* image x-res, in dpi */ gdouble yresolution; /* image y-res, in dpi */ - GimpUnit unit; /* resolution unit */ + GimpUnit resolution_unit; /* resolution unit */ GimpImageBaseType base_type; /* base gimp_image type */ guchar *cmap; /* colormap--for indexed */ diff --git a/app/core/gimptemplate.c b/app/core/gimptemplate.c index c2c4cb8c76..08a4ddf776 100644 --- a/app/core/gimptemplate.c +++ b/app/core/gimptemplate.c @@ -31,7 +31,6 @@ #include "config/gimpconfig.h" #include "config/gimpconfig-params.h" -#include "config/gimpcoreconfig.h" #include "gimp.h" #include "gimpcontext.h" @@ -383,10 +382,9 @@ gimp_template_set_from_image (GimpTemplate *template, g_object_set (template, "width", gimp_image_get_width (gimage), "height", gimp_image_get_height (gimage), - "unit", gimp_image_get_unit (gimage), "xresolution", xresolution, "yresolution", yresolution, - "resolution-unit", gimage->gimp->config->default_image->resolution_unit, + "resolution-unit", gimp_image_get_unit (gimage), "image-type", image_type, "comment", comment, NULL); diff --git a/app/dialogs/info-window.c b/app/dialogs/info-window.c index 253637d2c1..17349de03f 100644 --- a/app/dialogs/info-window.c +++ b/app/dialogs/info-window.c @@ -426,7 +426,7 @@ info_window_update_cursor (GimpDisplay *gdisp, gchar buf[32]; if (unit == GIMP_UNIT_PIXEL) - unit = image->unit; + unit = gimp_image_get_unit (image); unit_factor = _gimp_unit_get_factor (image->gimp, unit); unit_digits = _gimp_unit_get_digits (image->gimp, unit); @@ -544,7 +544,7 @@ info_window_update (GimpDisplay *gdisp) unit = GIMP_DISPLAY_SHELL (gdisp->shell)->unit; if (unit == GIMP_UNIT_PIXEL) - unit = image->unit; + unit = gimp_image_get_unit (image); unit_factor = _gimp_unit_get_factor (image->gimp, unit); unit_digits = _gimp_unit_get_digits (image->gimp, unit); @@ -557,7 +557,7 @@ info_window_update (GimpDisplay *gdisp) image->height * unit_factor / image->yresolution); /* resolution */ - unit = image->unit; + unit = gimp_image_get_unit (image); unit_factor = _gimp_unit_get_factor (image->gimp, unit); g_snprintf (format_buf, sizeof (format_buf), _("pixels/%s"), diff --git a/app/vectors/gimpvectors-export.c b/app/vectors/gimpvectors-export.c index 9696fe2f78..05ea3b02c6 100644 --- a/app/vectors/gimpvectors-export.c +++ b/app/vectors/gimpvectors-export.c @@ -172,7 +172,7 @@ gimp_vectors_export_image_size (const GimpImage *image, h = (gdouble) image->height / image->yresolution; /* FIXME: should probably use the display unit here */ - unit = image->unit; + unit = gimp_image_get_unit (image); switch (unit) { case GIMP_UNIT_INCH: abbrev = "in"; break; diff --git a/app/widgets/gimptoolbox-dnd.c b/app/widgets/gimptoolbox-dnd.c index 410ac3ec03..7de2678e9a 100644 --- a/app/widgets/gimptoolbox-dnd.c +++ b/app/widgets/gimptoolbox-dnd.c @@ -166,7 +166,8 @@ gimp_toolbox_drop_drawable (GtkWidget *widget, gimp_image_set_resolution (new_image, gimage->xresolution, gimage->yresolution); - gimp_image_set_unit (new_image, gimage->unit); + gimp_image_set_unit (new_image, + gimp_image_get_unit (gimage)); if (GIMP_IS_LAYER (drawable)) new_type = G_TYPE_FROM_INSTANCE (drawable); diff --git a/app/xcf/xcf-load.c b/app/xcf/xcf-load.c index 247423910e..d4988d3cae 100644 --- a/app/xcf/xcf-load.c +++ b/app/xcf/xcf-load.c @@ -434,7 +434,7 @@ xcf_load_image_props (XcfInfo *info, unit = GIMP_UNIT_INCH; } - gimage->unit = unit; + gimage->resolution_unit = unit; } break; @@ -488,7 +488,7 @@ xcf_load_image_props (XcfInfo *info, unit_strings[3], unit_strings[4]); - gimage->unit = unit; + gimage->resolution_unit = unit; for (i = 0; i < 5; i++) g_free (unit_strings[i]); diff --git a/app/xcf/xcf-save.c b/app/xcf/xcf-save.c index c9c23bab65..56ac8dd014 100644 --- a/app/xcf/xcf-save.c +++ b/app/xcf/xcf-save.c @@ -414,6 +414,7 @@ xcf_save_image_props (XcfInfo *info, GError **error) { GimpParasite *parasite = NULL; + GimpUnit unit = gimp_image_get_unit (gimage); /* check and see if we should save the colormap property */ if (gimage->cmap) @@ -438,9 +439,8 @@ xcf_save_image_props (XcfInfo *info, xcf_check_error (xcf_save_prop (info, gimage, PROP_PARASITES, error, gimage->parasites)); - if (gimage->unit < _gimp_unit_get_number_of_built_in_units (gimage->gimp)) - xcf_check_error (xcf_save_prop (info, gimage, PROP_UNIT, - error, gimage->unit)); + if (unit < _gimp_unit_get_number_of_built_in_units (gimage->gimp)) + xcf_check_error (xcf_save_prop (info, gimage, PROP_UNIT, error, unit)); if (gimp_container_num_children (gimage->vectors) > 0) { @@ -450,9 +450,8 @@ xcf_save_image_props (XcfInfo *info, xcf_check_error (xcf_save_prop (info, gimage, PROP_VECTORS, error)); } - if (gimage->unit >= _gimp_unit_get_number_of_built_in_units (gimage->gimp)) - xcf_check_error (xcf_save_prop (info, gimage, PROP_USER_UNIT, - error, gimage->unit)); + if (unit >= _gimp_unit_get_number_of_built_in_units (gimage->gimp)) + xcf_check_error (xcf_save_prop (info, gimage, PROP_USER_UNIT, error, unit)); if (GIMP_IS_GRID (gimage->grid)) {