mirror of https://github.com/GNOME/gimp.git
app/actions/image-commands.c app/actions/layers-commands.c
2005-08-24 Sven Neumann <sven@gimp.org> * app/actions/image-commands.c * app/actions/layers-commands.c * app/dialogs/image-scale-dialog.c * app/dialogs/resize-dialog.[ch]: remember the selected unit for scale and resize dialogs on a per-image basis (bug #312950).
This commit is contained in:
parent
dff3e7584e
commit
ad5287c3ba
|
@ -78,6 +78,7 @@ static void image_resize_callback (GtkWidget *dialog,
|
|||
GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpUnit unit,
|
||||
gint offset_x,
|
||||
gint offset_y,
|
||||
GimpImageResizeLayers resize_layers,
|
||||
|
@ -177,11 +178,12 @@ image_resize_cmd_callback (GtkAction *action,
|
|||
gpointer data)
|
||||
{
|
||||
ImageResizeOptions *options;
|
||||
GimpImage *gimage;
|
||||
GimpImage *image;
|
||||
GtkWidget *widget;
|
||||
GimpDisplay *gdisp;
|
||||
GtkWidget *dialog;
|
||||
return_if_no_image (gimage, data);
|
||||
GimpUnit unit;
|
||||
return_if_no_image (image, data);
|
||||
return_if_no_widget (widget, data);
|
||||
return_if_no_display (gdisp, data);
|
||||
|
||||
|
@ -190,11 +192,16 @@ image_resize_cmd_callback (GtkAction *action,
|
|||
options->gdisp = gdisp;
|
||||
options->context = action_data_get_context (data);
|
||||
|
||||
dialog = resize_dialog_new (GIMP_VIEWABLE (gimage),
|
||||
unit = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (image),
|
||||
"scale-dialog-unit"));
|
||||
if (! unit)
|
||||
unit = GIMP_DISPLAY_SHELL (gdisp->shell)->unit;
|
||||
|
||||
dialog = resize_dialog_new (GIMP_VIEWABLE (image),
|
||||
_("Set Image Canvas Size"), "gimp-image-resize",
|
||||
widget,
|
||||
gimp_standard_help_func, GIMP_HELP_IMAGE_RESIZE,
|
||||
GIMP_DISPLAY_SHELL (gdisp->shell)->unit,
|
||||
unit,
|
||||
image_resize_callback,
|
||||
options);
|
||||
|
||||
|
@ -452,6 +459,7 @@ image_resize_callback (GtkWidget *dialog,
|
|||
GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpUnit unit,
|
||||
gint offset_x,
|
||||
gint offset_y,
|
||||
GimpImageResizeLayers resize_layers,
|
||||
|
@ -468,6 +476,10 @@ image_resize_callback (GtkWidget *dialog,
|
|||
|
||||
gtk_widget_destroy (dialog);
|
||||
|
||||
/* remember the last used unit */
|
||||
g_object_set_data (G_OBJECT (image),
|
||||
"scale-dialog-unit", GINT_TO_POINTER (unit));
|
||||
|
||||
if (width == image->width && height == image->height)
|
||||
return;
|
||||
|
||||
|
|
|
@ -123,6 +123,7 @@ static void layers_resize_layer_callback (GtkWidget *dialog,
|
|||
GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpUnit unit,
|
||||
gint offset_x,
|
||||
gint offset_y,
|
||||
GimpImageResizeLayers unused,
|
||||
|
@ -459,22 +460,26 @@ layers_resize_cmd_callback (GtkAction *action,
|
|||
gpointer data)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
GimpImage *gimage;
|
||||
GimpImage *image;
|
||||
GimpLayer *layer;
|
||||
GtkWidget *widget;
|
||||
GtkWidget *dialog;
|
||||
return_if_no_layer (gimage, layer, data);
|
||||
GimpUnit unit;
|
||||
return_if_no_layer (image, layer, data);
|
||||
return_if_no_widget (widget, data);
|
||||
|
||||
gdisp = GIMP_IS_DISPLAY (data) ? data : NULL;
|
||||
|
||||
unit = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (image),
|
||||
"scale-dialog-unit"));
|
||||
if (! unit)
|
||||
unit = gdisp ? GIMP_DISPLAY_SHELL (gdisp->shell)->unit : GIMP_UNIT_PIXEL;
|
||||
|
||||
dialog = resize_dialog_new (GIMP_VIEWABLE (layer),
|
||||
_("Set Layer Boundary Size"), "gimp-layer-resize",
|
||||
widget,
|
||||
gimp_standard_help_func, GIMP_HELP_LAYER_RESIZE,
|
||||
(gdisp ?
|
||||
GIMP_DISPLAY_SHELL (gdisp->shell)->unit :
|
||||
GIMP_UNIT_PIXEL),
|
||||
unit,
|
||||
layers_resize_layer_callback,
|
||||
action_data_get_context (data));
|
||||
|
||||
|
@ -497,24 +502,27 @@ void
|
|||
layers_scale_cmd_callback (GtkAction *action,
|
||||
gpointer data)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
GimpImage *image;
|
||||
GimpLayer *layer;
|
||||
GtkWidget *widget;
|
||||
GimpDisplay *gdisp;
|
||||
GtkWidget *dialog;
|
||||
GimpUnit unit;
|
||||
return_if_no_layer (gimage, layer, data);
|
||||
return_if_no_layer (image, layer, data);
|
||||
return_if_no_widget (widget, data);
|
||||
|
||||
gdisp = action_data_get_display (data);
|
||||
|
||||
unit = gdisp ? GIMP_DISPLAY_SHELL (gdisp->shell)->unit : GIMP_UNIT_PIXEL;
|
||||
unit = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (image),
|
||||
"scale-dialog-unit"));
|
||||
if (! unit)
|
||||
unit = gdisp ? GIMP_DISPLAY_SHELL (gdisp->shell)->unit : GIMP_UNIT_PIXEL;
|
||||
|
||||
dialog = scale_dialog_new (GIMP_VIEWABLE (layer),
|
||||
_("Scale Layer"), "gimp-layer-scale",
|
||||
widget,
|
||||
gimp_standard_help_func, GIMP_HELP_LAYER_SCALE,
|
||||
unit, gimage->gimp->config->interpolation_type,
|
||||
unit, image->gimp->config->interpolation_type,
|
||||
layers_scale_layer_callback,
|
||||
gdisp);
|
||||
|
||||
|
@ -960,6 +968,10 @@ layers_scale_layer_callback (GtkWidget *dialog,
|
|||
|
||||
gtk_widget_destroy (dialog);
|
||||
|
||||
/* remember the last used unit */
|
||||
g_object_set_data (G_OBJECT (gimp_item_get_image (item)),
|
||||
"scale-dialog-unit", GINT_TO_POINTER (unit));
|
||||
|
||||
if (width == gimp_item_width (item) && height == gimp_item_height (item))
|
||||
return;
|
||||
|
||||
|
@ -998,6 +1010,7 @@ layers_resize_layer_callback (GtkWidget *dialog,
|
|||
GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpUnit unit,
|
||||
gint offset_x,
|
||||
gint offset_y,
|
||||
GimpImageResizeLayers unused,
|
||||
|
@ -1011,6 +1024,10 @@ layers_resize_layer_callback (GtkWidget *dialog,
|
|||
|
||||
gtk_widget_destroy (dialog);
|
||||
|
||||
/* remember the last used unit */
|
||||
g_object_set_data (G_OBJECT (gimp_item_get_image (item)),
|
||||
"scale-dialog-unit", GINT_TO_POINTER (unit));
|
||||
|
||||
if (width == gimp_item_width (item) && height == gimp_item_height (item))
|
||||
return;
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ image_scale_dialog_new (GimpImage *image,
|
|||
ImageScaleDialogCallback callback)
|
||||
{
|
||||
ImageScaleDialog *dialog;
|
||||
GimpUnit unit;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_DISPLAY (display), NULL);
|
||||
|
@ -84,6 +85,11 @@ image_scale_dialog_new (GimpImage *image,
|
|||
|
||||
dialog = g_new0 (ImageScaleDialog, 1);
|
||||
|
||||
unit = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (image),
|
||||
"scale-dialog-unit"));
|
||||
if (! unit)
|
||||
unit = GIMP_DISPLAY_SHELL (display->shell)->unit;
|
||||
|
||||
dialog->gimage = image;
|
||||
dialog->gdisp = display;
|
||||
dialog->context = context;
|
||||
|
@ -92,7 +98,7 @@ image_scale_dialog_new (GimpImage *image,
|
|||
parent,
|
||||
gimp_standard_help_func,
|
||||
GIMP_HELP_IMAGE_SCALE,
|
||||
GIMP_DISPLAY_SHELL (display->shell)->unit,
|
||||
unit,
|
||||
image->gimp->config->interpolation_type,
|
||||
image_scale_callback,
|
||||
dialog);
|
||||
|
@ -152,6 +158,10 @@ image_scale_callback (GtkWidget *widget,
|
|||
/* If all is well, return directly after scaling image. */
|
||||
dialog->callback (dialog);
|
||||
gtk_widget_destroy (widget);
|
||||
|
||||
/* remember the last used unit */
|
||||
g_object_set_data (G_OBJECT (image),
|
||||
"scale-dialog-unit", GINT_TO_POINTER (unit));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -311,6 +311,7 @@ resize_dialog_response (GtkWidget *dialog,
|
|||
ResizeDialog *private)
|
||||
{
|
||||
GimpSizeEntry *entry = GIMP_SIZE_ENTRY (private->offset);
|
||||
GimpUnit unit;
|
||||
gint width;
|
||||
gint height;
|
||||
|
||||
|
@ -324,12 +325,14 @@ resize_dialog_response (GtkWidget *dialog,
|
|||
g_object_get (private->box,
|
||||
"width", &width,
|
||||
"height", &height,
|
||||
"unit", &unit,
|
||||
NULL);
|
||||
|
||||
private->callback (dialog,
|
||||
private->viewable,
|
||||
width,
|
||||
height,
|
||||
unit,
|
||||
gimp_size_entry_get_refval (entry, 0),
|
||||
gimp_size_entry_get_refval (entry, 1),
|
||||
private->resize_layers,
|
||||
|
|
|
@ -24,6 +24,7 @@ typedef void (* GimpResizeCallback) (GtkWidget *dialog,
|
|||
GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpUnit unit,
|
||||
gint offset_x,
|
||||
gint offset_y,
|
||||
GimpImageResizeLayers resize_layers,
|
||||
|
|
Loading…
Reference in New Issue