Skip to content

Commit

Permalink
Add custom selection/unselection (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
qarmin authored Dec 14, 2020
1 parent ff353c7 commit 40f981d
Show file tree
Hide file tree
Showing 4 changed files with 550 additions and 14 deletions.
17 changes: 9 additions & 8 deletions czkawka_core/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ impl Common {

/// Function to check if directory match expression
pub fn regex_check(expression: &str, directory: impl AsRef<Path>) -> bool {
if !expression.contains('*') {
#[cfg(debug_assertions)]
{
println!("Invalid expression ERROR: Expression should have *");
}
return false;
}
// if !expression.contains('*') {
// #[cfg(debug_assertions)]
// {
// println!("Invalid expression Warning: Expression should have *,");
// }
// //return false;
// }

let temp_splits: Vec<&str> = expression.split('*').collect();
let mut splits: Vec<&str> = Vec::new();
Expand Down Expand Up @@ -139,6 +139,8 @@ mod test {
assert!(Common::regex_check("*home/*", "/home/"));
assert!(Common::regex_check("*.git*", "/home/.git"));
assert!(Common::regex_check("*/home/rafal*rafal*rafal*rafal*", "/home/rafal/rafalrafalrafal"));
assert!(Common::regex_check("AAA", "AAA"));
assert!(Common::regex_check("AAA*", "AAABDGG/QQPW*"));
assert!(!Common::regex_check("*home", "/home/"));
assert!(!Common::regex_check("*home", "/homefasfasfasfasf/"));
assert!(!Common::regex_check("*home", "/homefasfasfasfasf"));
Expand All @@ -149,7 +151,6 @@ mod test {
assert!(!Common::regex_check("*home/*koc", "/koc/home/"));
assert!(!Common::regex_check("*home/", "/home"));
assert!(!Common::regex_check("*TTT", "/GGG"));
assert!(!Common::regex_check("AAA", "AAA"));
}
#[test]
fn test_windows_path() {
Expand Down
119 changes: 113 additions & 6 deletions czkawka_gui/czkawka.glade
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ Author: Rafał Mikrut
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">0</property>
</packing>
</child>
<child>
Expand All @@ -208,6 +208,17 @@ Author: Rafał Mikrut
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
Expand All @@ -227,6 +238,17 @@ Author: Rafał Mikrut
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkButton" id="buttons_popover_duplicate_select_all_except_oldest">
<property name="label" translatable="yes">Select all except oldest</property>
Expand All @@ -237,7 +259,7 @@ Author: Rafał Mikrut
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
<property name="position">5</property>
</packing>
</child>
<child>
Expand All @@ -250,7 +272,7 @@ Author: Rafał Mikrut
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
<property name="position">6</property>
</packing>
</child>
<child>
Expand All @@ -263,7 +285,7 @@ Author: Rafał Mikrut
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">6</property>
<property name="position">7</property>
</packing>
</child>
<child>
Expand All @@ -276,7 +298,44 @@ Author: Rafał Mikrut
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">7</property>
<property name="position">8</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">9</property>
</packing>
</child>
<child>
<object class="GtkButton" id="buttons_popover_duplicate_select_custom">
<property name="label" translatable="yes">Select custom</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">10</property>
</packing>
</child>
<child>
<object class="GtkButton" id="buttons_popover_duplicate_unselect_custom">
<property name="label" translatable="yes">Unselect custom</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">11</property>
</packing>
</child>
</object>
Expand All @@ -299,7 +358,7 @@ Author: Rafał Mikrut
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">0</property>
</packing>
</child>
<child>
Expand All @@ -309,6 +368,17 @@ Author: Rafał Mikrut
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
Expand All @@ -328,6 +398,43 @@ Author: Rafał Mikrut
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkButton" id="buttons_popover_simple_list_select_custom">
<property name="label" translatable="yes">Select custom</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkButton" id="buttons_popover_simple_list_unselect_custom">
<property name="label" translatable="yes">Unselect custom</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">6</property>
</packing>
</child>
</object>
</child>
</object>
Expand Down
Loading

0 comments on commit 40f981d

Please sign in to comment.