Skip to content

Commit

Permalink
Merge branch 'main' into jeremypw/gtk4prep-view-eventscroll
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit authored Oct 8, 2024
2 parents 25f67bd + 2f1a233 commit 759dbd2
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 213 deletions.
1 change: 0 additions & 1 deletion libcore/Interfaces/SearchableInterface.vala
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,5 @@ namespace Files.View.Chrome {

public abstract void cancel ();
public abstract void search (string txt, GLib.File search_location);
public abstract bool has_popped_up ();
}
}
14 changes: 13 additions & 1 deletion libcore/Widgets/BasicBreadcrumbsEntry.vala
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,19 @@ namespace Files.View.Chrome {
}
}

public bool hide_breadcrumbs { get; set; default = false; }
private bool _hide_breadcrumbs = false;
public bool hide_breadcrumbs {
get {
return _hide_breadcrumbs;
}

set {
_hide_breadcrumbs = value;
if (!hide_breadcrumbs) {
set_entry_text ("");
}
}
}
public const double MINIMUM_LOCATION_BAR_ENTRY_WIDTH = 16;
public const double MINIMUM_BREADCRUMB_WIDTH = 12;
public const int ICON_WIDTH = 32;
Expand Down
12 changes: 11 additions & 1 deletion src/View/AbstractDirectoryView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,12 @@ namespace Files {
return;
}

// Ensure focus file not overridden later
if (set_cursor_timeout_id > 0) {
Source.remove (set_cursor_timeout_id);
set_cursor_timeout_id = 0;
}

if (select_source_handler > 0) {
disconnect (select_source_handler);
select_source_handler = 0;
Expand All @@ -513,7 +519,6 @@ namespace Files {

uint count = 0;
Gtk.TreeIter? iter;

foreach (Files.File f in files_to_select) {
/* Not all files selected in previous view (e.g. expanded tree view) may appear in this one. */
if (model.get_first_iter_for_file (f, out iter)) {
Expand Down Expand Up @@ -3505,6 +3510,7 @@ namespace Files {
/* on expanders (if any) or xpad. Handle ourselves so that clicking
* on xpad also expands/collapses row (accessibility). */
expand_collapse (path);
button_controller.set_state (CLAIMED);
break;

default:
Expand All @@ -3523,6 +3529,10 @@ namespace Files {
break;

case Gdk.BUTTON_SECONDARY: // button 3
// No native behaviours on secondary click that we want
// ListView will cause unwanted deselections otherwise.
button_controller.set_state (CLAIMED);

switch (click_zone) {
case ClickZone.BLANK_NO_PATH:
case ClickZone.INVALID:
Expand Down
47 changes: 26 additions & 21 deletions src/View/ViewContainer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -509,29 +509,34 @@ namespace Files.View {
return;
}

FileInfo? info = aslot.lookup_file_info (loc);
FileType filetype = FileType.UNKNOWN;
if (info != null) { /* location is in the current folder */
filetype = info.get_file_type ();
if (filetype != FileType.DIRECTORY || no_path_change) {
if (unselect_others) {
aslot.set_all_selected (false);
selected_locations = null;
// Tab may still be loading so wait until finished
Idle.add_full (GLib.Priority.LOW, () => {
if (is_loading) {
return Source.CONTINUE;
} else if (no_path_change) {
Files.File? file = aslot.directory.file_hash_lookup_location (loc);
if (file != null) { /* location is in the current folder */
if (unselect_others) {
aslot.set_all_selected (false);
selected_locations = null;
}

var list = new List<GLib.File> ();
list.prepend (loc);
aslot.select_glib_files (list, loc);
} else {
view.focus_first_for_empty_selection (false); /* Just focus first file */
}
} else {
/* Attempt to navigate to the location */
if (loc != null) {
open_location (loc);
}

var list = new List<GLib.File> ();
list.prepend (loc);
aslot.select_glib_files (list, loc);
return;
}
} else if (no_path_change) { /* not in current, do not navigate to it*/
view.focus_first_for_empty_selection (false); /* Just focus first file */
return;
}
/* Attempt to navigate to the location */
if (loc != null) {
open_location (loc);
}

return Source.REMOVE;
});

}

public void focus_location_if_in_current_directory (
Expand Down
24 changes: 20 additions & 4 deletions src/View/Widgets/BreadcrumbsEntry.vala
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,18 @@ namespace Files.View.Chrome {
}
} // Candidate completion (placeholder)

public bool search_mode = false; // Used to suppress activate events while searching
public new bool hide_breadcrumbs {
get {
return base.hide_breadcrumbs || search_mode;
}

set {
base.hide_breadcrumbs = value;
}
}

// Used to suppress various events while searching
public bool search_mode { set; get; default = false; }

/** Drag and drop support **/
protected const Gdk.DragAction FILE_DRAG_ACTIONS = (Gdk.DragAction.COPY |
Expand Down Expand Up @@ -106,9 +117,14 @@ namespace Files.View.Chrome {
}

public override void reset () {
base.reset ();
completion_text = "";
current_completion_dir = null; // Do not cancel as this could interfere with a loading tab
if (search_mode) {
return;
} else {
base.reset ();
completion_text = "";
// Do not cancel as this could interfere with a loading tab
current_completion_dir = null;
}
}

/** Search related functions **/
Expand Down
22 changes: 12 additions & 10 deletions src/View/Widgets/LocationBar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ namespace Files.View.Chrome {
search_results.file_activated.connect (on_search_results_file_activated);
search_results.cursor_changed.connect (on_search_results_cursor_changed);
search_results.first_match_found.connect (on_search_results_first_match_found);
search_results.realize.connect (on_search_results_realize);
search_results.exit.connect (on_search_results_exit);
search_results.notify["working"].connect (on_search_results_working_changed);
}
Expand All @@ -84,6 +83,7 @@ namespace Files.View.Chrome {
gof.ensure_query_info ();

path_change_request (gof.get_target_location ().get_uri ());
on_search_results_exit ();
}
private void on_search_results_file_activated (GLib.File file) {
AppInfo? app = MimeActions.get_default_application_for_glib_file (file);
Expand All @@ -101,12 +101,9 @@ namespace Files.View.Chrome {
}
}

private void on_search_results_realize () {
/*Is this necessary every popup? */
((Gtk.Window)get_toplevel ()).get_group ().add_window (search_results);
}
private void on_search_results_exit (bool exit_navigate = true) {
/* Search result widget ensures it has closed and released grab */
search_results.is_active = false;
bread.reset_im_context ();
if (focus_timeout_id > 0) {
GLib.Source.remove (focus_timeout_id);
Expand All @@ -128,11 +125,16 @@ namespace Files.View.Chrome {
}

protected override bool after_bread_focus_out_event (Gdk.EventFocus event) {
base.after_bread_focus_out_event (event);
search_mode = false;
show_refresh_icon ();
focus_out_event (event);
check_home ();
if (search_results.is_active) {
bread.hide_breadcrumbs = true;
} else {
base.after_bread_focus_out_event (event);
search_mode = false;
show_refresh_icon ();
focus_out_event (event);
check_home ();
}

return true;
}
protected override bool after_bread_focus_in_event (Gdk.EventFocus event) {
Expand Down
Loading

0 comments on commit 759dbd2

Please sign in to comment.