diff --git a/libcore/Widgets/BasicBreadcrumbsEntry.vala b/libcore/Widgets/BasicBreadcrumbsEntry.vala index 2f7bba8a6..c48450e0e 100644 --- a/libcore/Widgets/BasicBreadcrumbsEntry.vala +++ b/libcore/Widgets/BasicBreadcrumbsEntry.vala @@ -62,6 +62,7 @@ namespace Files.View.Chrome { protected const double YPAD = 0; /* y padding */ private Gdk.Window? entry_window = null; + private Gtk.EventControllerKey key_controller; protected bool context_menu_showing = false; @@ -82,15 +83,7 @@ namespace Files.View.Chrome { elements = new Gee.ArrayList (); old_elements = new Gee.ArrayList (); - connect_signals (); - minimum_width = 100; - notify["scale-factor"].connect (() => { - breadcrumb_icons.scale = scale_factor; - }); - } - - protected virtual void connect_signals () { realize.connect_after (after_realize); activate.connect (on_activate); button_release_event.connect (on_button_release_event); @@ -99,8 +92,17 @@ namespace Files.View.Chrome { motion_notify_event.connect_after (after_motion_notify); focus_in_event.connect (on_focus_in); focus_out_event.connect (on_focus_out); - key_press_event.connect (on_key_press_event); changed.connect (on_entry_text_changed); + + key_controller = new Gtk.EventControllerKey (this) { + propagation_phase = BUBBLE + }; + key_controller.key_pressed.connect (on_key_press_event); + + minimum_width = 100; + notify["scale-factor"].connect (() => { + breadcrumb_icons.scale = scale_factor; + }); } /** Navigatable Interface **/ @@ -180,24 +182,15 @@ namespace Files.View.Chrome { /** Signal handling **/ /*********************/ - public virtual bool on_key_press_event (Gdk.EventKey event) { - if (event.is_modifier == 1) { - return true; - } - - Gdk.ModifierType state; - event.get_state (out state); + public virtual bool on_key_press_event (uint keyval, uint keycode, Gdk.ModifierType state) { var mods = state & Gtk.accelerator_get_default_mod_mask (); bool only_control_pressed = (mods == Gdk.ModifierType.CONTROL_MASK); - - uint keyval; - event.get_keyval (out keyval); switch (keyval) { /* Do not trap unmodified Down and Up keys - used by some input methods */ case Gdk.Key.KP_Down: case Gdk.Key.Down: if (only_control_pressed) { - go_down (); + activate_path (""); return true; } @@ -216,14 +209,6 @@ namespace Files.View.Chrome { activate_path (""); return true; - case Gdk.Key.l: - if (only_control_pressed) { - set_entry_text (current_dir_path); - grab_focus (); - return true; - } else { - break; - } default: break; } @@ -367,10 +352,6 @@ namespace Files.View.Chrome { entry_text_changed (text); } - protected virtual void go_down () { - activate_path (""); - } - protected virtual void go_up () { text = FileUtils.get_parent_path_from_path (text); set_position (-1); diff --git a/src/View/Widgets/BreadcrumbsEntry.vala b/src/View/Widgets/BreadcrumbsEntry.vala index 21f285f14..4fdd638a2 100644 --- a/src/View/Widgets/BreadcrumbsEntry.vala +++ b/src/View/Widgets/BreadcrumbsEntry.vala @@ -75,9 +75,7 @@ namespace Files.View.Chrome { /** Overridden Navigatable interface functions **/ /************************************************/ - public override bool on_key_press_event (Gdk.EventKey event) { - uint keyval; - event.get_keyval (out keyval); + public override bool on_key_press_event (uint keyval, uint keycode, Gdk.ModifierType state) { switch (keyval) { case Gdk.Key.Return: case Gdk.Key.KP_Enter: @@ -85,6 +83,7 @@ namespace Files.View.Chrome { if (search_mode) { return true; } + break; case Gdk.Key.KP_Tab: case Gdk.Key.Tab: @@ -92,7 +91,7 @@ namespace Files.View.Chrome { return true; } - return base.on_key_press_event (event); + return base.on_key_press_event (keyval, keycode, state); } public override void reset () {