Commit 8a59640b authored by Michael Natterer's avatar Michael Natterer 😴

app: remove helper struct ImageResizeOptions

Instead, pass a GimpContext in GimpResizeCallback, it's needed
in all callbacks anyway.
parent 3f1104b6
......@@ -75,17 +75,11 @@
#include "gimp-intl.h"
typedef struct
{
GimpContext *context;
GimpDisplay *display;
} ImageResizeOptions;
/* local function prototypes */
static void image_resize_callback (GtkWidget *dialog,
GimpViewable *viewable,
GimpContext *context,
gint width,
gint height,
GimpUnit unit,
......@@ -93,15 +87,14 @@ static void image_resize_callback (GtkWidget *dialog,
gint offset_y,
GimpItemSet layer_set,
gboolean resize_text_layers,
gpointer data);
static void image_resize_options_free (ImageResizeOptions *options);
gpointer user_data);
static void image_print_size_callback (GtkWidget *dialog,
GimpImage *image,
gdouble xresolution,
gdouble yresolution,
GimpUnit resolution_unit,
gpointer data);
gpointer user_data);
static void image_scale_callback (GtkWidget *dialog,
GimpViewable *viewable,
......@@ -498,20 +491,14 @@ void
image_resize_cmd_callback (GtkAction *action,
gpointer data)
{
ImageResizeOptions *options;
GimpImage *image;
GtkWidget *widget;
GimpDisplay *display;
GtkWidget *dialog;
GimpImage *image;
GtkWidget *widget;
GimpDisplay *display;
GtkWidget *dialog;
return_if_no_image (image, data);
return_if_no_widget (widget, data);
return_if_no_display (display, data);
options = g_slice_new (ImageResizeOptions);
options->display = display;
options->context = action_data_get_context (data);
if (image_resize_unit != GIMP_UNIT_PERCENT)
image_resize_unit = gimp_display_get_shell (display)->unit;
......@@ -522,15 +509,12 @@ image_resize_cmd_callback (GtkAction *action,
gimp_standard_help_func, GIMP_HELP_IMAGE_RESIZE,
image_resize_unit,
image_resize_callback,
options);
display);
g_signal_connect_object (display, "disconnect",
G_CALLBACK (gtk_widget_destroy),
dialog, G_CONNECT_SWAPPED);
g_object_weak_ref (G_OBJECT (dialog),
(GWeakNotify) image_resize_options_free, options);
gtk_widget_show (dialog);
}
......@@ -850,7 +834,7 @@ image_configure_grid_cmd_callback (GtkAction *action,
dialog = grid_dialog_new (image,
action_data_get_context (data),
GTK_WIDGET (shell));
gtk_widget_get_toplevel (GTK_WIDGET (shell)));
dialogs_attach_dialog (G_OBJECT (image), GRID_DIALOG_KEY, dialog);
}
......@@ -862,23 +846,27 @@ void
image_properties_cmd_callback (GtkAction *action,
gpointer data)
{
GimpDisplay *display;
GimpImage *image;
GimpDisplayShell *shell;
GtkWidget *dialog;
GimpDisplay *display;
GimpImage *image;
GtkWidget *dialog;
return_if_no_display (display, data);
image = gimp_display_get_image (display);
shell = gimp_display_get_shell (display);
dialog = image_properties_dialog_new (image,
action_data_get_context (data),
GTK_WIDGET (shell));
#define PROPERTIES_DIALOG_KEY "gimp-image-properties-dialog"
dialog = dialogs_get_dialog (G_OBJECT (image), PROPERTIES_DIALOG_KEY);
if (! dialog)
{
GimpDisplayShell *shell = gimp_display_get_shell (display);
dialog = image_properties_dialog_new (image,
action_data_get_context (data),
gtk_widget_get_toplevel (GTK_WIDGET (shell)));
gtk_window_set_transient_for (GTK_WINDOW (dialog),
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (shell))));
gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog),
TRUE);
dialogs_attach_dialog (G_OBJECT (image), PROPERTIES_DIALOG_KEY, dialog);
}
gtk_window_present (GTK_WINDOW (dialog));
}
......@@ -889,6 +877,7 @@ image_properties_cmd_callback (GtkAction *action,
static void
image_resize_callback (GtkWidget *dialog,
GimpViewable *viewable,
GimpContext *context,
gint width,
gint height,
GimpUnit unit,
......@@ -896,17 +885,15 @@ image_resize_callback (GtkWidget *dialog,
gint offset_y,
GimpItemSet layer_set,
gboolean resize_text_layers,
gpointer data)
gpointer user_data)
{
ImageResizeOptions *options = data;
GimpDisplay *display = user_data;
image_resize_unit = unit;
if (width > 0 && height > 0)
{
GimpImage *image = GIMP_IMAGE (viewable);
GimpDisplay *display = options->display;
GimpContext *context = options->context;
GimpImage *image = GIMP_IMAGE (viewable);
GimpProgress *progress;
gtk_widget_destroy (dialog);
......@@ -937,12 +924,6 @@ image_resize_callback (GtkWidget *dialog,
}
}
static void
image_resize_options_free (ImageResizeOptions *options)
{
g_slice_free (ImageResizeOptions, options);
}
static void
image_print_size_callback (GtkWidget *dialog,
GimpImage *image,
......
......@@ -133,9 +133,10 @@ static void layers_scale_layer_callback (GtkWidget *dialog,
gdouble xresolution,
gdouble yresolution,
GimpUnit resolution_unit,
gpointer data);
gpointer user_data);
static void layers_resize_layer_callback (GtkWidget *dialog,
GimpViewable *viewable,
GimpContext *context,
gint width,
gint height,
GimpUnit unit,
......@@ -643,7 +644,7 @@ layers_resize_cmd_callback (GtkAction *action,
GIMP_HELP_LAYER_RESIZE,
layer_resize_unit,
layers_resize_layer_callback,
action_data_get_context (data));
NULL);
dialogs_attach_dialog (G_OBJECT (layer), RESIZE_DIALOG_KEY, dialog);
}
......@@ -1241,9 +1242,9 @@ layers_scale_layer_callback (GtkWidget *dialog,
gdouble xresolution, /* unused */
gdouble yresolution, /* unused */
GimpUnit resolution_unit,/* unused */
gpointer data)
gpointer user_data)
{
GimpDisplay *display = GIMP_DISPLAY (data);
GimpDisplay *display = GIMP_DISPLAY (user_data);
layer_scale_unit = unit;
layer_scale_interp = interpolation;
......@@ -1294,6 +1295,7 @@ layers_scale_layer_callback (GtkWidget *dialog,
static void
layers_resize_layer_callback (GtkWidget *dialog,
GimpViewable *viewable,
GimpContext *context,
gint width,
gint height,
GimpUnit unit,
......@@ -1301,10 +1303,8 @@ layers_resize_layer_callback (GtkWidget *dialog,
gint offset_y,
GimpItemSet unused,
gboolean unused2,
gpointer data)
gpointer user_data)
{
GimpContext *context = GIMP_CONTEXT (data);
layer_resize_unit = unit;
if (width > 0 && height > 0)
......
......@@ -46,6 +46,7 @@
typedef struct
{
GimpViewable *viewable;
GimpContext *context;
gint old_width;
gint old_height;
GimpUnit old_unit;
......@@ -135,6 +136,18 @@ resize_dialog_new (GimpViewable *viewable,
g_return_val_if_reached (NULL);
}
private = g_slice_new0 (ResizeDialog);
private->viewable = viewable;
private->context = context;
private->old_width = width;
private->old_height = height;
private->old_unit = unit;
private->layer_set = GIMP_ITEM_SET_NONE;
private->resize_text_layers = FALSE;
private->callback = callback;
private->user_data = user_data;
dialog = gimp_viewable_dialog_new (viewable, context,
title, role, GIMP_STOCK_RESIZE, title,
parent,
......@@ -154,19 +167,12 @@ resize_dialog_new (GimpViewable *viewable,
GTK_RESPONSE_CANCEL,
-1);
private = g_slice_new0 (ResizeDialog);
g_object_weak_ref (G_OBJECT (dialog),
(GWeakNotify) resize_dialog_free, private);
private->viewable = viewable;
private->old_width = width;
private->old_height = height;
private->old_unit = unit;
private->layer_set = GIMP_ITEM_SET_NONE;
private->resize_text_layers = FALSE;
private->callback = callback;
private->user_data = user_data;
g_signal_connect (dialog, "response",
G_CALLBACK (resize_dialog_response),
private);
gimp_image_get_resolution (image, &xres, &yres);
......@@ -180,10 +186,6 @@ resize_dialog_new (GimpViewable *viewable,
"edit-resolution", FALSE,
NULL);
g_signal_connect (dialog, "response",
G_CALLBACK (resize_dialog_response),
private);
main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
......@@ -352,6 +354,7 @@ resize_dialog_response (GtkWidget *dialog,
private->callback (dialog,
private->viewable,
private->context,
width,
height,
unit,
......
......@@ -21,6 +21,7 @@
typedef void (* GimpResizeCallback) (GtkWidget *dialog,
GimpViewable *viewable,
GimpContext *context,
gint width,
gint height,
GimpUnit unit,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment