Skip to content

Commit

Permalink
Broken
Browse files Browse the repository at this point in the history
  • Loading branch information
qarmin committed Jun 7, 2022
1 parent 3df10a6 commit 407b954
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 2 deletions.
13 changes: 13 additions & 0 deletions czkawka_core/src/broken_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ pub enum TypeOfFile {
PDF,
}

bitflags! {
pub struct CheckedFiles : u32 {
const NONE = 0;

const TRACK_TITLE = 0b1;
const TRACK_ARTIST = 0b10;
const YEAR = 0b100;
const LENGTH = 0b1000;
const GENRE = 0b10000;
const BITRATE = 0b100000;
}
}

/// Info struck with helpful information's about results
#[derive(Default)]
pub struct Info {
Expand Down
5 changes: 5 additions & 0 deletions czkawka_gui/i18n/en/czkawka_gui.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ main_label_shown_files = Number of shown files
main_label_resize_algorithm = Resize algorithm
main_label_similarity = Similarity{" "}
main_check_box_broken_files_audio = Audio
main_check_box_broken_files_pdf = Pdf
main_check_box_broken_files_archive = Archive
main_check_box_broken_files_image = Image
check_button_general_same_size = Ignore same size
check_button_general_same_size_tooltip = Ignore from results, files which have identical size - usually this are 1:1 duplicates
Expand Down
20 changes: 20 additions & 0 deletions czkawka_gui/src/gui_structs/gui_main_notebook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ pub struct GuiMainNotebook {

pub scale_similarity_similar_videos: Scale,

// Broken Files
pub check_button_broken_files_audio: CheckButton,
pub check_button_broken_files_pdf: CheckButton,
pub check_button_broken_files_archive: CheckButton,
pub check_button_broken_files_image: CheckButton,

// Music
pub check_button_music_title: CheckButton,
pub check_button_music_artist: CheckButton,
Expand Down Expand Up @@ -209,6 +215,11 @@ impl GuiMainNotebook {
let check_button_music_length: CheckButton = builder.object("check_button_music_length").unwrap();
let check_button_music_approximate_comparison: CheckButton = builder.object("check_button_music_approximate_comparison").unwrap();

let check_button_broken_files_audio: CheckButton = builder.object("check_button_broken_files_audio").unwrap();
let check_button_broken_files_pdf: CheckButton = builder.object("check_button_broken_files_pdf").unwrap();
let check_button_broken_files_archive: CheckButton = builder.object("check_button_broken_files_archive").unwrap();
let check_button_broken_files_image: CheckButton = builder.object("check_button_broken_files_image").unwrap();

let scale_similarity_similar_images: Scale = builder.object("scale_similarity_similar_images").unwrap();
let scale_similarity_similar_videos: Scale = builder.object("scale_similarity_similar_videos").unwrap();

Expand Down Expand Up @@ -284,6 +295,9 @@ impl GuiMainNotebook {
check_button_music_approximate_comparison,
scale_similarity_similar_images,
scale_similarity_similar_videos,
check_button_broken_files_audio,
check_button_broken_files_pdf,
check_button_broken_files_archive,
check_button_image_ignore_same_size,
label_similar_images_minimal_similarity,
label_duplicate_check_method,
Expand Down Expand Up @@ -321,6 +335,7 @@ impl GuiMainNotebook {
gc_tree_view_bad_extensions,
combo_box_big_files_mode,
label_big_files_mode,
check_button_broken_files_image,
}
}

Expand Down Expand Up @@ -396,6 +411,11 @@ impl GuiMainNotebook {
self.check_button_image_fast_compare
.set_tooltip_text(Some(&flg!("main_notebook_image_fast_compare_tooltip")));

self.check_button_broken_files_audio.set_label(Some(&flg!("main_check_box_broken_files_audio")));
self.check_button_broken_files_archive.set_label(Some(&flg!("main_check_box_broken_files_archive")));
self.check_button_broken_files_image.set_label(Some(&flg!("main_check_box_broken_files_image")));
self.check_button_broken_files_pdf.set_label(Some(&flg!("main_check_box_broken_files_pdf")));

{
let hash_size_index = self.combo_box_image_hash_size.active().unwrap() as usize;
let hash_size = IMAGES_HASH_SIZE_COMBO_BOX[hash_size_index];
Expand Down
45 changes: 45 additions & 0 deletions czkawka_gui/src/saving_loading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ const DEFAULT_IMAGE_REMOVE_AUTO_OUTDATED_CACHE: bool = true;
const DEFAULT_DUPLICATE_REMOVE_AUTO_OUTDATED_CACHE: bool = true;
const DEFAULT_DUPLICATE_CASE_SENSITIVE_NAME_CHECKING: bool = false;

const DEFAULT_BROKEN_FILES_PDF: bool = true;
const DEFAULT_BROKEN_FILES_AUDIO: bool = true;
const DEFAULT_BROKEN_FILES_ARCHIVE: bool = true;
const DEFAULT_BROKEN_FILES_IMAGE: bool = true;

const DEFAULT_NUMBER_OF_BIGGEST_FILES: &str = "50";
const DEFAULT_SIMILAR_IMAGES_SIMILARITY: i32 = 0;
const DEFAULT_SIMILAR_IMAGES_IGNORE_SAME_SIZE: bool = false;
Expand Down Expand Up @@ -427,6 +432,10 @@ enum LoadText {
SimilarVideosIgnoreSameSize,
MusicApproximateComparison,
DuplicateNameCaseSensitive,
BrokenFilesPdf,
BrokenFilesAudio,
BrokenFilesImage,
BrokenFilesArchive,
}

fn create_hash_map() -> (HashMap<LoadText, String>, HashMap<String, LoadText>) {
Expand Down Expand Up @@ -469,6 +478,10 @@ fn create_hash_map() -> (HashMap<LoadText, String>, HashMap<String, LoadText>) {
(LoadText::MusicApproximateComparison, "music_approximate_comparison"),
(LoadText::DuplicateNameCaseSensitive, "duplicate_name_case_sensitive"),
(LoadText::ComboBoxBigFiles, "combo_box_big_files_mode"),
(LoadText::BrokenFilesPdf, "broken_files_pdf"),
(LoadText::BrokenFilesAudio, "broken_files_audio"),
(LoadText::BrokenFilesImage, "broken_files_image"),
(LoadText::BrokenFilesArchive, "broken_files_archive"),
];
let mut hashmap_ls: HashMap<LoadText, String> = Default::default();
let mut hashmap_sl: HashMap<String, LoadText> = Default::default();
Expand Down Expand Up @@ -583,6 +596,23 @@ pub fn save_configuration(manual_execution: bool, upper_notebook: &GuiUpperNoteb
settings.check_button_settings_show_text_view.is_active(),
);

saving_struct.save_var(
hashmap_ls.get(&LoadText::BrokenFilesArchive).unwrap().to_string(),
main_notebook.check_button_broken_files_archive.is_active(),
);
saving_struct.save_var(
hashmap_ls.get(&LoadText::BrokenFilesImage).unwrap().to_string(),
main_notebook.check_button_broken_files_image.is_active(),
);
saving_struct.save_var(
hashmap_ls.get(&LoadText::BrokenFilesAudio).unwrap().to_string(),
main_notebook.check_button_broken_files_audio.is_active(),
);
saving_struct.save_var(
hashmap_ls.get(&LoadText::BrokenFilesPdf).unwrap().to_string(),
main_notebook.check_button_broken_files_pdf.is_active(),
);

// Others
saving_struct.save_var(
hashmap_ls.get(&LoadText::MinimalCacheSize).unwrap().to_string(),
Expand Down Expand Up @@ -756,6 +786,11 @@ pub fn load_configuration(
DEFAULT_DUPLICATE_CASE_SENSITIVE_NAME_CHECKING,
);

let check_button_broken_files_archive = loaded_entries.get_integer(hashmap_ls.get(&LoadText::BrokenFilesArchive).unwrap().clone(), DEFAULT_BROKEN_FILES_ARCHIVE);
let check_button_broken_files_pdf = loaded_entries.get_integer(hashmap_ls.get(&LoadText::BrokenFilesPdf).unwrap().clone(), DEFAULT_BROKEN_FILES_ARCHIVE);
let check_button_broken_files_image = loaded_entries.get_integer(hashmap_ls.get(&LoadText::BrokenFilesImage).unwrap().clone(), DEFAULT_BROKEN_FILES_ARCHIVE);
let check_button_broken_files_audio = loaded_entries.get_integer(hashmap_ls.get(&LoadText::BrokenFilesAudio).unwrap().clone(), DEFAULT_BROKEN_FILES_ARCHIVE);

// Setting data
if manual_execution || loading_at_start {
{
Expand Down Expand Up @@ -880,6 +915,11 @@ pub fn load_configuration(
main_notebook.check_button_video_ignore_same_size.set_active(similar_videos_ignore_same_size);
main_notebook.scale_similarity_similar_videos.set_value(similar_videos_similarity as f64);

main_notebook.check_button_broken_files_audio.set_active(check_button_broken_files_audio);
main_notebook.check_button_broken_files_pdf.set_active(check_button_broken_files_pdf);
main_notebook.check_button_broken_files_image.set_active(check_button_broken_files_image);
main_notebook.check_button_broken_files_archive.set_active(check_button_broken_files_archive);

{
let combo_chosen_index = main_notebook.combo_box_duplicate_check_method.active().unwrap();

Expand Down Expand Up @@ -1004,6 +1044,11 @@ pub fn reset_configuration(manual_clearing: bool, upper_notebook: &GuiUpperNoteb
main_notebook.combo_box_image_hash_size.set_active(Some(0));
main_notebook.combo_box_big_files_mode.set_active(Some(0));

main_notebook.check_button_broken_files_audio.set_active(DEFAULT_BROKEN_FILES_AUDIO);
main_notebook.check_button_broken_files_pdf.set_active(DEFAULT_BROKEN_FILES_PDF);
main_notebook.check_button_broken_files_archive.set_active(DEFAULT_BROKEN_FILES_ARCHIVE);
main_notebook.check_button_broken_files_image.set_active(DEFAULT_BROKEN_FILES_IMAGE);

main_notebook.scale_similarity_similar_images.set_range(0_f64, SIMILAR_VALUES[0][5] as f64); // DEFAULT FOR MAX of 8
main_notebook.scale_similarity_similar_images.set_fill_level(SIMILAR_VALUES[0][5] as f64);

Expand Down
18 changes: 17 additions & 1 deletion czkawka_gui/ui/czkawka.cmb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
(5,129,"GtkScrolledWindow","scrolled_window_invalid_symlinks",128,None,None,None,None),
(5,130,"GtkLabel",None,128,None,None,None,None),
(5,131,"GtkNotebookPage",None,56,None,None,None,9),
(5,132,"GtkScrolledWindow","scrolled_window_broken_files",131,None,None,None,None),
(5,132,"GtkBox",None,131,None,None,None,None),
(5,133,"GtkLabel",None,131,None,None,None,None),
(5,134,"GtkNotebookPage",None,56,None,None,None,10),
(5,135,"GtkScrolledWindow","scrolled_window_bad_extensions",134,None,None,None,None),
Expand Down Expand Up @@ -225,6 +225,12 @@
(5,220,"GtkImage",None,219,None,None,None,None),
(5,221,"GtkComboBoxText","combo_box_big_files_mode",74,None,None,None,1),
(5,222,"GtkLabel","label_big_files_mode",74,None,None,None,None),
(5,223,"GtkScrolledWindow","scrolled_window_broken_files",132,None,None,None,1),
(5,224,"GtkBox",None,132,None,None,None,None),
(5,225,"GtkCheckButton","check_button_broken_files_audio",224,None,None,None,None),
(5,226,"GtkCheckButton","check_button_broken_files_pdf",224,None,None,None,1),
(5,227,"GtkCheckButton","check_button_broken_files_archive",224,None,None,None,2),
(5,228,"GtkCheckButton","check_button_broken_files_image",224,None,None,None,3),
(6,1,"GtkPopover","popover_right_click",None,None,None,None,None),
(6,2,"GtkBox",None,1,None,None,None,None),
(6,3,"GtkButton","buttons_popover_right_click_open_file",2,None,None,None,None),
Expand Down Expand Up @@ -627,6 +633,7 @@
(5,131,"GtkNotebookPage","child",None,None,None,None,None,132),
(5,131,"GtkNotebookPage","position","9",None,None,None,None,None),
(5,131,"GtkNotebookPage","tab",None,None,None,None,None,133),
(5,132,"GtkOrientable","orientation","vertical",None,None,None,None,None),
(5,132,"GtkWidget","focusable","1",None,None,None,None,None),
(5,133,"GtkLabel","label","Broken Files",1,None,None,None,None),
(5,134,"GtkNotebookPage","child",None,None,None,None,None,135),
Expand Down Expand Up @@ -727,6 +734,15 @@
(5,220,"GtkImage","icon-name","image-missing",None,None,None,None,None),
(5,220,"GtkWidget","halign","center",None,None,None,None,None),
(5,222,"GtkLabel","label","VVV",None,None,None,None,None),
(5,223,"GtkWidget","vexpand","True",None,None,None,None,None),
(5,225,"GtkCheckButton","active","True",None,None,None,None,None),
(5,225,"GtkCheckButton","label","Audio",None,None,None,None,None),
(5,226,"GtkCheckButton","active","True",None,None,None,None,None),
(5,226,"GtkCheckButton","label","PDF",None,None,None,None,None),
(5,227,"GtkCheckButton","active","True",None,None,None,None,None),
(5,227,"GtkCheckButton","label","Archive",None,None,None,None,None),
(5,228,"GtkCheckButton","active","True",None,None,None,None,None),
(5,228,"GtkCheckButton","label","Image",None,None,None,None,None),
(6,1,"GtkPopover","child",None,None,None,None,None,2),
(6,1,"GtkPopover","position","left",None,None,None,None,None),
(6,2,"GtkOrientable","orientation","vertical",None,None,None,None,None),
Expand Down
36 changes: 35 additions & 1 deletion czkawka_gui/ui/main_window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -778,8 +778,42 @@
<child>
<object class="GtkNotebookPage">
<property name="child">
<object class="GtkScrolledWindow" id="scrolled_window_broken_files">
<object class="GtkBox">
<property name="focusable">1</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<child>
<object class="GtkCheckButton" id="check_button_broken_files_audio">
<property name="active">True</property>
<property name="label">Audio</property>
</object>
</child>
<child>
<object class="GtkCheckButton" id="check_button_broken_files_pdf">
<property name="active">True</property>
<property name="label">PDF</property>
</object>
</child>
<child>
<object class="GtkCheckButton" id="check_button_broken_files_archive">
<property name="active">True</property>
<property name="label">Archive</property>
</object>
</child>
<child>
<object class="GtkCheckButton" id="check_button_broken_files_image">
<property name="active">True</property>
<property name="label">Image</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolled_window_broken_files">
<property name="vexpand">True</property>
</object>
</child>
</object>
</property>
<property name="position">9</property>
Expand Down

0 comments on commit 407b954

Please sign in to comment.