Commit 80dad0fc authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

some s/0/FALSE/

2001-06-05  Michael Natterer  <mitch@gimp.org>

	* app/global_edit.c: some s/0/FALSE/

	* app/resize.[ch]: removed resize_scale_implement() and
	resize_check_layer_scaling(), cleanup.

	* app/core/gimpimage.[ch]: added gimp_image_check_scaling().

	* app/gui/commands.c: added image_scale_implement() as static
	function.

	* app/gui/tool-options-dialog.[ch]: add the tool options widgets
	to the dialog when they are first needed. Removed
	tool_options_dialog_add().

	* app/tools/tool_manager.c: don't call tool_options_dialog_add().
parent f1e229ab
2001-06-05 Michael Natterer <mitch@gimp.org>
* app/global_edit.c: some s/0/FALSE/
* app/resize.[ch]: removed resize_scale_implement() and
resize_check_layer_scaling(), cleanup.
* app/core/gimpimage.[ch]: added gimp_image_check_scaling().
* app/gui/commands.c: added image_scale_implement() as static
function.
* app/gui/tool-options-dialog.[ch]: add the tool options widgets
to the dialog when they are first needed. Removed
tool_options_dialog_add().
* app/tools/tool_manager.c: don't call tool_options_dialog_add().
2001-06-03 Dave Neary <dneary@eircom.net>
* app/gimprc.[ch]: Made all the global options members of one
......
......@@ -76,26 +76,30 @@
/* local functions */
static void image_resize_callback (GtkWidget *widget,
gpointer data);
static void image_scale_callback (GtkWidget *widget,
gpointer data);
static void gimage_mask_feather_callback (GtkWidget *widget,
gdouble size,
GimpUnit unit,
gpointer data);
static void gimage_mask_border_callback (GtkWidget *widget,
gdouble size,
GimpUnit unit,
gpointer data);
static void gimage_mask_grow_callback (GtkWidget *widget,
gdouble size,
GimpUnit unit,
gpointer data);
static void gimage_mask_shrink_callback (GtkWidget *widget,
gdouble size,
GimpUnit unit,
gpointer data);
static void image_resize_callback (GtkWidget *widget,
gpointer data);
static void image_scale_callback (GtkWidget *widget,
gpointer data);
static void image_scale_warn_callback (GtkWidget *widget,
gboolean do_scale,
gpointer data);
static void image_scale_implement (ImageResize *image_scale);
static void gimage_mask_feather_callback (GtkWidget *widget,
gdouble size,
GimpUnit unit,
gpointer data);
static void gimage_mask_border_callback (GtkWidget *widget,
gdouble size,
GimpUnit unit,
gpointer data);
static void gimage_mask_grow_callback (GtkWidget *widget,
gdouble size,
GimpUnit unit,
gpointer data);
static void gimage_mask_shrink_callback (GtkWidget *widget,
gdouble size,
GimpUnit unit,
gpointer data);
/* local variables */
......@@ -1097,11 +1101,132 @@ image_scale_callback (GtkWidget *widget,
gtk_widget_set_sensitive (image_scale->resize->resize_shell, FALSE);
if (resize_check_layer_scaling (image_scale))
if (gimp_image_check_scaling (image_scale->gimage,
image_scale->resize->width,
image_scale->resize->height))
{
resize_scale_implement (image_scale);
image_scale_implement (image_scale);
gtk_widget_destroy (image_scale->resize->resize_shell);
}
else
{
GtkWidget *dialog;
dialog =
gimp_query_boolean_box (_("Layer Too Small"),
gimp_standard_help_func,
"dialogs/scale_layer_warn.html",
FALSE,
_("The chosen image size will shrink\n"
"some layers completely away.\n"
"Is this what you want?"),
_("OK"), _("Cancel"),
GTK_OBJECT (image_scale->resize->resize_shell),
"destroy",
image_scale_warn_callback,
image_scale);
gtk_widget_show (dialog);
}
}
static void
image_scale_warn_callback (GtkWidget *widget,
gboolean do_scale,
gpointer data)
{
ImageResize *image_scale;
GimpImage *gimage;
image_scale = (ImageResize *) data;
gimage = image_scale->gimage;
if (do_scale == TRUE) /* User doesn't mind losing layers... */
{
image_scale_implement (image_scale);
gtk_widget_destroy (image_scale->resize->resize_shell);
}
else
{
gtk_widget_set_sensitive (image_scale->resize->resize_shell, TRUE);
}
}
static void
image_scale_implement (ImageResize *image_scale)
{
GimpImage *gimage = NULL;
gboolean rulers_flush = FALSE;
gboolean display_flush = FALSE; /* this is a bit ugly:
we hijack the flush variable
to check if an undo_group was
already started */
g_assert (image_scale != NULL);
gimage = image_scale->gimage;
g_assert (gimage != NULL);
if (image_scale->resize->resolution_x != gimage->xresolution ||
image_scale->resize->resolution_y != gimage->yresolution)
{
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
gimp_image_set_resolution (gimage,
image_scale->resize->resolution_x,
image_scale->resize->resolution_y);
rulers_flush = TRUE;
display_flush = TRUE;
}
if (image_scale->resize->unit != gimage->unit)
{
if (!display_flush)
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
gimp_image_set_unit (gimage, image_scale->resize->unit);
gdisplays_setup_scale (gimage);
gdisplays_resize_cursor_label (gimage);
rulers_flush = TRUE;
display_flush = TRUE;
}
if (image_scale->resize->width != gimage->width ||
image_scale->resize->height != gimage->height)
{
if (image_scale->resize->width > 0 &&
image_scale->resize->height > 0)
{
if (!display_flush)
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
gimp_image_scale (gimage,
image_scale->resize->width,
image_scale->resize->height);
display_flush = TRUE;
}
else
{
g_message (_("Scale Error: Both width and height must be "
"greater than zero."));
return;
}
}
if (rulers_flush)
{
gdisplays_setup_scale (gimage);
gdisplays_resize_cursor_label (gimage);
}
if (display_flush)
{
undo_push_group_end (gimage);
gdisplays_flush ();
}
}
static void
......
......@@ -223,7 +223,7 @@ edit_cut (GimpImage *gimage,
/* Only crop if the gimage mask wasn't empty */
if (cut && empty == FALSE)
{
cropped_cut = crop_buffer (cut, 0);
cropped_cut = crop_buffer (cut, FALSE);
if (cropped_cut != cut)
tile_manager_destroy (cut);
......@@ -274,7 +274,7 @@ edit_copy (GimpImage *gimage,
/* Only crop if the gimage mask wasn't empty */
if (copy && empty == FALSE)
{
cropped_copy = crop_buffer (copy, 0);
cropped_copy = crop_buffer (copy, FALSE);
if (cropped_copy != copy)
tile_manager_destroy (copy);
......
......@@ -223,7 +223,7 @@ edit_cut (GimpImage *gimage,
/* Only crop if the gimage mask wasn't empty */
if (cut && empty == FALSE)
{
cropped_cut = crop_buffer (cut, 0);
cropped_cut = crop_buffer (cut, FALSE);
if (cropped_cut != cut)
tile_manager_destroy (cut);
......@@ -274,7 +274,7 @@ edit_copy (GimpImage *gimage,
/* Only crop if the gimage mask wasn't empty */
if (copy && empty == FALSE)
{
cropped_copy = crop_buffer (copy, 0);
cropped_copy = crop_buffer (copy, FALSE);
if (cropped_copy != copy)
tile_manager_destroy (copy);
......
......@@ -908,7 +908,7 @@ gimp_image_scale (GimpImage *gimage,
gimp_channel_resize(gimage->selection_mask, new_width, new_height, 0, 0)
else
*/
gimp_channel_scale (gimage->selection_mask, new_width, new_height);
gimage_mask_invalidate (gimage);
......@@ -919,21 +919,20 @@ gimp_image_scale (GimpImage *gimage,
{
layer = (GimpLayer *) list->data;
if (gimp_layer_scale_by_factors (layer, img_scale_w, img_scale_h) == FALSE)
if (! gimp_layer_scale_by_factors (layer, img_scale_w, img_scale_h))
{
/* Since 0 < img_scale_w, img_scale_h, failure due to one or more
* vanishing scaled layer dimensions. Implicit delete implemented
* here. Upstream warning implemented in resize_check_layer_scaling()
* [resize.c line 1295], which offers the user the chance to bail out.
*/
remove = g_slist_append (remove, layer);
}
}
/* We defer removing layers lost to scaling until now */
/* so as not to mix the operations of iterating over and removal */
/* from gimage->layers. */
/* We defer removing layers lost to scaling until now so as not to mix
* the operations of iterating over and removal from gimage->layers.
*/
for (slist = remove; slist; slist = g_slist_next (slist))
{
layer = slist->data;
......@@ -975,6 +974,43 @@ gimp_image_scale (GimpImage *gimage,
gimp_unset_busy ();
}
/**
* gimp_image_check_scaling:
* @gimage: A #GimpImage.
* @new_width: The new width.
* @new_height: The new height.
*
* Inventory the layer list in gimage and return #TRUE if, after
* scaling, they all retain positive x and y pixel dimensions.
*
* Return value: #TRUE if scaling the image will shrink none of it's
* layers completely away.
**/
gboolean
gimp_image_check_scaling (const GimpImage *gimage,
gint new_width,
gint new_height)
{
GList *list;
g_return_val_if_fail (gimage != NULL, FALSE);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
for (list = GIMP_LIST (gimage->layers)->list;
list;
list = g_list_next (list))
{
GimpLayer *layer;
layer = (GimpLayer *) list->data;
if (! gimp_layer_check_scaling (layer, new_width, new_height))
return FALSE;
}
return TRUE;
}
TileManager *
gimp_image_shadow (GimpImage *gimage,
gint width,
......
......@@ -199,6 +199,9 @@ void gimp_image_resize (GimpImage *gimage,
void gimp_image_scale (GimpImage *gimage,
gint new_width,
gint new_height);
gboolean gimp_image_check_scaling (const GimpImage *gimage,
gint new_width,
gint new_height);
TileManager * gimp_image_shadow (GimpImage *gimage,
gint width,
gint height,
......
......@@ -908,7 +908,7 @@ gimp_image_scale (GimpImage *gimage,
gimp_channel_resize(gimage->selection_mask, new_width, new_height, 0, 0)
else
*/
gimp_channel_scale (gimage->selection_mask, new_width, new_height);
gimage_mask_invalidate (gimage);
......@@ -919,21 +919,20 @@ gimp_image_scale (GimpImage *gimage,
{
layer = (GimpLayer *) list->data;
if (gimp_layer_scale_by_factors (layer, img_scale_w, img_scale_h) == FALSE)
if (! gimp_layer_scale_by_factors (layer, img_scale_w, img_scale_h))
{
/* Since 0 < img_scale_w, img_scale_h, failure due to one or more
* vanishing scaled layer dimensions. Implicit delete implemented
* here. Upstream warning implemented in resize_check_layer_scaling()
* [resize.c line 1295], which offers the user the chance to bail out.
*/
remove = g_slist_append (remove, layer);
}
}
/* We defer removing layers lost to scaling until now */
/* so as not to mix the operations of iterating over and removal */
/* from gimage->layers. */
/* We defer removing layers lost to scaling until now so as not to mix
* the operations of iterating over and removal from gimage->layers.
*/
for (slist = remove; slist; slist = g_slist_next (slist))
{
layer = slist->data;
......@@ -975,6 +974,43 @@ gimp_image_scale (GimpImage *gimage,
gimp_unset_busy ();
}
/**
* gimp_image_check_scaling:
* @gimage: A #GimpImage.
* @new_width: The new width.
* @new_height: The new height.
*
* Inventory the layer list in gimage and return #TRUE if, after
* scaling, they all retain positive x and y pixel dimensions.
*
* Return value: #TRUE if scaling the image will shrink none of it's
* layers completely away.
**/
gboolean
gimp_image_check_scaling (const GimpImage *gimage,
gint new_width,
gint new_height)
{
GList *list;
g_return_val_if_fail (gimage != NULL, FALSE);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
for (list = GIMP_LIST (gimage->layers)->list;
list;
list = g_list_next (list))
{
GimpLayer *layer;
layer = (GimpLayer *) list->data;
if (! gimp_layer_check_scaling (layer, new_width, new_height))
return FALSE;
}
return TRUE;
}
TileManager *
gimp_image_shadow (GimpImage *gimage,
gint width,
......
......@@ -199,6 +199,9 @@ void gimp_image_resize (GimpImage *gimage,
void gimp_image_scale (GimpImage *gimage,
gint new_width,
gint new_height);
gboolean gimp_image_check_scaling (const GimpImage *gimage,
gint new_width,
gint new_height);
TileManager * gimp_image_shadow (GimpImage *gimage,
gint width,
gint height,
......
......@@ -908,7 +908,7 @@ gimp_image_scale (GimpImage *gimage,
gimp_channel_resize(gimage->selection_mask, new_width, new_height, 0, 0)
else
*/
gimp_channel_scale (gimage->selection_mask, new_width, new_height);
gimage_mask_invalidate (gimage);
......@@ -919,21 +919,20 @@ gimp_image_scale (GimpImage *gimage,
{
layer = (GimpLayer *) list->data;
if (gimp_layer_scale_by_factors (layer, img_scale_w, img_scale_h) == FALSE)
if (! gimp_layer_scale_by_factors (layer, img_scale_w, img_scale_h))
{
/* Since 0 < img_scale_w, img_scale_h, failure due to one or more
* vanishing scaled layer dimensions. Implicit delete implemented
* here. Upstream warning implemented in resize_check_layer_scaling()
* [resize.c line 1295], which offers the user the chance to bail out.
*/
remove = g_slist_append (remove, layer);
}
}
/* We defer removing layers lost to scaling until now */
/* so as not to mix the operations of iterating over and removal */
/* from gimage->layers. */
/* We defer removing layers lost to scaling until now so as not to mix
* the operations of iterating over and removal from gimage->layers.
*/
for (slist = remove; slist; slist = g_slist_next (slist))
{
layer = slist->data;
......@@ -975,6 +974,43 @@ gimp_image_scale (GimpImage *gimage,
gimp_unset_busy ();
}
/**
* gimp_image_check_scaling:
* @gimage: A #GimpImage.
* @new_width: The new width.
* @new_height: The new height.
*
* Inventory the layer list in gimage and return #TRUE if, after
* scaling, they all retain positive x and y pixel dimensions.
*
* Return value: #TRUE if scaling the image will shrink none of it's
* layers completely away.
**/
gboolean
gimp_image_check_scaling (const GimpImage *gimage,
gint new_width,
gint new_height)
{
GList *list;
g_return_val_if_fail (gimage != NULL, FALSE);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
for (list = GIMP_LIST (gimage->layers)->list;
list;
list = g_list_next (list))
{
GimpLayer *layer;
layer = (GimpLayer *) list->data;
if (! gimp_layer_check_scaling (layer, new_width, new_height))
return FALSE;
}
return TRUE;
}
TileManager *
gimp_image_shadow (GimpImage *gimage,
gint width,
......
......@@ -199,6 +199,9 @@ void gimp_image_resize (GimpImage *gimage,
void gimp_image_scale (GimpImage *gimage,
gint new_width,
gint new_height);
gboolean gimp_image_check_scaling (const GimpImage *gimage,
gint new_width,
gint new_height);
TileManager * gimp_image_shadow (GimpImage *gimage,
gint width,
gint height,
......
......@@ -908,7 +908,7 @@ gimp_image_scale (GimpImage *gimage,
gimp_channel_resize(gimage->selection_mask, new_width, new_height, 0, 0)
else
*/
gimp_channel_scale (gimage->selection_mask, new_width, new_height);
gimage_mask_invalidate (gimage);
......@@ -919,21 +919,20 @@ gimp_image_scale (GimpImage *gimage,
{
layer = (GimpLayer *) list->data;
if (gimp_layer_scale_by_factors (layer, img_scale_w, img_scale_h) == FALSE)
if (! gimp_layer_scale_by_factors (layer, img_scale_w, img_scale_h))
{
/* Since 0 < img_scale_w, img_scale_h, failure due to one or more
* vanishing scaled layer dimensions. Implicit delete implemented
* here. Upstream warning implemented in resize_check_layer_scaling()
* [resize.c line 1295], which offers the user the chance to bail out.
*/
remove = g_slist_append (remove, layer);
}
}
/* We defer removing layers lost to scaling until now */
/* so as not to mix the operations of iterating over and removal */
/* from gimage->layers. */
/* We defer removing layers lost to scaling until now so as not to mix
* the operations of iterating over and removal from gimage->layers.
*/
for (slist = remove; slist; slist = g_slist_next (slist))
{
layer = slist->data;
......@@ -975,6 +974,43 @@ gimp_image_scale (GimpImage *gimage,
gimp_unset_busy ();
}
/**
* gimp_image_check_scaling:
* @gimage: A #GimpImage.
* @new_width: The new width.
* @new_height: The new height.
*
* Inventory the layer list in gimage and return #TRUE if, after
* scaling, they all retain positive x and y pixel dimensions.
*
* Return value: #TRUE if scaling the image will shrink none of it's
* layers completely away.
**/
gboolean
gimp_image_check_scaling (const GimpImage *gimage,
gint new_width,
gint new_height)
{
GList *list;
g_return_val_if_fail (gimage != NULL, FALSE);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
for (list = GIMP_LIST (gimage->layers)->list;
list;
list = g_list_next (list))
{
GimpLayer *layer;
layer = (GimpLayer *) list->data;
if (! gimp_layer_check_scaling (layer, new_width, new_height))
return FALSE;
}
return TRUE;
}
TileManager *
gimp_image_shadow (GimpImage *gimage,
gint width,
......
......@@ -199,6 +199,9 @@ void gimp_image_resize (GimpImage *gimage,
void gimp_image_scale (GimpImage *gimage,
gint new_width,
gint new_height);
gboolean gimp_image_check_scaling (const GimpImage *gimage,
gint new_width,
gint new_height);
TileManager * gimp_image_shadow (GimpImage *gimage,
gint width,
gint height,
......
......@@ -908,7 +908,7 @@ gimp_image_scale (GimpImage *gimage,
gimp_channel_resize(gimage->selection_mask, new_width, new_height, 0, 0)
else
*/
gimp_channel_scale (gimage->selection_mask, new_width, new_height);