Skip to content

Commit 3ff89f8

Browse files
committed
Search: Allow TryExec to be a list of programs.
1 parent 15e73a5 commit 3ff89f8

8 files changed

+26
-14
lines changed

libnemo-private/nemo-search-engine-advanced.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ process_search_helper_file (const gchar *path)
132132
{
133133
GKeyFile *key_file;
134134
gchar *exec_format = NULL;
135-
gchar *try_exec = NULL;
135+
gchar **try_exec_list = NULL;
136136
gchar *abs_try_path = NULL;
137137
gchar **mime_types = NULL;
138138
gint priority = 100;
@@ -158,10 +158,24 @@ process_search_helper_file (const gchar *path)
158158
goto done;
159159
}
160160

161-
try_exec = g_key_file_get_string (key_file, SEARCH_HELPER_GROUP, "TryExec", NULL);
162-
abs_try_path = g_find_program_in_path (try_exec);
163-
if (!abs_try_path) {
164-
DEBUG ("Skipping search helper '%s' - program is not available (%s)", path, try_exec);
161+
try_exec_list = g_key_file_get_string_list (key_file, SEARCH_HELPER_GROUP, "TryExec", NULL, NULL);
162+
gboolean try_failed = FALSE;
163+
164+
for (i = 0; i < g_strv_length (try_exec_list); i++) {
165+
abs_try_path = g_find_program_in_path (try_exec_list[i]);
166+
167+
if (!abs_try_path) {
168+
DEBUG ("Skipping search helper '%s' - program is not available (%s)", path, try_exec_list[i]);
169+
try_failed = TRUE;
170+
break;
171+
}
172+
173+
g_free (abs_try_path);
174+
}
175+
176+
g_strfreev (try_exec_list);
177+
178+
if (try_failed) {
165179
goto done;
166180
}
167181

@@ -215,8 +229,6 @@ process_search_helper_file (const gchar *path)
215229
done:
216230
g_key_file_free (key_file);
217231
g_free (exec_format);
218-
g_free (try_exec);
219-
g_free (abs_try_path);
220232

221233
if (mime_types != NULL) {
222234
g_strfreev (mime_types);

search-helpers/mso.nemo_search_helper

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[Nemo Search Helper]
2-
TryExec=nemo-mso-to-txt
2+
TryExec=nemo-mso-to-txt;
33
Exec=nemo-mso-to-txt %s
44
MimeType=application/vnd.openxmlformats-officedocument.wordprocessingml.document;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;application/vnd.openxmlformats-officedocument.presentationml.presentation;
55
priority=100
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[Nemo Search Helper]
2-
TryExec=exif
2+
TryExec=exif;
33
Exec=exif -m %s
44
MimeType=image/jpeg;image/png;image/gif;image/bmp;image/tiff;
55
Priority=100
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[Nemo Search Helper]
2-
TryExec=id3
2+
TryExec=id3;
33
Exec=id3 -l %s
44
MimeType=audio/mpeg;
55
Priority=100
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[Nemo Search Helper]
2-
TryExec=odt2txt
2+
TryExec=odt2txt;
33
Exec=odt2txt %s
44
MimeType=application/vnd.oasis.opendocument.text;application/vnd.oasis.opendocument.spreadsheet;application/vnd.oasis.opendocument.presentation;application/vnd.oasis.opendocument.graphics;
55
priority=100
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[Nemo Search Helper]
2-
TryExec=pdf2txt
2+
TryExec=pdf2txt;
33
Exec=pdf2txt %s
44
MimeType=application/pdf;
55
Priority=100
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[Nemo Search Helper]
2-
TryExec=pdftotext
2+
TryExec=pdftotext;
33
Exec=pdftotext %s -
44
MimeType=application/pdf;
55
Priority=200
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[Nemo Search Helper]
2-
TryExec=ps2ascii
2+
TryExec=ps2ascii;
33
Exec=ps2ascii %s
44
MimeType=application/ps;
55
Priority=100;

0 commit comments

Comments
 (0)