[gimp] app: add new action "view-scroll-center" with shortcut Shift+J



commit 2439ae3acf9876c37adf7f0a9a0b22977188e3ed
Author: Michael Natterer <mitch gimp org>
Date:   Sat May 19 18:03:23 2018 +0200

    app: add new action "view-scroll-center" with shortcut Shift+J
    
    The zoom focus discussion on IRC suggests that everybody is annoyed
    about centering behavior (or lack thereof), so here is a way to
    explicitly center the image witout zooming.

 NEWS                        |    2 ++
 app/actions/view-actions.c  |    8 ++++++++
 app/actions/view-commands.c |   11 +++++++++++
 app/actions/view-commands.h |    3 +++
 app/widgets/gimphelp-ids.h  |    1 +
 menus/image-menu.xml.in     |    1 +
 6 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/NEWS b/NEWS
index 00cd086..84ee4d9 100644
--- a/NEWS
+++ b/NEWS
@@ -46,6 +46,8 @@ Usability:
   - Improve mouse wheel zooming behavior to keep the same point
     centered under the pointer even if the image is completely visible
     in the canvas.
+  - Add "View -> Center Image in Window" (Shift+J) as a quick way to
+    center the image at any zoom level.
 
 Translations:
 
diff --git a/app/actions/view-actions.c b/app/actions/view-actions.c
index 206aa73..b47de76 100644
--- a/app/actions/view-actions.c
+++ b/app/actions/view-actions.c
@@ -97,6 +97,12 @@ static const GimpActionEntry view_actions[] =
     G_CALLBACK (view_close_cmd_callback),
     GIMP_HELP_FILE_CLOSE },
 
+  { "view-scroll-center", GIMP_ICON_CENTER,
+    NC_("view-action", "Center Image in Window"), "<shift>J",
+    NC_("view-action", "Scroll the image so that it is centered in the window"),
+    G_CALLBACK (view_scroll_center_cmd_callback),
+    GIMP_HELP_VIEW_SCROLL_CENTER },
+
   { "view-zoom-fit-in", GIMP_ICON_ZOOM_FIT_BEST,
     NC_("view-action", "_Fit Image in Window"), "<primary><shift>J",
     NC_("view-action", "Adjust the zoom ratio so that the image becomes fully visible"),
@@ -897,6 +903,8 @@ view_actions_update (GimpActionGroup *group,
   SET_SENSITIVE ("view-dot-for-dot", image);
   SET_ACTIVE    ("view-dot-for-dot", display && shell->dot_for_dot);
 
+  SET_SENSITIVE ("view-scroll-center", image);
+
   SET_SENSITIVE ("view-zoom-revert", revert_enabled);
   if (revert_enabled)
     {
diff --git a/app/actions/view-commands.c b/app/actions/view-commands.c
index a567741..669fa49 100644
--- a/app/actions/view-commands.c
+++ b/app/actions/view-commands.c
@@ -126,6 +126,17 @@ view_close_cmd_callback (GtkAction *action,
 }
 
 void
+view_scroll_center_cmd_callback (GtkAction *action,
+                                 gpointer   data)
+{
+  GimpDisplay *display;
+  return_if_no_display (display, data);
+
+  gimp_display_shell_scroll_center_image (gimp_display_get_shell (display),
+                                          TRUE, TRUE);
+}
+
+void
 view_zoom_fit_in_cmd_callback (GtkAction *action,
                                gpointer   data)
 {
diff --git a/app/actions/view-commands.h b/app/actions/view-commands.h
index e18b72f..984ca36 100644
--- a/app/actions/view-commands.h
+++ b/app/actions/view-commands.h
@@ -24,6 +24,9 @@ void   view_new_cmd_callback                    (GtkAction *action,
 void   view_close_cmd_callback                  (GtkAction *action,
                                                  gpointer   data);
 
+void   view_scroll_center_cmd_callback          (GtkAction *action,
+                                                 gpointer   data);
+
 void   view_zoom_fit_in_cmd_callback            (GtkAction *action,
                                                  gpointer   data);
 void   view_zoom_fill_cmd_callback              (GtkAction *action,
diff --git a/app/widgets/gimphelp-ids.h b/app/widgets/gimphelp-ids.h
index 2c3971d..50bd9d5 100644
--- a/app/widgets/gimphelp-ids.h
+++ b/app/widgets/gimphelp-ids.h
@@ -85,6 +85,7 @@
 
 #define GIMP_HELP_VIEW_NEW                        "gimp-view-new"
 #define GIMP_HELP_VIEW_DOT_FOR_DOT                "gimp-view-dot-for-dot"
+#define GIMP_HELP_VIEW_SCROLL_CENTER              "gimp-view-scroll-center"
 #define GIMP_HELP_VIEW_ZOOM_REVERT                "gimp-view-zoom-revert"
 #define GIMP_HELP_VIEW_ZOOM_OUT                   "gimp-view-zoom-out"
 #define GIMP_HELP_VIEW_ZOOM_IN                    "gimp-view-zoom-in"
diff --git a/menus/image-menu.xml.in b/menus/image-menu.xml.in
index b456877..52067f0 100644
--- a/menus/image-menu.xml.in
+++ b/menus/image-menu.xml.in
@@ -294,6 +294,7 @@
         <separator />
         <menuitem action="view-rotate-other" />
       </menu>
+      <menuitem action="view-scroll-center" />
       <separator />
       <menuitem action="view-shrink-wrap" />
       <menuitem action="view-fullscreen" />


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]