Skip to content

Commit 5119a37

Browse files
authored
Fix pack (#740)
1 parent 3748411 commit 5119a37

File tree

6 files changed

+106
-74
lines changed

6 files changed

+106
-74
lines changed

Changelog.md

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
- Improve checking for invalid extensions - [#705](https://github.com/qarmin/czkawka/pull/705)
99
- Support for finding invalid PDF files - [#705](https://github.com/qarmin/czkawka/pull/705)
1010
- Re-enable checking for broken music files(`libasound.so.2` no longer needed) - [#705](https://github.com/qarmin/czkawka/pull/705)
11+
- Fix disabled ui when using invalid settings in similar music - [#740](https://github.com/qarmin/czkawka/pull/740)
12+
- Speedup searching for invalid extensions - [#740](https://github.com/qarmin/czkawka/pull/740)
1113

1214
## Version 4.1.0 - 24.04.2022r
1315
- New mode - finding files whose content not match with their extension - [#678](https://github.com/qarmin/czkawka/pull/678)

czkawka_core/src/bad_extensions.rs

+84-70
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::collections::BTreeSet;
1+
use std::collections::{BTreeSet, HashMap};
22
use std::fs::File;
33
use std::io::prelude::*;
44
use std::io::BufWriter;
@@ -27,6 +27,7 @@ static DISABLED_EXTENSIONS: &[&str] = &["file", "cache", "bak"]; // Such files c
2727
// ("real_content_extension", "current_file_extension")
2828
static WORKAROUNDS: &[(&str, &str)] = &[
2929
// Wine/Windows
30+
("der", "cat"),
3031
("exe", "acm"),
3132
("exe", "ax"),
3233
("exe", "bck"),
@@ -38,78 +39,86 @@ static WORKAROUNDS: &[(&str, &str)] = &[
3839
("exe", "drv"),
3940
("exe", "drv16"),
4041
("exe", "ds"),
42+
("exe", "efi"),
4143
("exe", "exe16"),
4244
("exe", "fon"), // Type of font or something else
45+
("exe", "mod16"),
4346
("exe", "msstyles"),
47+
("exe", "mui"),
4448
("exe", "orig"),
49+
("exe", "signed"),
50+
("exe", "sys"),
4551
("exe", "sys"),
4652
("exe", "tlb"),
4753
("exe", "vxd"),
48-
("exe", "sys"),
49-
("exe", "mod16"),
54+
("exe", "winmd"),
55+
("xml", "adml"),
56+
("xml", "manifest"),
57+
("xml", "mum"),
5058
// Other
51-
("zip", "odg"), // Libreoffice
52-
("ods", "ots"), // Libreoffice
53-
("exe", "efi"),
54-
("sh", "sample"), // Git
55-
("exe", "signed"),
56-
("gz", "blend"),
57-
("gz", "crate"),
58-
("gz", "svgz"),
59-
("gz", "tgz"),
60-
("html", "md"),
61-
("html", "svg"), // Quite strange, but yes it works
62-
("jpg", "jfif"),
63-
("mobi", "azw3"),
64-
("obj", "o"),
65-
("obj", "bin"),
66-
("odp", "otp"),
67-
("odt", "ott"),
68-
("ogg", "ogv"),
69-
("pptx", "ppsx"),
70-
("sh", "bash"),
71-
("sh", "py"),
72-
("sh", "pyx"),
73-
("xml", "sopcinfo"), // Quartus
74-
("xml", "bsp"), // Quartus
75-
("xml", "fb2"),
76-
("xml", "user"), // Qtcreator
77-
("sh", "rs"),
78-
("sh", "pl"), // Gnome/Linux
79-
("sh", "pm"), // Gnome/Linux
80-
("xml", "cbp"), // CodeBlocks config
81-
("xml", "cmb"),
82-
("xml", "cfg"),
83-
("xml", "conf"),
84-
("xml", "config"),
85-
("xml", "dae"),
86-
("xml", "docbook"),
87-
("xml", "gir"),
88-
("xml", "glade"),
59+
("gz", "blend"), // Blender
60+
("gz", "crate"), // Cargo
61+
("gz", "svgz"), // Archive svg
62+
("gz", "tgz"), // Archive
63+
("html", "md"), // Markdown
64+
("jpg", "jfif"), // Photo format
65+
("mobi", "azw3"), // Ebook format
66+
("mpg", "vob"), // Weddings in parts have usually vob extension
67+
("obj", "bin"), // Multiple apps, Czkawka, Nvidia, Windows
68+
("obj", "o"), // Compilators
69+
("odp", "otp"), // LibreOffice
70+
("ods", "ots"), // Libreoffice
71+
("odt", "ott"), // Libreoffice
72+
("ogg", "ogv"), // Audio format
73+
("pptx", "ppsx"), // Powerpoint
74+
("sh", "bash"), // Linux
75+
("sh", "pl"), // Gnome/Linux
76+
("sh", "pm"), // Gnome/Linux
77+
("sh", "py"), // Python
78+
("sh", "pyx"), // Python
79+
("sh", "rs"), // Rust
80+
("sh", "sample"), // Git
81+
("xml", "bsp"), // Quartus
82+
("xml", "cbp"), // CodeBlocks config
83+
("xml", "cfg"), // Multiple apps - Godot
84+
("xml", "cmb"), // Cambalache
85+
("xml", "conf"), // Multiple apps - Python
86+
("xml", "config"), // Multiple apps - QT Creator
87+
("xml", "dae"), // 3D models
88+
("xml", "docbook"), //
89+
("xml", "fb2"), //
90+
("xml", "gir"), // GTK
91+
("xml", "glade"), // Glade
92+
("xml", "iml"), // Intelij Idea
93+
("xml", "kdenlive"), // KDenLive
94+
("xml", "lang"), // ?
95+
("xml", "policy"), // SystemD
96+
("xml", "qsys"), // Quartus
97+
("xml", "sopcinfo"), // Quartus
98+
("xml", "svg"), // SVG
99+
("xml", "ui"), // Cambalache, Glade
100+
("xml", "user"), // Qtcreator
101+
("xml", "vbox"), // VirtualBox
102+
("xml", "vbox-prev"), // VirtualBox
103+
("xml", "vcproj"), // VisualStudio
104+
("xml", "xba"), // Libreoffice
105+
("xml", "xcd"), // Libreoffice files
106+
("zip", "apk"), // Android apk
107+
("zip", "cbr"), // Komiksy
108+
("zip", "dat"), // Multiple - python, brave
109+
("zip", "doc"), // Word
110+
("zip", "docx"), // Word
111+
("zip", "jar"), // Java
112+
("zip", "kra"), // Krita
113+
("zip", "nupkg"), // Nuget packages
114+
("zip", "odg"), // Libreoffice
115+
("zip", "pptx"), // Powerpoint
116+
("zip", "whl"), // Python packages
117+
("zip", "xpi"), // Firefox extensions
118+
("zip", "zcos"), // Scilab
119+
// Probably invalid
120+
("html", "svg"),
89121
("xml", "html"),
90-
("xml", "kdenlive"),
91-
("xml", "lang"),
92-
("xml", "svg"),
93-
("xml", "ui"), // Cambalache, Glade
94-
("xml", "vcproj"), // VisualStudio
95-
("xml", "iml"), // Intelij Idea
96-
("xml", "manifest"),
97-
("xml", "xcd"), // Libreoffice files
98-
("xml", "policy"),
99-
("xml", "qsys"), // Quartus
100-
("xml", "xba"), // Libreoffice
101-
("zip", "apk"),
102-
("zip", "doc"),
103-
("zip", "docx"),
104-
("zip", "dat"),
105-
("zip", "jar"), // Java
106-
("zip", "kra"), // Krita
107-
("zip", "nupkg"),
108-
("zip", "pptx"),
109-
("zip", "whl"),
110-
("zip", "xpi"),
111-
("zip", "zcos"),
112-
("zip", "cbr"), // Komiksy
113122
// Probably bug in external library
114123
("exe", "doc"), // Not sure whe doc is not recognized
115124
("exe", "xls"), // Not sure whe xls is not recognized
@@ -306,10 +315,15 @@ impl BadExtensions {
306315

307316
let mut files_to_check = Default::default();
308317
mem::swap(&mut files_to_check, &mut self.files_to_check);
309-
310318
//// PROGRESS THREAD END
319+
320+
let mut hashmap_workarounds: HashMap<&str, &str> = Default::default();
321+
for (proper, found) in WORKAROUNDS {
322+
hashmap_workarounds.insert(found, proper);
323+
}
324+
311325
self.bad_extensions_files = files_to_check
312-
.into_par_iter() // TODO into par iter after
326+
.into_par_iter()
313327
.map(|file_entry| {
314328
atomic_file_counter.fetch_add(1, Ordering::Relaxed);
315329
if stop_receiver.is_some() && stop_receiver.unwrap().try_recv().is_ok() {
@@ -350,7 +364,7 @@ impl BadExtensions {
350364
}
351365

352366
// Check for all extensions that file can use(not sure if it is worth to do it)
353-
let mut all_available_extensions: BTreeSet<_> = Default::default();
367+
let mut all_available_extensions: BTreeSet<&str> = Default::default();
354368
let think_extension = match current_extension.is_empty() {
355369
true => "".to_string(),
356370
false => {
@@ -363,9 +377,9 @@ impl BadExtensions {
363377
}
364378

365379
// Workarounds
366-
for (pre, post) in WORKAROUNDS {
367-
if post == &current_extension.as_str() && all_available_extensions.contains(&pre) {
368-
all_available_extensions.insert(post);
380+
if let Some(pre) = hashmap_workarounds.get(current_extension.as_str()) {
381+
if all_available_extensions.contains(pre) {
382+
all_available_extensions.insert(current_extension.as_str());
369383
}
370384
}
371385

czkawka_gui/src/gui_structs/gui_bottom_buttons.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use gtk4::prelude::*;
22
use gtk4::{GestureClick, Widget};
33

4-
use crate::help_functions::{get_custom_label_from_widget, set_icon_of_button, BottomButtonsEnum};
4+
use crate::help_functions::{get_custom_label_from_widget, get_custom_label_with_name_from_widget, set_icon_of_button, BottomButtonsEnum};
55
use crate::{
66
flg, CZK_ICON_COMPARE, CZK_ICON_HARDLINK, CZK_ICON_HIDE_DOWN, CZK_ICON_HIDE_UP, CZK_ICON_MOVE, CZK_ICON_SAVE, CZK_ICON_SEARCH, CZK_ICON_SELECT, CZK_ICON_SYMLINK,
77
CZK_ICON_TRASH,
@@ -96,7 +96,7 @@ impl GuiBottomButtons {
9696
}
9797
pub fn update_language(&self) {
9898
get_custom_label_from_widget(&self.buttons_search.clone()).set_text(&flg!("bottom_search_button"));
99-
get_custom_label_from_widget(&self.buttons_select.clone()).set_text(&flg!("bottom_select_button"));
99+
get_custom_label_with_name_from_widget(&self.buttons_select.clone(), "SelectMenu").set_text(&flg!("bottom_select_button"));
100100
get_custom_label_from_widget(&self.buttons_delete.clone()).set_text(&flg!("bottom_delete_button"));
101101
get_custom_label_from_widget(&self.buttons_save.clone()).set_text(&flg!("bottom_save_button"));
102102
get_custom_label_from_widget(&self.buttons_symlink.clone()).set_text(&flg!("bottom_symlink_button"));

czkawka_gui/src/help_functions.rs

+14
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,20 @@ pub fn get_custom_label_from_widget<P: IsA<gtk4::Widget>>(item: &P) -> gtk4::Lab
795795
}
796796
panic!("Button doesn't have proper custom label child");
797797
}
798+
pub fn get_custom_label_with_name_from_widget<P: IsA<gtk4::Widget>>(item: &P, name: &str) -> gtk4::Label {
799+
let mut widgets_to_check = vec![item.clone().upcast::<gtk4::Widget>()];
800+
801+
while let Some(widget) = widgets_to_check.pop() {
802+
if let Ok(label) = widget.clone().downcast::<gtk4::Label>() {
803+
if name == label.text().as_str() {
804+
return label;
805+
}
806+
} else {
807+
widgets_to_check.extend(get_all_children(&widget));
808+
}
809+
}
810+
panic!("Button doesn't have proper custom label child");
811+
}
798812
pub fn get_custom_image_from_widget<P: IsA<gtk4::Widget>>(item: &P) -> gtk4::Image {
799813
let mut widgets_to_check = vec![item.clone().upcast::<gtk4::Widget>()];
800814

czkawka_gui/ui/czkawka.cmb

+2-1
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@
346346
(5,4,"GtkPaned","resize-start-child","0",None,None,None,None,None),
347347
(5,4,"GtkPaned","shrink-end-child","0",None,None,None,None,None),
348348
(5,4,"GtkPaned","shrink-start-child","0",None,None,None,None,None),
349+
(5,4,"GtkPaned","wide-handle","True",None,None,None,None,None),
349350
(5,4,"GtkWidget","focusable","1",None,None,None,None,None),
350351
(5,4,"GtkWidget","vexpand","1",None,None,None,None,None),
351352
(5,5,"GtkWidget","focusable","1",None,None,None,None,None),
@@ -678,7 +679,7 @@
678679
(5,190,"GtkBox","spacing","2",None,None,None,None,None),
679680
(5,190,"GtkWidget","halign","center",None,None,None,None,None),
680681
(5,191,"GtkImage","icon-name","image-missing",None,None,None,None,None),
681-
(5,192,"GtkLabel","label","Select",1,None,None,None,None),
682+
(5,192,"GtkLabel","label","SelectMenu",None,None,None,None,None),
682683
(5,193,"GtkWidget","focusable","1",None,None,None,None,None),
683684
(5,193,"GtkWidget","receives-default","1",None,None,None,None,None),
684685
(5,194,"GtkBox","spacing","2",None,None,None,None,None),

czkawka_gui/ui/main_window.ui

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<property name="shrink-end-child">0</property>
2121
<property name="shrink-start-child">0</property>
2222
<property name="vexpand">1</property>
23+
<property name="wide-handle">True</property>
2324
<child>
2425
<object class="GtkNotebook" id="notebook_upper">
2526
<property name="focusable">1</property>
@@ -857,7 +858,7 @@
857858
</child>
858859
<child>
859860
<object class="GtkLabel">
860-
<property name="label" translatable="yes">Select</property>
861+
<property name="label">SelectMenu</property>
861862
</object>
862863
</child>
863864
</object>

0 commit comments

Comments
 (0)