Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c9dca59
fix typo
hacknus Nov 29, 2024
9c1ed8e
truncate date
hacknus Nov 30, 2024
9291016
fixed selection
hacknus Nov 30, 2024
860e256
sorting implemented
hacknus Nov 30, 2024
593a5ef
restructure code
hacknus Dec 1, 2024
0e3bd3b
clippy
hacknus Dec 1, 2024
6685bf2
Merge branch 'develop' into sort_by_metadata
hacknus Dec 22, 2024
1a2e081
move helper functions to `utils.rs`
hacknus Dec 30, 2024
4cfd2e8
rustfmt
hacknus Dec 30, 2024
06019d5
labels moved to `labels.rs`
hacknus Dec 30, 2024
a957a36
moved sorting configuration to `FileDialogConfig`
hacknus Jan 3, 2025
2eb1a75
fix scroll bug with tables
hacknus Jan 3, 2025
284fe40
fix scroll bug with tables, final!
hacknus Jan 4, 2025
1d6effe
header typo fix
hacknus Jan 4, 2025
7c884fc
Merge branch 'develop' into sort_by_metadata
hacknus Jan 4, 2025
288accb
rustfmt
hacknus Jan 4, 2025
1ffb5e1
Merge branch 'develop' into sort_by_metadata
hacknus Jan 28, 2025
ac9bdce
rustfmt and pick directory fix
hacknus Jan 28, 2025
25c9b40
Merge branch 'main' into sort_by_metadata
hacknus Feb 9, 2025
e463dae
update from main
hacknus Feb 9, 2025
703760f
Merge remote-tracking branch 'origin/main' into sort_by_metadata
hacknus Apr 28, 2025
f6e26ea
merge main into this branch
hacknus Apr 28, 2025
3ccf371
Merge remote-tracking branch 'origin/main' into sort_by_metadata
hacknus Jul 12, 2025
2719e32
replace deprecated function
hacknus Jul 12, 2025
fa44fd6
Merge remote-tracking branch 'origin/main' into sort_by_metadata
hacknus Nov 28, 2025
4423762
update to egui 0.33
hacknus Nov 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ exclude = ["media/", "!media/readme/", ".github/"]

