[gnome-commander] InternalViewer: Only move up to image edges, not further, when using keyboard arrows



commit 3ecea40d287fe0b1afa211377513050947340ea3
Author: Uwe Scholz <u scholz83 gmx de>
Date:   Mon Feb 15 21:01:06 2021 +0100

    InternalViewer: Only move up to image edges, not further, when using keyboard arrows

 src/intviewer/image-render.cc | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)
---
diff --git a/src/intviewer/image-render.cc b/src/intviewer/image-render.cc
index 3235260f..136c7494 100644
--- a/src/intviewer/image-render.cc
+++ b/src/intviewer/image-render.cc
@@ -331,10 +331,15 @@ static gboolean image_render_key_press (GtkWidget *widget, GdkEventKey *event)
             auto vAdjustment = image_render_get_v_adjustment(imageRender);
             auto current = gtk_adjustment_get_value(vAdjustment);
             auto lower = gtk_adjustment_get_lower(vAdjustment);
-            if (current > lower)
+            if (current - INC_VALUE > lower)
             {
                 gtk_adjustment_set_value(vAdjustment, current - INC_VALUE);
             }
+            else
+            {
+                gtk_adjustment_set_value(vAdjustment, lower);
+            }
+
             return TRUE;
         }
         case GDK_KEY_Down:
@@ -343,10 +348,14 @@ static gboolean image_render_key_press (GtkWidget *widget, GdkEventKey *event)
             auto current = gtk_adjustment_get_value(vAdjustment);
             auto upper = gtk_adjustment_get_upper(vAdjustment);
             auto page_size = gtk_adjustment_get_page_size(vAdjustment);
-            if (current < upper - page_size)
+            if (current + INC_VALUE < upper - page_size)
             {
                 gtk_adjustment_set_value(vAdjustment, current + INC_VALUE);
             }
+            else
+            {
+                gtk_adjustment_set_value(vAdjustment, upper - page_size);
+            }
             return TRUE;
         }
         case GDK_KEY_Left:
@@ -354,10 +363,15 @@ static gboolean image_render_key_press (GtkWidget *widget, GdkEventKey *event)
             auto hAdjustment = image_render_get_h_adjustment(imageRender);
             auto current = gtk_adjustment_get_value(hAdjustment);
             auto lower = gtk_adjustment_get_lower(hAdjustment);
-            if (current > lower)
+            if (current - INC_VALUE > lower)
             {
                 gtk_adjustment_set_value(hAdjustment, current - INC_VALUE);
             }
+            else
+            {
+                gtk_adjustment_set_value(hAdjustment, lower);
+            }
+
             return TRUE;
         }
         case GDK_KEY_Right:
@@ -366,10 +380,15 @@ static gboolean image_render_key_press (GtkWidget *widget, GdkEventKey *event)
             auto current = gtk_adjustment_get_value(hAdjustment);
             auto upper = gtk_adjustment_get_upper(hAdjustment);
             auto page_size = gtk_adjustment_get_page_size(hAdjustment);
-            if (current < upper - page_size)
+            if (current + INC_VALUE < upper - page_size)
             {
                 gtk_adjustment_set_value(hAdjustment, current + INC_VALUE);
             }
+            else
+            {
+                gtk_adjustment_set_value(hAdjustment, upper - page_size);
+            }
+
             return TRUE;
         }
 


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