...
  View open merge request
Commits (1)
  • Nelson Benítez León's avatar
    ev-window.c: Don't send Ctrl and Alt accels to sidebar · bab8bbda
    Nelson Benítez León authored
    Don't send Ctrl and Alt accels to sidebar, as they may be handled by
    GtkTreeView or other sidebar focused widgets, while we want them to reach
    the main EvApplication accels.
    
    We except GtkEntry's (eg. cell tex editing in tree views) as eg. Ctrl+L
    accel should be handled by GtkEntry instead of rotating document.
    
    Issues #860 and #795
    bab8bbda
......@@ -5834,15 +5834,36 @@ static gboolean
ev_window_key_press_event (GtkWidget *widget,
GdkEventKey *event)
{
GtkWidget *sidebar;
GtkWidget *find_sidebar;
GtkWidget *focus_widget;
gboolean skip_sending_accel_to_sidebar = FALSE;
static gpointer grand_parent_class = NULL;
GtkWindow *window = GTK_WINDOW (widget);
if (grand_parent_class == NULL)
grand_parent_class = g_type_class_peek_parent (ev_window_parent_class);
/* Handle focus widget key events */
if (gtk_window_propagate_key_event (window, event))
return TRUE;
/* Don't send Ctrl and Alt accels to sidebar, as they may be handled by
* GtkTreeView or other sidebar focused widgets, while we want them to reach
* the main EvApplication accels. Issues #860 and #795 */
if (event->state & GDK_CONTROL_MASK || event->state & GDK_MOD1_MASK) {
sidebar = ev_window_get_sidebar (EV_WINDOW (widget));
find_sidebar = ev_window_get_find_sidebar (EV_WINDOW (widget));
focus_widget = gtk_window_get_focus (window);
if (focus_widget && gtk_widget_has_focus (focus_widget) &&
!GTK_IS_ENTRY (focus_widget) &&
(gtk_widget_is_ancestor (focus_widget, sidebar)
|| gtk_widget_is_ancestor (focus_widget, find_sidebar)))
skip_sending_accel_to_sidebar = TRUE;
}
if (!skip_sending_accel_to_sidebar) {
/* Handle focus widget key events */
if (gtk_window_propagate_key_event (window, event))
return TRUE;
}
/* Handle mnemonics and accelerators */
if (gtk_window_activate_key (window, event))
......@@ -7450,6 +7471,22 @@ ev_window_get_toolbar (EvWindow *ev_window)
return ev_window->priv->toolbar;
}
GtkWidget *
ev_window_get_sidebar (EvWindow *ev_window)
{
g_return_val_if_fail (EV_WINDOW (ev_window), NULL);
return ev_window->priv->sidebar;
}
GtkWidget *
ev_window_get_find_sidebar (EvWindow *ev_window)
{
g_return_val_if_fail (EV_WINDOW (ev_window), NULL);
return ev_window->priv->find_sidebar;
}
void
ev_window_focus_view (EvWindow *ev_window)
{
......
......@@ -96,6 +96,8 @@ void ev_window_focus_view (EvWindow *ev_win
GtkWidget *ev_window_get_toolbar (EvWindow *ev_window);
void ev_window_handle_annot_popup (EvWindow *ev_window,
EvAnnotation *annot);
GtkWidget *ev_window_get_sidebar (EvWindow *ev_window);
GtkWidget *ev_window_get_find_sidebar (EvWindow *ev_window);
G_END_DECLS
......