Commit 51687bba authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

Wishlist item #57812:

2001-11-16  Michael Natterer  <mitch@gimp.org>

	Wishlist item #57812:

	* app/core/gimpimage.[ch]: added a progress_callback to
	gimp_image_scale().

	* app/gui/gui.c
	* app/gui/image-commands.c
	* app/gui/resize-dialog.h
	* tools/pdbgen/pdb/image.pdb: changed accordingly.

	* app/core/gimp.[ch]: found that gimp->busy needs to be a counter,
	not a boolean, so nested calls work.

	* app/pdb/image_cmds.c: regenerated.
parent 4403d58a
2001-11-16 Michael Natterer <mitch@gimp.org>
Wishlist item #57812:
* app/core/gimpimage.[ch]: added a progress_callback to
gimp_image_scale().
* app/gui/gui.c
* app/gui/image-commands.c
* app/gui/resize-dialog.h
* tools/pdbgen/pdb/image.pdb: changed accordingly.
* app/core/gimp.[ch]: found that gimp->busy needs to be a counter,
not a boolean, so nested calls work.
* app/pdb/image_cmds.c: regenerated.
2001-11-16 Michael Natterer <mitch@gimp.org>
Wishlist item #57669:
......
......@@ -41,11 +41,20 @@
#include "offset-dialog.h"
#include "resize-dialog.h"
#include "gimpprogress.h"
#include "undo.h"
#include "libgimp/gimpintl.h"
typedef struct
{
Resize *resize;
GimpDisplay *gdisp;
GimpImage *gimage;
} ImageResize;
#define return_if_no_display(gdisp,data) \
gdisp = gimp_context_get_display (gimp_get_user_context (GIMP (data))); \
if (! gdisp) \
......@@ -199,11 +208,12 @@ image_resize_cmd_callback (GtkWidget *widget,
image_resize = g_new0 (ImageResize, 1);
image_resize->gdisp = gdisp;
image_resize->gimage = gimage;
image_resize->resize = resize_widget_new (gimage,
ResizeWidget,
ResizeImage,
G_OBJECT (gimage),
G_OBJECT (gdisp),
"disconnect",
gimage->width,
gimage->height,
......@@ -235,11 +245,12 @@ image_scale_cmd_callback (GtkWidget *widget,
image_scale = g_new0 (ImageResize, 1);
image_scale->gdisp = gdisp;
image_scale->gimage = gimage;
image_scale->resize = resize_widget_new (gimage,
ScaleWidget,
ResizeImage,
G_OBJECT (gimage),
G_OBJECT (gdisp),
"disconnect",
gimage->width,
gimage->height,
......@@ -415,12 +426,21 @@ image_scale_implement (ImageResize *image_scale)
if (image_scale->resize->width > 0 &&
image_scale->resize->height > 0)
{
GimpProgress *progress;
if (! display_flush)
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
progress = progress_start (image_scale->gdisp,
_("Scaling..."),
TRUE, NULL, NULL);
gimp_image_scale (gimage,
image_scale->resize->width,
image_scale->resize->height);
image_scale->resize->height,
progress_update_and_flush, progress);
progress_end (progress);
display_flush = TRUE;
}
......
......@@ -125,7 +125,7 @@ gimp_init (Gimp *gimp)
gimp->gui_set_busy_func = NULL;
gimp->gui_unset_busy_func = NULL;
gimp->busy = FALSE;
gimp->busy = 0;
gimp->busy_idle_id = 0;
gimp_units_init (gimp);
......@@ -480,10 +480,13 @@ gimp_set_busy (Gimp *gimp)
g_return_if_fail (GIMP_IS_GIMP (gimp));
/* FIXME: gimp_busy HACK */
gimp->busy = TRUE;
gimp->busy++;
if (gimp->gui_set_busy_func)
gimp->gui_set_busy_func (gimp);
if (gimp->busy == 1)
{
if (gimp->gui_set_busy_func)
gimp->gui_set_busy_func (gimp);
}
}
static gboolean
......@@ -519,12 +522,16 @@ void
gimp_unset_busy (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (gimp->gui_unset_busy_func)
gimp->gui_unset_busy_func (gimp);
g_return_if_fail (gimp->busy > 0);
/* FIXME: gimp_busy HACK */
gimp->busy = FALSE;
gimp->busy--;
if (gimp->busy == 0)
{
if (gimp->gui_unset_busy_func)
gimp->gui_unset_busy_func (gimp);
}
}
GimpImage *
......@@ -573,7 +580,7 @@ gimp_create_display (Gimp *gimp,
return NULL;
}
/*
#if 0
void
gimp_open_file (Gimp *gimp,
const gchar *filename,
......@@ -597,10 +604,10 @@ gimp_open_file (Gimp *gimp,
{
gchar *absolute;
* enable & clear all undo steps *
/* enable & clear all undo steps */
gimp_image_undo_enable (gimage);
* set the image to clean *
/* set the image to clean */
gimp_image_clean_all (gimage);
if (with_display)
......@@ -614,7 +621,7 @@ gimp_open_file (Gimp *gimp,
g_free (absolute);
}
}
*/
#endif
GimpContext *
gimp_create_context (Gimp *gimp,
......@@ -624,7 +631,7 @@ gimp_create_context (Gimp *gimp,
GimpContext *context;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (!template || GIMP_IS_CONTEXT (template), NULL);
g_return_val_if_fail (! template || GIMP_IS_CONTEXT (template), NULL);
/* FIXME: need unique names here */
if (! name)
......
......@@ -53,7 +53,7 @@ struct _Gimp
GimpSetBusyFunc gui_set_busy_func;
GimpUnsetBusyFunc gui_unset_busy_func;
gboolean busy;
gint busy;
guint busy_idle_id;
GList *user_units;
......
......@@ -1020,9 +1020,11 @@ gimp_image_resize (GimpImage *gimage,
}
void
gimp_image_scale (GimpImage *gimage,
gint new_width,
gint new_height)
gimp_image_scale (GimpImage *gimage,
gint new_width,
gint new_height,
GimpProgressFunc progress_func,
gpointer progress_data)
{
GimpChannel *channel;
GimpLayer *layer;
......@@ -1035,12 +1037,18 @@ gimp_image_scale (GimpImage *gimage,
gint old_height;
gdouble img_scale_w = 1.0;
gdouble img_scale_h = 1.0;
gint num_channels;
gint num_layers;
gint progress_current = 1;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (new_width > 0 && new_height > 0);
gimp_set_busy (gimage->gimp);
num_channels = gimage->channels->num_children;
num_layers = gimage->layers->num_children;
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
......@@ -1070,6 +1078,13 @@ gimp_image_scale (GimpImage *gimage,
channel = (GimpChannel *) list->data;
gimp_channel_scale (channel, new_width, new_height);
if (progress_func)
{
(* progress_func) (0, num_channels + num_layers,
progress_current++,
progress_data);
}
}
/* Don't forget the selection mask! */
......@@ -1097,6 +1112,13 @@ gimp_image_scale (GimpImage *gimage,
*/
remove = g_slist_append (remove, layer);
}
if (progress_func)
{
(* progress_func) (0, num_channels + num_layers,
progress_current++,
progress_data);
}
}
/* We defer removing layers lost to scaling until now so as not to mix
......
......@@ -207,7 +207,9 @@ void gimp_image_resize (GimpImage *gimage,
gint offset_y);
void gimp_image_scale (GimpImage *gimage,
gint new_width,
gint new_height);
gint new_height,
GimpProgressFunc progress_func,
gpointer progress_data);
gboolean gimp_image_check_scaling (const GimpImage *gimage,
gint new_width,
gint new_height);
......
......@@ -1020,9 +1020,11 @@ gimp_image_resize (GimpImage *gimage,
}
void
gimp_image_scale (GimpImage *gimage,
gint new_width,
gint new_height)
gimp_image_scale (GimpImage *gimage,
gint new_width,
gint new_height,
GimpProgressFunc progress_func,
gpointer progress_data)
{
GimpChannel *channel;
GimpLayer *layer;
......@@ -1035,12 +1037,18 @@ gimp_image_scale (GimpImage *gimage,
gint old_height;
gdouble img_scale_w = 1.0;
gdouble img_scale_h = 1.0;
gint num_channels;
gint num_layers;
gint progress_current = 1;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (new_width > 0 && new_height > 0);
gimp_set_busy (gimage->gimp);
num_channels = gimage->channels->num_children;
num_layers = gimage->layers->num_children;
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
......@@ -1070,6 +1078,13 @@ gimp_image_scale (GimpImage *gimage,
channel = (GimpChannel *) list->data;
gimp_channel_scale (channel, new_width, new_height);
if (progress_func)
{
(* progress_func) (0, num_channels + num_layers,
progress_current++,
progress_data);
}
}
/* Don't forget the selection mask! */
......@@ -1097,6 +1112,13 @@ gimp_image_scale (GimpImage *gimage,
*/
remove = g_slist_append (remove, layer);
}
if (progress_func)
{
(* progress_func) (0, num_channels + num_layers,
progress_current++,
progress_data);
}
}
/* We defer removing layers lost to scaling until now so as not to mix
......
......@@ -207,7 +207,9 @@ void gimp_image_resize (GimpImage *gimage,
gint offset_y);
void gimp_image_scale (GimpImage *gimage,
gint new_width,
gint new_height);
gint new_height,
GimpProgressFunc progress_func,
gpointer progress_data);
gboolean gimp_image_check_scaling (const GimpImage *gimage,
gint new_width,
gint new_height);
......
......@@ -1020,9 +1020,11 @@ gimp_image_resize (GimpImage *gimage,
}
void
gimp_image_scale (GimpImage *gimage,
gint new_width,
gint new_height)
gimp_image_scale (GimpImage *gimage,
gint new_width,
gint new_height,
GimpProgressFunc progress_func,
gpointer progress_data)
{
GimpChannel *channel;
GimpLayer *layer;
......@@ -1035,12 +1037,18 @@ gimp_image_scale (GimpImage *gimage,
gint old_height;
gdouble img_scale_w = 1.0;
gdouble img_scale_h = 1.0;
gint num_channels;
gint num_layers;
gint progress_current = 1;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (new_width > 0 && new_height > 0);
gimp_set_busy (gimage->gimp);
num_channels = gimage->channels->num_children;
num_layers = gimage->layers->num_children;
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
......@@ -1070,6 +1078,13 @@ gimp_image_scale (GimpImage *gimage,
channel = (GimpChannel *) list->data;
gimp_channel_scale (channel, new_width, new_height);
if (progress_func)
{
(* progress_func) (0, num_channels + num_layers,
progress_current++,
progress_data);
}
}
/* Don't forget the selection mask! */
......@@ -1097,6 +1112,13 @@ gimp_image_scale (GimpImage *gimage,
*/
remove = g_slist_append (remove, layer);
}
if (progress_func)
{
(* progress_func) (0, num_channels + num_layers,
progress_current++,
progress_data);
}
}
/* We defer removing layers lost to scaling until now so as not to mix
......
......@@ -207,7 +207,9 @@ void gimp_image_resize (GimpImage *gimage,
gint offset_y);
void gimp_image_scale (GimpImage *gimage,
gint new_width,
gint new_height);
gint new_height,
GimpProgressFunc progress_func,
gpointer progress_data);
gboolean gimp_image_check_scaling (const GimpImage *gimage,
gint new_width,
gint new_height);
......
......@@ -1020,9 +1020,11 @@ gimp_image_resize (GimpImage *gimage,
}
void
gimp_image_scale (GimpImage *gimage,
gint new_width,
gint new_height)
gimp_image_scale (GimpImage *gimage,
gint new_width,
gint new_height,
GimpProgressFunc progress_func,
gpointer progress_data)
{
GimpChannel *channel;
GimpLayer *layer;
......@@ -1035,12 +1037,18 @@ gimp_image_scale (GimpImage *gimage,
gint old_height;
gdouble img_scale_w = 1.0;
gdouble img_scale_h = 1.0;
gint num_channels;
gint num_layers;
gint progress_current = 1;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (new_width > 0 && new_height > 0);
gimp_set_busy (gimage->gimp);
num_channels = gimage->channels->num_children;
num_layers = gimage->layers->num_children;
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
......@@ -1070,6 +1078,13 @@ gimp_image_scale (GimpImage *gimage,
channel = (GimpChannel *) list->data;
gimp_channel_scale (channel, new_width, new_height);
if (progress_func)
{
(* progress_func) (0, num_channels + num_layers,
progress_current++,
progress_data);
}
}
/* Don't forget the selection mask! */
......@@ -1097,6 +1112,13 @@ gimp_image_scale (GimpImage *gimage,
*/
remove = g_slist_append (remove, layer);
}
if (progress_func)
{
(* progress_func) (0, num_channels + num_layers,
progress_current++,
progress_data);
}
}
/* We defer removing layers lost to scaling until now so as not to mix
......
......@@ -207,7 +207,9 @@ void gimp_image_resize (GimpImage *gimage,
gint offset_y);
void gimp_image_scale (GimpImage *gimage,
gint new_width,
gint new_height);
gint new_height,
GimpProgressFunc progress_func,
gpointer progress_data);
gboolean gimp_image_check_scaling (const GimpImage *gimage,
gint new_width,
gint new_height);
......
......@@ -1020,9 +1020,11 @@ gimp_image_resize (GimpImage *gimage,
}
void
gimp_image_scale (GimpImage *gimage,
gint new_width,
gint new_height)
gimp_image_scale (GimpImage *gimage,
gint new_width,
gint new_height,
GimpProgressFunc progress_func,
gpointer progress_data)
{
GimpChannel *channel;
GimpLayer *layer;
......@@ -1035,12 +1037,18 @@ gimp_image_scale (GimpImage *gimage,
gint old_height;
gdouble img_scale_w = 1.0;
gdouble img_scale_h = 1.0;
gint num_channels;
gint num_layers;
gint progress_current = 1;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (new_width > 0 && new_height > 0);
gimp_set_busy (gimage->gimp);
num_channels = gimage->channels->num_children;
num_layers = gimage->layers->num_children;
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
......@@ -1070,6 +1078,13 @@ gimp_image_scale (GimpImage *gimage,
channel = (GimpChannel *) list->data;
gimp_channel_scale (channel, new_width, new_height);
if (progress_func)
{
(* progress_func) (0, num_channels + num_layers,
progress_current++,
progress_data);
}
}
/* Don't forget the selection mask! */
......@@ -1097,6 +1112,13 @@ gimp_image_scale (GimpImage *gimage,
*/
remove = g_slist_append (remove, layer);
}
if (progress_func)
{
(* progress_func) (0, num_channels + num_layers,
progress_current++,
progress_data);
}
}
/* We defer removing layers lost to scaling until now so as not to mix
......
......@@ -207,7 +207,9 @@ void gimp_image_resize (GimpImage *gimage,
gint offset_y);
void gimp_image_scale (GimpImage *gimage,
gint new_width,
gint new_height);
gint new_height,
GimpProgressFunc progress_func,
gpointer progress_data);
gboolean gimp_image_check_scaling (const GimpImage *gimage,
gint new_width,
gint new_height);
......
......@@ -1020,9 +1020,11 @@ gimp_image_resize (GimpImage *gimage,
}
void
gimp_image_scale (GimpImage *gimage,
gint new_width,
gint new_height)
gimp_image_scale (GimpImage *gimage,
gint new_width,
gint new_height,
GimpProgressFunc progress_func,
gpointer progress_data)
{
GimpChannel *channel;
GimpLayer *layer;
......@@ -1035,12 +1037,18 @@ gimp_image_scale (GimpImage *gimage,
gint old_height;
gdouble img_scale_w = 1.0;
gdouble img_scale_h = 1.0;
gint num_channels;
gint num_layers;
gint progress_current = 1;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (new_width > 0 && new_height > 0);
gimp_set_busy (gimage->gimp);
num_channels = gimage->channels->num_children;
num_layers = gimage->layers->num_children;
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
......@@ -1070,6 +1078,13 @@ gimp_image_scale (GimpImage *gimage,
channel = (GimpChannel *) list->data;
gimp_channel_scale (channel, new_width, new_height);
if (progress_func)
{
(* progress_func) (0, num_channels + num_layers,
progress_current++,
progress_data);
}
}
/* Don't forget the selection mask! */
......@@ -1097,6 +1112,13 @@ gimp_image_scale (GimpImage *gimage,
*/
remove = g_slist_append (remove, layer);
}
if (progress_func)
{
(* progress_func) (0, num_channels + num_layers,
progress_current++,
progress_data);
}
}
/* We defer removing layers lost to scaling until now so as not to mix
......
......@@ -207,7 +207,9 @@ void gimp_image_resize (GimpImage *gimage,
gint offset_y);
void gimp_image_scale (GimpImage *gimage,
gint new_width,
gint new_height);
gint new_height,
GimpProgressFunc progress_func,
gpointer progress_data);
gboolean gimp_image_check_scaling (const GimpImage *gimage,
gint new_width,
gint new_height);
......