diff --git a/ChangeLog b/ChangeLog index be1c8b6fa3..c6099bc9a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,51 @@ +2004-06-01 Sven Neumann + + * tools/pdbgen/pdb/image.pdb + * app/pdb/image_cmds.c + * app/core/gimpimage.[ch]: reverted changes I did to the image + unit earlier. As in 2.0, it will continue to not accept pixels. + This makes the PDB API and the XCF format compatible again and + fixes bug #142961 (and to some extent bug #137704). + + * app/core/Makefile.am + * app/core/gimpimage-unit.[ch]: removed these files. The + convenience accessors defined here aren't commonly used any + longer. + + * app/display/gimpdisplay.[ch] + * app/display/gimpdisplayshell.[ch]: added a unit parameter to + gimp_display_new(). Made "unit" and "scale" properties of + GimpDisplayShell. + + * app/actions/image-commands.c + * app/actions/images-commands.c + * app/actions/layers-commands.c + * app/actions/select-commands.c + * app/actions/view-commands.c + * app/core/gimp-edit.c + * app/core/gimp.[ch] + * app/core/gimptemplate.c + * app/display/gimpdisplayshell-handlers.c + * app/display/gimpdisplayshell-scale.c + * app/display/gimpdisplayshell-title.c + * app/display/gimpstatusbar.c + * app/file/file-open.c + * app/gui/gui-vtable.c + * app/gui/info-window.c + * app/gui/offset-dialog.c + * app/gui/resize-dialog.[ch] + * app/pdb/display_cmds.c + * app/tools/gimpcroptool.c + * app/tools/gimpmeasuretool.c + * app/tools/gimppainttool.c + * app/tools/gimprectselecttool.c + * app/tools/gimprotatetool.c + * app/tools/gimpscaletool.c + * app/vectors/gimpvectors-export.c + * app/widgets/gimptoolbox-dnd.c + * tools/pdbgen/pdb/display.pdb: changed accordingly. Use the + display unit where the image unit was used before. + 2004-06-01 Michael Natterer * tools/pdbgen/pdb/gradient_edit.pdb: use enums instead of diff --git a/app/actions/image-commands.c b/app/actions/image-commands.c index 66eab7a39e..78fbb5f2dc 100644 --- a/app/actions/image-commands.c +++ b/app/actions/image-commands.c @@ -203,8 +203,7 @@ image_resize_cmd_callback (GtkAction *action, gimage->height, gimage->xresolution, gimage->yresolution, - gimage->unit, - GIMP_DISPLAY_SHELL (gdisp->shell)->dot_for_dot, + GIMP_DISPLAY_SHELL (gdisp->shell)->unit, G_CALLBACK (image_resize_callback), options); @@ -244,8 +243,7 @@ image_scale_cmd_callback (GtkAction *action, gimage->height, gimage->xresolution, gimage->yresolution, - gimage->unit, - GIMP_DISPLAY_SHELL (gdisp->shell)->dot_for_dot, + GIMP_DISPLAY_SHELL (gdisp->shell)->unit, G_CALLBACK (image_scale_callback), options); @@ -325,12 +323,21 @@ void image_duplicate_cmd_callback (GtkAction *action, gpointer data) { - GimpImage *gimage; - GimpImage *new_gimage; - return_if_no_image (gimage, data); + GimpDisplay *gdisp; + GimpDisplayShell *shell; + GimpImage *gimage; + GimpImage *new_gimage; + return_if_no_display (gdisp, data); + + shell = GIMP_DISPLAY_SHELL (gdisp->shell); + gimage = gdisp->gimage; new_gimage = gimp_image_duplicate (gimage); - gimp_create_display (new_gimage->gimp, new_gimage, 1.0); + + gimp_create_display (new_gimage->gimp, + new_gimage, + shell->unit, shell->scale); + g_object_unref (new_gimage); } diff --git a/app/actions/images-commands.c b/app/actions/images-commands.c index 874ae999fe..1558244975 100644 --- a/app/actions/images-commands.c +++ b/app/actions/images-commands.c @@ -73,7 +73,7 @@ images_new_view_cmd_callback (GtkAction *action, if (image && gimp_container_have (container, GIMP_OBJECT (image))) { - gimp_create_display (image->gimp, image, 1.0); + gimp_create_display (image->gimp, image, GIMP_UNIT_PIXEL, 1.0); } } diff --git a/app/actions/layers-commands.c b/app/actions/layers-commands.c index 3a9231adb0..e249fbe100 100644 --- a/app/actions/layers-commands.c +++ b/app/actions/layers-commands.c @@ -53,6 +53,7 @@ #include "widgets/gimpviewabledialog.h" #include "display/gimpdisplay.h" +#include "display/gimpdisplayshell.h" #include "display/gimpprogress.h" #include "tools/gimptexttool.h" @@ -74,7 +75,8 @@ static void layers_scale_layer_query (GimpDisplay *gdisp, GimpImage *gimage, GimpLayer *layer, GtkWidget *parent); -static void layers_resize_layer_query (GimpImage *gimage, +static void layers_resize_layer_query (GimpDisplay *gdisp, + GimpImage *gimage, GimpLayer *layer, GimpContext *context, GtkWidget *parent); @@ -343,7 +345,8 @@ layers_resize_cmd_callback (GtkAction *action, return_if_no_layer (gimage, layer, data); return_if_no_widget (widget, data); - layers_resize_layer_query (gimage, layer, action_data_get_context (data), + layers_resize_layer_query (GIMP_IS_DISPLAY (data) ? data : NULL, + gimage, layer, action_data_get_context (data), widget); } @@ -767,7 +770,7 @@ layers_new_layer_query (GimpImage *gimage, 1, 2); gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 10); - options->size_se = gimp_size_entry_new (1, gimage->unit, "%a", + options->size_se = gimp_size_entry_new (1, GIMP_UNIT_PIXEL, "%a", TRUE, TRUE, FALSE, 10, GIMP_SIZE_ENTRY_UPDATE_SIZE); gtk_table_set_col_spacing (GTK_TABLE (options->size_se), 1, 4); @@ -1176,8 +1179,9 @@ layers_scale_layer_query (GimpDisplay *gdisp, gimp_item_height (GIMP_ITEM (layer)), gimage->xresolution, gimage->yresolution, - gimage->unit, - TRUE, + (gdisp ? + GIMP_DISPLAY_SHELL (gdisp->shell)->unit : + GIMP_UNIT_PIXEL), G_CALLBACK (scale_layer_query_ok_callback), options); @@ -1234,7 +1238,8 @@ resize_layer_query_ok_callback (GtkWidget *widget, } static void -layers_resize_layer_query (GimpImage *gimage, +layers_resize_layer_query (GimpDisplay *gdisp, + GimpImage *gimage, GimpLayer *layer, GimpContext *context, GtkWidget *parent) @@ -1253,8 +1258,9 @@ layers_resize_layer_query (GimpImage *gimage, gimp_item_height (GIMP_ITEM (layer)), gimage->xresolution, gimage->yresolution, - gimage->unit, - TRUE, + (gdisp ? + GIMP_DISPLAY_SHELL (gdisp->shell)->unit : + GIMP_UNIT_PIXEL), G_CALLBACK (resize_layer_query_ok_callback), options); diff --git a/app/actions/select-commands.c b/app/actions/select-commands.c index 4d273b93a1..3255492dea 100644 --- a/app/actions/select-commands.c +++ b/app/actions/select-commands.c @@ -155,10 +155,10 @@ select_feather_cmd_callback (GtkAction *action, GIMP_HELP_SELECTION_FEATHER, _("Feather selection by"), selection_feather_radius, 0, 32767, 3, - gdisp->gimage->unit, + GIMP_DISPLAY_SHELL (gdisp->shell)->unit, MIN (gdisp->gimage->xresolution, gdisp->gimage->yresolution), - GIMP_DISPLAY_SHELL (gdisp->shell)->dot_for_dot, + FALSE, G_OBJECT (gdisp->gimage), "disconnect", gimp_image_mask_feather_callback, gdisp->gimage); gtk_widget_show (qbox); @@ -191,10 +191,10 @@ select_shrink_cmd_callback (GtkAction *action, GIMP_HELP_SELECTION_SHRINK, _("Shrink selection by"), selection_shrink_pixels, 1, 32767, 0, - gdisp->gimage->unit, + GIMP_DISPLAY_SHELL (gdisp->shell)->unit, MIN (gdisp->gimage->xresolution, gdisp->gimage->yresolution), - GIMP_DISPLAY_SHELL (gdisp->shell)->dot_for_dot, + FALSE, G_OBJECT (gdisp->gimage), "disconnect", gimp_image_mask_shrink_callback, gdisp->gimage); @@ -225,10 +225,10 @@ select_grow_cmd_callback (GtkAction *action, GIMP_HELP_SELECTION_GROW, _("Grow selection by"), selection_grow_pixels, 1, 32767, 0, - gdisp->gimage->unit, + GIMP_DISPLAY_SHELL (gdisp->shell)->unit, MIN (gdisp->gimage->xresolution, gdisp->gimage->yresolution), - GIMP_DISPLAY_SHELL (gdisp->shell)->dot_for_dot, + FALSE, G_OBJECT (gdisp->gimage), "disconnect", gimp_image_mask_grow_callback, gdisp->gimage); gtk_widget_show (qbox); @@ -248,10 +248,10 @@ select_border_cmd_callback (GtkAction *action, GIMP_HELP_SELECTION_BORDER, _("Border selection by"), selection_border_radius, 1, 32767, 0, - gdisp->gimage->unit, + GIMP_DISPLAY_SHELL (gdisp->shell)->unit, MIN (gdisp->gimage->xresolution, gdisp->gimage->yresolution), - GIMP_DISPLAY_SHELL (gdisp->shell)->dot_for_dot, + FALSE, G_OBJECT (gdisp->gimage), "disconnect", gimp_image_mask_border_callback, gdisp->gimage); gtk_widget_show (qbox); diff --git a/app/actions/view-commands.c b/app/actions/view-commands.c index 4a24b819a1..bc0237d888 100644 --- a/app/actions/view-commands.c +++ b/app/actions/view-commands.c @@ -66,11 +66,15 @@ void view_new_view_cmd_callback (GtkAction *action, gpointer data) { - GimpDisplay *gdisp; + GimpDisplay *gdisp; + GimpDisplayShell *shell; return_if_no_display (gdisp, data); - gimp_create_display (gdisp->gimage->gimp, gdisp->gimage, - GIMP_DISPLAY_SHELL (gdisp->shell)->scale); + shell = GIMP_DISPLAY_SHELL (gdisp->shell); + + gimp_create_display (gdisp->gimage->gimp, + gdisp->gimage, + shell->unit, shell->scale); } void diff --git a/app/core/Makefile.am b/app/core/Makefile.am index a0e105464d..83d3215292 100644 --- a/app/core/Makefile.am +++ b/app/core/Makefile.am @@ -145,8 +145,6 @@ libappcore_a_sources = \ gimpimage-undo.h \ gimpimage-undo-push.c \ gimpimage-undo-push.h \ - gimpimage-unit.c \ - gimpimage-unit.h \ gimpimagefile.c \ gimpimagefile.h \ gimpimagemap.c \ diff --git a/app/core/gimp-edit.c b/app/core/gimp-edit.c index 587ec3bdba..ffefa74de1 100644 --- a/app/core/gimp-edit.c +++ b/app/core/gimp-edit.c @@ -204,8 +204,8 @@ gimp_edit_paste_as_new (Gimp *gimp, GimpImage *invoke, GimpBuffer *paste) { - GimpImage *gimage; - GimpLayer *layer; + GimpImage *gimage; + GimpLayer *layer; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); g_return_val_if_fail (invoke == NULL || GIMP_IS_IMAGE (invoke), NULL); @@ -242,7 +242,7 @@ gimp_edit_paste_as_new (Gimp *gimp, gimp_image_undo_enable (gimage); - gimp_create_display (gimp, gimage, 1.0); + gimp_create_display (gimp, gimage, 1.0, GIMP_UNIT_PIXEL); g_object_unref (gimage); return gimage; diff --git a/app/core/gimp.c b/app/core/gimp.c index b0aeb1dbd5..63243cd70c 100644 --- a/app/core/gimp.c +++ b/app/core/gimp.c @@ -1229,6 +1229,7 @@ gimp_create_image (Gimp *gimp, GimpObject * gimp_create_display (Gimp *gimp, GimpImage *gimage, + GimpUnit unit, gdouble scale) { GimpObject *display = NULL; @@ -1238,7 +1239,7 @@ gimp_create_display (Gimp *gimp, if (gimp->gui_create_display_func) { - display = gimp->gui_create_display_func (gimage, scale); + display = gimp->gui_create_display_func (gimage, unit, scale); gimp_container_add (gimp->displays, display); } diff --git a/app/core/gimp.h b/app/core/gimp.h index 79746c85f8..919c71abf3 100644 --- a/app/core/gimp.h +++ b/app/core/gimp.h @@ -26,6 +26,7 @@ typedef void (* GimpThreadEnterFunc) (Gimp *gimp); typedef void (* GimpThreadLeaveFunc) (Gimp *gimp); typedef GimpObject * (* GimpCreateDisplayFunc) (GimpImage *gimage, + GimpUnit unit, gdouble scale); typedef void (* GimpSetBusyFunc) (Gimp *gimp); typedef void (* GimpUnsetBusyFunc) (Gimp *gimp); @@ -276,6 +277,7 @@ GimpImage * gimp_create_image (Gimp *gimp, GimpObject * gimp_create_display (Gimp *gimp, GimpImage *gimage, + GimpUnit unit, gdouble scale); void gimp_set_default_context (Gimp *gimp, diff --git a/app/core/gimpimage-unit.c b/app/core/gimpimage-unit.c deleted file mode 100644 index d1342ff5af..0000000000 --- a/app/core/gimpimage-unit.c +++ /dev/null @@ -1,70 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattisbvf - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#include - -#include "core-types.h" - -#include "gimpimage.h" -#include "gimpimage-unit.h" -#include "gimpunit.h" - - -gdouble -gimp_image_unit_get_factor (GimpImage *gimage) -{ - return _gimp_unit_get_factor (gimage->gimp, gimage->unit); -} - -gint -gimp_image_unit_get_digits (GimpImage *gimage) -{ - return _gimp_unit_get_digits (gimage->gimp, gimage->unit); -} - -const gchar * -gimp_image_unit_get_identifier (GimpImage *gimage) -{ - return _gimp_unit_get_identifier (gimage->gimp, gimage->unit); -} - -const gchar * -gimp_image_unit_get_symbol (GimpImage *gimage) -{ - return _gimp_unit_get_symbol (gimage->gimp, gimage->unit); -} - -const gchar * -gimp_image_unit_get_abbreviation (GimpImage *gimage) -{ - return _gimp_unit_get_abbreviation (gimage->gimp, gimage->unit); -} - -const gchar * -gimp_image_unit_get_singular (GimpImage *gimage) -{ - return _gimp_unit_get_singular (gimage->gimp, gimage->unit); -} - -const gchar * -gimp_image_unit_get_plural (GimpImage *gimage) -{ - return _gimp_unit_get_plural (gimage->gimp, gimage->unit); -} diff --git a/app/core/gimpimage-unit.h b/app/core/gimpimage-unit.h deleted file mode 100644 index 3b51496aea..0000000000 --- a/app/core/gimpimage-unit.h +++ /dev/null @@ -1,32 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattisbvf - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef __GIMP_IMAGE_UNIT_H__ -#define __GIMP_IMAGE_UNIT_H__ - - -gdouble gimp_image_unit_get_factor (GimpImage *gimage); -gint gimp_image_unit_get_digits (GimpImage *gimage); -const gchar * gimp_image_unit_get_identifier (GimpImage *gimage); -const gchar * gimp_image_unit_get_symbol (GimpImage *gimage); -const gchar * gimp_image_unit_get_abbreviation (GimpImage *gimage); -const gchar * gimp_image_unit_get_singular (GimpImage *gimage); -const gchar * gimp_image_unit_get_plural (GimpImage *gimage); - - -#endif /* __GIMP_IMAGE_UNIT_H__ */ diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c index 013b9989da..92105eda54 100644 --- a/app/core/gimpimage.c +++ b/app/core/gimpimage.c @@ -468,7 +468,7 @@ gimp_image_init (GimpImage *gimage) gimage->height = 0; gimage->xresolution = 1.0; gimage->yresolution = 1.0; - gimage->unit = GIMP_UNIT_PIXEL; + gimage->unit = GIMP_UNIT_INCH; gimage->base_type = GIMP_RGB; gimage->cmap = NULL; @@ -1034,7 +1034,7 @@ gimp_image_new (Gimp *gimp, gimage->xresolution = gimp->config->default_image->xresolution; gimage->yresolution = gimp->config->default_image->yresolution; - gimage->unit = gimp->config->default_image->unit; + gimage->unit = gimp->config->default_image->resolution_unit; gimage->grid = gimp_config_duplicate (GIMP_CONFIG (gimp->config->default_grid)); @@ -1257,6 +1257,7 @@ gimp_image_set_unit (GimpImage *gimage, GimpUnit unit) { g_return_if_fail (GIMP_IS_IMAGE (gimage)); + g_return_if_fail (unit > GIMP_UNIT_PIXEL); if (gimage->unit != unit) { @@ -1264,7 +1265,6 @@ gimp_image_set_unit (GimpImage *gimage, _("Change Image Unit")); gimage->unit = unit; - gimp_image_unit_changed (gimage); } } @@ -1272,7 +1272,7 @@ gimp_image_set_unit (GimpImage *gimage, GimpUnit gimp_image_get_unit (const GimpImage *gimage) { - g_return_val_if_fail (GIMP_IS_IMAGE (gimage), GIMP_UNIT_PIXEL); + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), GIMP_UNIT_INCH); return gimage->unit; } diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h index 265b8473ce..ccfa0391ad 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; /* image unit */ + GimpUnit unit; /* resolution unit */ GimpImageBaseType base_type; /* base gimp_image type */ guchar *cmap; /* colormap--for indexed */ diff --git a/app/core/gimpprojection.c b/app/core/gimpprojection.c index 7c16a840d2..2f2b700ce6 100644 --- a/app/core/gimpprojection.c +++ b/app/core/gimpprojection.c @@ -58,7 +58,6 @@ enum static void gimp_display_class_init (GimpDisplayClass *klass); static void gimp_display_init (GimpDisplay *gdisp); -static void gimp_display_finalize (GObject *object); static void gimp_display_set_property (GObject *object, guint property_id, const GValue *value, @@ -114,13 +113,10 @@ gimp_display_get_type (void) static void gimp_display_class_init (GimpDisplayClass *klass) { - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); parent_class = g_type_class_peek_parent (klass); - object_class->finalize = gimp_display_finalize; object_class->set_property = gimp_display_set_property; object_class->get_property = gimp_display_get_property; @@ -147,26 +143,12 @@ gimp_display_init (GimpDisplay *gdisp) gdisp->idle_render.update_areas = NULL; } -static void -gimp_display_finalize (GObject *object) -{ - GimpDisplay *gdisp; - - gdisp = GIMP_DISPLAY (object); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - static void gimp_display_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { - GimpDisplay *gdisp; - - gdisp = GIMP_DISPLAY (object); - switch (property_id) { case PROP_IMAGE: @@ -184,9 +166,7 @@ gimp_display_get_property (GObject *object, GValue *value, GParamSpec *pspec) { - GimpDisplay *gdisp; - - gdisp = GIMP_DISPLAY (object); + GimpDisplay *gdisp = GIMP_DISPLAY (object); switch (property_id) { @@ -201,6 +181,7 @@ gimp_display_get_property (GObject *object, GimpDisplay * gimp_display_new (GimpImage *gimage, + GimpUnit unit, gdouble scale, GimpMenuFactory *menu_factory, GimpUIManager *popup_manager) @@ -221,7 +202,7 @@ gimp_display_new (GimpImage *gimage, gimp_display_connect (gdisp, gimage); /* create the shell for the image */ - gdisp->shell = gimp_display_shell_new (gdisp, scale, + gdisp->shell = gimp_display_shell_new (gdisp, unit, scale, menu_factory, popup_manager); gtk_widget_show (gdisp->shell); @@ -446,9 +427,7 @@ static void gimp_display_flush_whenever (GimpDisplay *gdisp, gboolean now) { - GimpDisplayShell *shell; - - shell = GIMP_DISPLAY_SHELL (gdisp->shell); + GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (gdisp->shell); /* Flush the items in the displays and updates lists - * but only if gdisplay has been mapped and exposed @@ -522,8 +501,8 @@ gimp_display_flush_whenever (GimpDisplay *gdisp, static void gimp_display_idlerender_init (GimpDisplay *gdisp) { - GSList *list; - GimpArea *area, *new_area; + GSList *list; + GimpArea *area; /* We need to merge the IdleRender's and the GimpDisplay's update_areas list * to keep track of which of the updates have been flushed and hence need @@ -531,13 +510,10 @@ gimp_display_idlerender_init (GimpDisplay *gdisp) */ for (list = gdisp->update_areas; list; list = g_slist_next (list)) { - area = (GimpArea *) list->data; - - new_area = g_memdup (area, sizeof (GimpArea)); + area = g_memdup (list->data, sizeof (GimpArea)); gdisp->idle_render.update_areas = - gimp_display_area_list_process (gdisp->idle_render.update_areas, - new_area); + gimp_display_area_list_process (gdisp->idle_render.update_areas, area); } /* If an idlerender was already running, merge the remainder of its @@ -546,7 +522,7 @@ gimp_display_idlerender_init (GimpDisplay *gdisp) */ if (gdisp->idle_render.idle_id) { - new_area = + area = gimp_area_new (gdisp->idle_render.basex, gdisp->idle_render.y, gdisp->idle_render.basex + gdisp->idle_render.width, @@ -555,8 +531,7 @@ gimp_display_idlerender_init (GimpDisplay *gdisp) gdisp->idle_render.basey))); gdisp->idle_render.update_areas = - gimp_display_area_list_process (gdisp->idle_render.update_areas, - new_area); + gimp_display_area_list_process (gdisp->idle_render.update_areas, area); gimp_display_idle_render_next_area (gdisp); } @@ -665,12 +640,10 @@ gimp_display_paint_area (GimpDisplay *gdisp, gint w, gint h) { - GimpDisplayShell *shell; + GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (gdisp->shell); gint x1, y1, x2, y2; gdouble x1_f, y1_f, x2_f, y2_f; - shell = GIMP_DISPLAY_SHELL (gdisp->shell); - /* Bounds check */ x1 = CLAMP (x, 0, gdisp->gimage->width); y1 = CLAMP (y, 0, gdisp->gimage->height); diff --git a/app/core/gimpprojection.h b/app/core/gimpprojection.h index cce9c81692..89b235aa59 100644 --- a/app/core/gimpprojection.h +++ b/app/core/gimpprojection.h @@ -74,6 +74,7 @@ struct _GimpDisplayClass GType gimp_display_get_type (void) G_GNUC_CONST; GimpDisplay * gimp_display_new (GimpImage *gimage, + GimpUnit unit, gdouble scale, GimpMenuFactory *menu_factory, GimpUIManager *popup_manager); diff --git a/app/core/gimptemplate.c b/app/core/gimptemplate.c index 52b5635530..8fe74fab6f 100644 --- a/app/core/gimptemplate.c +++ b/app/core/gimptemplate.c @@ -416,7 +416,7 @@ gimp_template_create_image (Gimp *gimp, gimp_image_set_resolution (gimage, template->xresolution, template->yresolution); - gimp_image_set_unit (gimage, template->unit); + gimp_image_set_unit (gimage, template->resolution_unit); width = gimp_image_get_width (gimage); height = gimp_image_get_height (gimage); @@ -445,7 +445,7 @@ gimp_template_create_image (Gimp *gimp, gimp_image_undo_enable (gimage); gimp_image_clean_all (gimage); - gimp_create_display (gimp, gimage, 1.0); + gimp_create_display (gimp, gimage, template->unit, 1.0); g_object_unref (gimage); diff --git a/app/dialogs/info-window.c b/app/dialogs/info-window.c index c87a3fbc69..26ef856330 100644 --- a/app/dialogs/info-window.c +++ b/app/dialogs/info-window.c @@ -33,7 +33,6 @@ #include "core/gimpcontext.h" #include "core/gimpimage.h" #include "core/gimpimage-projection.h" -#include "core/gimpimage-unit.h" #include "core/gimptemplate.h" #include "core/gimpunit.h" @@ -374,16 +373,15 @@ info_window_update_extended (GimpDisplay *gdisp, } else { - gdouble unit_factor; - gint unit_digits; - const gchar *unit_str; + GimpImage *image = gdisp->gimage; + GimpUnit unit = GIMP_DISPLAY_SHELL (gdisp->shell)->unit; + gdouble unit_factor = _gimp_unit_get_factor (image->gimp, unit); + gint unit_digits = _gimp_unit_get_digits (image->gimp, unit); + const gchar *unit_str = _gimp_unit_get_abbreviation (image->gimp, + unit); gchar format_buf[32]; gchar buf[32]; - unit_factor = gimp_image_unit_get_factor (gdisp->gimage); - unit_digits = gimp_image_unit_get_digits (gdisp->gimage); - unit_str = gimp_image_unit_get_abbreviation (gdisp->gimage); - g_snprintf (buf, sizeof (buf), "%d", (gint) tx); gtk_label_set_text (GTK_LABEL (iwd->pixel_labels[0]), buf); @@ -394,11 +392,11 @@ info_window_update_extended (GimpDisplay *gdisp, "%%.%df %s", unit_digits, unit_str); g_snprintf (buf, sizeof (buf), format_buf, - tx * unit_factor / gdisp->gimage->xresolution); + tx * unit_factor / image->xresolution); gtk_label_set_text (GTK_LABEL (iwd->unit_labels[0]), buf); g_snprintf (buf, sizeof (buf), format_buf, - ty * unit_factor / gdisp->gimage->yresolution); + ty * unit_factor / image->yresolution); gtk_label_set_text (GTK_LABEL (iwd->unit_labels[1]), buf); } @@ -457,9 +455,10 @@ void info_window_update (GimpDisplay *gdisp) { GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (gdisp->shell); - GimpImage *gimage; + GimpImage *image; InfoWinData *iwd; gint type; + GimpUnit unit; gdouble unit_factor; gint unit_digits; GimpUnit res_unit; @@ -486,30 +485,31 @@ info_window_update (GimpDisplay *gdisp) if (info_window_auto && iwd->gdisp != gdisp) return; - gimage = gdisp->gimage; + image = gdisp->gimage; + unit = GIMP_DISPLAY_SHELL (gdisp->shell)->unit; + + unit_factor = _gimp_unit_get_factor (image->gimp, unit); + unit_digits = _gimp_unit_get_digits (image->gimp, unit); /* width and height */ - unit_factor = gimp_image_unit_get_factor (gimage); - unit_digits = gimp_image_unit_get_digits (gimage); - g_snprintf (iwd->dimensions_str, MAX_BUF, _("%d x %d pixels"), - gimage->width, gimage->height); + image->width, image->height); g_snprintf (format_buf, sizeof (format_buf), "%%.%df x %%.%df %s", unit_digits + 1, unit_digits + 1, - gimp_image_unit_get_plural (gimage)); + _gimp_unit_get_plural (image->gimp, unit)); g_snprintf (iwd->real_dimensions_str, MAX_BUF, format_buf, - gimage->width * unit_factor / gimage->xresolution, - gimage->height * unit_factor / gimage->yresolution); + image->width * unit_factor / image->xresolution, + image->height * unit_factor / image->yresolution); /* image resolution */ - res_unit = gimage->gimp->config->default_image->resolution_unit; - res_unit_factor = _gimp_unit_get_factor (gimage->gimp, res_unit); + res_unit = image->gimp->config->default_image->resolution_unit; + res_unit_factor = _gimp_unit_get_factor (image->gimp, res_unit); g_snprintf (format_buf, sizeof (format_buf), _("pixels/%s"), - _gimp_unit_get_abbreviation (gimage->gimp, res_unit)); + _gimp_unit_get_abbreviation (image->gimp, res_unit)); g_snprintf (iwd->resolution_str, MAX_BUF, _("%g x %g %s"), - gimage->xresolution / res_unit_factor, - gimage->yresolution / res_unit_factor, + image->xresolution / res_unit_factor, + image->yresolution / res_unit_factor, res_unit == GIMP_UNIT_INCH ? _("dpi") : format_buf); /* user zoom ratio */ @@ -517,11 +517,11 @@ info_window_update (GimpDisplay *gdisp) /* number of layers */ g_snprintf (iwd->num_layers_str, MAX_BUF, "%d", - gimp_container_num_children (gimage->layers)); + gimp_container_num_children (image->layers)); /* size in memory */ { - GimpObject *object = GIMP_OBJECT (gimage); + GimpObject *object = GIMP_OBJECT (image); gchar *str; str = gimp_memsize_to_string (gimp_object_get_memsize (object, NULL)); @@ -531,7 +531,7 @@ info_window_update (GimpDisplay *gdisp) g_free (str); } - type = gimp_image_base_type (gimage); + type = gimp_image_base_type (image); /* color type */ switch (type) @@ -544,16 +544,13 @@ info_window_update (GimpDisplay *gdisp) break; case GIMP_INDEXED: g_snprintf (iwd->color_type_str, MAX_BUF, "%s (%d %s)", - _("Indexed Color"), gimage->num_cols, _("colors")); + _("Indexed Color"), image->num_cols, _("colors")); break; } { - GdkScreen *screen; - GdkVisual *visual; - - screen = gtk_widget_get_screen (GTK_WIDGET (shell)); - visual = gdk_screen_get_rgb_visual (screen); + GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (shell)); + GdkVisual *visual = gdk_screen_get_rgb_visual (screen); /* visual class */ g_snprintf (iwd->visual_class_str, MAX_BUF, "%s", diff --git a/app/dialogs/offset-dialog.c b/app/dialogs/offset-dialog.c index ed3bee3c07..a88ad9d303 100644 --- a/app/dialogs/offset-dialog.c +++ b/app/dialogs/offset-dialog.c @@ -147,7 +147,7 @@ offset_dialog_new (GimpDrawable *drawable, 1, 2); gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 10); - off_d->off_se = gimp_size_entry_new (1, off_d->gimage->unit, "%a", + off_d->off_se = gimp_size_entry_new (1, GIMP_UNIT_PIXEL, "%a", TRUE, TRUE, FALSE, 10, GIMP_SIZE_ENTRY_UPDATE_SIZE); diff --git a/app/dialogs/resize-dialog.c b/app/dialogs/resize-dialog.c index 5ac313476d..c71150cc19 100644 --- a/app/dialogs/resize-dialog.c +++ b/app/dialogs/resize-dialog.c @@ -128,7 +128,6 @@ resize_dialog_new (GimpViewable *viewable, gdouble resolution_x, gdouble resolution_y, GimpUnit unit, - gboolean dot_for_dot, GCallback ok_cb, gpointer user_data) { @@ -348,10 +347,6 @@ resize_dialog_new (GimpViewable *viewable, GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); gtk_widget_show (private->size_se); - if (dot_for_dot) - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (private->size_se), - GIMP_UNIT_PIXEL); - gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 0, resolution_x, FALSE); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 1, @@ -489,10 +484,6 @@ resize_dialog_new (GimpViewable *viewable, gtk_box_pack_start (GTK_BOX (vbox), private->offset_se, FALSE, FALSE, 0); gtk_widget_show (private->offset_se); - if (dot_for_dot) - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (private->offset_se), - GIMP_UNIT_PIXEL); - gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->offset_se), 0, resolution_x, FALSE); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->offset_se), 1, diff --git a/app/dialogs/resize-dialog.h b/app/dialogs/resize-dialog.h index a5828dc3f1..e033995c8a 100644 --- a/app/dialogs/resize-dialog.h +++ b/app/dialogs/resize-dialog.h @@ -79,7 +79,6 @@ ResizeDialog * resize_dialog_new (GimpViewable *viewable, gdouble resolution_x, gdouble resolution_y, GimpUnit unit, - gboolean dot_for_dot, GCallback ok_cb, gpointer user_data); diff --git a/app/display/gimpdisplay.c b/app/display/gimpdisplay.c index 7c16a840d2..2f2b700ce6 100644 --- a/app/display/gimpdisplay.c +++ b/app/display/gimpdisplay.c @@ -58,7 +58,6 @@ enum static void gimp_display_class_init (GimpDisplayClass *klass); static void gimp_display_init (GimpDisplay *gdisp); -static void gimp_display_finalize (GObject *object); static void gimp_display_set_property (GObject *object, guint property_id, const GValue *value, @@ -114,13 +113,10 @@ gimp_display_get_type (void) static void gimp_display_class_init (GimpDisplayClass *klass) { - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); parent_class = g_type_class_peek_parent (klass); - object_class->finalize = gimp_display_finalize; object_class->set_property = gimp_display_set_property; object_class->get_property = gimp_display_get_property; @@ -147,26 +143,12 @@ gimp_display_init (GimpDisplay *gdisp) gdisp->idle_render.update_areas = NULL; } -static void -gimp_display_finalize (GObject *object) -{ - GimpDisplay *gdisp; - - gdisp = GIMP_DISPLAY (object); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - static void gimp_display_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { - GimpDisplay *gdisp; - - gdisp = GIMP_DISPLAY (object); - switch (property_id) { case PROP_IMAGE: @@ -184,9 +166,7 @@ gimp_display_get_property (GObject *object, GValue *value, GParamSpec *pspec) { - GimpDisplay *gdisp; - - gdisp = GIMP_DISPLAY (object); + GimpDisplay *gdisp = GIMP_DISPLAY (object); switch (property_id) { @@ -201,6 +181,7 @@ gimp_display_get_property (GObject *object, GimpDisplay * gimp_display_new (GimpImage *gimage, + GimpUnit unit, gdouble scale, GimpMenuFactory *menu_factory, GimpUIManager *popup_manager) @@ -221,7 +202,7 @@ gimp_display_new (GimpImage *gimage, gimp_display_connect (gdisp, gimage); /* create the shell for the image */ - gdisp->shell = gimp_display_shell_new (gdisp, scale, + gdisp->shell = gimp_display_shell_new (gdisp, unit, scale, menu_factory, popup_manager); gtk_widget_show (gdisp->shell); @@ -446,9 +427,7 @@ static void gimp_display_flush_whenever (GimpDisplay *gdisp, gboolean now) { - GimpDisplayShell *shell; - - shell = GIMP_DISPLAY_SHELL (gdisp->shell); + GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (gdisp->shell); /* Flush the items in the displays and updates lists - * but only if gdisplay has been mapped and exposed @@ -522,8 +501,8 @@ gimp_display_flush_whenever (GimpDisplay *gdisp, static void gimp_display_idlerender_init (GimpDisplay *gdisp) { - GSList *list; - GimpArea *area, *new_area; + GSList *list; + GimpArea *area; /* We need to merge the IdleRender's and the GimpDisplay's update_areas list * to keep track of which of the updates have been flushed and hence need @@ -531,13 +510,10 @@ gimp_display_idlerender_init (GimpDisplay *gdisp) */ for (list = gdisp->update_areas; list; list = g_slist_next (list)) { - area = (GimpArea *) list->data; - - new_area = g_memdup (area, sizeof (GimpArea)); + area = g_memdup (list->data, sizeof (GimpArea)); gdisp->idle_render.update_areas = - gimp_display_area_list_process (gdisp->idle_render.update_areas, - new_area); + gimp_display_area_list_process (gdisp->idle_render.update_areas, area); } /* If an idlerender was already running, merge the remainder of its @@ -546,7 +522,7 @@ gimp_display_idlerender_init (GimpDisplay *gdisp) */ if (gdisp->idle_render.idle_id) { - new_area = + area = gimp_area_new (gdisp->idle_render.basex, gdisp->idle_render.y, gdisp->idle_render.basex + gdisp->idle_render.width, @@ -555,8 +531,7 @@ gimp_display_idlerender_init (GimpDisplay *gdisp) gdisp->idle_render.basey))); gdisp->idle_render.update_areas = - gimp_display_area_list_process (gdisp->idle_render.update_areas, - new_area); + gimp_display_area_list_process (gdisp->idle_render.update_areas, area); gimp_display_idle_render_next_area (gdisp); } @@ -665,12 +640,10 @@ gimp_display_paint_area (GimpDisplay *gdisp, gint w, gint h) { - GimpDisplayShell *shell; + GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (gdisp->shell); gint x1, y1, x2, y2; gdouble x1_f, y1_f, x2_f, y2_f; - shell = GIMP_DISPLAY_SHELL (gdisp->shell); - /* Bounds check */ x1 = CLAMP (x, 0, gdisp->gimage->width); y1 = CLAMP (y, 0, gdisp->gimage->height); diff --git a/app/display/gimpdisplay.h b/app/display/gimpdisplay.h index cce9c81692..89b235aa59 100644 --- a/app/display/gimpdisplay.h +++ b/app/display/gimpdisplay.h @@ -74,6 +74,7 @@ struct _GimpDisplayClass GType gimp_display_get_type (void) G_GNUC_CONST; GimpDisplay * gimp_display_new (GimpImage *gimage, + GimpUnit unit, gdouble scale, GimpMenuFactory *menu_factory, GimpUIManager *popup_manager); diff --git a/app/display/gimpdisplayshell-handlers.c b/app/display/gimpdisplayshell-handlers.c index a0752653d4..af51ae25b9 100644 --- a/app/display/gimpdisplayshell-handlers.c +++ b/app/display/gimpdisplayshell-handlers.c @@ -67,8 +67,6 @@ static void gimp_display_shell_size_changed_handler (GimpImage *g GimpDisplayShell *shell); static void gimp_display_shell_resolution_changed_handler (GimpImage *gimage, GimpDisplayShell *shell); -static void gimp_display_shell_unit_changed_handler (GimpImage *gimage, - GimpDisplayShell *shell); static void gimp_display_shell_qmask_changed_handler (GimpImage *gimage, GimpDisplayShell *shell); static void gimp_display_shell_update_guide_handler (GimpImage *gimage, @@ -152,9 +150,6 @@ gimp_display_shell_connect (GimpDisplayShell *shell) g_signal_connect (gimage, "resolution_changed", G_CALLBACK (gimp_display_shell_resolution_changed_handler), shell); - g_signal_connect (gimage, "unit_changed", - G_CALLBACK (gimp_display_shell_unit_changed_handler), - shell); g_signal_connect (gimage, "qmask_changed", G_CALLBACK (gimp_display_shell_qmask_changed_handler), shell); @@ -316,9 +311,6 @@ gimp_display_shell_disconnect (GimpDisplayShell *shell) g_signal_handlers_disconnect_by_func (gimage, gimp_display_shell_qmask_changed_handler, shell); - g_signal_handlers_disconnect_by_func (gimage, - gimp_display_shell_unit_changed_handler, - shell); g_signal_handlers_disconnect_by_func (gimage, gimp_display_shell_resolution_changed_handler, shell); @@ -410,14 +402,6 @@ gimp_display_shell_resolution_changed_handler (GimpImage *gimage, gimp_display_shell_scaled (shell); } -static void -gimp_display_shell_unit_changed_handler (GimpImage *gimage, - GimpDisplayShell *shell) -{ - gimp_display_shell_scale_setup (shell); - gimp_display_shell_scaled (shell); -} - static void gimp_display_shell_qmask_changed_handler (GimpImage *gimage, GimpDisplayShell *shell) diff --git a/app/display/gimpdisplayshell-scale.c b/app/display/gimpdisplayshell-scale.c index 05c8b23c8c..977bab55d1 100644 --- a/app/display/gimpdisplayshell-scale.c +++ b/app/display/gimpdisplayshell-scale.c @@ -30,7 +30,7 @@ #include "core/gimp.h" #include "core/gimpimage.h" -#include "core/gimpimage-unit.h" +#include "core/gimpunit.h" #include "widgets/gimphelp-ids.h" #include "widgets/gimpviewabledialog.h" @@ -224,6 +224,9 @@ gimp_display_shell_scale_setup (GimpDisplayShell *shell) g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); + if (! shell->gdisp) + return; + image_width = shell->gdisp->gimage->width; image_height = shell->gdisp->gimage->height; @@ -359,11 +362,14 @@ gimp_display_shell_scale (GimpDisplayShell *shell, g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); + scale = shell->scale; + + if (! shell->gdisp) + return; + offset_x = shell->offset_x + (shell->disp_width / 2.0); offset_y = shell->offset_y + (shell->disp_height / 2.0); - scale = shell->scale; - offset_x /= scale; offset_y /= scale; @@ -675,7 +681,7 @@ img2real (GimpDisplayShell *shell, GimpImage *image = shell->gdisp->gimage; gdouble res; - if (image->unit == GIMP_UNIT_PIXEL) + if (shell->unit == GIMP_UNIT_PIXEL) return len; if (xdir) @@ -683,5 +689,5 @@ img2real (GimpDisplayShell *shell, else res = image->yresolution; - return len * gimp_image_unit_get_factor (image) / res; + return len * _gimp_unit_get_factor (image->gimp, shell->unit) / res; } diff --git a/app/display/gimpdisplayshell-title.c b/app/display/gimpdisplayshell-title.c index 2b037e3342..7bffbe2ed4 100644 --- a/app/display/gimpdisplayshell-title.c +++ b/app/display/gimpdisplayshell-title.c @@ -36,8 +36,8 @@ #include "core/gimp.h" #include "core/gimpcontainer.h" #include "core/gimpimage.h" -#include "core/gimpimage-unit.h" #include "core/gimpitem.h" +#include "core/gimpunit.h" #include "file/file-utils.h" @@ -148,13 +148,15 @@ gimp_display_shell_format_title (GimpDisplayShell *shell, gint title_len, const gchar *format) { - GimpImage *gimage; + Gimp *gimp; + GimpImage *image; gint num, denom; gint i = 0; g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); - gimage = shell->gdisp->gimage; + image = shell->gdisp->gimage; + gimp = image->gimp; gimp_display_shell_scale_get_fraction (shell->scale, &num, &denom); @@ -176,7 +178,7 @@ gimp_display_shell_format_title (GimpDisplayShell *shell, case 'f': /* pruned filename */ { - const gchar *uri = gimp_image_get_uri (gimage); + const gchar *uri = gimp_image_get_uri (image); gchar *basename; basename = file_utils_uri_to_utf8_basename (uri); @@ -190,7 +192,7 @@ gimp_display_shell_format_title (GimpDisplayShell *shell, case 'F': /* full filename */ { gchar *filename; - const gchar *uri = gimp_image_get_uri (gimage); + const gchar *uri = gimp_image_get_uri (image); filename = file_utils_uri_to_utf8_filename (uri); @@ -201,7 +203,7 @@ gimp_display_shell_format_title (GimpDisplayShell *shell, break; case 'p': /* PDB id */ - i += print (title, title_len, i, "%d", gimp_image_get_ID (gimage)); + i += print (title, title_len, i, "%d", gimp_image_get_ID (image)); break; case 'i': /* instance */ @@ -211,9 +213,9 @@ gimp_display_shell_format_title (GimpDisplayShell *shell, case 't': /* type */ { const gchar *image_type_str = NULL; - gboolean empty = gimp_image_is_empty (gimage); + gboolean empty = gimp_image_is_empty (image); - switch (gimp_image_base_type (gimage)) + switch (gimp_image_base_type (image)) { case GIMP_RGB: image_type_str = empty ? _("RGB-empty") : _("RGB"); @@ -254,7 +256,7 @@ gimp_display_shell_format_title (GimpDisplayShell *shell, "%%D-sequence"); break; } - if (gimage->dirty) + if (image->dirty) title[i++] = format[1]; format++; break; @@ -266,14 +268,14 @@ gimp_display_shell_format_title (GimpDisplayShell *shell, "%%C-sequence"); break; } - if (! gimage->dirty) + if (! image->dirty) title[i++] = format[1]; format++; break; case 'm': /* memory used by image */ { - GimpObject *object = GIMP_OBJECT (gimage); + GimpObject *object = GIMP_OBJECT (image); gchar *str; str = gimp_memsize_to_string (gimp_object_get_memsize (object, @@ -287,12 +289,12 @@ gimp_display_shell_format_title (GimpDisplayShell *shell, case 'l': /* number of layers */ i += print (title, title_len, i, "%d", - gimp_container_num_children (gimage->layers)); + gimp_container_num_children (image->layers)); break; case 'L': /* number of layers (long) */ { - gint num = gimp_container_num_children (gimage->layers); + gint num = gimp_container_num_children (image->layers); i += print (title, title_len, i, num == 1 ? _("1 layer") : _("%d layers"), num); @@ -301,7 +303,7 @@ gimp_display_shell_format_title (GimpDisplayShell *shell, case 'n': /* active drawable name */ { - GimpDrawable *drawable = gimp_image_active_drawable (gimage); + GimpDrawable *drawable = gimp_image_active_drawable (image); if (drawable) i += print (title, title_len, i, "%s", @@ -313,7 +315,7 @@ gimp_display_shell_format_title (GimpDisplayShell *shell, case 'P': /* active drawable PDB id */ { - GimpDrawable *drawable = gimp_image_active_drawable (gimage); + GimpDrawable *drawable = gimp_image_active_drawable (image); if (drawable) i += print (title, title_len, i, "%d", @@ -324,49 +326,49 @@ gimp_display_shell_format_title (GimpDisplayShell *shell, break; case 'W': /* width in real-world units */ - if (gimage->unit != GIMP_UNIT_PIXEL) + if (shell->unit != GIMP_UNIT_PIXEL) { gchar unit_format[8]; g_snprintf (unit_format, sizeof (unit_format), "%%.%df", - gimp_image_unit_get_digits (gimage) + 1); + _gimp_unit_get_digits (gimp, shell->unit) + 1); i += print (title, title_len, i, unit_format, - (gimage->width * - gimp_image_unit_get_factor (gimage) / - gimage->xresolution)); + (image->width * + _gimp_unit_get_factor (gimp, shell->unit) / + image->xresolution)); break; } /* else fallthru */ case 'w': /* width in pixels */ - i += print (title, title_len, i, "%d", gimage->width); + i += print (title, title_len, i, "%d", image->width); break; case 'H': /* height in real-world units */ - if (gimage->unit != GIMP_UNIT_PIXEL) + if (shell->unit != GIMP_UNIT_PIXEL) { gchar unit_format[8]; g_snprintf (unit_format, sizeof (unit_format), "%%.%df", - gimp_image_unit_get_digits (gimage) + 1); + _gimp_unit_get_digits (gimp, shell->unit) + 1); i += print (title, title_len, i, unit_format, - (gimage->height * - gimp_image_unit_get_factor (gimage) / - gimage->yresolution)); + (image->height * + _gimp_unit_get_factor (gimp, shell->unit) / + image->yresolution)); break; } /* else fallthru */ case 'h': /* height in pixels */ - i += print (title, title_len, i, "%d", gimage->height); + i += print (title, title_len, i, "%d", image->height); break; case 'u': /* unit symbol */ i += print (title, title_len, i, "%s", - gimp_image_unit_get_symbol (gimage)); + _gimp_unit_get_symbol (gimp, shell->unit)); break; case 'U': /* unit abbreviation */ i += print (title, title_len, i, "%s", - gimp_image_unit_get_abbreviation (gimage)); + _gimp_unit_get_abbreviation (gimp, shell->unit)); break; /* Other cool things to be added: diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c index a7be6f59bc..e4b8818398 100644 --- a/app/display/gimpdisplayshell.c +++ b/app/display/gimpdisplayshell.c @@ -32,6 +32,7 @@ #include "gui/gui-types.h" #include "config/gimpconfig.h" +#include "config/gimpconfig-params.h" #include "config/gimpconfig-utils.h" #include "config/gimpdisplayconfig.h" #include "config/gimpguiconfig.h" @@ -86,6 +87,13 @@ #include "gimp-intl.h" +enum +{ + PROP_0, + PROP_SCALE, + PROP_UNIT +}; + enum { SCALED, @@ -102,6 +110,14 @@ static void gimp_display_shell_init (GimpDisplayShell *shell) static void gimp_display_shell_finalize (GObject *object); static void gimp_display_shell_destroy (GtkObject *object); +static void gimp_display_shell_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); +static void gimp_display_shell_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); static void gimp_display_shell_screen_changed (GtkWidget *widget, GdkScreen *previous); static gboolean gimp_display_shell_delete_event (GtkWidget *widget, @@ -190,6 +206,8 @@ gimp_display_shell_class_init (GimpDisplayShellClass *klass) G_TYPE_NONE, 0); gobject_class->finalize = gimp_display_shell_finalize; + gobject_class->set_property = gimp_display_shell_set_property; + gobject_class->get_property = gimp_display_shell_get_property; object_class->destroy = gimp_display_shell_destroy; @@ -200,6 +218,16 @@ gimp_display_shell_class_init (GimpDisplayShellClass *klass) klass->scaled = gimp_display_shell_real_scaled; klass->scrolled = NULL; klass->reconnect = NULL; + + g_object_class_install_property (gobject_class, PROP_SCALE, + g_param_spec_double ("scale", NULL, NULL, + 1.0 / 256, 256, 1.0, + G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, PROP_UNIT, + gimp_param_spec_unit ("unit", NULL, NULL, + TRUE, FALSE, + GIMP_UNIT_PIXEL, + G_PARAM_READWRITE)); } static void @@ -210,6 +238,8 @@ gimp_display_shell_init (GimpDisplayShell *shell) shell->menubar_manager = NULL; shell->popup_manager = NULL; + shell->unit = GIMP_UNIT_PIXEL; + shell->scale = 1.0; shell->other_scale = 0.0; shell->dot_for_dot = TRUE; @@ -426,17 +456,61 @@ gimp_display_shell_destroy (GtkObject *object) GTK_OBJECT_CLASS (parent_class)->destroy (object); } +static void +gimp_display_shell_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (object); + + switch (property_id) + { + case PROP_SCALE: + gimp_display_shell_scale (shell, + GIMP_ZOOM_TO, g_value_get_double (value)); + break; + case PROP_UNIT: + gimp_display_shell_set_unit (shell, g_value_get_int (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +gimp_display_shell_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (object); + + switch (property_id) + { + case PROP_SCALE: + g_value_set_double (value, shell->scale); + break; + case PROP_UNIT: + g_value_set_int (value, shell->unit); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + static void gimp_display_shell_screen_changed (GtkWidget *widget, GdkScreen *previous) { - GimpDisplayShell *shell; + GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (widget); GimpDisplayConfig *config; if (GTK_WIDGET_CLASS (parent_class)->screen_changed) GTK_WIDGET_CLASS (parent_class)->screen_changed (widget, previous); - shell = GIMP_DISPLAY_SHELL (widget); config = GIMP_DISPLAY_CONFIG (shell->gdisp->gimage->gimp->config); if (GIMP_DISPLAY_CONFIG (config)->monitor_res_from_gdk) @@ -468,6 +542,9 @@ gimp_display_shell_real_scaled (GimpDisplayShell *shell) { GimpContext *user_context; + if (! shell->gdisp) + return; + gimp_display_shell_update_title (shell); /* update the /View/Zoom menu */ @@ -481,6 +558,7 @@ gimp_display_shell_real_scaled (GimpDisplayShell *shell) GtkWidget * gimp_display_shell_new (GimpDisplay *gdisp, + GimpUnit unit, gdouble scale, GimpMenuFactory *menu_factory, GimpUIManager *popup_manager) @@ -506,10 +584,12 @@ gimp_display_shell_new (GimpDisplay *gdisp, g_return_val_if_fail (GIMP_IS_UI_MANAGER (popup_manager), NULL); /* the toplevel shell */ - shell = g_object_new (GIMP_TYPE_DISPLAY_SHELL, NULL); + shell = g_object_new (GIMP_TYPE_DISPLAY_SHELL, + "unit", unit, + "scale", scale, + NULL); shell->gdisp = gdisp; - shell->scale = scale; image_width = gdisp->gimage->width; image_height = gdisp->gimage->height; @@ -937,9 +1017,7 @@ void gimp_display_shell_close (GimpDisplayShell *shell, gboolean kill_it) { - GimpImage *gimage; - - gimage = shell->gdisp->gimage; + GimpImage *gimage = shell->gdisp->gimage; /* FIXME: gimp_busy HACK not really appropriate here because we only * want to prevent the busy image and display to be closed. --Mitch @@ -996,6 +1074,23 @@ gimp_display_shell_scrolled (GimpDisplayShell *shell) g_signal_emit (shell, display_shell_signals[SCROLLED], 0); } +void +gimp_display_shell_set_unit (GimpDisplayShell *shell, + GimpUnit unit) +{ + g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); + + if (shell->unit != unit) + { + shell->unit = unit; + + gimp_display_shell_scale_setup (shell); + gimp_display_shell_scaled (shell); + + g_object_notify (G_OBJECT (shell), "unit"); + } +} + gboolean gimp_display_shell_snap_coords (GimpDisplayShell *shell, GimpCoords *coords, diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h index bca5532ad3..e31cd95c3c 100644 --- a/app/display/gimpdisplayshell.h +++ b/app/display/gimpdisplayshell.h @@ -28,7 +28,7 @@ /* Apply to a float the same rounding mode used in the renderer */ -#define PROJ_ROUND(coord) ((gint) ceil (coord)) +#define PROJ_ROUND(coord) ((gint) ceil (coord)) /* finding the effective screen resolution (double) */ #define SCREEN_XRES(s) (s->dot_for_dot ? \ @@ -76,6 +76,8 @@ struct _GimpDisplayShell gdouble monitor_xres; gdouble monitor_yres; + GimpUnit unit; + gdouble scale; /* scale factor from original raw image */ gdouble other_scale; /* scale factor entered in Zoom->Other */ gboolean dot_for_dot; /* is monitor resolution being ignored? */ @@ -174,6 +176,7 @@ struct _GimpDisplayShellClass GType gimp_display_shell_get_type (void) G_GNUC_CONST; GtkWidget * gimp_display_shell_new (GimpDisplay *gdisp, + GimpUnit unit, gdouble scale, GimpMenuFactory *menu_factory, GimpUIManager *popup_manager); @@ -186,6 +189,9 @@ void gimp_display_shell_reconnect (GimpDisplayShell *shell); void gimp_display_shell_scaled (GimpDisplayShell *shell); void gimp_display_shell_scrolled (GimpDisplayShell *shell); +void gimp_display_shell_set_unit (GimpDisplayShell *shell, + GimpUnit unit); + gboolean gimp_display_shell_snap_coords (GimpDisplayShell *shell, GimpCoords *coords, GimpCoords *snapped_coords, diff --git a/app/display/gimpstatusbar.c b/app/display/gimpstatusbar.c index 460fd8ae52..0978f4c8fc 100644 --- a/app/display/gimpstatusbar.c +++ b/app/display/gimpstatusbar.c @@ -25,7 +25,7 @@ #include "display-types.h" #include "core/gimpimage.h" -#include "core/gimpimage-unit.h" +#include "core/gimpunit.h" #include "widgets/gimpunitstore.h" #include "widgets/gimpunitcombobox.h" @@ -261,16 +261,16 @@ gimp_statusbar_push_coords (GimpStatusbar *statusbar, const gchar *separator, gdouble y) { - GimpImage *gimage; - gchar buf[CURSOR_LEN]; + GimpDisplayShell *shell; + gchar buf[CURSOR_LEN]; g_return_if_fail (GIMP_IS_STATUSBAR (statusbar)); g_return_if_fail (title != NULL); g_return_if_fail (separator != NULL); - gimage = statusbar->shell->gdisp->gimage; + shell = statusbar->shell; - if (gimage->unit == GIMP_UNIT_PIXEL) + if (shell->unit == GIMP_UNIT_PIXEL) { g_snprintf (buf, sizeof (buf), statusbar->cursor_format_str, title, @@ -280,13 +280,15 @@ gimp_statusbar_push_coords (GimpStatusbar *statusbar, } else /* show real world units */ { - gdouble unit_factor = gimp_image_unit_get_factor (gimage); + GimpImage *image = shell->gdisp->gimage; + gdouble unit_factor = _gimp_unit_get_factor (image->gimp, + shell->unit); g_snprintf (buf, sizeof (buf), statusbar->cursor_format_str, title, - x * unit_factor / gimage->xresolution, + x * unit_factor / image->xresolution, separator, - y * unit_factor / gimage->yresolution); + y * unit_factor / image->yresolution); } gimp_statusbar_push (statusbar, context_id, buf); @@ -297,30 +299,32 @@ gimp_statusbar_set_cursor (GimpStatusbar *statusbar, gdouble x, gdouble y) { - GimpImage *image; - GtkTreeModel *model; - GimpUnitStore *store; - gchar buffer[CURSOR_LEN]; + GimpDisplayShell *shell; + GtkTreeModel *model; + GimpUnitStore *store; + gchar buffer[CURSOR_LEN]; g_return_if_fail (GIMP_IS_STATUSBAR (statusbar)); - image = statusbar->shell->gdisp->gimage; + shell = statusbar->shell; model = gtk_combo_box_get_model (GTK_COMBO_BOX (statusbar->unit_combo)); store = GIMP_UNIT_STORE (model); gimp_unit_store_set_pixel_values (store, x, y); - if (image->unit == GIMP_UNIT_PIXEL) + if (shell->unit == GIMP_UNIT_PIXEL) { - g_snprintf (buffer, sizeof (buffer), statusbar->cursor_format_str, + g_snprintf (buffer, sizeof (buffer), + statusbar->cursor_format_str, "", ROUND (x), ", ", ROUND (y)); } else /* show real world units */ { - gimp_unit_store_get_values (store, image->unit, &x, &y); + gimp_unit_store_get_values (store, shell->unit, &x, &y); - g_snprintf (buffer, sizeof (buffer), statusbar->cursor_format_str, + g_snprintf (buffer, sizeof (buffer), + statusbar->cursor_format_str, "", x, ", ", y); } @@ -339,7 +343,7 @@ gimp_statusbar_shell_scaled (GimpDisplayShell *shell, { static PangoLayout *layout = NULL; - GimpImage *image; + GimpImage *image = shell->gdisp->gimage; GtkTreeModel *model; const gchar *text; gint width; @@ -352,8 +356,6 @@ gimp_statusbar_shell_scaled (GimpDisplayShell *shell, g_signal_handlers_unblock_by_func (statusbar->scale_combo, gimp_statusbar_scale_changed, statusbar); - image = statusbar->shell->gdisp->gimage; - model = gtk_combo_box_get_model (GTK_COMBO_BOX (statusbar->unit_combo)); gimp_unit_store_set_resolutions (GIMP_UNIT_STORE (model), image->xresolution, image->yresolution); @@ -361,11 +363,11 @@ gimp_statusbar_shell_scaled (GimpDisplayShell *shell, g_signal_handlers_block_by_func (statusbar->unit_combo, gimp_statusbar_unit_changed, statusbar); gimp_unit_combo_box_set_active (GIMP_UNIT_COMBO_BOX (statusbar->unit_combo), - image->unit); + shell->unit); g_signal_handlers_unblock_by_func (statusbar->unit_combo, gimp_statusbar_unit_changed, statusbar); - if (image->unit == GIMP_UNIT_PIXEL) + if (shell->unit == GIMP_UNIT_PIXEL) { g_snprintf (statusbar->cursor_format_str, sizeof (statusbar->cursor_format_str), @@ -376,8 +378,8 @@ gimp_statusbar_shell_scaled (GimpDisplayShell *shell, g_snprintf (statusbar->cursor_format_str, sizeof (statusbar->cursor_format_str), "%%s%%.%df%%s%%.%df", - gimp_image_unit_get_digits (image), - gimp_image_unit_get_digits (image)); + _gimp_unit_get_digits (image->gimp, shell->unit), + _gimp_unit_get_digits (image->gimp, shell->unit)); } gimp_statusbar_set_cursor (statusbar, - image->width, - image->height); @@ -411,8 +413,8 @@ static void gimp_statusbar_unit_changed (GimpUnitComboBox *combo, GimpStatusbar *statusbar) { - gimp_image_set_unit (statusbar->shell->gdisp->gimage, - gimp_unit_combo_box_get_active (combo)); + gimp_display_shell_set_unit (statusbar->shell, + gimp_unit_combo_box_get_active (combo)); } static void diff --git a/app/file/file-open.c b/app/file/file-open.c index 4079b0301f..2b5a39d541 100644 --- a/app/file/file-open.c +++ b/app/file/file-open.c @@ -223,12 +223,11 @@ file_open_with_proc_and_display (Gimp *gimp, if (gimage) { - GimpDocumentList *documents; + GimpDocumentList *documents = GIMP_DOCUMENT_LIST (gimp->documents); GimpImagefile *imagefile; - gimp_create_display (gimage->gimp, gimage, 1.0); + gimp_create_display (gimage->gimp, gimage, GIMP_UNIT_PIXEL, 1.0); - documents = GIMP_DOCUMENT_LIST (gimp->documents); imagefile = gimp_document_list_add_uri (documents, uri, mime_type); /* can only create a thumbnail if the passed uri and the diff --git a/app/gui/gui-vtable.c b/app/gui/gui-vtable.c index a0a6eedd6d..f73f90ec71 100644 --- a/app/gui/gui-vtable.c +++ b/app/gui/gui-vtable.c @@ -69,7 +69,8 @@ static void gui_unset_busy (Gimp *gimp); static void gui_message (Gimp *gimp, const gchar *domain, const gchar *message); -static GimpObject * gui_display_new (GimpImage *gimage, +static GimpObject * gui_create_display (GimpImage *gimage, + GimpUnit unit, gdouble scale); static void gui_menus_init (Gimp *gimp, GSList *plug_in_defs, @@ -113,7 +114,7 @@ gui_vtable_init (Gimp *gimp) gimp->gui_set_busy_func = gui_set_busy; gimp->gui_unset_busy_func = gui_unset_busy; gimp->gui_message_func = gui_message; - gimp->gui_create_display_func = gui_display_new; + gimp->gui_create_display_func = gui_create_display; gimp->gui_menus_init_func = gui_menus_init; gimp->gui_menus_create_func = gui_menus_create_entry; gimp->gui_menus_delete_func = gui_menus_delete_entry; @@ -191,8 +192,9 @@ gui_message (Gimp *gimp, } static GimpObject * -gui_display_new (GimpImage *gimage, - gdouble scale) +gui_create_display (GimpImage *gimage, + GimpUnit unit, + gdouble scale) { GimpDisplayShell *shell; GimpDisplay *gdisp; @@ -200,7 +202,7 @@ gui_display_new (GimpImage *gimage, image_managers = gimp_ui_managers_from_name (""); - gdisp = gimp_display_new (gimage, scale, + gdisp = gimp_display_new (gimage, unit, scale, global_menu_factory, image_managers->data); diff --git a/app/gui/info-window.c b/app/gui/info-window.c index c87a3fbc69..26ef856330 100644 --- a/app/gui/info-window.c +++ b/app/gui/info-window.c @@ -33,7 +33,6 @@ #include "core/gimpcontext.h" #include "core/gimpimage.h" #include "core/gimpimage-projection.h" -#include "core/gimpimage-unit.h" #include "core/gimptemplate.h" #include "core/gimpunit.h" @@ -374,16 +373,15 @@ info_window_update_extended (GimpDisplay *gdisp, } else { - gdouble unit_factor; - gint unit_digits; - const gchar *unit_str; + GimpImage *image = gdisp->gimage; + GimpUnit unit = GIMP_DISPLAY_SHELL (gdisp->shell)->unit; + gdouble unit_factor = _gimp_unit_get_factor (image->gimp, unit); + gint unit_digits = _gimp_unit_get_digits (image->gimp, unit); + const gchar *unit_str = _gimp_unit_get_abbreviation (image->gimp, + unit); gchar format_buf[32]; gchar buf[32]; - unit_factor = gimp_image_unit_get_factor (gdisp->gimage); - unit_digits = gimp_image_unit_get_digits (gdisp->gimage); - unit_str = gimp_image_unit_get_abbreviation (gdisp->gimage); - g_snprintf (buf, sizeof (buf), "%d", (gint) tx); gtk_label_set_text (GTK_LABEL (iwd->pixel_labels[0]), buf); @@ -394,11 +392,11 @@ info_window_update_extended (GimpDisplay *gdisp, "%%.%df %s", unit_digits, unit_str); g_snprintf (buf, sizeof (buf), format_buf, - tx * unit_factor / gdisp->gimage->xresolution); + tx * unit_factor / image->xresolution); gtk_label_set_text (GTK_LABEL (iwd->unit_labels[0]), buf); g_snprintf (buf, sizeof (buf), format_buf, - ty * unit_factor / gdisp->gimage->yresolution); + ty * unit_factor / image->yresolution); gtk_label_set_text (GTK_LABEL (iwd->unit_labels[1]), buf); } @@ -457,9 +455,10 @@ void info_window_update (GimpDisplay *gdisp) { GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (gdisp->shell); - GimpImage *gimage; + GimpImage *image; InfoWinData *iwd; gint type; + GimpUnit unit; gdouble unit_factor; gint unit_digits; GimpUnit res_unit; @@ -486,30 +485,31 @@ info_window_update (GimpDisplay *gdisp) if (info_window_auto && iwd->gdisp != gdisp) return; - gimage = gdisp->gimage; + image = gdisp->gimage; + unit = GIMP_DISPLAY_SHELL (gdisp->shell)->unit; + + unit_factor = _gimp_unit_get_factor (image->gimp, unit); + unit_digits = _gimp_unit_get_digits (image->gimp, unit); /* width and height */ - unit_factor = gimp_image_unit_get_factor (gimage); - unit_digits = gimp_image_unit_get_digits (gimage); - g_snprintf (iwd->dimensions_str, MAX_BUF, _("%d x %d pixels"), - gimage->width, gimage->height); + image->width, image->height); g_snprintf (format_buf, sizeof (format_buf), "%%.%df x %%.%df %s", unit_digits + 1, unit_digits + 1, - gimp_image_unit_get_plural (gimage)); + _gimp_unit_get_plural (image->gimp, unit)); g_snprintf (iwd->real_dimensions_str, MAX_BUF, format_buf, - gimage->width * unit_factor / gimage->xresolution, - gimage->height * unit_factor / gimage->yresolution); + image->width * unit_factor / image->xresolution, + image->height * unit_factor / image->yresolution); /* image resolution */ - res_unit = gimage->gimp->config->default_image->resolution_unit; - res_unit_factor = _gimp_unit_get_factor (gimage->gimp, res_unit); + res_unit = image->gimp->config->default_image->resolution_unit; + res_unit_factor = _gimp_unit_get_factor (image->gimp, res_unit); g_snprintf (format_buf, sizeof (format_buf), _("pixels/%s"), - _gimp_unit_get_abbreviation (gimage->gimp, res_unit)); + _gimp_unit_get_abbreviation (image->gimp, res_unit)); g_snprintf (iwd->resolution_str, MAX_BUF, _("%g x %g %s"), - gimage->xresolution / res_unit_factor, - gimage->yresolution / res_unit_factor, + image->xresolution / res_unit_factor, + image->yresolution / res_unit_factor, res_unit == GIMP_UNIT_INCH ? _("dpi") : format_buf); /* user zoom ratio */ @@ -517,11 +517,11 @@ info_window_update (GimpDisplay *gdisp) /* number of layers */ g_snprintf (iwd->num_layers_str, MAX_BUF, "%d", - gimp_container_num_children (gimage->layers)); + gimp_container_num_children (image->layers)); /* size in memory */ { - GimpObject *object = GIMP_OBJECT (gimage); + GimpObject *object = GIMP_OBJECT (image); gchar *str; str = gimp_memsize_to_string (gimp_object_get_memsize (object, NULL)); @@ -531,7 +531,7 @@ info_window_update (GimpDisplay *gdisp) g_free (str); } - type = gimp_image_base_type (gimage); + type = gimp_image_base_type (image); /* color type */ switch (type) @@ -544,16 +544,13 @@ info_window_update (GimpDisplay *gdisp) break; case GIMP_INDEXED: g_snprintf (iwd->color_type_str, MAX_BUF, "%s (%d %s)", - _("Indexed Color"), gimage->num_cols, _("colors")); + _("Indexed Color"), image->num_cols, _("colors")); break; } { - GdkScreen *screen; - GdkVisual *visual; - - screen = gtk_widget_get_screen (GTK_WIDGET (shell)); - visual = gdk_screen_get_rgb_visual (screen); + GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (shell)); + GdkVisual *visual = gdk_screen_get_rgb_visual (screen); /* visual class */ g_snprintf (iwd->visual_class_str, MAX_BUF, "%s", diff --git a/app/gui/offset-dialog.c b/app/gui/offset-dialog.c index ed3bee3c07..a88ad9d303 100644 --- a/app/gui/offset-dialog.c +++ b/app/gui/offset-dialog.c @@ -147,7 +147,7 @@ offset_dialog_new (GimpDrawable *drawable, 1, 2); gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 10); - off_d->off_se = gimp_size_entry_new (1, off_d->gimage->unit, "%a", + off_d->off_se = gimp_size_entry_new (1, GIMP_UNIT_PIXEL, "%a", TRUE, TRUE, FALSE, 10, GIMP_SIZE_ENTRY_UPDATE_SIZE); diff --git a/app/gui/resize-dialog.c b/app/gui/resize-dialog.c index 5ac313476d..c71150cc19 100644 --- a/app/gui/resize-dialog.c +++ b/app/gui/resize-dialog.c @@ -128,7 +128,6 @@ resize_dialog_new (GimpViewable *viewable, gdouble resolution_x, gdouble resolution_y, GimpUnit unit, - gboolean dot_for_dot, GCallback ok_cb, gpointer user_data) { @@ -348,10 +347,6 @@ resize_dialog_new (GimpViewable *viewable, GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); gtk_widget_show (private->size_se); - if (dot_for_dot) - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (private->size_se), - GIMP_UNIT_PIXEL); - gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 0, resolution_x, FALSE); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 1, @@ -489,10 +484,6 @@ resize_dialog_new (GimpViewable *viewable, gtk_box_pack_start (GTK_BOX (vbox), private->offset_se, FALSE, FALSE, 0); gtk_widget_show (private->offset_se); - if (dot_for_dot) - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (private->offset_se), - GIMP_UNIT_PIXEL); - gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->offset_se), 0, resolution_x, FALSE); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->offset_se), 1, diff --git a/app/gui/resize-dialog.h b/app/gui/resize-dialog.h index a5828dc3f1..e033995c8a 100644 --- a/app/gui/resize-dialog.h +++ b/app/gui/resize-dialog.h @@ -79,7 +79,6 @@ ResizeDialog * resize_dialog_new (GimpViewable *viewable, gdouble resolution_x, gdouble resolution_y, GimpUnit unit, - gboolean dot_for_dot, GCallback ok_cb, gpointer user_data); diff --git a/app/pdb/display_cmds.c b/app/pdb/display_cmds.c index 4a17e96750..6e7ea0890f 100644 --- a/app/pdb/display_cmds.c +++ b/app/pdb/display_cmds.c @@ -65,7 +65,8 @@ display_new_invoker (Gimp *gimp, if (success) { - display = (GimpDisplay *) gimp_create_display (gimp, gimage, 1.0); + display = (GimpDisplay *) gimp_create_display (gimp, + gimage, GIMP_UNIT_PIXEL, 1.0); success = (display != NULL); diff --git a/app/pdb/image_cmds.c b/app/pdb/image_cmds.c index daa158284a..850872fe80 100644 --- a/app/pdb/image_cmds.c +++ b/app/pdb/image_cmds.c @@ -3831,7 +3831,7 @@ image_set_unit_invoker (Gimp *gimp, success = FALSE; unit = args[1].value.pdb_int; - if (unit < GIMP_UNIT_PIXEL || unit >= _gimp_unit_get_number_of_units (gimp)) + if (unit < GIMP_UNIT_INCH || unit >= _gimp_unit_get_number_of_units (gimp)) success = FALSE; if (success) diff --git a/app/tools/gimpbrushtool.c b/app/tools/gimpbrushtool.c index 050c5774a7..32ddb4fb23 100644 --- a/app/tools/gimpbrushtool.c +++ b/app/tools/gimpbrushtool.c @@ -34,9 +34,9 @@ #include "core/gimpcontainer.h" #include "core/gimpdrawable.h" #include "core/gimpimage.h" -#include "core/gimpimage-unit.h" #include "core/gimppaintinfo.h" #include "core/gimptoolinfo.h" +#include "core/gimpunit.h" #include "paint/gimpbrushcore.h" #include "paint/gimppaintcore.h" @@ -680,14 +680,15 @@ gimp_paint_tool_oper_update (GimpTool *tool, core->cur_coords.x -= off_x; core->cur_coords.y -= off_y; - hard = (gimp_paint_options_get_brush_mode (paint_options) == GIMP_BRUSH_HARD); + hard = (gimp_paint_options_get_brush_mode (paint_options) == + GIMP_BRUSH_HARD); gimp_paint_tool_round_line (core, hard, state); dx = core->cur_coords.x - core->last_coords.x; dy = core->cur_coords.y - core->last_coords.y; /* show distance in statusbar */ - if (shell->dot_for_dot) + if (shell->unit == GIMP_UNIT_PIXEL) { dist = sqrt (SQR (dx) + SQR (dy)); @@ -696,18 +697,18 @@ gimp_paint_tool_oper_update (GimpTool *tool, } else { - gchar format_str[64]; + GimpImage *image = gdisp->gimage; + gchar format_str[64]; g_snprintf (format_str, sizeof (format_str), "%%.%df %s", - gimp_image_unit_get_digits (gdisp->gimage), - gimp_image_unit_get_symbol (gdisp->gimage)); + _gimp_unit_get_digits (image->gimp, shell->unit), + _gimp_unit_get_symbol (image->gimp, shell->unit)); - dist = (gimp_image_unit_get_factor (gdisp->gimage) * - sqrt (SQR (dx / gdisp->gimage->xresolution) + - SQR (dy / gdisp->gimage->yresolution))); + dist = (_gimp_unit_get_factor (image->gimp, shell->unit) * + sqrt (SQR (dx / image->xresolution) + + SQR (dy / image->yresolution))); - g_snprintf (status_str, sizeof (status_str), format_str, - dist); + g_snprintf (status_str, sizeof (status_str), format_str, dist); } gimp_statusbar_push (GIMP_STATUSBAR (shell->statusbar), diff --git a/app/tools/gimpcroptool.c b/app/tools/gimpcroptool.c index 64b02f2515..609a1c910d 100644 --- a/app/tools/gimpcroptool.c +++ b/app/tools/gimpcroptool.c @@ -198,13 +198,9 @@ gimp_crop_tool_get_type (void) static void gimp_crop_tool_class_init (GimpCropToolClass *klass) { - GObjectClass *object_class; - GimpToolClass *tool_class; - GimpDrawToolClass *draw_tool_class; - - object_class = G_OBJECT_CLASS (klass); - tool_class = GIMP_TOOL_CLASS (klass); - draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass); + GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass); parent_class = g_type_class_peek_parent (klass); @@ -279,11 +275,8 @@ gimp_crop_tool_button_press (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { - GimpCropTool *crop; - GimpDrawTool *draw_tool; - - crop = GIMP_CROP_TOOL (tool); - draw_tool = GIMP_DRAW_TOOL (tool); + GimpCropTool *crop = GIMP_CROP_TOOL (tool); + GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool); if (gdisp != tool->gdisp) { @@ -314,11 +307,8 @@ gimp_crop_tool_button_release (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { - GimpCropTool *crop; - GimpCropOptions *options; - - crop = GIMP_CROP_TOOL (tool); - options = GIMP_CROP_OPTIONS (tool->tool_info->tool_options); + GimpCropTool *crop = GIMP_CROP_TOOL (tool); + GimpCropOptions *options = GIMP_CROP_OPTIONS (tool->tool_info->tool_options); gimp_tool_control_halt (tool->control); gimp_tool_pop_status (tool); @@ -351,17 +341,14 @@ gimp_crop_tool_motion (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { - GimpCropTool *crop; - GimpCropOptions *options; + GimpCropTool *crop = GIMP_CROP_TOOL (tool); + GimpCropOptions *options = GIMP_CROP_OPTIONS (tool->tool_info->tool_options); GimpLayer *layer; gint x1, y1, x2, y2; gint curx, cury; gint inc_x, inc_y; gint min_x, min_y, max_x, max_y; - crop = GIMP_CROP_TOOL (tool); - options = GIMP_CROP_OPTIONS (tool->tool_info->tool_options); - /* This is the only case when the motion events should be ignored-- we're just waiting for the button release event to crop the image */ if (crop->function == CROPPING) @@ -532,16 +519,13 @@ gimp_crop_tool_arrow_key (GimpTool *tool, GdkEventKey *kevent, GimpDisplay *gdisp) { - GimpCropTool *crop; - GimpCropOptions *options; + GimpCropTool *crop = GIMP_CROP_TOOL (tool); + GimpCropOptions *options = GIMP_CROP_OPTIONS (tool->tool_info->tool_options); GimpLayer *layer; gint inc_x, inc_y; gint min_x, min_y; gint max_x, max_y; - crop = GIMP_CROP_TOOL (tool); - options = GIMP_CROP_OPTIONS (tool->tool_info->tool_options); - if (gdisp != tool->gdisp) return; @@ -617,9 +601,7 @@ gimp_crop_tool_modifier_key (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { - GimpCropOptions *options; - - options = GIMP_CROP_OPTIONS (tool->tool_info->tool_options); + GimpCropOptions *options = GIMP_CROP_OPTIONS (tool->tool_info->tool_options); if (state & GDK_MOD1_MASK) { @@ -667,11 +649,8 @@ gimp_crop_tool_oper_update (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { - GimpCropTool *crop; - GimpDrawTool *draw_tool; - - crop = GIMP_CROP_TOOL (tool); - draw_tool = GIMP_DRAW_TOOL (tool); + GimpCropTool *crop = GIMP_CROP_TOOL (tool); + GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool); if (tool->gdisp != gdisp) return; @@ -761,12 +740,11 @@ gimp_crop_tool_cursor_update (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { - GimpCropTool *crop; + GimpCropTool *crop = GIMP_CROP_TOOL (tool); GimpCropOptions *options; GdkCursorType ctype = GIMP_CROSSHAIR_SMALL_CURSOR; GimpCursorModifier cmodifier = GIMP_CURSOR_MODIFIER_NONE; - crop = GIMP_CROP_TOOL (tool); options = GIMP_CROP_OPTIONS (tool->tool_info->tool_options); if (tool->gdisp == gdisp) @@ -801,16 +779,10 @@ gimp_crop_tool_cursor_update (GimpTool *tool, static void gimp_crop_tool_draw (GimpDrawTool *draw) { - GimpCropTool *crop; - GimpTool *tool; - GimpDisplayShell *shell; - GimpCanvas *canvas; - - crop = GIMP_CROP_TOOL (draw); - tool = GIMP_TOOL (draw); - - shell = GIMP_DISPLAY_SHELL (tool->gdisp->shell); - canvas = GIMP_CANVAS (shell->canvas); + GimpCropTool *crop = GIMP_CROP_TOOL (draw); + GimpTool *tool = GIMP_TOOL (draw); + GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (tool->gdisp->shell); + GimpCanvas *canvas = GIMP_CANVAS (shell->canvas); gimp_canvas_draw_line (canvas, GIMP_CANVAS_STYLE_XOR, crop->dx1, crop->dy1, @@ -905,7 +877,8 @@ crop_recalc (GimpCropTool *crop) static void crop_start (GimpCropTool *crop) { - GimpTool *tool = GIMP_TOOL (crop); + GimpTool *tool = GIMP_TOOL (crop); + GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (tool->gdisp->shell); crop_recalc (crop); @@ -943,17 +916,9 @@ crop_start (GimpCropTool *crop) 0, tool->gdisp->gimage->height); gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (crop->origin_sizeentry), - tool->gdisp->gimage->unit) ; + shell->unit); gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (crop->size_sizeentry), - tool->gdisp->gimage->unit); - - if (GIMP_DISPLAY_SHELL (tool->gdisp->shell)->dot_for_dot) - { - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (crop->origin_sizeentry), - GIMP_UNIT_PIXEL); - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (crop->size_sizeentry), - GIMP_UNIT_PIXEL); - } + shell->unit); g_signal_handlers_unblock_by_func (crop->origin_sizeentry, crop_origin_changed, @@ -976,20 +941,15 @@ crop_start (GimpCropTool *crop) static void crop_info_create (GimpCropTool *crop) { - GimpTool *tool; - GimpDisplay *gdisp; - GimpDisplayShell *shell; + GimpTool *tool = GIMP_TOOL (crop); + GimpDisplay *gdisp = tool->gdisp; + GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (gdisp->shell); GtkWidget *spinbutton; GtkWidget *bbox; GtkWidget *button; GtkWidget *widget; const gchar *stock_id; - tool = GIMP_TOOL (crop); - - gdisp = tool->gdisp; - shell = GIMP_DISPLAY_SHELL (gdisp->shell); - stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (tool->tool_info)); crop->crop_info = info_dialog_new (NULL, @@ -1020,8 +980,7 @@ crop_info_create (GimpCropTool *crop) crop->origin_sizeentry = info_dialog_add_sizeentry (crop->crop_info, _("Origin Y:"), crop->orig_vals, 1, - shell->dot_for_dot ? - GIMP_UNIT_PIXEL : gdisp->gimage->unit, "%a", + shell->unit, "%a", TRUE, TRUE, FALSE, GIMP_SIZE_ENTRY_UPDATE_SIZE, G_CALLBACK (crop_origin_changed), crop); @@ -1038,8 +997,7 @@ crop_info_create (GimpCropTool *crop) crop->size_sizeentry = info_dialog_add_sizeentry (crop->crop_info, _("Height:"), crop->size_vals, 1, - shell->dot_for_dot ? - GIMP_UNIT_PIXEL : gdisp->gimage->unit, "%a", + shell->unit, "%a", TRUE, TRUE, FALSE, GIMP_SIZE_ENTRY_UPDATE_SIZE, G_CALLBACK (crop_size_changed), crop); diff --git a/app/tools/gimpmeasuretool.c b/app/tools/gimpmeasuretool.c index 3cebb528b5..84a5da3f51 100644 --- a/app/tools/gimpmeasuretool.c +++ b/app/tools/gimpmeasuretool.c @@ -34,8 +34,8 @@ #include "core/gimpimage-guides.h" #include "core/gimpimage-undo.h" #include "core/gimpimage-undo-push.h" -#include "core/gimpimage-unit.h" #include "core/gimptoolinfo.h" +#include "core/gimpunit.h" #include "widgets/gimphelp-ids.h" #include "widgets/gimptooldialog.h" @@ -706,7 +706,8 @@ static void gimp_measure_tool_dialog_update (GimpMeasureTool *mtool, GimpDisplay *gdisp) { - GimpDisplayShell *shell; + GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (gdisp->shell); + GimpImage *image = gdisp->gimage; gint ax, ay; gint bx, by; gdouble theta1, theta2; @@ -717,8 +718,6 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *mtool, gchar format[128]; gchar buf[128]; - shell = GIMP_DISPLAY_SHELL (gdisp->shell); - /* calculate distance and angle */ ax = mtool->x[1] - mtool->x[0]; ay = mtool->y[1] - mtool->y[0]; @@ -735,10 +734,9 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *mtool, } pixel_distance = sqrt (SQR (ax - bx) + SQR (ay - by)); - unit_distance = - gimp_image_unit_get_factor (gdisp->gimage) * - sqrt (SQR ((gdouble)(ax - bx) / gdisp->gimage->xresolution) + - SQR ((gdouble)(ay - by) / gdisp->gimage->yresolution)); + unit_distance = (_gimp_unit_get_factor (image->gimp, shell->unit) * + sqrt (SQR ((gdouble)(ax - bx) / image->xresolution) + + SQR ((gdouble)(ay - by) / image->yresolution))); if (mtool->num_points != 3) bx = ax > 0 ? 1 : -1; @@ -746,35 +744,23 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *mtool, theta1 = measure_tool_get_angle (ax, ay, 1.0, 1.0); theta2 = measure_tool_get_angle (bx, by, 1.0, 1.0); - if (shell->dot_for_dot) - { - mtool->angle1 = theta1; - mtool->angle2 = theta2; - } - pixel_angle = fabs (theta1 - theta2); if (pixel_angle > 180.0) pixel_angle = fabs (360.0 - pixel_angle); theta1 = measure_tool_get_angle (ax, ay, - gdisp->gimage->xresolution, - gdisp->gimage->yresolution); + image->xresolution, image->yresolution); theta2 = measure_tool_get_angle (bx, by, - gdisp->gimage->xresolution, - gdisp->gimage->yresolution); + image->xresolution, image->yresolution); - if (! shell->dot_for_dot) - { - mtool->angle1 = theta1; - mtool->angle2 = theta2; - } + mtool->angle1 = theta1; + mtool->angle2 = theta2; unit_angle = fabs (theta1 - theta2); if (unit_angle > 180.0) unit_angle = fabs (360.0 - unit_angle); - - if (shell->dot_for_dot) + if (shell->unit == GIMP_UNIT_PIXEL) { g_snprintf (buf, sizeof (buf), "%.1f %s, %.2f \302\260", pixel_distance, _("pixels"), pixel_angle); @@ -782,8 +768,8 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *mtool, else { g_snprintf (format, sizeof (format), "%%.%df %s, %%.2f \302\260", - gimp_image_unit_get_digits (gdisp->gimage), - gimp_image_unit_get_plural (gdisp->gimage)); + _gimp_unit_get_digits (image->gimp, shell->unit), + _gimp_unit_get_plural (image->gimp, shell->unit)); g_snprintf (buf, sizeof (buf), format, unit_distance, unit_angle); } @@ -800,12 +786,12 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *mtool, gtk_label_set_text (GTK_LABEL (mtool->angle_label[0]), buf); g_snprintf (format, sizeof (format), - "%%.%df", gimp_image_unit_get_digits (gdisp->gimage)); + "%%.%df", _gimp_unit_get_digits (image->gimp, shell->unit)); g_snprintf (buf, sizeof (buf), format, unit_distance); gtk_label_set_text (GTK_LABEL (mtool->distance_label[1]), buf); gtk_label_set_text (GTK_LABEL (mtool->unit_label[0]), - gimp_image_unit_get_plural (gdisp->gimage)); + _gimp_unit_get_plural (image->gimp, shell->unit)); if (fabs (unit_angle - pixel_angle) > 0.01) { diff --git a/app/tools/gimppainttool.c b/app/tools/gimppainttool.c index 050c5774a7..32ddb4fb23 100644 --- a/app/tools/gimppainttool.c +++ b/app/tools/gimppainttool.c @@ -34,9 +34,9 @@ #include "core/gimpcontainer.h" #include "core/gimpdrawable.h" #include "core/gimpimage.h" -#include "core/gimpimage-unit.h" #include "core/gimppaintinfo.h" #include "core/gimptoolinfo.h" +#include "core/gimpunit.h" #include "paint/gimpbrushcore.h" #include "paint/gimppaintcore.h" @@ -680,14 +680,15 @@ gimp_paint_tool_oper_update (GimpTool *tool, core->cur_coords.x -= off_x; core->cur_coords.y -= off_y; - hard = (gimp_paint_options_get_brush_mode (paint_options) == GIMP_BRUSH_HARD); + hard = (gimp_paint_options_get_brush_mode (paint_options) == + GIMP_BRUSH_HARD); gimp_paint_tool_round_line (core, hard, state); dx = core->cur_coords.x - core->last_coords.x; dy = core->cur_coords.y - core->last_coords.y; /* show distance in statusbar */ - if (shell->dot_for_dot) + if (shell->unit == GIMP_UNIT_PIXEL) { dist = sqrt (SQR (dx) + SQR (dy)); @@ -696,18 +697,18 @@ gimp_paint_tool_oper_update (GimpTool *tool, } else { - gchar format_str[64]; + GimpImage *image = gdisp->gimage; + gchar format_str[64]; g_snprintf (format_str, sizeof (format_str), "%%.%df %s", - gimp_image_unit_get_digits (gdisp->gimage), - gimp_image_unit_get_symbol (gdisp->gimage)); + _gimp_unit_get_digits (image->gimp, shell->unit), + _gimp_unit_get_symbol (image->gimp, shell->unit)); - dist = (gimp_image_unit_get_factor (gdisp->gimage) * - sqrt (SQR (dx / gdisp->gimage->xresolution) + - SQR (dy / gdisp->gimage->yresolution))); + dist = (_gimp_unit_get_factor (image->gimp, shell->unit) * + sqrt (SQR (dx / image->xresolution) + + SQR (dy / image->yresolution))); - g_snprintf (status_str, sizeof (status_str), format_str, - dist); + g_snprintf (status_str, sizeof (status_str), format_str, dist); } gimp_statusbar_push (GIMP_STATUSBAR (shell->statusbar), diff --git a/app/tools/gimprectselecttool.c b/app/tools/gimprectselecttool.c index 052a5776f7..9b50a7de31 100644 --- a/app/tools/gimprectselecttool.c +++ b/app/tools/gimprectselecttool.c @@ -32,7 +32,6 @@ #include "core/gimpchannel-select.h" #include "core/gimpimage.h" #include "core/gimpimage-crop.h" -#include "core/gimpimage-unit.h" #include "core/gimplayer-floating-sel.h" #include "core/gimpmarshal.h" #include "core/gimptoolinfo.h" @@ -615,35 +614,36 @@ static void gimp_rect_select_tool_update_options (GimpRectSelectTool *rect_sel, GimpDisplay *gdisp) { - GimpUnit unit; - gdouble width; - gdouble height; + GimpDisplayShell *shell; + gdouble width; + gdouble height; if (rect_sel->fixed_mode != GIMP_RECT_SELECT_MODE_FREE) return; - if (GIMP_DISPLAY_SHELL (gdisp->shell)->dot_for_dot) + shell = GIMP_DISPLAY_SHELL (gdisp->shell); + + if (shell->unit == GIMP_UNIT_PIXEL) { width = fabs (rect_sel->w); height = fabs (rect_sel->h); - unit = GIMP_UNIT_PIXEL; } else { - GimpImage *gimage = gdisp->gimage; - - unit = gimage->unit; + GimpImage *image = gdisp->gimage; width = (fabs (rect_sel->w) * - gimp_image_unit_get_factor (gimage) / gimage->xresolution); + _gimp_unit_get_factor (image->gimp, + shell->unit) / image->xresolution); height = (fabs (rect_sel->h) * - gimp_image_unit_get_factor (gimage) / gimage->yresolution); + _gimp_unit_get_factor (image->gimp, + shell->unit) / image->yresolution); } g_object_set (GIMP_TOOL (rect_sel)->tool_info->tool_options, "fixed-width", width, "fixed-height", height, - "fixed-unit", unit, + "fixed-unit", shell->unit, NULL); } @@ -662,6 +662,7 @@ gimp_rect_select_tool_coords_to_integer (GimpDisplay *gdisp, y = MIN (y, y + h); w = ABS (w); h = ABS (h); + *ix = RINT (x); *iy = RINT (y); *iw = RINT (w + (x - *ix)); diff --git a/app/tools/gimprotatetool.c b/app/tools/gimprotatetool.c index 2f1f09e19a..5402448377 100644 --- a/app/tools/gimprotatetool.c +++ b/app/tools/gimprotatetool.c @@ -222,10 +222,7 @@ gimp_rotate_tool_prepare (GimpTransformTool *tr_tool, tr_tool); gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), - gdisp->gimage->unit); - - if (GIMP_DISPLAY_SHELL (gdisp->shell)->dot_for_dot) - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), GIMP_UNIT_PIXEL); + GIMP_DISPLAY_SHELL (gdisp->shell)->unit); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0, gdisp->gimage->xresolution, FALSE); diff --git a/app/tools/gimpscaletool.c b/app/tools/gimpscaletool.c index 57064922d4..2c6d84fd1b 100644 --- a/app/tools/gimpscaletool.c +++ b/app/tools/gimpscaletool.c @@ -221,10 +221,7 @@ gimp_scale_tool_prepare (GimpTransformTool *tr_tool, tr_tool); gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), - gdisp->gimage->unit); - - if (GIMP_DISPLAY_SHELL (gdisp->shell)->dot_for_dot) - gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), GIMP_UNIT_PIXEL); + GIMP_DISPLAY_SHELL (gdisp->shell)->unit); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0, gdisp->gimage->xresolution, FALSE); diff --git a/app/vectors/gimpvectors-export.c b/app/vectors/gimpvectors-export.c index dfbd71553b..9696fe2f78 100644 --- a/app/vectors/gimpvectors-export.c +++ b/app/vectors/gimpvectors-export.c @@ -171,6 +171,7 @@ gimp_vectors_export_image_size (const GimpImage *image, w = (gdouble) image->width / image->xresolution; h = (gdouble) image->height / image->yresolution; + /* FIXME: should probably use the display unit here */ unit = image->unit; switch (unit) { diff --git a/app/widgets/gimptoolbox-dnd.c b/app/widgets/gimptoolbox-dnd.c index eebdb96ba5..b78afcab9c 100644 --- a/app/widgets/gimptoolbox-dnd.c +++ b/app/widgets/gimptoolbox-dnd.c @@ -144,7 +144,7 @@ gimp_toolbox_drop_drawable (GtkWidget *widget, gimp_image_undo_enable (new_image); - gimp_create_display (gimage->gimp, new_image, 1.0); + gimp_create_display (gimage->gimp, new_image, GIMP_UNIT_PIXEL, 1.0); g_object_unref (new_image); } diff --git a/tools/pdbgen/pdb/display.pdb b/tools/pdbgen/pdb/display.pdb index 6dcd7a4ea4..7d19e5f25c 100644 --- a/tools/pdbgen/pdb/display.pdb +++ b/tools/pdbgen/pdb/display.pdb @@ -42,7 +42,8 @@ HELP %invoke = ( code => <<'CODE' { - display = (GimpDisplay *) gimp_create_display (gimp, gimage, 1.0); + display = (GimpDisplay *) gimp_create_display (gimp, + gimage, GIMP_UNIT_PIXEL, 1.0); success = (display != NULL); diff --git a/tools/pdbgen/pdb/image.pdb b/tools/pdbgen/pdb/image.pdb index 92a1c547b1..b118159399 100644 --- a/tools/pdbgen/pdb/image.pdb +++ b/tools/pdbgen/pdb/image.pdb @@ -1323,7 +1323,7 @@ my $unit_misc = <<'CODE'; $date = '1998'; CODE -&image_accessors('unit', 'unit', 'unit', 1, +&image_accessors('unit', 'unit (min GIMP_UNIT_INCH)', 'unit', 1, [ <