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:
Federico Mena Quintero 2012-08-29 18:13:22 -05:00
parent 32cc946446
commit 9fe57cb979
2 changed files with 72 additions and 96 deletions

View file

@ -1405,6 +1405,7 @@ display_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer data)
double zoom; double zoom;
gboolean do_scroll; gboolean do_scroll;
int xofs, yofs; int xofs, yofs;
GdkModifierType modifiers;
view = EOG_SCROLL_VIEW (data); view = EOG_SCROLL_VIEW (data);
priv = view->priv; 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); gtk_widget_get_allocation (GTK_WIDGET (priv->display), &allocation);
/* EogScrollView doesn't handle/have any Alt+Key combos */ modifiers = gtk_accelerator_get_default_mod_mask ();
if (event->state & GDK_MOD1_MASK) {
return FALSE;
}
switch (event->keyval) { switch (event->keyval) {
case GDK_KEY_Up: case GDK_KEY_Up:
do_scroll = TRUE; if ((event->state & modifiers) == GDK_MOD1_MASK) {
xofs = 0; do_scroll = TRUE;
yofs = -SCROLL_STEP_SIZE; xofs = 0;
yofs = -SCROLL_STEP_SIZE;
}
break; break;
case GDK_KEY_Page_Up: case GDK_KEY_Page_Up:
do_scroll = TRUE; if ((event->state & GDK_MOD1_MASK) != 0) {
if (event->state & GDK_CONTROL_MASK) { do_scroll = TRUE;
xofs = -(allocation.width * 3) / 4; if (event->state & GDK_CONTROL_MASK) {
yofs = 0; xofs = -(allocation.width * 3) / 4;
} else { yofs = 0;
xofs = 0; } else {
yofs = -(allocation.height * 3) / 4; xofs = 0;
yofs = -(allocation.height * 3) / 4;
}
} }
break; break;
case GDK_KEY_Down: case GDK_KEY_Down:
do_scroll = TRUE; if ((event->state & modifiers) == GDK_MOD1_MASK) {
xofs = 0; do_scroll = TRUE;
yofs = SCROLL_STEP_SIZE; xofs = 0;
yofs = SCROLL_STEP_SIZE;
}
break; break;
case GDK_KEY_Page_Down: case GDK_KEY_Page_Down:
do_scroll = TRUE; if ((event->state & GDK_MOD1_MASK) != 0) {
if (event->state & GDK_CONTROL_MASK) { do_scroll = TRUE;
xofs = (allocation.width * 3) / 4; if (event->state & GDK_CONTROL_MASK) {
yofs = 0; xofs = (allocation.width * 3) / 4;
} else { yofs = 0;
xofs = 0; } else {
yofs = (allocation.height * 3) / 4; xofs = 0;
yofs = (allocation.height * 3) / 4;
}
} }
break; break;
case GDK_KEY_Left: case GDK_KEY_Left:
do_scroll = TRUE; if ((event->state & modifiers) == GDK_MOD1_MASK) {
xofs = -SCROLL_STEP_SIZE; do_scroll = TRUE;
yofs = 0; xofs = -SCROLL_STEP_SIZE;
yofs = 0;
}
break; break;
case GDK_KEY_Right: case GDK_KEY_Right:
do_scroll = TRUE; if ((event->state & modifiers) == GDK_MOD1_MASK) {
xofs = SCROLL_STEP_SIZE; do_scroll = TRUE;
yofs = 0; xofs = SCROLL_STEP_SIZE;
yofs = 0;
}
break; break;
case GDK_KEY_plus: case GDK_KEY_plus:

View file

@ -4939,91 +4939,57 @@ eog_window_key_press (GtkWidget *widget, GdkEventKey *event)
} }
break; break;
case GDK_KEY_Left: case GDK_KEY_Left:
if ((event->state & modifiers) == GDK_MOD1_MASK) { case GDK_KEY_Up:
/* Alt+Left moves to previous image */ if ((event->state & modifiers) == 0) {
/* Left and Up move to previous image */
if (is_rtl) { /* move to next in RTL mode */ if (is_rtl) { /* move to next in RTL mode */
eog_window_cmd_go_next (NULL, EOG_WINDOW (widget)); eog_window_cmd_go_next (NULL, EOG_WINDOW (widget));
} else { } else {
eog_window_cmd_go_prev (NULL, EOG_WINDOW (widget)); eog_window_cmd_go_prev (NULL, EOG_WINDOW (widget));
} }
result = TRUE; 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: case GDK_KEY_Right:
if ((event->state & modifiers) == GDK_MOD1_MASK) { case GDK_KEY_Down:
/* Alt+Right moves to next image */ if ((event->state & modifiers) == 0) {
/* Right and Down move to next image */
if (is_rtl) { /* move to previous in RTL mode */ if (is_rtl) { /* move to previous in RTL mode */
eog_window_cmd_go_prev (NULL, EOG_WINDOW (widget)); eog_window_cmd_go_prev (NULL, EOG_WINDOW (widget));
} else { } else {
eog_window_cmd_go_next (NULL, EOG_WINDOW (widget)); eog_window_cmd_go_next (NULL, EOG_WINDOW (widget));
} }
result = TRUE; 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: case GDK_KEY_Page_Up:
if (!eog_scroll_view_scrollbars_visible (EOG_SCROLL_VIEW (EOG_WINDOW (widget)->priv->view))) { if ((event->state & modifiers) == 0) {
if (!gtk_widget_get_visible (EOG_WINDOW (widget)->priv->nav)) { if (!eog_scroll_view_scrollbars_visible (EOG_SCROLL_VIEW (EOG_WINDOW (widget)->priv->view))) {
/* If the iconview is not visible skip to the if (!gtk_widget_get_visible (EOG_WINDOW (widget)->priv->nav)) {
* previous image manually as it won't handle /* If the iconview is not visible skip to the
* the keypress then. */ * previous image manually as it won't handle
eog_window_cmd_go_prev (NULL, * the keypress then. */
EOG_WINDOW (widget)); eog_window_cmd_go_prev (NULL,
result = TRUE; EOG_WINDOW (widget));
} else result = TRUE;
handle_selection = TRUE; } else
handle_selection = TRUE;
}
} }
break; break;
case GDK_KEY_Page_Down: case GDK_KEY_Page_Down:
if (!eog_scroll_view_scrollbars_visible (EOG_SCROLL_VIEW (EOG_WINDOW (widget)->priv->view))) { if ((event->state & modifiers) == 0) {
if (!gtk_widget_get_visible (EOG_WINDOW (widget)->priv->nav)) { if (!eog_scroll_view_scrollbars_visible (EOG_SCROLL_VIEW (EOG_WINDOW (widget)->priv->view))) {
/* If the iconview is not visible skip to the if (!gtk_widget_get_visible (EOG_WINDOW (widget)->priv->nav)) {
* next image manually as it won't handle /* If the iconview is not visible skip to the
* the keypress then. */ * next image manually as it won't handle
eog_window_cmd_go_next (NULL, * the keypress then. */
EOG_WINDOW (widget)); eog_window_cmd_go_next (NULL,
result = TRUE; EOG_WINDOW (widget));
} else result = TRUE;
handle_selection = TRUE; } else
handle_selection = TRUE;
}
} }
break; break;
} }