mirror of https://github.com/GNOME/gimp.git
Remember the settings in the scale and resize dialogs for images and
2006-10-14 Michael Natterer <mitch@gimp.org> Remember the settings in the scale and resize dialogs for images and layers. Fixes bug #164995, bug #316392, and bug #357424. * app/dialogs/scale-dialog.h: removed GimpScaleCallback typedef. * app/dialogs/dialogs-types.h: added it here. * app/dialogs/image-scale-dialog.[ch]: made the ImageScaleDialog struct private, return a GtkWidget* from image_scale_dialog_new() and use a GimpScaleCallback in the public API. * app/actions/actions-types.h: #include "dialogs/dialogs-types.h" * app/actions/image-commands.c: changed according to image scale dialog changes. Remember the scale dialog's unit (if it is "percent") and interpolation type across dialog invocations. Also remember the resize dialog's unit (if it is "percent"). * app/actions/layers-commands.c: remember scale and resize dialog stuff as in image-commands.c
This commit is contained in:
parent
1e5f8625a4
commit
76ba5de16a
25
ChangeLog
25
ChangeLog
|
@ -1,6 +1,29 @@
|
|||
2006-10-14 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/gimpgrid.c: don't include "libgimpbase/gimplimits.h"
|
||||
Remember the settings in the scale and resize dialogs for images
|
||||
and layers. Fixes bug #164995, bug #316392, and bug #357424.
|
||||
|
||||
* app/dialogs/scale-dialog.h: removed GimpScaleCallback typedef.
|
||||
|
||||
* app/dialogs/dialogs-types.h: added it here.
|
||||
|
||||
* app/dialogs/image-scale-dialog.[ch]: made the ImageScaleDialog
|
||||
struct private, return a GtkWidget* from image_scale_dialog_new()
|
||||
and use a GimpScaleCallback in the public API.
|
||||
|
||||
* app/actions/actions-types.h: #include "dialogs/dialogs-types.h"
|
||||
|
||||
* app/actions/image-commands.c: changed according to image scale
|
||||
dialog changes. Remember the scale dialog's unit (if it is
|
||||
"percent") and interpolation type across dialog invocations. Also
|
||||
remember the resize dialog's unit (if it is "percent").
|
||||
|
||||
* app/actions/layers-commands.c: remember scale and resize dialog
|
||||
stuff as in image-commands.c
|
||||
|
||||
2006-10-14 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/gimpgrid.c: don't #include "libgimpbase/gimplimits.h"
|
||||
|
||||
* app/core/gimpimage-undo-push.c: one more g_message() converted
|
||||
to gimp_message().
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#define __ACTIONS_TYPES_H__
|
||||
|
||||
|
||||
#include "dialogs/dialogs-types.h"
|
||||
#include "tools/tools-types.h"
|
||||
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
#include "actions-types.h"
|
||||
|
||||
#include "config/gimpcoreconfig.h"
|
||||
|
||||
#include "core/core-enums.h"
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpchannel.h"
|
||||
|
@ -89,7 +91,16 @@ static void image_print_size_callback (GtkWidget *dialog,
|
|||
gdouble yresolution,
|
||||
GimpUnit resolution_unit,
|
||||
gpointer data);
|
||||
static void image_scale_callback (ImageScaleDialog *dialog);
|
||||
static void image_scale_callback (GtkWidget *dialog,
|
||||
GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpUnit unit,
|
||||
GimpInterpolationType interpolation,
|
||||
gdouble xresolution,
|
||||
gdouble yresolution,
|
||||
GimpUnit resolution_unit,
|
||||
gpointer user_data);
|
||||
|
||||
static void image_merge_layers_response (GtkWidget *widget,
|
||||
gint response_id,
|
||||
|
@ -98,8 +109,11 @@ static void image_merge_layers_response (GtkWidget *widget,
|
|||
|
||||
/* private variables */
|
||||
|
||||
static GimpMergeType image_merge_layers_type = GIMP_EXPAND_AS_NECESSARY;
|
||||
static gboolean image_merge_layers_discard_invisible = FALSE;
|
||||
static GimpMergeType image_merge_layers_type = GIMP_EXPAND_AS_NECESSARY;
|
||||
static gboolean image_merge_layers_discard_invisible = FALSE;
|
||||
static GimpUnit image_resize_unit = GIMP_UNIT_PIXEL;
|
||||
static GimpUnit image_scale_unit = GIMP_UNIT_PIXEL;
|
||||
static GimpInterpolationType image_scale_interp = -1;
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
@ -215,7 +229,6 @@ image_resize_cmd_callback (GtkAction *action,
|
|||
GtkWidget *widget;
|
||||
GimpDisplay *display;
|
||||
GtkWidget *dialog;
|
||||
GimpUnit unit;
|
||||
return_if_no_image (image, data);
|
||||
return_if_no_widget (widget, data);
|
||||
return_if_no_display (display, data);
|
||||
|
@ -225,17 +238,15 @@ image_resize_cmd_callback (GtkAction *action,
|
|||
options->display = display;
|
||||
options->context = action_data_get_context (data);
|
||||
|
||||
unit = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (image),
|
||||
"scale-dialog-unit"));
|
||||
if (! unit)
|
||||
unit = GIMP_DISPLAY_SHELL (display->shell)->unit;
|
||||
if (image_resize_unit != GIMP_UNIT_PERCENT)
|
||||
image_resize_unit = GIMP_DISPLAY_SHELL (display->shell)->unit;
|
||||
|
||||
dialog = resize_dialog_new (GIMP_VIEWABLE (image),
|
||||
action_data_get_context (data),
|
||||
_("Set Image Canvas Size"), "gimp-image-resize",
|
||||
widget,
|
||||
gimp_standard_help_func, GIMP_HELP_IMAGE_RESIZE,
|
||||
unit,
|
||||
image_resize_unit,
|
||||
image_resize_callback,
|
||||
options);
|
||||
|
||||
|
@ -243,8 +254,7 @@ image_resize_cmd_callback (GtkAction *action,
|
|||
G_CALLBACK (gtk_widget_destroy),
|
||||
dialog, G_CONNECT_SWAPPED);
|
||||
|
||||
g_object_weak_ref (G_OBJECT (dialog),
|
||||
(GWeakNotify) g_free, options);
|
||||
g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) g_free, options);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
|
@ -301,22 +311,31 @@ void
|
|||
image_scale_cmd_callback (GtkAction *action,
|
||||
gpointer data)
|
||||
{
|
||||
ImageScaleDialog *dialog;
|
||||
GimpDisplay *display;
|
||||
GtkWidget *widget;
|
||||
GimpDisplay *display;
|
||||
GtkWidget *widget;
|
||||
GtkWidget *dialog;
|
||||
return_if_no_display (display, data);
|
||||
return_if_no_widget (widget, data);
|
||||
|
||||
dialog = image_scale_dialog_new (display->image, display,
|
||||
if (image_scale_unit != GIMP_UNIT_PERCENT)
|
||||
image_scale_unit = GIMP_DISPLAY_SHELL (display->shell)->unit;
|
||||
|
||||
if (image_scale_interp == -1)
|
||||
image_scale_interp = display->image->gimp->config->interpolation_type;
|
||||
|
||||
dialog = image_scale_dialog_new (display->image,
|
||||
action_data_get_context (data),
|
||||
widget,
|
||||
image_scale_callback);
|
||||
image_scale_unit,
|
||||
image_scale_interp,
|
||||
image_scale_callback,
|
||||
display);
|
||||
|
||||
g_signal_connect_object (display, "disconnect",
|
||||
G_CALLBACK (gtk_widget_destroy),
|
||||
dialog->dialog, G_CONNECT_SWAPPED);
|
||||
dialog, G_CONNECT_SWAPPED);
|
||||
|
||||
gtk_widget_show (dialog->dialog);
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -510,6 +529,8 @@ image_resize_callback (GtkWidget *dialog,
|
|||
{
|
||||
ImageResizeOptions *options = data;
|
||||
|
||||
image_resize_unit = unit;
|
||||
|
||||
if (width > 0 && height > 0)
|
||||
{
|
||||
GimpImage *image = GIMP_IMAGE (viewable);
|
||||
|
@ -519,11 +540,8 @@ 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)
|
||||
if (width == image->width &&
|
||||
height == image->height)
|
||||
return;
|
||||
|
||||
progress = gimp_progress_start (GIMP_PROGRESS (display),
|
||||
|
@ -573,54 +591,62 @@ image_print_size_callback (GtkWidget *dialog,
|
|||
gimp_image_flush (image);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
image_scale_callback (ImageScaleDialog *dialog)
|
||||
image_scale_callback (GtkWidget *dialog,
|
||||
GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpUnit unit,
|
||||
GimpInterpolationType interpolation,
|
||||
gdouble xresolution,
|
||||
gdouble yresolution,
|
||||
GimpUnit resolution_unit,
|
||||
gpointer user_data)
|
||||
{
|
||||
GimpImage *image = dialog->image;
|
||||
GimpImage *image = GIMP_IMAGE (viewable);
|
||||
|
||||
if (dialog->width == image->width &&
|
||||
dialog->height == image->height &&
|
||||
dialog->xresolution == image->xresolution &&
|
||||
dialog->yresolution == image->yresolution &&
|
||||
dialog->resolution_unit == image->resolution_unit)
|
||||
return;
|
||||
image_scale_unit = unit;
|
||||
image_scale_interp = interpolation;
|
||||
|
||||
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_IMAGE_SCALE,
|
||||
_("Scale Image"));
|
||||
|
||||
gimp_image_set_resolution (image,
|
||||
dialog->xresolution, dialog->yresolution);
|
||||
gimp_image_set_unit (image, dialog->resolution_unit);
|
||||
|
||||
if (dialog->width != image->width || dialog->height != image->height)
|
||||
if (width > 0 && height > 0)
|
||||
{
|
||||
if (dialog->width > 0 && dialog->height > 0)
|
||||
if (width == image->width &&
|
||||
height == image->height &&
|
||||
xresolution == image->xresolution &&
|
||||
yresolution == image->yresolution &&
|
||||
resolution_unit == image->resolution_unit)
|
||||
return;
|
||||
|
||||
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_IMAGE_SCALE,
|
||||
_("Scale Image"));
|
||||
|
||||
gimp_image_set_resolution (image, xresolution, yresolution);
|
||||
gimp_image_set_unit (image, resolution_unit);
|
||||
|
||||
if (width != image->width ||
|
||||
height != image->height)
|
||||
{
|
||||
GimpProgress *progress;
|
||||
|
||||
progress = gimp_progress_start (GIMP_PROGRESS (dialog->display),
|
||||
progress = gimp_progress_start (GIMP_PROGRESS (user_data),
|
||||
_("Scaling"), FALSE);
|
||||
|
||||
gimp_image_scale (image,
|
||||
dialog->width,
|
||||
dialog->height,
|
||||
dialog->interpolation,
|
||||
gimp_image_scale (image, width, height, interpolation,
|
||||
progress);
|
||||
|
||||
if (progress)
|
||||
gimp_progress_end (progress);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("Scale Error: "
|
||||
"Both width and height must be greater than zero.");
|
||||
}
|
||||
|
||||
gimp_image_undo_group_end (image);
|
||||
|
||||
gimp_image_flush (image);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("Scale Error: "
|
||||
"Both width and height must be greater than zero.");
|
||||
}
|
||||
|
||||
gimp_image_undo_group_end (image);
|
||||
|
||||
gimp_image_flush (image);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -136,10 +136,13 @@ static gint layers_mode_index (GimpLayerModeEffects layer_mode);
|
|||
|
||||
/* private variables */
|
||||
|
||||
static GimpFillType layer_fill_type = GIMP_TRANSPARENT_FILL;
|
||||
static gchar *layer_name = NULL;
|
||||
static GimpAddMaskType layer_add_mask_type = GIMP_ADD_WHITE_MASK;
|
||||
static gboolean layer_mask_invert = FALSE;
|
||||
static GimpFillType layer_fill_type = GIMP_TRANSPARENT_FILL;
|
||||
static gchar *layer_name = NULL;
|
||||
static GimpUnit layer_resize_unit = GIMP_UNIT_PIXEL;
|
||||
static GimpUnit layer_scale_unit = GIMP_UNIT_PIXEL;
|
||||
static GimpInterpolationType layer_scale_interp = -1;
|
||||
static GimpAddMaskType layer_add_mask_type = GIMP_ADD_WHITE_MASK;
|
||||
static gboolean layer_mask_invert = FALSE;
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
@ -513,28 +516,22 @@ void
|
|||
layers_resize_cmd_callback (GtkAction *action,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDisplay *display;
|
||||
GimpImage *image;
|
||||
GimpLayer *layer;
|
||||
GtkWidget *widget;
|
||||
GtkWidget *dialog;
|
||||
GimpUnit unit;
|
||||
GimpImage *image;
|
||||
GimpLayer *layer;
|
||||
GtkWidget *widget;
|
||||
GtkWidget *dialog;
|
||||
return_if_no_layer (image, layer, data);
|
||||
return_if_no_widget (widget, data);
|
||||
|
||||
display = GIMP_IS_DISPLAY (data) ? data : NULL;
|
||||
|
||||
unit = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (image),
|
||||
"scale-dialog-unit"));
|
||||
if (! unit)
|
||||
unit = display ? GIMP_DISPLAY_SHELL (display->shell)->unit : GIMP_UNIT_PIXEL;
|
||||
if (layer_resize_unit != GIMP_UNIT_PERCENT && GIMP_IS_DISPLAY (data))
|
||||
layer_resize_unit = GIMP_DISPLAY_SHELL (GIMP_DISPLAY (data)->shell)->unit;
|
||||
|
||||
dialog = resize_dialog_new (GIMP_VIEWABLE (layer),
|
||||
action_data_get_context (data),
|
||||
_("Set Layer Boundary Size"), "gimp-layer-resize",
|
||||
widget,
|
||||
gimp_standard_help_func, GIMP_HELP_LAYER_RESIZE,
|
||||
unit,
|
||||
layer_resize_unit,
|
||||
layers_resize_layer_callback,
|
||||
action_data_get_context (data));
|
||||
|
||||
|
@ -557,30 +554,28 @@ void
|
|||
layers_scale_cmd_callback (GtkAction *action,
|
||||
gpointer data)
|
||||
{
|
||||
GimpImage *image;
|
||||
GimpLayer *layer;
|
||||
GtkWidget *widget;
|
||||
GimpDisplay *display;
|
||||
GtkWidget *dialog;
|
||||
GimpUnit unit;
|
||||
GimpImage *image;
|
||||
GimpLayer *layer;
|
||||
GtkWidget *widget;
|
||||
GtkWidget *dialog;
|
||||
return_if_no_layer (image, layer, data);
|
||||
return_if_no_widget (widget, data);
|
||||
|
||||
display = action_data_get_display (data);
|
||||
if (layer_scale_unit != GIMP_UNIT_PERCENT && GIMP_IS_DISPLAY (data))
|
||||
layer_scale_unit = GIMP_DISPLAY_SHELL (GIMP_DISPLAY (data)->shell)->unit;
|
||||
|
||||
unit = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (image),
|
||||
"scale-dialog-unit"));
|
||||
if (! unit)
|
||||
unit = display ? GIMP_DISPLAY_SHELL (display->shell)->unit : GIMP_UNIT_PIXEL;
|
||||
if (layer_scale_interp == -1)
|
||||
layer_scale_interp = image->gimp->config->interpolation_type;
|
||||
|
||||
dialog = scale_dialog_new (GIMP_VIEWABLE (layer),
|
||||
action_data_get_context (data),
|
||||
_("Scale Layer"), "gimp-layer-scale",
|
||||
widget,
|
||||
gimp_standard_help_func, GIMP_HELP_LAYER_SCALE,
|
||||
unit, image->gimp->config->interpolation_type,
|
||||
layer_scale_unit,
|
||||
layer_scale_interp,
|
||||
layers_scale_layer_callback,
|
||||
display);
|
||||
GIMP_IS_DISPLAY (data) ? data : NULL);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
|
@ -1028,6 +1023,9 @@ layers_scale_layer_callback (GtkWidget *dialog,
|
|||
{
|
||||
GimpDisplay *display = GIMP_DISPLAY (data);
|
||||
|
||||
layer_scale_unit = unit;
|
||||
layer_scale_interp = interpolation;
|
||||
|
||||
if (width > 0 && height > 0)
|
||||
{
|
||||
GimpItem *item = GIMP_ITEM (viewable);
|
||||
|
@ -1036,11 +1034,8 @@ 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))
|
||||
if (width == gimp_item_width (item) &&
|
||||
height == gimp_item_height (item))
|
||||
return;
|
||||
|
||||
if (display)
|
||||
|
@ -1069,8 +1064,8 @@ layers_scale_layer_callback (GtkWidget *dialog,
|
|||
}
|
||||
else
|
||||
{
|
||||
gimp_message (display->image->gimp, NULL, GIMP_MESSAGE_ERROR,
|
||||
"Invalid width or height. Both must be positive.");
|
||||
g_warning ("Scale Error: "
|
||||
"Both width and height must be greater than zero.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1087,29 +1082,27 @@ layers_resize_layer_callback (GtkWidget *dialog,
|
|||
{
|
||||
GimpContext *context = GIMP_CONTEXT (data);
|
||||
|
||||
layer_resize_unit = unit;
|
||||
|
||||
if (width > 0 && height > 0)
|
||||
{
|
||||
GimpItem *item = GIMP_ITEM (viewable);
|
||||
|
||||
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))
|
||||
if (width == gimp_item_width (item) &&
|
||||
height == gimp_item_height (item))
|
||||
return;
|
||||
|
||||
gimp_item_resize (item,
|
||||
context,
|
||||
gimp_item_resize (item, context,
|
||||
width, height, offset_x, offset_y);
|
||||
|
||||
gimp_image_flush (gimp_item_get_image (item));
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_message (context->gimp, NULL, GIMP_MESSAGE_ERROR,
|
||||
"Invalid width or height. Both must be positive.");
|
||||
g_warning ("Resize Error: "
|
||||
"Both width and height must be greater than zero.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,4 +23,16 @@
|
|||
#include "display/display-types.h"
|
||||
|
||||
|
||||
typedef void (* GimpScaleCallback) (GtkWidget *dialog,
|
||||
GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpUnit unit,
|
||||
GimpInterpolationType interpolation,
|
||||
gdouble xresolution,
|
||||
gdouble yresolution,
|
||||
GimpUnit resolution_unit,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
#endif /* __DIALOGS_TYPES_H__ */
|
||||
|
|
|
@ -36,9 +36,6 @@
|
|||
#include "widgets/gimpmessagebox.h"
|
||||
#include "widgets/gimpmessagedialog.h"
|
||||
|
||||
#include "display/gimpdisplay.h"
|
||||
#include "display/gimpdisplayshell.h"
|
||||
|
||||
#include "scale-dialog.h"
|
||||
|
||||
#include "image-scale-dialog.h"
|
||||
|
@ -46,16 +43,36 @@
|
|||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
static void image_scale_callback (GtkWidget *widget,
|
||||
GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpUnit unit,
|
||||
GimpInterpolationType interpolation,
|
||||
gdouble xresolution,
|
||||
gdouble yresolution,
|
||||
GimpUnit resolution_unit,
|
||||
gpointer data);
|
||||
typedef struct _ImageScaleDialog ImageScaleDialog;
|
||||
|
||||
struct _ImageScaleDialog
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
GimpImage *image;
|
||||
|
||||
gint width;
|
||||
gint height;
|
||||
GimpUnit unit;
|
||||
GimpInterpolationType interpolation;
|
||||
gdouble xresolution;
|
||||
gdouble yresolution;
|
||||
GimpUnit resolution_unit;
|
||||
|
||||
GimpScaleCallback callback;
|
||||
gpointer user_data;
|
||||
};
|
||||
|
||||
static void image_scale_callback (GtkWidget *widget,
|
||||
GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpUnit unit,
|
||||
GimpInterpolationType interpolation,
|
||||
gdouble xresolution,
|
||||
gdouble yresolution,
|
||||
GimpUnit resolution_unit,
|
||||
gpointer data);
|
||||
|
||||
static GtkWidget * image_scale_confirm_dialog (ImageScaleDialog *dialog);
|
||||
static void image_scale_confirm_large (ImageScaleDialog *dialog,
|
||||
|
@ -66,50 +83,44 @@ static void image_scale_confirm_response (GtkWidget *widget,
|
|||
gint response_id,
|
||||
ImageScaleDialog *dialog);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
ImageScaleDialog *
|
||||
image_scale_dialog_new (GimpImage *image,
|
||||
GimpDisplay *display,
|
||||
GimpContext *context,
|
||||
GtkWidget *parent,
|
||||
ImageScaleDialogCallback callback)
|
||||
GtkWidget *
|
||||
image_scale_dialog_new (GimpImage *image,
|
||||
GimpContext *context,
|
||||
GtkWidget *parent,
|
||||
GimpUnit unit,
|
||||
GimpInterpolationType interpolation,
|
||||
GimpScaleCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
ImageScaleDialog *dialog;
|
||||
GimpUnit unit;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_DISPLAY (display), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
||||
g_return_val_if_fail (callback != NULL, NULL);
|
||||
|
||||
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->image = image;
|
||||
dialog->dialog = scale_dialog_new (GIMP_VIEWABLE (image), context,
|
||||
Q_("dialog-title|Scale Image"),
|
||||
"gimp-image-scale",
|
||||
parent,
|
||||
gimp_standard_help_func,
|
||||
GIMP_HELP_IMAGE_SCALE,
|
||||
unit,
|
||||
interpolation,
|
||||
image_scale_callback,
|
||||
dialog);
|
||||
|
||||
dialog->image = image;
|
||||
dialog->display = display;
|
||||
dialog->context = context;
|
||||
dialog->dialog = scale_dialog_new (GIMP_VIEWABLE (display->image), context,
|
||||
Q_("dialog-title|Scale Image"),
|
||||
"gimp-image-scale",
|
||||
parent,
|
||||
gimp_standard_help_func,
|
||||
GIMP_HELP_IMAGE_SCALE,
|
||||
unit,
|
||||
image->gimp->config->interpolation_type,
|
||||
image_scale_callback,
|
||||
dialog);
|
||||
g_object_weak_ref (G_OBJECT (dialog->dialog), (GWeakNotify) g_free, dialog);
|
||||
|
||||
g_object_weak_ref (G_OBJECT (dialog->dialog),
|
||||
(GWeakNotify) g_free, dialog);
|
||||
dialog->callback = callback;
|
||||
dialog->user_data = user_data;
|
||||
|
||||
dialog->callback = callback;
|
||||
|
||||
return dialog;
|
||||
return dialog->dialog;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -157,7 +168,16 @@ image_scale_callback (GtkWidget *widget,
|
|||
|
||||
case GIMP_IMAGE_SCALE_OK:
|
||||
/* If all is well, return directly after scaling image. */
|
||||
dialog->callback (dialog);
|
||||
dialog->callback (dialog->dialog,
|
||||
GIMP_VIEWABLE (dialog->image),
|
||||
dialog->width,
|
||||
dialog->height,
|
||||
dialog->unit,
|
||||
dialog->interpolation,
|
||||
dialog->xresolution,
|
||||
dialog->yresolution,
|
||||
dialog->resolution_unit,
|
||||
dialog->user_data);
|
||||
gtk_widget_destroy (widget);
|
||||
|
||||
/* remember the last used unit */
|
||||
|
@ -184,15 +204,15 @@ image_scale_confirm_dialog (ImageScaleDialog *dialog)
|
|||
|
||||
NULL);
|
||||
|
||||
g_signal_connect (widget, "response",
|
||||
G_CALLBACK (image_scale_confirm_response),
|
||||
dialog);
|
||||
|
||||
gtk_dialog_set_alternative_button_order (GTK_DIALOG (widget),
|
||||
GTK_RESPONSE_OK,
|
||||
GTK_RESPONSE_CANCEL,
|
||||
-1);
|
||||
|
||||
g_signal_connect (widget, "response",
|
||||
G_CALLBACK (image_scale_confirm_response),
|
||||
dialog);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
|
@ -245,7 +265,16 @@ image_scale_confirm_response (GtkWidget *widget,
|
|||
|
||||
if (response_id == GTK_RESPONSE_OK)
|
||||
{
|
||||
dialog->callback (dialog);
|
||||
dialog->callback (dialog->dialog,
|
||||
GIMP_VIEWABLE (dialog->image),
|
||||
dialog->width,
|
||||
dialog->height,
|
||||
dialog->unit,
|
||||
dialog->interpolation,
|
||||
dialog->xresolution,
|
||||
dialog->yresolution,
|
||||
dialog->resolution_unit,
|
||||
dialog->user_data);
|
||||
gtk_widget_destroy (dialog->dialog);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -16,39 +16,17 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __IMAGE_SCALE_LAYERS_DIALOG_H__
|
||||
#define __IMAGE_SCALE_LAYERS_DIALOG_H__
|
||||
#ifndef __IMAGE_SCALE_DIALOG_H__
|
||||
#define __IMAGE_SCALE_DIALOG_H__
|
||||
|
||||
|
||||
typedef struct _ImageScaleDialog ImageScaleDialog;
|
||||
|
||||
typedef void (* ImageScaleDialogCallback) (ImageScaleDialog *dialog);
|
||||
|
||||
struct _ImageScaleDialog
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
GimpImage *image;
|
||||
GimpDisplay *display;
|
||||
GimpContext *context;
|
||||
|
||||
gint width;
|
||||
gint height;
|
||||
GimpUnit unit;
|
||||
GimpInterpolationType interpolation;
|
||||
gdouble xresolution;
|
||||
gdouble yresolution;
|
||||
GimpUnit resolution_unit;
|
||||
|
||||
ImageScaleDialogCallback callback;
|
||||
};
|
||||
|
||||
|
||||
ImageScaleDialog * image_scale_dialog_new (GimpImage *image,
|
||||
GimpDisplay *display,
|
||||
GimpContext *context,
|
||||
GtkWidget *parent,
|
||||
ImageScaleDialogCallback callback);
|
||||
GtkWidget * image_scale_dialog_new (GimpImage *image,
|
||||
GimpContext *context,
|
||||
GtkWidget *parent,
|
||||
GimpUnit unit,
|
||||
GimpInterpolationType interpolation,
|
||||
GimpScaleCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
#endif /* __IMAGE_SCALE_DIALOG_H__ */
|
||||
|
|
|
@ -20,18 +20,6 @@
|
|||
#define __SCALE_DIALOG_H__
|
||||
|
||||
|
||||
typedef void (* GimpScaleCallback) (GtkWidget *dialog,
|
||||
GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpUnit unit,
|
||||
GimpInterpolationType interpolation,
|
||||
gdouble xresolution,
|
||||
gdouble yresolution,
|
||||
GimpUnit resolution_unit,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
GtkWidget * scale_dialog_new (GimpViewable *viewable,
|
||||
GimpContext *context,
|
||||
const gchar *title,
|
||||
|
|
Loading…
Reference in New Issue