[dependencies]
egui = { version = "0.33.0", default-features = false }
egui_extras = "0.33.0"
# fetch user folders
directories = "6.0"
# canonicalize paths
Expand Down
5 changes: 5 additions & 0 deletions examples/multilingual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ fn get_labels_german() -> FileDialogLabels {
unpin_folder: "✖ Ordner loslösen".to_string(),
rename_pinned_folder: "✏ Ordner umbenennen".to_string(),

file_name_header: "Name".to_string(),
file_size_header: "Grösse".to_string(),
created_date_header: "Erstellt".to_string(),
modified_date_header: "Geändert".to_string(),

selected_directory: "Ausgewählter Ordner:".to_string(),
selected_file: "Ausgewählte Datei:".to_string(),
selected_items: "Ausgewählte Elemente:".to_string(),
Expand Down
12 changes: 12 additions & 0 deletions src/config/labels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ pub struct FileDialogLabels {
pub unpin_folder: String,
/// Text used for the option to rename a pinned folder.
pub rename_pinned_folder: String,
/// Text used for the file name column.
pub file_name_header: String,
/// Text used for the file size column.
pub file_size_header: String,
/// Text used for the created date column.
pub created_date_header: String,
/// Text used for the modified date column.
pub modified_date_header: String,

// ------------------------------------------------------------------------
// Bottom panel:
Expand Down Expand Up @@ -156,6 +164,10 @@ impl Default for FileDialogLabels {
unpin_folder: "✖ Unpin".to_string(),
rename_pinned_folder: "✏ Rename".to_string(),

file_name_header: "Name".to_string(),
file_size_header: "File Size".to_string(),
created_date_header: "Created".to_string(),
modified_date_header: "Modified".to_string(),
selected_directory: "Selected directory:".to_string(),
selected_file: "Selected file:".to_string(),
selected_items: "Selected items:".to_string(),
Expand Down
12 changes: 12 additions & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::fmt::Display;
use std::path::{Path, PathBuf};
use std::sync::Arc;

use crate::file_dialog::{SortBy, SortOrder};
use crate::{FileSystem, NativeFileSystem};

/// Folder that the user pinned to the left sidebar.
Expand Down Expand Up @@ -235,6 +236,13 @@ pub struct FileDialogConfig {
pub show_devices: bool,
/// If the Removable Devices section in the left sidebar should be visible.
pub show_removable_devices: bool,

/// sort by
pub sort_by: SortBy,
/// sort order
pub sort_order: SortOrder,
/// show only filename and no meta-data in the central window
pub show_only_file_name: bool,
}

impl Default for FileDialogConfig {
Expand Down Expand Up @@ -321,6 +329,10 @@ impl FileDialogConfig {
show_devices: true,
show_removable_devices: true,

sort_by: SortBy::Filename,
sort_order: SortOrder::Ascending,
show_only_file_name: false,

file_system,
}
}
Expand Down
59 changes: 59 additions & 0 deletions src/data/directory_content.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::config::{FileDialogConfig, FileFilter};
use crate::file_dialog::{SortBy, SortOrder};
use crate::FileSystem;
use egui::mutex::Mutex;
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -331,6 +332,17 @@ impl DirectoryContent {
) -> impl Iterator<Item = &mut DirectoryEntry> {
self.content[range].iter_mut()
}
/// Returns one directory entry by index
pub fn get(&mut self, i: usize) -> Option<&mut DirectoryEntry> {
self.content.get_mut(i)
}

/// Returns one directory entry by index
pub fn get_index(&self, item: &DirectoryEntry) -> Option<usize> {
self.content
.iter()
.position(|entry| entry.path == item.path)
}

pub fn filtered_iter<'s>(
&'s self,
Expand All @@ -350,6 +362,53 @@ impl DirectoryContent {
.filter(|p| apply_search_value(p, search_value))
}

pub fn filtered_get<'s>(
&'s mut self,
index: usize,
search_value: &'s str,
) -> Option<&'s mut DirectoryEntry> {
self.content
.iter_mut()
.filter(|p| apply_search_value(p, search_value))
.nth(index)
}

pub fn filtered_count(&self, search_value: &str) -> usize {
self.filtered_iter(search_value).count()
}

pub fn sort_directory_entries(&mut self, sort_by: &SortBy, order: &SortOrder) {
self.content.sort_by(|a, b| {
let cmp = match sort_by {
SortBy::Filename => {
let a_name = a.path.file_name().unwrap_or_default().to_string_lossy();
let b_name = b.path.file_name().unwrap_or_default().to_string_lossy();
a_name.cmp(&b_name)
}
SortBy::Size => {
let a_size = a.metadata.size.unwrap_or(0);
let b_size = b.metadata.size.unwrap_or(0);
a_size.cmp(&b_size)
}
SortBy::DateCreated => {
let a_created = a.metadata.created.unwrap_or(SystemTime::UNIX_EPOCH);
let b_created = b.metadata.created.unwrap_or(SystemTime::UNIX_EPOCH);
a_created.cmp(&b_created)
}
SortBy::DateLastModified => {
let a_modified = a.metadata.last_modified.unwrap_or(SystemTime::UNIX_EPOCH);
let b_modified = b.metadata.last_modified.unwrap_or(SystemTime::UNIX_EPOCH);
a_modified.cmp(&b_modified)
}
};

match order {
SortOrder::Ascending => cmp,
SortOrder::Descending => cmp.reverse(),
}
});
}

/// Marks each element in the content as unselected.
pub fn reset_multi_selection(&mut self) {
for item in &mut self.content {
Expand Down
Loading
Loading