Commit 91fbc3af authored by Michael Natterer's avatar Michael Natterer 😴

Bug 734573 - Zoom to selection

Implement View -> Zoom -> Zoom to Selection using
gimp_display_shell_scale_to_rectangle()
parent 5bc9ad94
......@@ -98,6 +98,12 @@ static const GimpActionEntry view_actions[] =
G_CALLBACK (view_zoom_fill_cmd_callback),
GIMP_HELP_VIEW_ZOOM_FILL },
{ "view-zoom-selection", "gimp-selection",
NC_("view-action", "Zoom to _Selection"), NULL,
NC_("view-action", "Adjust the zoom ratio so that the selection fills the window"),
G_CALLBACK (view_zoom_selection_cmd_callback),
GIMP_HELP_VIEW_ZOOM_SELECTION },
{ "view-zoom-revert", NULL,
NC_("view-action", "Re_vert Zoom"), "grave",
NC_("view-action", "Restore the previous zoom level"),
......@@ -692,6 +698,7 @@ view_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("view-zoom-fit-in", image);
SET_SENSITIVE ("view-zoom-fill", image);
SET_SENSITIVE ("view-zoom-selection", image);
SET_SENSITIVE ("view-zoom-revert", image);
SET_SENSITIVE ("view-zoom-16-1", image);
......
......@@ -134,6 +134,25 @@ view_zoom_fill_cmd_callback (GtkAction *action,
gimp_display_shell_scale_fill (gimp_display_get_shell (display));
}
void
view_zoom_selection_cmd_callback (GtkAction *action,
gpointer data)
{
GimpDisplay *display;
GimpImage *image;
gint x, y, width, height;
return_if_no_display (display, data);
return_if_no_image (image, data);
gimp_item_bounds (GIMP_ITEM (gimp_image_get_mask (image)),
&x, &y, &width, &height);
gimp_display_shell_scale_to_rectangle (gimp_display_get_shell (display),
GIMP_ZOOM_IN,
x, y, width, height,
FALSE);
}
void
view_zoom_revert_cmd_callback (GtkAction *action,
gpointer data)
......
......@@ -28,6 +28,8 @@ void view_zoom_fit_in_cmd_callback (GtkAction *action,
gpointer data);
void view_zoom_fill_cmd_callback (GtkAction *action,
gpointer data);
void view_zoom_selection_cmd_callback (GtkAction *action,
gpointer data);
void view_zoom_revert_cmd_callback (GtkAction *action,
gpointer data);
void view_zoom_cmd_callback (GtkAction *action,
......
......@@ -86,6 +86,7 @@
#define GIMP_HELP_VIEW_ZOOM_100 "gimp-view-zoom-100"
#define GIMP_HELP_VIEW_ZOOM_FIT_IN "gimp-view-zoom-fit-in"
#define GIMP_HELP_VIEW_ZOOM_FILL "gimp-view-zoom-fill"
#define GIMP_HELP_VIEW_ZOOM_SELECTION "gimp-view-zoom-selection"
#define GIMP_HELP_VIEW_ZOOM_OTHER "gimp-view-zoom-other"
#define GIMP_HELP_VIEW_ROTATE_RESET "gimp-view-rotate-reset"
#define GIMP_HELP_VIEW_ROTATE_15 "gimp-view-rotate-15"
......
......@@ -260,6 +260,7 @@
<menuitem action="view-zoom-in" />
<menuitem action="view-zoom-fit-in" />
<menuitem action="view-zoom-fill" />
<menuitem action="view-zoom-selection" />
<separator />
<menuitem action="view-zoom-16-1" />
<menuitem action="view-zoom-8-1" />
......
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