Skip to content

Commit

Permalink
Add sort button
Browse files Browse the repository at this point in the history
  • Loading branch information
qarmin committed Jan 29, 2023
1 parent 8ea9b4b commit 22cb6b3
Show file tree
Hide file tree
Showing 21 changed files with 349 additions and 114 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ panic = "unwind"
# LTO setting is disabled by default, because release mode is usually needed to develop app and compilation with LTO would take a lot of time
#lto = "fat"

# Optimize all dependencies except application/workspaces
# Optimize all dependencies except application/workspaces, even in debug builds
[profile.dev.package."*"]
opt-level = 3
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Icons used inside GUI version
Reshot license
Reshot license - https://www.reshot.com/

czkawka_gui/icons/*

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![com github qarmin czkawka](https://user-images.githubusercontent.com/41945903/102616149-66490400-4137-11eb-9cd6-813b2b070834.png)

**Czkawka** (_tch•kav•ka_ (IPA: [ʈ͡ʂkafka]), "hiccup" in Polish) is a simple, fast and free app to remove unnecessary files from your computer.
**Czkawka** (_tch•kav•ka_ (IPA: [ˈʧ̑kafka]), "hiccup" in Polish) is a simple, fast and free app to remove unnecessary files from your computer.

## Features
- Written in memory-safe Rust
Expand Down
54 changes: 23 additions & 31 deletions czkawka_core/src/broken_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH};
use std::{fs, mem, panic, thread};

use crossbeam_channel::Receiver;
use pdf::object::ParseOptions;
use pdf::PdfError;
use pdf::PdfError::Try;
use rayon::prelude::*;
Expand Down Expand Up @@ -521,41 +522,32 @@ impl BrokenFiles {
Err(_inspected) => Some(None),
},

TypeOfFile::PDF => {
match fs::read(&file_entry.path) {
Ok(content) => {
// Will be available in pdf > 0.7.2
// let parser_options = ParseOptions {
// allow_error_in_option: true,
// allow_xref_error: true,
// allow_invalid_ops: true,
// allow_missing_endobj: true,
// };
// if let Err(e) = pdf::file::File::from_data_with_options(content, parser_options) {

let mut file_entry_clone = file_entry.clone();
let result = panic::catch_unwind(|| {
if let Err(e) = pdf::file::File::from_data(content) {
file_entry.error_string = e.to_string();
let error = unpack_pdf_error(e);
if let PdfError::InvalidPassword = error {
return Some(None);
}
TypeOfFile::PDF => match fs::read(&file_entry.path) {
Ok(content) => {
let parser_options = ParseOptions::tolerant(); // Only show as broken files with really big bugs

let mut file_entry_clone = file_entry.clone();
let result = panic::catch_unwind(|| {
if let Err(e) = pdf::file::File::from_data_with_options(content, parser_options) {
file_entry.error_string = e.to_string();
let error = unpack_pdf_error(e);
if let PdfError::InvalidPassword = error {
return Some(None);
}
Some(Some(file_entry))
});
if let Ok(pdf_result) = result {
pdf_result
} else {
let message = create_crash_message("PDF-rs", &file_entry_clone.path.to_string_lossy(), "https://github.com/pdf-rs/pdf");
println!("{message}");
file_entry_clone.error_string = message;
Some(Some(file_entry_clone))
}
Some(Some(file_entry))
});
if let Ok(pdf_result) = result {
pdf_result
} else {
let message = create_crash_message("PDF-rs", &file_entry_clone.path.to_string_lossy(), "https://github.com/pdf-rs/pdf");
println!("{message}");
file_entry_clone.error_string = message;
Some(Some(file_entry_clone))
}
Err(_inspected) => Some(None),
}
}
Err(_inspected) => Some(None),
},

// This means that cache read invalid value because maybe cache comes from different czkawka version
TypeOfFile::Unknown => Some(None),
Expand Down
10 changes: 9 additions & 1 deletion czkawka_gui/i18n/en/czkawka_gui.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ popover_custom_all_in_group_label = Don't select all records in group
popover_custom_mode_unselect = Unselect Custom
popover_custom_mode_select = Select Custom
popover_sort_file_name = "Sort by file name"
popover_sort_folder_name = "Sort by folder name"
popover_sort_full_name = "Sort by full name"
popover_sort_size = "Sort by size"
popover_sort_selection = "Sort by selection"
popover_invalid_regex = Regex is invalid
popover_valid_regex = Regex is valid
Expand All @@ -250,6 +255,7 @@ bottom_save_button = Save
bottom_symlink_button = Symlink
bottom_hardlink_button = Hardlink
bottom_move_button = Move
bottom_sort_button = Sort
bottom_search_button_tooltip = Start search
bottom_select_button_tooltip = Select records. Only selected files/folders can be later processed.
Expand All @@ -268,10 +274,12 @@ bottom_hardlink_button_not_available_tooltip =
Button is disabled, because hardlinks cannot be created.
Hardlinks only works with administrator privileges on Windows, so be sure to run app as administrator.
If app already works with such privileges check for similar issues on Github.
bottom_move_button_tooltip =
bottom_move_button_tooltip =
Moves files to chosen directory.
It copies all files to the directory without preserving the directory tree.
When trying to move two files with identical name to folder, second will fail and show error.
bottom_sort_button_tooltip =
Sorts files/folders according to selected method.
bottom_show_errors_tooltip = Show/Hide bottom text panel.
bottom_show_upper_notebook_tooltip = Show/Hide upper notebook panel.
Expand Down
62 changes: 62 additions & 0 deletions czkawka_gui/icons/czk_sort.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 19 additions & 19 deletions czkawka_gui/src/connect_things/connect_button_select.rs
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
use gtk4::prelude::*;

use crate::gui_structs::gui_data::GuiData;
use crate::gui_structs::gui_popovers::GuiPopovers;
use crate::gui_structs::gui_popovers_select::GuiSelectPopovers;
use crate::help_functions::PopoverTypes;
use crate::notebook_enums::*;
use crate::notebook_info::NOTEBOOKS_INFO;

pub fn connect_button_select(gui_data: &GuiData) {
let popovers = gui_data.popovers.clone();
let popovers_select = gui_data.popovers_select.clone();
let notebook_main = gui_data.main_notebook.notebook_main.clone();
let gc_buttons_select = gui_data.bottom_buttons.gc_buttons_select.clone();

gc_buttons_select.connect_pressed(move |_, _, _, _| {
show_required_popovers(&popovers, &to_notebook_main_enum(notebook_main.current_page().unwrap()));
show_required_popovers(&popovers_select, &to_notebook_main_enum(notebook_main.current_page().unwrap()));
});
}

fn show_required_popovers(popovers: &GuiPopovers, current_mode: &NotebookMainEnum) {
let buttons_popover_select_all = popovers.buttons_popover_select_all.clone();
let buttons_popover_unselect_all = popovers.buttons_popover_unselect_all.clone();
let buttons_popover_reverse = popovers.buttons_popover_reverse.clone();
let buttons_popover_select_all_except_oldest = popovers.buttons_popover_select_all_except_oldest.clone();
let buttons_popover_select_all_except_newest = popovers.buttons_popover_select_all_except_newest.clone();
let buttons_popover_select_one_oldest = popovers.buttons_popover_select_one_oldest.clone();
let buttons_popover_select_one_newest = popovers.buttons_popover_select_one_newest.clone();
let buttons_popover_select_custom = popovers.buttons_popover_select_custom.clone();
let buttons_popover_unselect_custom = popovers.buttons_popover_unselect_custom.clone();
let buttons_popover_select_all_images_except_biggest = popovers.buttons_popover_select_all_images_except_biggest.clone();
let buttons_popover_select_all_images_except_smallest = popovers.buttons_popover_select_all_images_except_smallest.clone();
fn show_required_popovers(popovers_select: &GuiSelectPopovers, current_mode: &NotebookMainEnum) {
let buttons_popover_select_all = popovers_select.buttons_popover_select_all.clone();
let buttons_popover_unselect_all = popovers_select.buttons_popover_unselect_all.clone();
let buttons_popover_reverse = popovers_select.buttons_popover_reverse.clone();
let buttons_popover_select_all_except_oldest = popovers_select.buttons_popover_select_all_except_oldest.clone();
let buttons_popover_select_all_except_newest = popovers_select.buttons_popover_select_all_except_newest.clone();
let buttons_popover_select_one_oldest = popovers_select.buttons_popover_select_one_oldest.clone();
let buttons_popover_select_one_newest = popovers_select.buttons_popover_select_one_newest.clone();
let buttons_popover_select_custom = popovers_select.buttons_popover_select_custom.clone();
let buttons_popover_unselect_custom = popovers_select.buttons_popover_unselect_custom.clone();
let buttons_popover_select_all_images_except_biggest = popovers_select.buttons_popover_select_all_images_except_biggest.clone();
let buttons_popover_select_all_images_except_smallest = popovers_select.buttons_popover_select_all_images_except_smallest.clone();

let separator_select_custom = popovers.separator_select_custom.clone();
let separator_select_date = popovers.separator_select_date.clone();
let separator_select_image_size = popovers.separator_select_image_size.clone();
let separator_select_reverse = popovers.separator_select_reverse.clone();
let separator_select_custom = popovers_select.separator_select_custom.clone();
let separator_select_date = popovers_select.separator_select_date.clone();
let separator_select_image_size = popovers_select.separator_select_image_size.clone();
let separator_select_reverse = popovers_select.separator_select_reverse.clone();

let arr = &NOTEBOOKS_INFO[current_mode.clone() as usize].available_modes;

Expand Down
9 changes: 9 additions & 0 deletions czkawka_gui/src/connect_things/connect_button_sort.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use crate::gui_structs::gui_data::GuiData;

pub fn connect_button_sort(_gui_data: &GuiData) {
// let popovers_select = gui_data.popovers_select.clone();
// let notebook_main = gui_data.main_notebook.notebook_main.clone();
// let gc_buttons_select = gui_data.bottom_buttons.gc_buttons_select.clone();
//
// gc_buttons_select.connect_pressed(move |_, _, _, _| ());
}
Loading

0 comments on commit 22cb6b3

Please sign in to comment.