1
0
Fork 0
mirror of synced 2024-05-06 13:32:30 +12:00

Reformat code with idea tool

This commit is contained in:
Rafał Mikrut 2021-11-27 20:57:10 +01:00
parent b7e4eaccaf
commit cf2e822435
27 changed files with 79 additions and 13 deletions

View file

@ -55,8 +55,8 @@ jobs:
path: target/release/czkawka_cli path: target/release/czkawka_cli
if: ${{ matrix.type == 'release' }} if: ${{ matrix.type == 'release' }}
# Duplicate finder checks included and excluded directories # Duplicate finder checks included and excluded directories
# Others are just check delete files number # Others are just check delete files number
- name: Linux Regression Test - name: Linux Regression Test
run: | run: |
wget https://github.com/qarmin/czkawka/releases/download/1.1.0/TestSuite.zip wget https://github.com/qarmin/czkawka/releases/download/1.1.0/TestSuite.zip

View file

@ -54,9 +54,9 @@ jobs:
path: target/release/czkawka_cli.exe path: target/release/czkawka_cli.exe
if: ${{ matrix.type == 'release' }} if: ${{ matrix.type == 'release' }}
# Duplicate finder checks included and excluded directories # Duplicate finder checks included and excluded directories
# Others are just check delete files number # Others are just check delete files number
# Windows build have some elements changed like powershell before wget and unzip, python instead python3, rm -r instead rm -r and one (at the top) additional test which check size of characyers # Windows build have some elements changed like powershell before wget and unzip, python instead python3, rm -r instead rm -r and one (at the top) additional test which check size of characyers
- name: test - name: test
run: | run: |
powershell wget https://github.com/qarmin/czkawka/releases/download/1.1.0/TestSuite.zip -O TestSuite.zip powershell wget https://github.com/qarmin/czkawka/releases/download/1.1.0/TestSuite.zip -O TestSuite.zip

View file

@ -1,4 +1,3 @@
newline_style = "Unix" newline_style = "Unix"
max_width = 250 max_width = 250
remove_nested_parens = true remove_nested_parens = true

View file

@ -30,7 +30,7 @@ pub enum Commands {
search_method: CheckingMethod, search_method: CheckingMethod,
#[structopt(short = "D", long, default_value = "NONE", parse(try_from_str = parse_delete_method), help = "Delete method (AEN, AEO, ON, OO, HARD)", long_help = "Methods to delete the files.\nAEN - All files except the newest,\nAEO - All files except the oldest,\nON - Only 1 file, the newest,\nOO - Only 1 file, the oldest\nHARD - create hard link\nNONE - not delete files")] #[structopt(short = "D", long, default_value = "NONE", parse(try_from_str = parse_delete_method), help = "Delete method (AEN, AEO, ON, OO, HARD)", long_help = "Methods to delete the files.\nAEN - All files except the newest,\nAEO - All files except the oldest,\nON - Only 1 file, the newest,\nOO - Only 1 file, the oldest\nHARD - create hard link\nNONE - not delete files")]
delete_method: DeleteMethod, delete_method: DeleteMethod,
#[structopt(short = "ht", long, default_value = "BLAKE3", parse(try_from_str = parse_hash_type), help="Hash type (BLAKE3, CRC32, XXH3)")] #[structopt(short = "ht", long, default_value = "BLAKE3", parse(try_from_str = parse_hash_type), help = "Hash type (BLAKE3, CRC32, XXH3)")]
hash_type: HashType, hash_type: HashType,
#[structopt(flatten)] #[structopt(flatten)]
file_to_save: FileToSave, file_to_save: FileToSave,
@ -123,11 +123,11 @@ pub enum Commands {
file_to_save: FileToSave, file_to_save: FileToSave,
#[structopt(flatten)] #[structopt(flatten)]
not_recursive: NotRecursive, not_recursive: NotRecursive,
#[structopt(short = "g", long, default_value = "Gradient", parse(try_from_str = parse_similar_hash_algorithm), help="Hash algorithm (allowed: Mean, Gradient, Blockhash, VertGradient, DoubleGradient)")] #[structopt(short = "g", long, default_value = "Gradient", parse(try_from_str = parse_similar_hash_algorithm), help = "Hash algorithm (allowed: Mean, Gradient, Blockhash, VertGradient, DoubleGradient)")]
hash_alg: HashAlg, hash_alg: HashAlg,
#[structopt(short = "z", long, default_value = "Lanczos3", parse(try_from_str = parse_similar_image_filter), help="Hash algorithm (allowed: Lanczos3, Nearest, Triangle, Faussian, Catmullrom)")] #[structopt(short = "z", long, default_value = "Lanczos3", parse(try_from_str = parse_similar_image_filter), help = "Hash algorithm (allowed: Lanczos3, Nearest, Triangle, Faussian, Catmullrom)")]
image_filter: FilterType, image_filter: FilterType,
#[structopt(short = "c", long, default_value = "8", parse(try_from_str = parse_image_hash_size), help="Hash size (allowed: 4, 8, 16)")] #[structopt(short = "c", long, default_value = "8", parse(try_from_str = parse_image_hash_size), help = "Hash size (allowed: 4, 8, 16)")]
hash_size: u8, hash_size: u8,
}, },
#[structopt(name = "music", about = "Finds same music by tags", help_message = HELP_MESSAGE, after_help = "EXAMPLE:\n czkawka music -d /home/rafal -f results.txt")] #[structopt(name = "music", about = "Finds same music by tags", help_message = HELP_MESSAGE, after_help = "EXAMPLE:\n czkawka music -d /home/rafal -f results.txt")]
@ -366,6 +366,7 @@ fn parse_similar_image_filter(src: &str) -> Result<FilterType, String> {
}; };
Ok(filter_type) Ok(filter_type)
} }
fn parse_similar_hash_algorithm(src: &str) -> Result<HashAlg, String> { fn parse_similar_hash_algorithm(src: &str) -> Result<HashAlg, String> {
let algorithm; let algorithm;
algorithm = match src.to_lowercase().as_str() { algorithm = match src.to_lowercase().as_str() {

View file

@ -42,7 +42,7 @@ xxhash-rust = { version = "0.8.2", features = ["xxh3"] }
tempfile = "3.2.0" tempfile = "3.2.0"
# Video Duplactes # Video Duplactes
vid_dup_finder_lib = { git = "https://github.com/qarmin/vid_dup_finder_lib"} vid_dup_finder_lib = { git = "https://github.com/qarmin/vid_dup_finder_lib" }
ffmpeg_cmdline_utils = "0.1.0" ffmpeg_cmdline_utils = "0.1.0"
[features] [features]

View file

@ -38,6 +38,7 @@ pub enum DeleteMethod {
None, None,
Delete, Delete,
} }
/// Info struck with helpful information's about results /// Info struck with helpful information's about results
#[derive(Default)] #[derive(Default)]
pub struct Info { pub struct Info {

View file

@ -61,6 +61,7 @@ pub struct Info {
pub number_of_removed_files: usize, pub number_of_removed_files: usize,
pub number_of_failed_to_remove_files: usize, pub number_of_failed_to_remove_files: usize,
} }
impl Info { impl Info {
pub fn new() -> Self { pub fn new() -> Self {
Default::default() Default::default()
@ -488,6 +489,7 @@ impl BrokenFiles {
Common::print_time(start_time, SystemTime::now(), "delete_files".to_string()); Common::print_time(start_time, SystemTime::now(), "delete_files".to_string());
} }
} }
impl Default for BrokenFiles { impl Default for BrokenFiles {
fn default() -> Self { fn default() -> Self {
Self::new() Self::new()
@ -523,6 +525,7 @@ impl DebugPrint for BrokenFiles {
println!("-----------------------------------------"); println!("-----------------------------------------");
} }
} }
impl SaveResults for BrokenFiles { impl SaveResults for BrokenFiles {
fn save_results_to_file(&mut self, file_name: &str) -> bool { fn save_results_to_file(&mut self, file_name: &str) -> bool {
let start_time: SystemTime = SystemTime::now(); let start_time: SystemTime = SystemTime::now();
@ -561,6 +564,7 @@ impl SaveResults for BrokenFiles {
true true
} }
} }
impl PrintResults for BrokenFiles { impl PrintResults for BrokenFiles {
/// Print information's about duplicated entries /// Print information's about duplicated entries
/// Only needed for CLI /// Only needed for CLI

View file

@ -6,6 +6,7 @@ use std::time::SystemTime;
/// Class for common functions used across other class/functions /// Class for common functions used across other class/functions
pub struct Common(); pub struct Common();
impl Common { impl Common {
/// Printing time which took between start and stop point and prints also function name /// Printing time which took between start and stop point and prints also function name
#[allow(unused_variables)] #[allow(unused_variables)]
@ -157,6 +158,7 @@ mod test {
assert!(Common::regex_check("*/home", "C:\\home")); assert!(Common::regex_check("*/home", "C:\\home"));
} }
} }
#[test] #[test]
fn test_windows_path() { fn test_windows_path() {
assert_eq!(PathBuf::from("C:\\path.txt"), Common::normalize_windows_path("c:/PATH.tXt")); assert_eq!(PathBuf::from("C:\\path.txt"), Common::normalize_windows_path("c:/PATH.tXt"));

View file

@ -9,6 +9,7 @@ pub struct Directories {
pub excluded_directories: Vec<PathBuf>, pub excluded_directories: Vec<PathBuf>,
pub included_directories: Vec<PathBuf>, pub included_directories: Vec<PathBuf>,
} }
impl Directories { impl Directories {
pub fn new() -> Self { pub fn new() -> Self {
Default::default() Default::default()

View file

@ -1,9 +1,11 @@
pub trait DebugPrint { pub trait DebugPrint {
fn debug_print(&self); fn debug_print(&self);
} }
pub trait SaveResults { pub trait SaveResults {
fn save_results_to_file(&mut self, file_name: &str) -> bool; fn save_results_to_file(&mut self, file_name: &str) -> bool;
} }
pub trait PrintResults { pub trait PrintResults {
fn print_results(&self); fn print_results(&self);
} }

View file

@ -1016,6 +1016,7 @@ impl DuplicateFinder {
Common::print_time(start_time, SystemTime::now(), "delete_files".to_string()); Common::print_time(start_time, SystemTime::now(), "delete_files".to_string());
} }
} }
impl Default for DuplicateFinder { impl Default for DuplicateFinder {
fn default() -> Self { fn default() -> Self {
Self::new() Self::new()
@ -1079,6 +1080,7 @@ impl DebugPrint for DuplicateFinder {
println!("-----------------------------------------"); println!("-----------------------------------------");
} }
} }
impl SaveResults for DuplicateFinder { impl SaveResults for DuplicateFinder {
fn save_results_to_file(&mut self, file_name: &str) -> bool { fn save_results_to_file(&mut self, file_name: &str) -> bool {
let start_time: SystemTime = SystemTime::now(); let start_time: SystemTime = SystemTime::now();
@ -1177,6 +1179,7 @@ impl SaveResults for DuplicateFinder {
true true
} }
} }
impl PrintResults for DuplicateFinder { impl PrintResults for DuplicateFinder {
/// Print information's about duplicated entries /// Print information's about duplicated entries
/// Only needed for CLI /// Only needed for CLI
@ -1496,6 +1499,7 @@ mod tests {
fn assert_inode(before: &Metadata, after: &Metadata) { fn assert_inode(before: &Metadata, after: &Metadata) {
assert_eq!(before.ino(), after.ino()); assert_eq!(before.ino(), after.ino());
} }
#[cfg(target_family = "windows")] #[cfg(target_family = "windows")]
fn assert_inode(_: &Metadata, _: &Metadata) {} fn assert_inode(_: &Metadata, _: &Metadata) {}

View file

@ -43,6 +43,7 @@ pub struct Info {
pub number_of_removed_files: usize, pub number_of_removed_files: usize,
pub number_of_failed_to_remove_files: usize, pub number_of_failed_to_remove_files: usize,
} }
impl Info { impl Info {
pub fn new() -> Self { pub fn new() -> Self {
Default::default() Default::default()
@ -290,6 +291,7 @@ impl EmptyFiles {
Common::print_time(start_time, SystemTime::now(), "delete_files".to_string()); Common::print_time(start_time, SystemTime::now(), "delete_files".to_string());
} }
} }
impl Default for EmptyFiles { impl Default for EmptyFiles {
fn default() -> Self { fn default() -> Self {
Self::new() Self::new()
@ -326,6 +328,7 @@ impl DebugPrint for EmptyFiles {
println!("-----------------------------------------"); println!("-----------------------------------------");
} }
} }
impl SaveResults for EmptyFiles { impl SaveResults for EmptyFiles {
fn save_results_to_file(&mut self, file_name: &str) -> bool { fn save_results_to_file(&mut self, file_name: &str) -> bool {
let start_time: SystemTime = SystemTime::now(); let start_time: SystemTime = SystemTime::now();
@ -364,6 +367,7 @@ impl SaveResults for EmptyFiles {
true true
} }
} }
impl PrintResults for EmptyFiles { impl PrintResults for EmptyFiles {
/// Print information's about duplicated entries /// Print information's about duplicated entries
/// Only needed for CLI /// Only needed for CLI

View file

@ -55,6 +55,7 @@ pub struct EmptyFolder {
pub struct Info { pub struct Info {
pub number_of_empty_folders: usize, pub number_of_empty_folders: usize,
} }
impl Info { impl Info {
pub fn new() -> Self { pub fn new() -> Self {
Default::default() Default::default()
@ -325,6 +326,7 @@ impl DebugPrint for EmptyFolder {
println!("-----------------------------------------"); println!("-----------------------------------------");
} }
} }
impl SaveResults for EmptyFolder { impl SaveResults for EmptyFolder {
fn save_results_to_file(&mut self, file_name: &str) -> bool { fn save_results_to_file(&mut self, file_name: &str) -> bool {
let start_time: SystemTime = SystemTime::now(); let start_time: SystemTime = SystemTime::now();
@ -360,6 +362,7 @@ impl SaveResults for EmptyFolder {
true true
} }
} }
impl PrintResults for EmptyFolder { impl PrintResults for EmptyFolder {
fn print_results(&self) { fn print_results(&self) {
if !self.empty_folder_list.is_empty() { if !self.empty_folder_list.is_empty() {

View file

@ -53,6 +53,7 @@ pub struct Info {
pub number_of_removed_files: usize, pub number_of_removed_files: usize,
pub number_of_failed_to_remove_files: usize, pub number_of_failed_to_remove_files: usize,
} }
impl Info { impl Info {
pub fn new() -> Self { pub fn new() -> Self {
Default::default() Default::default()
@ -337,6 +338,7 @@ impl InvalidSymlinks {
Common::print_time(start_time, SystemTime::now(), "delete_files".to_string()); Common::print_time(start_time, SystemTime::now(), "delete_files".to_string());
} }
} }
impl Default for InvalidSymlinks { impl Default for InvalidSymlinks {
fn default() -> Self { fn default() -> Self {
Self::new() Self::new()
@ -373,6 +375,7 @@ impl DebugPrint for InvalidSymlinks {
println!("-----------------------------------------"); println!("-----------------------------------------");
} }
} }
impl SaveResults for InvalidSymlinks { impl SaveResults for InvalidSymlinks {
fn save_results_to_file(&mut self, file_name: &str) -> bool { fn save_results_to_file(&mut self, file_name: &str) -> bool {
let start_time: SystemTime = SystemTime::now(); let start_time: SystemTime = SystemTime::now();
@ -421,6 +424,7 @@ impl SaveResults for InvalidSymlinks {
true true
} }
} }
impl PrintResults for InvalidSymlinks { impl PrintResults for InvalidSymlinks {
/// Print information's about duplicated entries /// Print information's about duplicated entries
/// Only needed for CLI /// Only needed for CLI

View file

@ -73,6 +73,7 @@ pub struct Info {
pub number_of_failed_to_remove_files: usize, pub number_of_failed_to_remove_files: usize,
pub number_of_duplicates_music_files: usize, pub number_of_duplicates_music_files: usize,
} }
impl Info { impl Info {
pub fn new() -> Self { pub fn new() -> Self {
Default::default() Default::default()
@ -637,6 +638,7 @@ impl SameMusic {
Common::print_time(start_time, SystemTime::now(), "delete_files".to_string()); Common::print_time(start_time, SystemTime::now(), "delete_files".to_string());
} }
} }
impl Default for SameMusic { impl Default for SameMusic {
fn default() -> Self { fn default() -> Self {
Self::new() Self::new()
@ -675,6 +677,7 @@ impl DebugPrint for SameMusic {
println!("-----------------------------------------"); println!("-----------------------------------------");
} }
} }
impl SaveResults for SameMusic { impl SaveResults for SameMusic {
fn save_results_to_file(&mut self, file_name: &str) -> bool { fn save_results_to_file(&mut self, file_name: &str) -> bool {
let start_time: SystemTime = SystemTime::now(); let start_time: SystemTime = SystemTime::now();
@ -713,6 +716,7 @@ impl SaveResults for SameMusic {
true true
} }
} }
impl PrintResults for SameMusic { impl PrintResults for SameMusic {
/// Print information's about duplicated entries /// Print information's about duplicated entries
/// Only needed for CLI /// Only needed for CLI

View file

@ -108,6 +108,7 @@ pub struct Info {
pub number_of_failed_to_remove_files: usize, pub number_of_failed_to_remove_files: usize,
pub gained_space: u64, pub gained_space: u64,
} }
impl Info { impl Info {
pub fn new() -> Self { pub fn new() -> Self {
Default::default() Default::default()
@ -625,6 +626,7 @@ impl SimilarImages {
self.excluded_items.set_excluded_items(excluded_items, &mut self.text_messages); self.excluded_items.set_excluded_items(excluded_items, &mut self.text_messages);
} }
} }
impl Default for SimilarImages { impl Default for SimilarImages {
fn default() -> Self { fn default() -> Self {
Self::new() Self::new()
@ -645,6 +647,7 @@ impl DebugPrint for SimilarImages {
println!("-----------------------------------------"); println!("-----------------------------------------");
} }
} }
impl SaveResults for SimilarImages { impl SaveResults for SimilarImages {
fn save_results_to_file(&mut self, file_name: &str) -> bool { fn save_results_to_file(&mut self, file_name: &str) -> bool {
let start_time: SystemTime = SystemTime::now(); let start_time: SystemTime = SystemTime::now();
@ -697,6 +700,7 @@ impl SaveResults for SimilarImages {
true true
} }
} }
impl PrintResults for SimilarImages { impl PrintResults for SimilarImages {
fn print_results(&self) { fn print_results(&self) {
if !self.similar_vectors.is_empty() { if !self.similar_vectors.is_empty() {
@ -761,6 +765,7 @@ fn save_hashes_to_file(hashmap: &BTreeMap<String, FileEntry>, text_messages: &mu
} }
} }
} }
fn load_hashes_from_file(text_messages: &mut Messages, hash_size: u8, hash_alg: HashAlg, image_filter: FilterType) -> Option<BTreeMap<String, FileEntry>> { fn load_hashes_from_file(text_messages: &mut Messages, hash_size: u8, hash_alg: HashAlg, image_filter: FilterType) -> Option<BTreeMap<String, FileEntry>> {
if let Some(proj_dirs) = ProjectDirs::from("pl", "Qarmin", "Czkawka") { if let Some(proj_dirs) = ProjectDirs::from("pl", "Qarmin", "Czkawka") {
let cache_dir = PathBuf::from(proj_dirs.cache_dir()); let cache_dir = PathBuf::from(proj_dirs.cache_dir());

View file

@ -81,6 +81,7 @@ pub struct Info {
pub number_of_failed_to_remove_files: usize, pub number_of_failed_to_remove_files: usize,
pub gained_space: u64, pub gained_space: u64,
} }
impl Info { impl Info {
pub fn new() -> Self { pub fn new() -> Self {
Default::default() Default::default()
@ -498,6 +499,7 @@ impl SimilarVideos {
self.excluded_items.set_excluded_items(excluded_items, &mut self.text_messages); self.excluded_items.set_excluded_items(excluded_items, &mut self.text_messages);
} }
} }
impl Default for SimilarVideos { impl Default for SimilarVideos {
fn default() -> Self { fn default() -> Self {
Self::new() Self::new()
@ -518,6 +520,7 @@ impl DebugPrint for SimilarVideos {
println!("-----------------------------------------"); println!("-----------------------------------------");
} }
} }
impl SaveResults for SimilarVideos { impl SaveResults for SimilarVideos {
fn save_results_to_file(&mut self, file_name: &str) -> bool { fn save_results_to_file(&mut self, file_name: &str) -> bool {
let start_time: SystemTime = SystemTime::now(); let start_time: SystemTime = SystemTime::now();
@ -562,6 +565,7 @@ impl SaveResults for SimilarVideos {
true true
} }
} }
impl PrintResults for SimilarVideos { impl PrintResults for SimilarVideos {
fn print_results(&self) { fn print_results(&self) {
if !self.similar_vectors.is_empty() { if !self.similar_vectors.is_empty() {
@ -624,6 +628,7 @@ fn save_hashes_to_file(hashmap: &BTreeMap<String, FileEntry>, text_messages: &mu
} }
} }
} }
fn load_hashes_from_file(text_messages: &mut Messages) -> Option<BTreeMap<String, FileEntry>> { fn load_hashes_from_file(text_messages: &mut Messages) -> Option<BTreeMap<String, FileEntry>> {
if let Some(proj_dirs) = ProjectDirs::from("pl", "Qarmin", "Czkawka") { if let Some(proj_dirs) = ProjectDirs::from("pl", "Qarmin", "Czkawka") {
let cache_dir = PathBuf::from(proj_dirs.cache_dir()); let cache_dir = PathBuf::from(proj_dirs.cache_dir());

View file

@ -42,6 +42,7 @@ pub struct Info {
pub number_of_removed_files: usize, pub number_of_removed_files: usize,
pub number_of_failed_to_remove_files: usize, pub number_of_failed_to_remove_files: usize,
} }
impl Info { impl Info {
pub fn new() -> Self { pub fn new() -> Self {
Default::default() Default::default()
@ -277,6 +278,7 @@ impl Temporary {
Common::print_time(start_time, SystemTime::now(), "delete_files".to_string()); Common::print_time(start_time, SystemTime::now(), "delete_files".to_string());
} }
} }
impl Default for Temporary { impl Default for Temporary {
fn default() -> Self { fn default() -> Self {
Self::new() Self::new()
@ -311,6 +313,7 @@ impl DebugPrint for Temporary {
println!("-----------------------------------------"); println!("-----------------------------------------");
} }
} }
impl SaveResults for Temporary { impl SaveResults for Temporary {
fn save_results_to_file(&mut self, file_name: &str) -> bool { fn save_results_to_file(&mut self, file_name: &str) -> bool {
let start_time: SystemTime = SystemTime::now(); let start_time: SystemTime = SystemTime::now();
@ -349,6 +352,7 @@ impl SaveResults for Temporary {
true true
} }
} }
impl PrintResults for Temporary { impl PrintResults for Temporary {
fn print_results(&self) { fn print_results(&self) {
let start_time: SystemTime = SystemTime::now(); let start_time: SystemTime = SystemTime::now();

View file

@ -92,6 +92,7 @@ pub async fn check_if_can_delete_files(check_button_settings_confirm_deletion: &
} }
true true
} }
fn create_dialog_ask_for_deletion(window_main: &gtk::Window) -> (Dialog, CheckButton) { fn create_dialog_ask_for_deletion(window_main: &gtk::Window) -> (Dialog, CheckButton) {
let confirmation_dialog_delete = gtk::Dialog::with_buttons( let confirmation_dialog_delete = gtk::Dialog::with_buttons(
Some("Delete confirmation"), Some("Delete confirmation"),

View file

@ -82,6 +82,7 @@ fn move_things(tree_view: &gtk::TreeView, column_file_name: i32, column_path: i3
file_chooser.close(); file_chooser.close();
}); });
} }
fn move_with_tree(tree_view: &gtk::TreeView, column_file_name: i32, column_path: i32, column_color: i32, column_selection: i32, destination_folder: PathBuf, entry_info: &gtk::Entry, text_view_errors: &gtk::TextView) { fn move_with_tree(tree_view: &gtk::TreeView, column_file_name: i32, column_path: i32, column_color: i32, column_selection: i32, destination_folder: PathBuf, entry_info: &gtk::Entry, text_view_errors: &gtk::TextView) {
let model = get_list_store(tree_view); let model = get_list_store(tree_view);

View file

@ -84,6 +84,7 @@ pub fn connect_button_save(gui_data: &GuiData) {
post_save_things(file_name, &to_notebook_main_enum(notebook_main.current_page().unwrap()), &shared_buttons, &entry_info, &buttons_save_clone); post_save_things(file_name, &to_notebook_main_enum(notebook_main.current_page().unwrap()), &shared_buttons, &entry_info, &buttons_save_clone);
}); });
} }
fn post_save_things(file_name: &str, type_of_tab: &NotebookMainEnum, shared_buttons: &Rc<RefCell<HashMap<NotebookMainEnum, HashMap<String, bool>>>>, entry_info: &Entry, buttons_save: &Button) { fn post_save_things(file_name: &str, type_of_tab: &NotebookMainEnum, shared_buttons: &Rc<RefCell<HashMap<NotebookMainEnum, HashMap<String, bool>>>>, entry_info: &Entry, buttons_save: &Button) {
entry_info.set_text(format!("Saved results to file {}", file_name).as_str()); entry_info.set_text(format!("Saved results to file {}", file_name).as_str());
// Set state // Set state

View file

@ -49,6 +49,7 @@ fn popover_unselect_all(popover: &gtk::Popover, tree_view: &gtk::TreeView, colum
} }
popover.popdown(); popover.popdown();
} }
fn popover_reverse(popover: &gtk::Popover, tree_view: &gtk::TreeView, column_button_selection: u32, column_color: Option<i32>) { fn popover_reverse(popover: &gtk::Popover, tree_view: &gtk::TreeView, column_button_selection: u32, column_color: Option<i32>) {
let model = get_list_store(tree_view); let model = get_list_store(tree_view);

View file

@ -208,10 +208,12 @@ pub enum ColumnsEmptyFolders {
Path, Path,
Modification, Modification,
} }
pub enum ColumnsDirectory { pub enum ColumnsDirectory {
// Columns for Included and Excluded Directories in upper Notebook // Columns for Included and Excluded Directories in upper Notebook
Path = 0, Path = 0,
} }
pub enum ColumnsBigFiles { pub enum ColumnsBigFiles {
SelectionButton = 0, SelectionButton = 0,
Size, Size,
@ -219,18 +221,21 @@ pub enum ColumnsBigFiles {
Path, Path,
Modification, Modification,
} }
pub enum ColumnsEmptyFiles { pub enum ColumnsEmptyFiles {
SelectionButton = 0, SelectionButton = 0,
Name, Name,
Path, Path,
Modification, Modification,
} }
pub enum ColumnsTemporaryFiles { pub enum ColumnsTemporaryFiles {
SelectionButton = 0, SelectionButton = 0,
Name, Name,
Path, Path,
Modification, Modification,
} }
pub enum ColumnsSimilarImages { pub enum ColumnsSimilarImages {
ActivatableSelectButton = 0, ActivatableSelectButton = 0,
SelectionButton, SelectionButton,
@ -258,6 +263,7 @@ pub enum ColumnsSimilarVideos {
Color, Color,
TextColor, TextColor,
} }
pub enum ColumnsSameMusic { pub enum ColumnsSameMusic {
ActivatableSelectButton = 0, ActivatableSelectButton = 0,
SelectionButton, SelectionButton,
@ -275,6 +281,7 @@ pub enum ColumnsSameMusic {
Color, Color,
TextColor, TextColor,
} }
pub enum ColumnsInvalidSymlinks { pub enum ColumnsInvalidSymlinks {
SelectionButton = 0, SelectionButton = 0,
Name, Name,
@ -316,6 +323,7 @@ pub fn get_string_from_list_store(tree_view: &gtk::TreeView) -> Vec<String> {
} }
} }
} }
pub fn get_path_buf_from_vector_of_strings(vec_string: Vec<String>) -> Vec<PathBuf> { pub fn get_path_buf_from_vector_of_strings(vec_string: Vec<String>) -> Vec<PathBuf> {
vec_string.iter().map(PathBuf::from).collect() vec_string.iter().map(PathBuf::from).collect()
} }
@ -386,6 +394,7 @@ pub fn set_buttons(hashmap: &mut HashMap<String, bool>, buttons_array: &[gtk::Bu
} }
} }
} }
pub fn hide_all_buttons(buttons_array: &[gtk::Button]) { pub fn hide_all_buttons(buttons_array: &[gtk::Button]) {
for button in buttons_array { for button in buttons_array {
button.hide(); button.hide();
@ -402,6 +411,7 @@ pub fn get_text_from_invalid_symlink_cause(error: &invalid_symlinks::ErrorType)
pub fn get_list_store(tree_view: &gtk::TreeView) -> ListStore { pub fn get_list_store(tree_view: &gtk::TreeView) -> ListStore {
tree_view.model().unwrap().downcast::<gtk::ListStore>().unwrap() tree_view.model().unwrap().downcast::<gtk::ListStore>().unwrap()
} }
pub fn get_dialog_box_child(dialog: &gtk::Dialog) -> gtk::Box { pub fn get_dialog_box_child(dialog: &gtk::Dialog) -> gtk::Box {
dialog.child().unwrap().downcast::<gtk::Box>().unwrap() dialog.child().unwrap().downcast::<gtk::Box>().unwrap()
} }

View file

@ -15,6 +15,7 @@ pub enum NotebookMainEnum {
Symlinks, Symlinks,
BrokenFiles, BrokenFiles,
} }
pub fn to_notebook_main_enum(notebook_number: u32) -> NotebookMainEnum { pub fn to_notebook_main_enum(notebook_number: u32) -> NotebookMainEnum {
match notebook_number { match notebook_number {
0 => NotebookMainEnum::Duplicate, 0 => NotebookMainEnum::Duplicate,
@ -30,6 +31,7 @@ pub fn to_notebook_main_enum(notebook_number: u32) -> NotebookMainEnum {
_ => panic!("Invalid Notebook Tab"), _ => panic!("Invalid Notebook Tab"),
} }
} }
pub fn get_all_main_tabs() -> [NotebookMainEnum; NUMBER_OF_NOTEBOOK_MAIN_TABS] { pub fn get_all_main_tabs() -> [NotebookMainEnum; NUMBER_OF_NOTEBOOK_MAIN_TABS] {
[ [
to_notebook_main_enum(0), to_notebook_main_enum(0),
@ -52,6 +54,7 @@ pub enum NotebookUpperEnum {
ExcludedItems, ExcludedItems,
AllowedExtensions, AllowedExtensions,
} }
pub fn to_notebook_upper_enum(notebook_number: u32) -> NotebookUpperEnum { pub fn to_notebook_upper_enum(notebook_number: u32) -> NotebookUpperEnum {
match notebook_number { match notebook_number {
0 => NotebookUpperEnum::IncludedDirectories, 0 => NotebookUpperEnum::IncludedDirectories,
@ -61,6 +64,7 @@ pub fn to_notebook_upper_enum(notebook_number: u32) -> NotebookUpperEnum {
_ => panic!("Invalid Upper Notebook Tab"), _ => panic!("Invalid Upper Notebook Tab"),
} }
} }
pub fn get_all_upper_tabs() -> [NotebookUpperEnum; NUMBER_OF_NOTEBOOK_UPPER_TABS] { pub fn get_all_upper_tabs() -> [NotebookUpperEnum; NUMBER_OF_NOTEBOOK_UPPER_TABS] {
[to_notebook_upper_enum(0), to_notebook_upper_enum(1), to_notebook_upper_enum(2), to_notebook_upper_enum(3)] [to_notebook_upper_enum(0), to_notebook_upper_enum(1), to_notebook_upper_enum(2), to_notebook_upper_enum(3)]
} }

View file

@ -16,6 +16,7 @@ pub fn opening_double_click_function(tree_view: &gtk::TreeView, event: &gdk::Eve
} }
gtk::Inhibit(false) gtk::Inhibit(false)
} }
pub fn opening_enter_function(tree_view: &gtk::TreeView, event: &gdk::EventKey) -> gtk::Inhibit { pub fn opening_enter_function(tree_view: &gtk::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
let nt_object = get_notebook_object_from_tree_view(tree_view); let nt_object = get_notebook_object_from_tree_view(tree_view);
handle_tree_keypress(tree_view, event, nt_object.column_name, nt_object.column_path, nt_object.column_selection) handle_tree_keypress(tree_view, event, nt_object.column_name, nt_object.column_path, nt_object.column_selection)
@ -91,6 +92,7 @@ pub fn select_function_duplicates(_tree_selection: &gtk::TreeSelection, tree_mod
true true
} }
pub fn select_function_same_music(_tree_selection: &gtk::TreeSelection, tree_model: &gtk::TreeModel, tree_path: &gtk::TreePath, _is_path_currently_selected: bool) -> bool { pub fn select_function_same_music(_tree_selection: &gtk::TreeSelection, tree_model: &gtk::TreeModel, tree_path: &gtk::TreePath, _is_path_currently_selected: bool) -> bool {
let color = tree_model.value(&tree_model.iter(tree_path).unwrap(), ColumnsSameMusic::Color as i32).get::<String>().unwrap(); let color = tree_model.value(&tree_model.iter(tree_path).unwrap(), ColumnsSameMusic::Color as i32).get::<String>().unwrap();
@ -100,6 +102,7 @@ pub fn select_function_same_music(_tree_selection: &gtk::TreeSelection, tree_mod
true true
} }
pub fn select_function_similar_images(_tree_selection: &gtk::TreeSelection, tree_model: &gtk::TreeModel, tree_path: &gtk::TreePath, _is_path_currently_selected: bool) -> bool { pub fn select_function_similar_images(_tree_selection: &gtk::TreeSelection, tree_model: &gtk::TreeModel, tree_path: &gtk::TreePath, _is_path_currently_selected: bool) -> bool {
let color = tree_model.value(&tree_model.iter(tree_path).unwrap(), ColumnsSimilarImages::Color as i32).get::<String>().unwrap(); let color = tree_model.value(&tree_model.iter(tree_path).unwrap(), ColumnsSimilarImages::Color as i32).get::<String>().unwrap();
@ -109,6 +112,7 @@ pub fn select_function_similar_images(_tree_selection: &gtk::TreeSelection, tree
true true
} }
pub fn select_function_similar_videos(_tree_selection: &gtk::TreeSelection, tree_model: &gtk::TreeModel, tree_path: &gtk::TreePath, _is_path_currently_selected: bool) -> bool { pub fn select_function_similar_videos(_tree_selection: &gtk::TreeSelection, tree_model: &gtk::TreeModel, tree_path: &gtk::TreePath, _is_path_currently_selected: bool) -> bool {
let color = tree_model.value(&tree_model.iter(tree_path).unwrap(), ColumnsSimilarVideos::Color as i32).get::<String>().unwrap(); let color = tree_model.value(&tree_model.iter(tree_path).unwrap(), ColumnsSimilarVideos::Color as i32).get::<String>().unwrap();

View file

@ -4,6 +4,7 @@
use std::convert::From; use std::convert::From;
enum HWND__ {} enum HWND__ {}
type HWND = *mut HWND__; type HWND = *mut HWND__;
#[allow(non_camel_case_types, dead_code)] #[allow(non_camel_case_types, dead_code)]

View file

@ -17,11 +17,11 @@ parts:
- curl - curl
- gcc - gcc
- git - git
rust-path: ["czkawka_gui"] rust-path: [ "czkawka_gui" ]
apps: apps:
czkawka: czkawka:
command: bin/czkawka_gui command: bin/czkawka_gui
extensions: [gnome-3-38] extensions: [ gnome-3-38 ]
plugs: plugs:
- home - home
- removable-media - removable-media