mirror of
https://gitlab.gnome.org/GNOME/eog
synced 2024-10-18 05:54:30 +00:00
bgo#659830 - Arrow keys should always navigate, never scroll
We use plain arrow keys to navigate the image list, regardless of whether the image is zoomed or whether it has the focus. We use Alt+arrows to scroll the image. This is to make it easier to browse an image collection while at the same time zooming on images from time to time. Signed-off-by: Federico Mena Quintero <federico@gnome.org>
This commit is contained in:
parent
32cc946446
commit
9fe57cb979
|
@ -1405,6 +1405,7 @@ display_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer data)
|
|||
double zoom;
|
||||
gboolean do_scroll;
|
||||
int xofs, yofs;
|
||||
GdkModifierType modifiers;
|
||||
|
||||
view = EOG_SCROLL_VIEW (data);
|
||||
priv = view->priv;
|
||||
|
@ -1416,56 +1417,65 @@ display_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer data)
|
|||
|
||||
gtk_widget_get_allocation (GTK_WIDGET (priv->display), &allocation);
|
||||
|
||||
/* EogScrollView doesn't handle/have any Alt+Key combos */
|
||||
if (event->state & GDK_MOD1_MASK) {
|
||||
return FALSE;
|
||||
}
|
||||
modifiers = gtk_accelerator_get_default_mod_mask ();
|
||||
|
||||
switch (event->keyval) {
|
||||
case GDK_KEY_Up:
|
||||
do_scroll = TRUE;
|
||||
xofs = 0;
|
||||
yofs = -SCROLL_STEP_SIZE;
|
||||
if ((event->state & modifiers) == GDK_MOD1_MASK) {
|
||||
do_scroll = TRUE;
|
||||
xofs = 0;
|
||||
yofs = -SCROLL_STEP_SIZE;
|
||||
}
|
||||
break;
|
||||
|
||||
case GDK_KEY_Page_Up:
|
||||
do_scroll = TRUE;
|
||||
if (event->state & GDK_CONTROL_MASK) {
|
||||
xofs = -(allocation.width * 3) / 4;
|
||||
yofs = 0;
|
||||
} else {
|
||||
xofs = 0;
|
||||
yofs = -(allocation.height * 3) / 4;
|
||||
if ((event->state & GDK_MOD1_MASK) != 0) {
|
||||
do_scroll = TRUE;
|
||||
if (event->state & GDK_CONTROL_MASK) {
|
||||
xofs = -(allocation.width * 3) / 4;
|
||||
yofs = 0;
|
||||
} else {
|
||||
xofs = 0;
|
||||
yofs = -(allocation.height * 3) / 4;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GDK_KEY_Down:
|
||||
do_scroll = TRUE;
|
||||
xofs = 0;
|
||||
yofs = SCROLL_STEP_SIZE;
|
||||
if ((event->state & modifiers) == GDK_MOD1_MASK) {
|
||||
do_scroll = TRUE;
|
||||
xofs = 0;
|
||||
yofs = SCROLL_STEP_SIZE;
|
||||
}
|
||||
break;
|
||||
|
||||
case GDK_KEY_Page_Down:
|
||||
do_scroll = TRUE;
|
||||
if (event->state & GDK_CONTROL_MASK) {
|
||||
xofs = (allocation.width * 3) / 4;
|
||||
yofs = 0;
|
||||
} else {
|
||||
xofs = 0;
|
||||
yofs = (allocation.height * 3) / 4;
|
||||
if ((event->state & GDK_MOD1_MASK) != 0) {
|
||||
do_scroll = TRUE;
|
||||
if (event->state & GDK_CONTROL_MASK) {
|
||||
xofs = (allocation.width * 3) / 4;
|
||||
yofs = 0;
|
||||
} else {
|
||||
xofs = 0;
|
||||
yofs = (allocation.height * 3) / 4;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GDK_KEY_Left:
|
||||
do_scroll = TRUE;
|
||||
xofs = -SCROLL_STEP_SIZE;
|
||||
yofs = 0;
|
||||
if ((event->state & modifiers) == GDK_MOD1_MASK) {
|
||||
do_scroll = TRUE;
|
||||
xofs = -SCROLL_STEP_SIZE;
|
||||
yofs = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case GDK_KEY_Right:
|
||||
do_scroll = TRUE;
|
||||
xofs = SCROLL_STEP_SIZE;
|
||||
yofs = 0;
|
||||
if ((event->state & modifiers) == GDK_MOD1_MASK) {
|
||||
do_scroll = TRUE;
|
||||
xofs = SCROLL_STEP_SIZE;
|
||||
yofs = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case GDK_KEY_plus:
|
||||
|
|
|
@ -4939,91 +4939,57 @@ eog_window_key_press (GtkWidget *widget, GdkEventKey *event)
|
|||
}
|
||||
break;
|
||||
case GDK_KEY_Left:
|
||||
if ((event->state & modifiers) == GDK_MOD1_MASK) {
|
||||
/* Alt+Left moves to previous image */
|
||||
case GDK_KEY_Up:
|
||||
if ((event->state & modifiers) == 0) {
|
||||
/* Left and Up move to previous image */
|
||||
if (is_rtl) { /* move to next in RTL mode */
|
||||
eog_window_cmd_go_next (NULL, EOG_WINDOW (widget));
|
||||
} else {
|
||||
eog_window_cmd_go_prev (NULL, EOG_WINDOW (widget));
|
||||
}
|
||||
result = TRUE;
|
||||
break;
|
||||
} /* else fall-trough is intended */
|
||||
case GDK_KEY_Up:
|
||||
if (eog_scroll_view_scrollbars_visible (EOG_SCROLL_VIEW (EOG_WINDOW (widget)->priv->view))) {
|
||||
/* break to let scrollview handle the key */
|
||||
break;
|
||||
}
|
||||
if (gtk_container_get_focus_child (tbcontainer) != NULL)
|
||||
break;
|
||||
if (!gtk_widget_get_visible (EOG_WINDOW (widget)->priv->nav)) {
|
||||
if (is_rtl && event->keyval == GDK_KEY_Left) {
|
||||
/* handle RTL fall-through,
|
||||
* need to behave like GDK_Down then */
|
||||
eog_window_cmd_go_next (NULL,
|
||||
EOG_WINDOW (widget));
|
||||
} else {
|
||||
eog_window_cmd_go_prev (NULL,
|
||||
EOG_WINDOW (widget));
|
||||
}
|
||||
result = TRUE;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case GDK_KEY_Right:
|
||||
if ((event->state & modifiers) == GDK_MOD1_MASK) {
|
||||
/* Alt+Right moves to next image */
|
||||
case GDK_KEY_Down:
|
||||
if ((event->state & modifiers) == 0) {
|
||||
/* Right and Down move to next image */
|
||||
if (is_rtl) { /* move to previous in RTL mode */
|
||||
eog_window_cmd_go_prev (NULL, EOG_WINDOW (widget));
|
||||
} else {
|
||||
eog_window_cmd_go_next (NULL, EOG_WINDOW (widget));
|
||||
}
|
||||
result = TRUE;
|
||||
break;
|
||||
} /* else fall-trough is intended */
|
||||
case GDK_KEY_Down:
|
||||
if (eog_scroll_view_scrollbars_visible (EOG_SCROLL_VIEW (EOG_WINDOW (widget)->priv->view))) {
|
||||
/* break to let scrollview handle the key */
|
||||
break;
|
||||
}
|
||||
if (gtk_container_get_focus_child (tbcontainer) != NULL)
|
||||
break;
|
||||
if (!gtk_widget_get_visible (EOG_WINDOW (widget)->priv->nav)) {
|
||||
if (is_rtl && event->keyval == GDK_KEY_Right) {
|
||||
/* handle RTL fall-through,
|
||||
* need to behave like GDK_Up then */
|
||||
eog_window_cmd_go_prev (NULL,
|
||||
EOG_WINDOW (widget));
|
||||
} else {
|
||||
eog_window_cmd_go_next (NULL,
|
||||
EOG_WINDOW (widget));
|
||||
}
|
||||
result = TRUE;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case GDK_KEY_Page_Up:
|
||||
if (!eog_scroll_view_scrollbars_visible (EOG_SCROLL_VIEW (EOG_WINDOW (widget)->priv->view))) {
|
||||
if (!gtk_widget_get_visible (EOG_WINDOW (widget)->priv->nav)) {
|
||||
/* If the iconview is not visible skip to the
|
||||
* previous image manually as it won't handle
|
||||
* the keypress then. */
|
||||
eog_window_cmd_go_prev (NULL,
|
||||
EOG_WINDOW (widget));
|
||||
result = TRUE;
|
||||
} else
|
||||
handle_selection = TRUE;
|
||||
if ((event->state & modifiers) == 0) {
|
||||
if (!eog_scroll_view_scrollbars_visible (EOG_SCROLL_VIEW (EOG_WINDOW (widget)->priv->view))) {
|
||||
if (!gtk_widget_get_visible (EOG_WINDOW (widget)->priv->nav)) {
|
||||
/* If the iconview is not visible skip to the
|
||||
* previous image manually as it won't handle
|
||||
* the keypress then. */
|
||||
eog_window_cmd_go_prev (NULL,
|
||||
EOG_WINDOW (widget));
|
||||
result = TRUE;
|
||||
} else
|
||||
handle_selection = TRUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GDK_KEY_Page_Down:
|
||||
if (!eog_scroll_view_scrollbars_visible (EOG_SCROLL_VIEW (EOG_WINDOW (widget)->priv->view))) {
|
||||
if (!gtk_widget_get_visible (EOG_WINDOW (widget)->priv->nav)) {
|
||||
/* If the iconview is not visible skip to the
|
||||
* next image manually as it won't handle
|
||||
* the keypress then. */
|
||||
eog_window_cmd_go_next (NULL,
|
||||
EOG_WINDOW (widget));
|
||||
result = TRUE;
|
||||
} else
|
||||
handle_selection = TRUE;
|
||||
if ((event->state & modifiers) == 0) {
|
||||
if (!eog_scroll_view_scrollbars_visible (EOG_SCROLL_VIEW (EOG_WINDOW (widget)->priv->view))) {
|
||||
if (!gtk_widget_get_visible (EOG_WINDOW (widget)->priv->nav)) {
|
||||
/* If the iconview is not visible skip to the
|
||||
* next image manually as it won't handle
|
||||
* the keypress then. */
|
||||
eog_window_cmd_go_next (NULL,
|
||||
EOG_WINDOW (widget));
|
||||
result = TRUE;
|
||||
} else
|
||||
handle_selection = TRUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue