Commit 88b53582 authored by Cosimo Cecchi's avatar Cosimo Cecchi

Revert "window: reverse the order of key-press event processing"

This reverts commit f76c50a0.
parent c55fa6b7
......@@ -5492,6 +5492,12 @@ key_press_event (GtkWidget *widget,
"context_click_background");
}
break;
case GDK_KEY_v:
/* Eat Control + v to not enable type ahead */
if ((event->state & GDK_CONTROL_MASK) != 0) {
handled = TRUE;
}
break;
default:
break;
}
......@@ -5507,8 +5513,7 @@ key_press_event (GtkWidget *widget,
if (!handled &&
event->keyval != GDK_KEY_slash /* don't steal slash key event, used for "go to" */ &&
event->keyval != GDK_KEY_BackSpace &&
event->keyval != GDK_KEY_Delete &&
!(event->keyval == GDK_KEY_v && event->state == GDK_CONTROL_MASK)) {
event->keyval != GDK_KEY_Delete) {
GdkEvent *new_event;
GdkWindow *window;
char *old_text;
......
......@@ -1003,20 +1003,6 @@ subdirectory_unloaded_callback (NautilusListModel *model,
nautilus_view_remove_subdirectory (NAUTILUS_VIEW (view), directory);
}
static gboolean
key_release_callback (GtkWidget *widget, GdkEventKey *event, gpointer callback_data)
{
switch (event->keyval) {
case GDK_KEY_v:
/* Re-enable tree search entry; disabled in key_press_callback */
if ((event->state & GDK_CONTROL_MASK) != 0) {
gtk_tree_view_set_enable_search (GTK_TREE_VIEW (widget), TRUE);
}
}
return FALSE;
}
static gboolean
key_press_callback (GtkWidget *widget, GdkEventKey *event, gpointer callback_data)
{
......@@ -1088,21 +1074,9 @@ key_press_callback (GtkWidget *widget, GdkEventKey *event, gpointer callback_dat
handled = TRUE;
break;
case GDK_KEY_v:
/* HACK: see https://bugzilla.gnome.org/show_bug.cgi?id=314431
*
* We force event propagating to the focus window before the keybindings
* in nautilus-window.c:nautilus_window_key_press_event(),
* but that will trigger the type-ahead window when Ctrl+V is pressed.
* We used to special-case Ctrl+V here, and handle the event,
* to block the default GtkTreeView handler to run and show the window,
* but that's ineffective as well, because it would break Copy/Paste, as keybindings
* are now processed later, and they won't run if we return TRUE here.
* So, we resort to disabling search while the handler runs, and re-enable it later
* in the key_release callback, while not handling the event, so the accelerator
* can still run.
*/
/* Eat Control + v to not enable type ahead */
if ((event->state & GDK_CONTROL_MASK) != 0) {
gtk_tree_view_set_enable_search (tree_view, FALSE);
handled = TRUE;
}
break;
......@@ -1648,8 +1622,6 @@ create_and_set_up_tree_view (NautilusListView *view)
G_CALLBACK (button_release_callback), view, 0);
g_signal_connect_object (view->details->tree_view, "key_press_event",
G_CALLBACK (key_press_callback), view, 0);
g_signal_connect_object (view->details->tree_view, "key_release_event",
G_CALLBACK (key_release_callback), view, 0);
g_signal_connect_object (view->details->tree_view, "popup_menu",
G_CALLBACK (popup_menu_callback), view, 0);
g_signal_connect_object (view->details->tree_view, "row_expanded",
......
......@@ -1091,27 +1091,10 @@ static gboolean
nautilus_window_key_press_event (GtkWidget *widget,
GdkEventKey *event)
{
static gpointer grand_parent_class = NULL;
NautilusWindow *window;
int i;
gboolean handled;
window = NAUTILUS_WINDOW (widget);
handled = FALSE;
if (!grand_parent_class) {
grand_parent_class = g_type_class_peek_parent (nautilus_window_parent_class);
}
/* See https://bugzilla.gnome.org/show_bug.cgi?id=314431
*
* We need to handle the keybindings for the currently focused widget
* before the common accelerator bindings.
*/
handled = gtk_window_propagate_key_event (GTK_WINDOW (window), event);
if (handled) {
return TRUE;
}
for (i = 0; i < G_N_ELEMENTS (extra_window_keybindings); i++) {
if (extra_window_keybindings[i].keyval == event->keyval) {
......@@ -1129,22 +1112,14 @@ nautilus_window_key_press_event (GtkWidget *widget,
g_assert (action != NULL);
if (gtk_action_is_sensitive (action)) {
gtk_action_activate (action);
handled = TRUE;
return TRUE;
}
break;
}
}
if (!handled) {
handled = gtk_window_activate_key (GTK_WINDOW (window), event);
}
if (!handled) {
handled = GTK_WIDGET_CLASS (grand_parent_class)->key_press_event (widget, event);
}
return handled;
return GTK_WIDGET_CLASS (nautilus_window_parent_class)->key_press_event (widget, event);
}
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment