forked from AuroraMiddleware/gtk
bgo#580560 - Make Backspace work in the file chooser to to to the parent directory
GtkFileChooserDefault actually implements a binding signal for Backspace, to make it go to the parent directory. However, GtkTreeView was eating our Backspace, and thus the file chooser was not getting a chance to execute its binding signal. GtkTreeView implements a Backspace binding itself, which it uses to move to the parent node of the current cursor node. However, the binding handler would return TRUE even if there was no parent to the current node. Now the binding handler only returns TRUE if it actually changed the cursor. Additionally, gtk_tree_view_key_press() sees if no bindings handled a key press; in that case, it re-sends the key press to the treeview's search entry. However, sending a Backspace to an empty entry makes the entry beep. Thus, we add a flag that gets set from GtkTreeView's Backspace binding handler, to tell gtk_tree_view_key_press() when it should *not* re-emit the key press on the search entry. Sort of, "yeah, I didn't handle this key press, but I don't want you to send it to the search entry, either!". Signed-off-by: Federico Mena Quintero <federico@novell.com>
This commit is contained in:
parent
bc42bca9dd
commit
2b3de3dd75
@ -238,6 +238,8 @@ struct _GtkTreeViewPrivate
|
||||
|
||||
guint post_validation_flag : 1;
|
||||
|
||||
/* Whether our key press handler is to avoid sending an unhandled binding to the search entry */
|
||||
guint search_entry_avoid_unhandled_binding : 1;
|
||||
|
||||
/* Auto expand/collapse timeout in hover mode */
|
||||
guint auto_expand_timeout;
|
||||
|
@ -5377,6 +5377,12 @@ gtk_tree_view_key_press (GtkWidget *widget,
|
||||
if (GTK_WIDGET_CLASS (gtk_tree_view_parent_class)->key_press_event (widget, event))
|
||||
return TRUE;
|
||||
|
||||
if (tree_view->priv->search_entry_avoid_unhandled_binding)
|
||||
{
|
||||
tree_view->priv->search_entry_avoid_unhandled_binding = FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* We pass the event to the search_entry. If its text changes, then we start
|
||||
* the typeahead find capabilities. */
|
||||
if (GTK_WIDGET_HAS_FOCUS (tree_view)
|
||||
@ -10231,27 +10237,21 @@ gtk_tree_view_real_select_cursor_parent (GtkTreeView *tree_view)
|
||||
GdkModifierType state;
|
||||
|
||||
if (! GTK_WIDGET_HAS_FOCUS (tree_view))
|
||||
return FALSE;
|
||||
goto out;
|
||||
|
||||
cursor_path = NULL;
|
||||
if (tree_view->priv->cursor)
|
||||
cursor_path = gtk_tree_row_reference_get_path (tree_view->priv->cursor);
|
||||
|
||||
if (cursor_path == NULL)
|
||||
return FALSE;
|
||||
goto out;
|
||||
|
||||
_gtk_tree_view_find_node (tree_view, cursor_path,
|
||||
&cursor_tree, &cursor_node);
|
||||
if (cursor_tree == NULL)
|
||||
{
|
||||
gtk_tree_path_free (cursor_path);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (gtk_get_current_event_state (&state))
|
||||
{
|
||||
if ((state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK)
|
||||
tree_view->priv->ctrl_pressed = TRUE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (cursor_tree->parent_node)
|
||||
@ -10262,9 +10262,13 @@ gtk_tree_view_real_select_cursor_parent (GtkTreeView *tree_view)
|
||||
|
||||
gtk_tree_path_up (cursor_path);
|
||||
|
||||
gtk_tree_view_real_set_cursor (tree_view, cursor_path, TRUE, FALSE);
|
||||
if (gtk_get_current_event_state (&state))
|
||||
{
|
||||
if ((state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK)
|
||||
tree_view->priv->ctrl_pressed = TRUE;
|
||||
}
|
||||
|
||||
gtk_tree_view_real_set_cursor (tree_view, cursor_path, TRUE, FALSE);
|
||||
gtk_tree_view_clamp_node_visible (tree_view, cursor_tree, cursor_node);
|
||||
|
||||
gtk_widget_grab_focus (GTK_WIDGET (tree_view));
|
||||
@ -10274,7 +10278,14 @@ gtk_tree_view_real_select_cursor_parent (GtkTreeView *tree_view)
|
||||
tree_view->priv->ctrl_pressed = FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
out:
|
||||
|
||||
tree_view->priv->search_entry_avoid_unhandled_binding = TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_tree_view_search_entry_flush_timeout (GtkTreeView *tree_view)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user