Skip to content

Commit bfdeba3

Browse files
committed
search: Allow regular expression filename matching, improve editor.
- Add a regex toggle to the editor's filename row. - Implement filename regex search in the advanced search engine. - Replace legacy filename search code with GPatternSpec matching - Add expression validation for filename and content patterns, provide visual feedback to the user when expressions are invalid, and prevent activation.
1 parent 5e96d69 commit bfdeba3

10 files changed

+499
-325
lines changed

gresources/nemo-search-bar.glade

+105-56
Large diffs are not rendered by default.

libnemo-private/nemo-global-preferences.h

+1
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ typedef enum
275275
#define NEMO_PREFERENCES_DEFERRED_ATTR_PRELOAD_LIMIT "deferred-attribute-preload-limit"
276276

277277
#define NEMO_PREFERENCES_SEARCH_CONTENT_REGEX "search-content-use-regex"
278+
#define NEMO_PREFERENCES_SEARCH_FILES_REGEX "search-files-use-regex"
278279
#define NEMO_PREFERENCES_SEARCH_REGEX_FORMAT "search-regex-format"
279280
#define NEMO_PREFERENCES_SEARCH_USE_RAW "search-content-use-raw"
280281
#define NEMO_PREFERENCES_SEARCH_FILE_CASE "search-file-case-sensitive"

libnemo-private/nemo-query.c

+29-5
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ struct NemoQueryDetails {
3636
GList *mime_types;
3737
gboolean show_hidden;
3838
gboolean file_case_sensitive;
39+
gboolean file_use_regex;
3940
gboolean content_case_sensitive;
40-
gboolean use_regex;
41+
gboolean content_use_regex;
4142
gboolean count_hits;
4243
gboolean recurse;
4344
};
@@ -118,6 +119,14 @@ nemo_query_set_content_pattern (NemoQuery *query, const char *text)
118119
}
119120
}
120121

122+
gboolean
123+
nemo_query_has_content_pattern (NemoQuery *query)
124+
{
125+
g_return_val_if_fail (NEMO_IS_QUERY (query), FALSE);
126+
127+
return query->details->content_pattern != NULL;
128+
}
129+
121130
char *
122131
nemo_query_get_location (NemoQuery *query)
123132
{
@@ -232,18 +241,33 @@ nemo_query_set_content_case_sensitive (NemoQuery *query, gboolean case_sensitive
232241
}
233242

234243
gboolean
235-
nemo_query_get_use_regex (NemoQuery *query)
244+
nemo_query_get_use_file_regex (NemoQuery *query)
245+
{
246+
g_return_val_if_fail (NEMO_IS_QUERY (query), FALSE);
247+
return query->details->file_use_regex;
248+
}
249+
250+
void
251+
nemo_query_set_use_file_regex (NemoQuery *query, gboolean file_use_regex)
252+
{
253+
g_return_if_fail (NEMO_IS_QUERY (query));
254+
255+
query->details->file_use_regex = file_use_regex;
256+
}
257+
258+
gboolean
259+
nemo_query_get_use_content_regex (NemoQuery *query)
236260
{
237261
g_return_val_if_fail (NEMO_IS_QUERY (query), FALSE);
238-
return query->details->use_regex;
262+
return query->details->content_use_regex;
239263
}
240264

241265
void
242-
nemo_query_set_use_regex (NemoQuery *query, gboolean use_regex)
266+
nemo_query_set_use_content_regex (NemoQuery *query, gboolean content_use_regex)
243267
{
244268
g_return_if_fail (NEMO_IS_QUERY (query));
245269

246-
query->details->use_regex = use_regex;
270+
query->details->content_use_regex = content_use_regex;
247271
}
248272

249273
gboolean

libnemo-private/nemo-query.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ void nemo_query_set_file_pattern (NemoQuery *query, const char *text);
5454

5555
char * nemo_query_get_content_pattern (NemoQuery *query);
5656
void nemo_query_set_content_pattern (NemoQuery *query, const char *text);
57+
gboolean nemo_query_has_content_pattern (NemoQuery *query);
5758

5859
char * nemo_query_get_location (NemoQuery *query);
5960
void nemo_query_set_location (NemoQuery *query, const char *uri);
@@ -71,8 +72,11 @@ void nemo_query_set_file_case_sensitive (NemoQuery *query, gboolean ca
7172
gboolean nemo_query_get_content_case_sensitive (NemoQuery *query);
7273
void nemo_query_set_content_case_sensitive (NemoQuery *query, gboolean case_sensitive);
7374

74-
gboolean nemo_query_get_use_regex (NemoQuery *query);
75-
void nemo_query_set_use_regex (NemoQuery *query, gboolean use_regex);
75+
gboolean nemo_query_get_use_file_regex (NemoQuery *query);
76+
void nemo_query_set_use_file_regex (NemoQuery *query, gboolean file_use_regex);
77+
78+
gboolean nemo_query_get_use_content_regex (NemoQuery *query);
79+
void nemo_query_set_use_content_regex (NemoQuery *query, gboolean content_use_regex);
7680

7781
gboolean nemo_query_get_recurse (NemoQuery *query);
7882
void nemo_query_set_recurse (NemoQuery *query, gboolean recurse);

0 commit comments

Comments
 (0)