Commit c509204b authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

tools/pdbgen/pdb/image.pdb app/pdb/image_cmds.c reverted changes I did to

2004-06-01  Sven Neumann  <sven@gimp.org>

	* 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.
parent 20b16129
2004-06-01 Sven Neumann <sven@gimp.org>
* 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 <mitch@gimp.org>
* tools/pdbgen/pdb/gradient_edit.pdb: use enums instead of
......
......@@ -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);
}
......
......@@ -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);
}
}
......
......@@ -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);
......
......@@ -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);
......
......@@ -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
......
......@@ -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 \
......
......@@ -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;
......
......@@ -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);
}
......
......@@ -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,
......
/* 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 <glib-object.h>
#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);
}
/* 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__ */
......@@ -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;
}
......
......@@ -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 */
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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;
/* width and height */
unit_factor = gimp_image_unit_get_factor (gimage);
unit_digits = gimp_image_unit_get_digits (gimage);
unit_factor = _gimp_unit_get_factor (image->gimp, unit);
unit_digits = _gimp_unit_get_digits (image->gimp, unit);
/* width and height */
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;