diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-03-19 18:03:16 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-03-19 18:03:16 -0400 |
commit | 31db61588543a1ba0935ac8ecb2ecac574c0a836 (patch) | |
tree | a2e2092e086a9c7d618e2c9ae1fc7b5a659e8a7a /gtk/gtktreeview.c | |
parent | 3ac4c76b18cc89a841ce09f0943539f16988fd21 (diff) | |
download | gtk+-31db61588543a1ba0935ac8ecb2ecac574c0a836.tar.gz |
Revert "Merge branch 'disable-window-test' into 'master'"
This reverts commit 3ac4c76b18cc89a841ce09f0943539f16988fd21, reversing
changes made to 6ec96d2e989d029a303b8b20ec72b86f974c0e87.
Diffstat (limited to 'gtk/gtktreeview.c')
-rw-r--r-- | gtk/gtktreeview.c | 428 |
1 files changed, 220 insertions, 208 deletions
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index 51fa6d5229..a30d0c0973 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -22,6 +22,7 @@ #include "gtkadjustmentprivate.h" #include "gtkbox.h" +#include "gtkbindings.h" #include "gtkbuildable.h" #include "gtkbutton.h" #include "gtkcelllayout.h" @@ -53,7 +54,6 @@ #include "gtkrendericonprivate.h" #include "gtkscrollable.h" #include "gtksettingsprivate.h" -#include "gtkshortcutcontroller.h" #include "gtksnapshot.h" #include "gtkstylecontextprivate.h" #include "gtktooltip.h" @@ -657,11 +657,6 @@ static void gtk_tree_view_size_allocate (GtkWidget *widget, static void gtk_tree_view_snapshot (GtkWidget *widget, GtkSnapshot *snapshot); -static gboolean gtk_tree_view_forward_controller_key_pressed (GtkEventControllerKey *key, - guint keyval, - guint keycode, - GdkModifierType state, - GtkTreeView *tree_view); static gboolean gtk_tree_view_key_controller_key_pressed (GtkEventControllerKey *key, guint keyval, guint keycode, @@ -770,7 +765,7 @@ static void invalidate_empty_focus (GtkTreeView *tree_view); static gboolean gtk_tree_view_is_expander_column (GtkTreeView *tree_view, GtkTreeViewColumn *column); static inline gboolean gtk_tree_view_draw_expanders (GtkTreeView *tree_view); -static void gtk_tree_view_add_move_binding (GtkWidgetClass *widget_class, +static void gtk_tree_view_add_move_binding (GtkBindingSet *binding_set, guint keyval, guint modmask, gboolean add_shifted_binding, @@ -1004,9 +999,16 @@ G_DEFINE_TYPE_WITH_CODE (GtkTreeView, gtk_tree_view, GTK_TYPE_CONTAINER, static void gtk_tree_view_class_init (GtkTreeViewClass *class) { - GObjectClass *o_class = G_OBJECT_CLASS (class); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class); - GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class); + GObjectClass *o_class; + GtkWidgetClass *widget_class; + GtkContainerClass *container_class; + GtkBindingSet *binding_set; + + binding_set = gtk_binding_set_by_class (class); + + o_class = (GObjectClass *) class; + widget_class = (GtkWidgetClass *) class; + container_class = (GtkContainerClass *) class; /* GObject signals */ o_class->set_property = gtk_tree_view_set_property; @@ -1501,198 +1503,217 @@ gtk_tree_view_class_init (GtkTreeViewClass *class) _gtk_marshal_BOOLEAN__VOIDv); /* Key bindings */ - gtk_tree_view_add_move_binding (widget_class, GDK_KEY_Up, 0, TRUE, + gtk_tree_view_add_move_binding (binding_set, GDK_KEY_Up, 0, TRUE, GTK_MOVEMENT_DISPLAY_LINES, -1); - gtk_tree_view_add_move_binding (widget_class, GDK_KEY_KP_Up, 0, TRUE, + gtk_tree_view_add_move_binding (binding_set, GDK_KEY_KP_Up, 0, TRUE, GTK_MOVEMENT_DISPLAY_LINES, -1); - gtk_tree_view_add_move_binding (widget_class, GDK_KEY_Down, 0, TRUE, + gtk_tree_view_add_move_binding (binding_set, GDK_KEY_Down, 0, TRUE, GTK_MOVEMENT_DISPLAY_LINES, 1); - gtk_tree_view_add_move_binding (widget_class, GDK_KEY_KP_Down, 0, TRUE, + gtk_tree_view_add_move_binding (binding_set, GDK_KEY_KP_Down, 0, TRUE, GTK_MOVEMENT_DISPLAY_LINES, 1); - gtk_tree_view_add_move_binding (widget_class, GDK_KEY_p, GDK_CONTROL_MASK, FALSE, + gtk_tree_view_add_move_binding (binding_set, GDK_KEY_p, GDK_CONTROL_MASK, FALSE, GTK_MOVEMENT_DISPLAY_LINES, -1); - gtk_tree_view_add_move_binding (widget_class, GDK_KEY_n, GDK_CONTROL_MASK, FALSE, + gtk_tree_view_add_move_binding (binding_set, GDK_KEY_n, GDK_CONTROL_MASK, FALSE, GTK_MOVEMENT_DISPLAY_LINES, 1); - gtk_tree_view_add_move_binding (widget_class, GDK_KEY_Home, 0, TRUE, + gtk_tree_view_add_move_binding (binding_set, GDK_KEY_Home, 0, TRUE, GTK_MOVEMENT_BUFFER_ENDS, -1); - gtk_tree_view_add_move_binding (widget_class, GDK_KEY_KP_Home, 0, TRUE, + gtk_tree_view_add_move_binding (binding_set, GDK_KEY_KP_Home, 0, TRUE, GTK_MOVEMENT_BUFFER_ENDS, -1); - gtk_tree_view_add_move_binding (widget_class, GDK_KEY_End, 0, TRUE, + gtk_tree_view_add_move_binding (binding_set, GDK_KEY_End, 0, TRUE, GTK_MOVEMENT_BUFFER_ENDS, 1); - gtk_tree_view_add_move_binding (widget_class, GDK_KEY_KP_End, 0, TRUE, + gtk_tree_view_add_move_binding (binding_set, GDK_KEY_KP_End, 0, TRUE, GTK_MOVEMENT_BUFFER_ENDS, 1); - gtk_tree_view_add_move_binding (widget_class, GDK_KEY_Page_Up, 0, TRUE, + gtk_tree_view_add_move_binding (binding_set, GDK_KEY_Page_Up, 0, TRUE, GTK_MOVEMENT_PAGES, -1); - gtk_tree_view_add_move_binding (widget_class, GDK_KEY_KP_Page_Up, 0, TRUE, + gtk_tree_view_add_move_binding (binding_set, GDK_KEY_KP_Page_Up, 0, TRUE, GTK_MOVEMENT_PAGES, -1); - gtk_tree_view_add_move_binding (widget_class, GDK_KEY_Page_Down, 0, TRUE, + gtk_tree_view_add_move_binding (binding_set, GDK_KEY_Page_Down, 0, TRUE, GTK_MOVEMENT_PAGES, 1); - gtk_tree_view_add_move_binding (widget_class, GDK_KEY_KP_Page_Down, 0, TRUE, + gtk_tree_view_add_move_binding (binding_set, GDK_KEY_KP_Page_Down, 0, TRUE, GTK_MOVEMENT_PAGES, 1); - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_Right, 0, - "move-cursor", - "(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, 1); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_Right, 0, "move-cursor", 2, + G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS, + G_TYPE_INT, 1); - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_Left, 0, - "move-cursor", - "(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, -1); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_Left, 0, "move-cursor", 2, + G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS, + G_TYPE_INT, -1); - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_KP_Right, 0, - "move-cursor", - "(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, 1); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Right, 0, "move-cursor", 2, + G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS, + G_TYPE_INT, 1); - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_KP_Left, 0, - "move-cursor", - "(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, -1); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Left, 0, "move-cursor", 2, + G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS, + G_TYPE_INT, -1); - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_Right, GDK_CONTROL_MASK, - "move-cursor", - "(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, 1); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_Right, GDK_CONTROL_MASK, + "move-cursor", 2, + G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS, + G_TYPE_INT, 1); - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_Left, GDK_CONTROL_MASK, - "move-cursor", - "(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, -1); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_Left, GDK_CONTROL_MASK, + "move-cursor", 2, + G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS, + G_TYPE_INT, -1); - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_KP_Right, GDK_CONTROL_MASK, - "move-cursor", - "(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, 1); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Right, GDK_CONTROL_MASK, + "move-cursor", 2, + G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS, + G_TYPE_INT, 1); - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_KP_Left, GDK_CONTROL_MASK, - "move-cursor", - "(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, -1); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Left, GDK_CONTROL_MASK, + "move-cursor", 2, + G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS, + G_TYPE_INT, -1); - gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_space, GDK_CONTROL_MASK, "toggle-cursor-row", NULL); - gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_KP_Space, GDK_CONTROL_MASK, "toggle-cursor-row", NULL); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_space, GDK_CONTROL_MASK, "toggle-cursor-row", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Space, GDK_CONTROL_MASK, "toggle-cursor-row", 0); - gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_a, GDK_CONTROL_MASK, "select-all", NULL); - gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_slash, GDK_CONTROL_MASK, "select-all", NULL); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_CONTROL_MASK, "select-all", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_slash, GDK_CONTROL_MASK, "select-all", 0); - gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_A, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "unselect-all", NULL); - gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_backslash, GDK_CONTROL_MASK, "unselect-all", NULL); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_A, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "unselect-all", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_backslash, GDK_CONTROL_MASK, "unselect-all", 0); - gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_space, GDK_SHIFT_MASK, "select-cursor-row", "(b)", TRUE); - gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_KP_Space, GDK_SHIFT_MASK, "select-cursor-row", "(b)", TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_space, GDK_SHIFT_MASK, "select-cursor-row", 1, + G_TYPE_BOOLEAN, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Space, GDK_SHIFT_MASK, "select-cursor-row", 1, + G_TYPE_BOOLEAN, TRUE); - gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_space, 0, "select-cursor-row", "(b)", TRUE); - gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_KP_Space, 0, "select-cursor-row", "(b)", TRUE); - gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_Return, 0, "select-cursor-row", "(b)", TRUE); - gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_ISO_Enter, 0, "select-cursor-row", "(b)", TRUE); - gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_KP_Enter, 0, "select-cursor-row", "(b)", TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_space, 0, "select-cursor-row", 1, + G_TYPE_BOOLEAN, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Space, 0, "select-cursor-row", 1, + G_TYPE_BOOLEAN, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_Return, 0, "select-cursor-row", 1, + G_TYPE_BOOLEAN, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_ISO_Enter, 0, "select-cursor-row", 1, + G_TYPE_BOOLEAN, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Enter, 0, "select-cursor-row", 1, + G_TYPE_BOOLEAN, TRUE); /* expand and collapse rows */ - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_plus, 0, - "expand-collapse-cursor-row", - "(bbb)", TRUE, TRUE, FALSE); - - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_asterisk, 0, - "expand-collapse-cursor-row", - "(bbb)", TRUE, TRUE, TRUE); - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_KP_Multiply, 0, - "expand-collapse-cursor-row", - "(bbb)", TRUE, TRUE, TRUE); - - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_slash, 0, - "expand-collapse-cursor-row", - "(bbb)", TRUE, FALSE, FALSE); - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_KP_Divide, 0, - "expand-collapse-cursor-row", - "(bbb)", TRUE, FALSE, FALSE); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_plus, 0, "expand-collapse-cursor-row", 3, + G_TYPE_BOOLEAN, TRUE, + G_TYPE_BOOLEAN, TRUE, + G_TYPE_BOOLEAN, FALSE); + + gtk_binding_entry_add_signal (binding_set, GDK_KEY_asterisk, 0, + "expand-collapse-cursor-row", 3, + G_TYPE_BOOLEAN, TRUE, + G_TYPE_BOOLEAN, TRUE, + G_TYPE_BOOLEAN, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Multiply, 0, + "expand-collapse-cursor-row", 3, + G_TYPE_BOOLEAN, TRUE, + G_TYPE_BOOLEAN, TRUE, + G_TYPE_BOOLEAN, TRUE); + + gtk_binding_entry_add_signal (binding_set, GDK_KEY_slash, 0, + "expand-collapse-cursor-row", 3, + G_TYPE_BOOLEAN, TRUE, + G_TYPE_BOOLEAN, FALSE, + G_TYPE_BOOLEAN, FALSE); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Divide, 0, + "expand-collapse-cursor-row", 3, + G_TYPE_BOOLEAN, TRUE, + G_TYPE_BOOLEAN, FALSE, + G_TYPE_BOOLEAN, FALSE); /* Not doable on US keyboards */ - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_plus, GDK_SHIFT_MASK, - "expand-collapse-cursor-row", - "(bbb)", TRUE, TRUE, TRUE); - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_KP_Add, 0, - "expand-collapse-cursor-row", - "(bbb)", TRUE, TRUE, FALSE); - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_KP_Add, GDK_SHIFT_MASK, - "expand-collapse-cursor-row", - "(bbb)", TRUE, TRUE, TRUE); - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_KP_Add, GDK_SHIFT_MASK, - "expand-collapse-cursor-row", - "(bbb)", TRUE, TRUE, TRUE); - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_Right, GDK_SHIFT_MASK, - "expand-collapse-cursor-row", - "(bbb)", FALSE, TRUE, TRUE); - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_KP_Right, GDK_SHIFT_MASK, - "expand-collapse-cursor-row", - "(bbb)", FALSE, TRUE, TRUE); - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_Right, GDK_CONTROL_MASK | GDK_SHIFT_MASK, - "expand-collapse-cursor-row", - "(bbb)", FALSE, TRUE, TRUE); - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_KP_Right, GDK_CONTROL_MASK | GDK_SHIFT_MASK, - "expand-collapse-cursor-row", - "(bbb)", FALSE, TRUE, TRUE); - - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_minus, 0, - "expand-collapse-cursor-row", - "(bbb)", TRUE, FALSE, FALSE); - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_minus, GDK_SHIFT_MASK, - "expand-collapse-cursor-row", - "(bbb)", TRUE, FALSE, TRUE); - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_KP_Subtract, 0, - "expand-collapse-cursor-row", - "(bbb)", TRUE, FALSE, FALSE); - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_KP_Subtract, GDK_SHIFT_MASK, - "expand-collapse-cursor-row", - "(bbb)", TRUE, FALSE, TRUE); - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_Left, GDK_SHIFT_MASK, - "expand-collapse-cursor-row", - "(bbb)", FALSE, FALSE, TRUE); - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_KP_Left, GDK_SHIFT_MASK, - "expand-collapse-cursor-row", - "(bbb)", FALSE, FALSE, TRUE); - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_Left, GDK_CONTROL_MASK | GDK_SHIFT_MASK, - "expand-collapse-cursor-row", - "(bbb)", FALSE, FALSE, TRUE); - gtk_widget_class_add_binding_signal (widget_class, - GDK_KEY_KP_Left, GDK_CONTROL_MASK | GDK_SHIFT_MASK, - "expand-collapse-cursor-row", - "(bbb)", FALSE, FALSE, TRUE); - - gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_BackSpace, 0, "select-cursor-parent", NULL); - gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_BackSpace, GDK_CONTROL_MASK, "select-cursor-parent", NULL); - - gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_f, GDK_CONTROL_MASK, "start-interactive-search", NULL); - - gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_F, GDK_CONTROL_MASK, "start-interactive-search", NULL); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_plus, GDK_SHIFT_MASK, "expand-collapse-cursor-row", 3, + G_TYPE_BOOLEAN, TRUE, + G_TYPE_BOOLEAN, TRUE, + G_TYPE_BOOLEAN, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Add, 0, "expand-collapse-cursor-row", 3, + G_TYPE_BOOLEAN, TRUE, + G_TYPE_BOOLEAN, TRUE, + G_TYPE_BOOLEAN, FALSE); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Add, GDK_SHIFT_MASK, "expand-collapse-cursor-row", 3, + G_TYPE_BOOLEAN, TRUE, + G_TYPE_BOOLEAN, TRUE, + G_TYPE_BOOLEAN, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Add, GDK_SHIFT_MASK, "expand-collapse-cursor-row", 3, + G_TYPE_BOOLEAN, TRUE, + G_TYPE_BOOLEAN, TRUE, + G_TYPE_BOOLEAN, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_Right, GDK_SHIFT_MASK, + "expand-collapse-cursor-row", 3, + G_TYPE_BOOLEAN, FALSE, + G_TYPE_BOOLEAN, TRUE, + G_TYPE_BOOLEAN, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Right, GDK_SHIFT_MASK, + "expand-collapse-cursor-row", 3, + G_TYPE_BOOLEAN, FALSE, + G_TYPE_BOOLEAN, TRUE, + G_TYPE_BOOLEAN, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_Right, + GDK_CONTROL_MASK | GDK_SHIFT_MASK, + "expand-collapse-cursor-row", 3, + G_TYPE_BOOLEAN, FALSE, + G_TYPE_BOOLEAN, TRUE, + G_TYPE_BOOLEAN, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Right, + GDK_CONTROL_MASK | GDK_SHIFT_MASK, + "expand-collapse-cursor-row", 3, + G_TYPE_BOOLEAN, FALSE, + G_TYPE_BOOLEAN, TRUE, + G_TYPE_BOOLEAN, TRUE); + + gtk_binding_entry_add_signal (binding_set, GDK_KEY_minus, 0, "expand-collapse-cursor-row", 3, + G_TYPE_BOOLEAN, TRUE, + G_TYPE_BOOLEAN, FALSE, + G_TYPE_BOOLEAN, FALSE); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_minus, GDK_SHIFT_MASK, "expand-collapse-cursor-row", 3, + G_TYPE_BOOLEAN, TRUE, + G_TYPE_BOOLEAN, FALSE, + G_TYPE_BOOLEAN, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Subtract, 0, "expand-collapse-cursor-row", 3, + G_TYPE_BOOLEAN, TRUE, + G_TYPE_BOOLEAN, FALSE, + G_TYPE_BOOLEAN, FALSE); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Subtract, GDK_SHIFT_MASK, "expand-collapse-cursor-row", 3, + G_TYPE_BOOLEAN, TRUE, + G_TYPE_BOOLEAN, FALSE, + G_TYPE_BOOLEAN, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_Left, GDK_SHIFT_MASK, + "expand-collapse-cursor-row", 3, + G_TYPE_BOOLEAN, FALSE, + G_TYPE_BOOLEAN, FALSE, + G_TYPE_BOOLEAN, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Left, GDK_SHIFT_MASK, + "expand-collapse-cursor-row", 3, + G_TYPE_BOOLEAN, FALSE, + G_TYPE_BOOLEAN, FALSE, + G_TYPE_BOOLEAN, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_Left, + GDK_CONTROL_MASK | GDK_SHIFT_MASK, + "expand-collapse-cursor-row", 3, + G_TYPE_BOOLEAN, FALSE, + G_TYPE_BOOLEAN, FALSE, + G_TYPE_BOOLEAN, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Left, + GDK_CONTROL_MASK | GDK_SHIFT_MASK, + "expand-collapse-cursor-row", 3, + G_TYPE_BOOLEAN, FALSE, + G_TYPE_BOOLEAN, FALSE, + G_TYPE_BOOLEAN, TRUE); + + gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, 0, "select-cursor-parent", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, GDK_CONTROL_MASK, "select-cursor-parent", 0); + + gtk_binding_entry_add_signal (binding_set, GDK_KEY_f, GDK_CONTROL_MASK, "start-interactive-search", 0); + + gtk_binding_entry_add_signal (binding_set, GDK_KEY_F, GDK_CONTROL_MASK, "start-interactive-search", 0); gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_TREE_VIEW_ACCESSIBLE); gtk_widget_class_set_css_name (widget_class, I_("treeview")); @@ -1704,7 +1725,6 @@ gtk_tree_view_init (GtkTreeView *tree_view) GtkCssNode *widget_node; GtkGesture *gesture; GtkEventController *controller; - GList *list, *controllers; gtk_widget_set_can_focus (GTK_WIDGET (tree_view), TRUE); gtk_widget_set_overflow (GTK_WIDGET (tree_view), GTK_OVERFLOW_HIDDEN); @@ -1766,24 +1786,6 @@ gtk_tree_view_init (GtkTreeView *tree_view) gtk_css_node_set_state (tree_view->header_node, gtk_css_node_get_state (widget_node)); g_object_unref (tree_view->header_node); - controller = gtk_event_controller_key_new (); - g_signal_connect (controller, "key-pressed", - G_CALLBACK (gtk_tree_view_forward_controller_key_pressed), tree_view); - gtk_widget_add_controller (GTK_WIDGET (tree_view), controller); - - controllers = gtk_widget_list_controllers (GTK_WIDGET (tree_view), GTK_PHASE_BUBBLE); - for (list = controllers; list; list = list->next) - { - if (GTK_IS_SHORTCUT_CONTROLLER (list->data)) - { - g_object_ref (list->data); - gtk_widget_remove_controller (GTK_WIDGET (tree_view), list->data); - gtk_widget_add_controller (GTK_WIDGET (tree_view), list->data); - break; - } - } - g_list_free (controllers); - tree_view->click_gesture = gtk_gesture_click_new (); gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (tree_view->click_gesture), 0); g_signal_connect (tree_view->click_gesture, "pressed", @@ -5310,6 +5312,7 @@ gtk_tree_view_key_controller_key_pressed (GtkEventControllerKey *key, { GtkWidget *widget = GTK_WIDGET (tree_view); GtkWidget *button; + GdkEvent *event; if (tree_view->rubber_band_status) { @@ -5429,16 +5432,16 @@ gtk_tree_view_key_controller_key_pressed (GtkEventControllerKey *key, } } - return FALSE; -} + /* Handle the keybindings. */ + event = gtk_get_current_event (); + if (gtk_bindings_activate_event (G_OBJECT (widget), event)) + { + gdk_event_unref (event); + return TRUE; + } + + gdk_event_unref (event); -static gboolean -gtk_tree_view_forward_controller_key_pressed (GtkEventControllerKey *key, - guint keyval, - guint keycode, - GdkModifierType state, - GtkTreeView *tree_view) -{ if (tree_view->search_entry_avoid_unhandled_binding) { tree_view->search_entry_avoid_unhandled_binding = FALSE; @@ -5484,6 +5487,15 @@ gtk_tree_view_key_controller_key_released (GtkEventControllerKey *key, GdkModifierType state, GtkTreeView *tree_view) { + GdkEvent *event; + + if (tree_view->rubber_band_status) + return; + + /* Handle the keybindings. */ + event = gtk_get_current_event (); + gtk_bindings_activate_event (G_OBJECT (tree_view), event); + gdk_event_unref (event); } static void @@ -8902,7 +8914,7 @@ gtk_tree_view_draw_expanders (GtkTreeView *tree_view) } static void -gtk_tree_view_add_move_binding (GtkWidgetClass *widget_class, +gtk_tree_view_add_move_binding (GtkBindingSet *binding_set, guint keyval, guint modmask, gboolean add_shifted_binding, @@ -8910,29 +8922,29 @@ gtk_tree_view_add_move_binding (GtkWidgetClass *widget_class, gint count) { - gtk_widget_class_add_binding_signal (widget_class, - keyval, modmask, - "move-cursor", - "(ii)", step, count); + gtk_binding_entry_add_signal (binding_set, keyval, modmask, + "move-cursor", 2, + G_TYPE_ENUM, step, + G_TYPE_INT, count); if (add_shifted_binding) - gtk_widget_class_add_binding_signal (widget_class, - keyval, GDK_SHIFT_MASK, - "move-cursor", - "(ii)", step, count); + gtk_binding_entry_add_signal (binding_set, keyval, GDK_SHIFT_MASK, + "move-cursor", 2, + G_TYPE_ENUM, step, + G_TYPE_INT, count); if ((modmask & GDK_CONTROL_MASK) == GDK_CONTROL_MASK) return; - gtk_widget_class_add_binding_signal (widget_class, keyval, - GDK_CONTROL_MASK | GDK_SHIFT_MASK, - "move-cursor", - "(ii)", step, count); + gtk_binding_entry_add_signal (binding_set, keyval, GDK_CONTROL_MASK | GDK_SHIFT_MASK, + "move-cursor", 2, + G_TYPE_ENUM, step, + G_TYPE_INT, count); - gtk_widget_class_add_binding_signal (widget_class, - keyval, GDK_CONTROL_MASK, - "move-cursor", - "(ii)", step, count); + gtk_binding_entry_add_signal (binding_set, keyval, GDK_CONTROL_MASK, + "move-cursor", 2, + G_TYPE_ENUM, step, + G_TYPE_INT, count); } static gint |