Commit 65385a47 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

added gimp_image_resize_to_selection().

2007-06-09  Sven Neumann  <sven@gimp.org>

	* app/core/gimpimage-resize.[ch]: added
	gimp_image_resize_to_selection().

	* app/actions/image-actions.c
	* app/actions/image-commands.[ch]
	* app/widgets/gimphelp-ids.h
	* menus/image-menu.xml.in: added an action and a menu item for 
it.
	Fixes bug #335672.

	* plug-ins/common/align_layers.c: resolved a conflicting 
mnemonic.


svn path=/trunk/; revision=22749
parent d7c71240
2007-06-09 Sven Neumann <sven@gimp.org>
* app/core/gimpimage-resize.[ch]: added
gimp_image_resize_to_selection().
* app/actions/image-actions.c
* app/actions/image-commands.[ch]
* app/widgets/gimphelp-ids.h
* menus/image-menu.xml.in: added an action and a menu item for it.
Fixes bug #335672.
* plug-ins/common/align_layers.c: resolved a conflicting mnemonic.
2007-06-09 Sven Neumann <sven@gimp.org>
* app/core/gimpselection.c (gimp_selection_extract): fixed
......@@ -92,6 +92,12 @@ static const GimpActionEntry image_actions[] =
G_CALLBACK (image_resize_to_layers_cmd_callback),
GIMP_HELP_IMAGE_RESIZE_TO_LAYERS },
{ "image-resize-to-selection", NULL,
N_("F_it Canvas to Selection"), NULL,
N_("Resize the image to the extents of the selection"),
G_CALLBACK (image_resize_to_selection_cmd_callback),
GIMP_HELP_IMAGE_RESIZE_TO_SELECTION },
{ "image-print-size", GIMP_STOCK_PRINT_RESOLUTION,
N_("_Print Size..."), NULL,
N_("Adjust the print resolution"),
......@@ -276,16 +282,17 @@ image_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("image-rotate-180", image);
SET_SENSITIVE ("image-rotate-270", image);
SET_SENSITIVE ("image-resize", image);
SET_SENSITIVE ("image-resize-to-layers", image);
SET_SENSITIVE ("image-print-size", image);
SET_SENSITIVE ("image-scale", image);
SET_SENSITIVE ("image-crop", image && sel);
SET_SENSITIVE ("image-duplicate", image);
SET_SENSITIVE ("image-merge-layers", image && !fs && !aux && lp);
SET_SENSITIVE ("image-flatten", image && !fs && !aux && lp);
SET_SENSITIVE ("image-configure-grid", image);
SET_SENSITIVE ("image-properties", image);
SET_SENSITIVE ("image-resize", image);
SET_SENSITIVE ("image-resize-to-layers", image);
SET_SENSITIVE ("image-resize-to-selection", image && sel);
SET_SENSITIVE ("image-print-size", image);
SET_SENSITIVE ("image-scale", image);
SET_SENSITIVE ("image-crop", image && sel);
SET_SENSITIVE ("image-duplicate", image);
SET_SENSITIVE ("image-merge-layers", image && !fs && !aux && lp);
SET_SENSITIVE ("image-flatten", image && !fs && !aux && lp);
SET_SENSITIVE ("image-configure-grid", image);
SET_SENSITIVE ("image-properties", image);
#undef SET_SENSITIVE
}
......@@ -282,6 +282,27 @@ image_resize_to_layers_cmd_callback (GtkAction *action,
gimp_image_flush (display->image);
}
void
image_resize_to_selection_cmd_callback (GtkAction *action,
gpointer data)
{
GimpDisplay *display;
GimpProgress *progress;
return_if_no_display (display, data);
progress = gimp_progress_start (GIMP_PROGRESS (display),
_("Resizing"), FALSE);
gimp_image_resize_to_selection (display->image,
action_data_get_context (data),
progress);
if (progress)
gimp_progress_end (progress);
gimp_image_flush (display->image);
}
void
image_print_size_cmd_callback (GtkAction *action,
gpointer data)
......
......@@ -20,34 +20,36 @@
#define __IMAGE_COMMANDS_H__
void image_new_cmd_callback (GtkAction *action,
gpointer data);
void image_new_from_image_cmd_callback (GtkAction *action,
gpointer data);
void image_new_cmd_callback (GtkAction *action,
gpointer data);
void image_new_from_image_cmd_callback (GtkAction *action,
gpointer data);
void image_convert_cmd_callback (GtkAction *action,
GtkAction *current,
gpointer data);
void image_convert_cmd_callback (GtkAction *action,
GtkAction *current,
gpointer data);
void image_resize_cmd_callback (GtkAction *action,
gpointer data);
void image_resize_to_layers_cmd_callback (GtkAction *action,
gpointer data);
void image_print_size_cmd_callback (GtkAction *action,
gpointer data);
void image_scale_cmd_callback (GtkAction *action,
gpointer data);
void image_flip_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void image_rotate_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void image_crop_cmd_callback (GtkAction *action,
gpointer data);
void image_resize_cmd_callback (GtkAction *action,
gpointer data);
void image_resize_to_layers_cmd_callback (GtkAction *action,
gpointer data);
void image_resize_to_selection_cmd_callback (GtkAction *action,
gpointer data);
void image_print_size_cmd_callback (GtkAction *action,
gpointer data);
void image_scale_cmd_callback (GtkAction *action,
gpointer data);
void image_flip_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void image_rotate_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void image_crop_cmd_callback (GtkAction *action,
gpointer data);
void image_duplicate_cmd_callback (GtkAction *action,
gpointer data);
void image_duplicate_cmd_callback (GtkAction *action,
gpointer data);
void image_merge_layers_cmd_callback (GtkAction *action,
gpointer data);
......
......@@ -23,6 +23,7 @@
#include "core-types.h"
#include "gimp.h"
#include "gimpchannel.h"
#include "gimpcontext.h"
#include "gimpguide.h"
#include "gimpimage.h"
......@@ -264,3 +265,22 @@ gimp_image_resize_to_layers (GimpImage *image,
progress);
}
void
gimp_image_resize_to_selection (GimpImage *image,
GimpContext *context,
GimpProgress *progress)
{
GimpChannel *selection = gimp_image_get_mask (image);
gint x1, y1;
gint x2, y2;
if (gimp_channel_is_empty (selection))
return;
gimp_channel_bounds (selection, &x1, &y1, &x2, &y2);
gimp_image_resize (image, context,
x2 - x1, y2 - y1,
- x1, - y1,
progress);
}
......@@ -20,26 +20,29 @@
#define __GIMP_IMAGE_RESIZE_H__
void gimp_image_resize (GimpImage *image,
GimpContext *context,
gint new_width,
gint new_height,
gint offset_x,
gint offset_y,
GimpProgress *progress);
void gimp_image_resize (GimpImage *image,
GimpContext *context,
gint new_width,
gint new_height,
gint offset_x,
gint offset_y,
GimpProgress *progress);
void gimp_image_resize_with_layers (GimpImage *image,
GimpContext *context,
gint new_width,
gint new_height,
gint offset_x,
gint offset_y,
GimpItemSet layer_set,
GimpProgress *progress);
void gimp_image_resize_with_layers (GimpImage *image,
GimpContext *context,
gint new_width,
gint new_height,
gint offset_x,
gint offset_y,
GimpItemSet layer_set,
GimpProgress *progress);
void gimp_image_resize_to_layers (GimpImage *image,
GimpContext *context,
GimpProgress *progress);
void gimp_image_resize_to_layers (GimpImage *image,
GimpContext *context,
GimpProgress *progress);
void gimp_image_resize_to_selection (GimpImage *image,
GimpContext *context,
GimpProgress *progress);
#endif /* __GIMP_IMAGE_RESIZE_H__ */
......@@ -119,6 +119,7 @@
#define GIMP_HELP_IMAGE_ROTATE_270 "gimp-image-rotate-270"
#define GIMP_HELP_IMAGE_RESIZE "gimp-image-resize"
#define GIMP_HELP_IMAGE_RESIZE_TO_LAYERS "gimp-image-resize-to-layers"
#define GIMP_HELP_IMAGE_RESIZE_TO_SELECTION "gimp-image-resize-to-selection"
#define GIMP_HELP_IMAGE_PRINT_SIZE "gimp-image-print-size"
#define GIMP_HELP_IMAGE_SCALE "gimp-image-scale"
#define GIMP_HELP_IMAGE_SCALE_WARNING "gimp-image-scale-warning"
......
......@@ -300,11 +300,13 @@
<placeholder name="Resize">
<menuitem action="image-resize" />
<menuitem action="image-resize-to-layers" />
<menuitem action="image-resize-to-selection" />
<menuitem action="image-print-size" />
</placeholder>
<placeholder name="Scale">
<menuitem action="image-scale" />
</placeholder>
<separator />
<placeholder name="Crop">
<menuitem action="image-crop" />
</placeholder>
......
......@@ -130,7 +130,7 @@ query (void)
"Shuji Narazaki <narazaki@InetQ.or.jp>",
"Shuji Narazaki",
"1997",
N_("Align _Visible Layers..."),
N_("Align Visi_ble Layers..."),
"RGB*,GRAY*,INDEXED*",
GIMP_PLUGIN,
G_N_ELEMENTS (args), 0,
......
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