Skip to content

Commit 8e3939d

Browse files
committed
Make file name search optional.
1 parent 332d02a commit 8e3939d

File tree

7 files changed

+28
-17
lines changed

7 files changed

+28
-17
lines changed

core/src/search.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ pub struct SearchFlags {
3232
pub case_sensitive: bool,
3333
pub fixed_string: bool,
3434

35+
pub search_names: bool,
3536
pub search_pdf: bool,
3637
pub search_office: bool,
3738

@@ -112,14 +113,16 @@ pub fn run(engine: SearchEngine, params: SearchParameters) {
112113
return WalkState::Continue;
113114
}
114115

115-
let file_name = entry.file_name();
116116
let mut path_matches = Vec::new();
117-
matcher
118-
.find_iter(file_name.as_bytes(), |m| {
119-
path_matches.push(m);
120-
true
121-
})
122-
.expect("RegexMatcher should never throw an error");
117+
if params.flags.search_names {
118+
let file_name = entry.file_name();
119+
matcher
120+
.find_iter(file_name.as_bytes(), |m| {
121+
path_matches.push(m);
122+
true
123+
})
124+
.expect("RegexMatcher should never throw an error");
125+
}
123126

124127
if !file_type.is_file() {
125128
return WalkState::Continue;

gnome/src/ui/search_window/imp.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ pub struct SearchWindow {
4343
#[property(get, set)]
4444
pub disable_regex: Cell<bool>,
4545

46+
#[property(get, set)]
47+
pub search_names: Cell<bool>,
4648
#[property(get, set)]
4749
pub search_pdf: Cell<bool>,
4850
#[property(get, set)]
@@ -250,6 +252,7 @@ impl SearchWindow {
250252
case_sensitive: self.case_sensitive.get(),
251253
fixed_string: self.disable_regex.get(),
252254

255+
search_names: self.search_names.get(),
253256
search_pdf: self.search_pdf.get(),
254257
search_office: self.search_office.get(),
255258

gnome/src/ui/search_window/search_window.blp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,17 @@ template $ClapgrepSearchWindow: Adw.ApplicationWindow {
116116
title: _("Extra File Formats");
117117

118118
Adw.SwitchRow {
119-
title: _("PDF files");
119+
title: _("File Names");
120+
active: bind template.search_names bidirectional;
121+
}
122+
123+
Adw.SwitchRow {
124+
title: _("PDF Files");
120125
active: bind template.search_pdf bidirectional;
121126
}
122127

123128
Adw.SwitchRow {
124-
title: _("Office files");
129+
title: _("Office Files");
125130
active: bind template.search_office bidirectional;
126131
}
127132
}

po/cs.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@ msgid "Extra File Formats"
141141
msgstr "Extra formáty souborů"
142142

143143
#: gnome/src/ui/search_window/search_window.blp:119
144-
msgid "PDF files"
144+
msgid "PDF Files"
145145
msgstr "PDF soubory"
146146

147147
#: gnome/src/ui/search_window/search_window.blp:124
148-
msgid "Office files"
148+
msgid "Office Files"
149149
msgstr "Soubory Office"
150150

151151
#: gnome/src/ui/search_window/search_window.blp:135

po/de.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ msgid "Extra File Formats"
151151
msgstr "Zusätzliche Dateiformate"
152152

153153
#: gnome/src/ui/search_window/search_window.blp:119
154-
msgid "PDF files"
154+
msgid "PDF Files"
155155
msgstr "PDF Dateien"
156156

157157
#: gnome/src/ui/search_window/search_window.blp:124
158-
msgid "Office files"
158+
msgid "Office Files"
159159
msgstr "Office Dateien"
160160

161161
#: gnome/src/ui/search_window/search_window.blp:135

po/it.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,11 @@ msgid "Extra File Formats"
148148
msgstr "Formati di file extra"
149149

150150
#: gnome/src/ui/search_window/search_window.blp:119
151-
msgid "PDF files"
151+
msgid "PDF Files"
152152
msgstr "File PDF"
153153

154154
#: gnome/src/ui/search_window/search_window.blp:124
155-
msgid "Office files"
155+
msgid "Office Files"
156156
msgstr "File di ufficio"
157157

158158
#: gnome/src/ui/search_window/search_window.blp:135

po/ru.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@ msgid "Extra File Formats"
141141
msgstr "Дополнительные форматы файлов"
142142

143143
#: gnome/src/ui/search_window/search_window.blp:119
144-
msgid "PDF files"
144+
msgid "PDF Files"
145145
msgstr "PDF файлы"
146146

147147
#: gnome/src/ui/search_window/search_window.blp:124
148-
msgid "Office files"
148+
msgid "Office Files"
149149
msgstr "Файлы Office"
150150

151151
#: gnome/src/ui/search_window/search_window.blp:135

0 commit comments

Comments
 (0)