diff --git a/files/usr/share/nemo/actions/sample.nemo_action b/files/usr/share/nemo/actions/sample.nemo_action index 50011992d..f9c3e795d 100644 --- a/files/usr/share/nemo/actions/sample.nemo_action +++ b/files/usr/share/nemo/actions/sample.nemo_action @@ -80,7 +80,10 @@ Extensions=any; # You can also supply an absolute path to a file (i.e. /usr/lib/gvfs/gvfsd-archive) to check # instead of or in addition to an executable in the path. # This is an array, separate entries with semi-colon, and terminate with a semicolon. -#Dependencies=gedit; +# +# v3.0: Reverse dependencies: Prefixing a program with '!' will reverse the logic - if +# the program exists, the check will FAIL. +#Dependencies=xed;!gedit; # Conditions - semicolon-separated array of special conditions: # "desktop" current (parent) folder is desktop diff --git a/libnemo-private/nemo-action.c b/libnemo-private/nemo-action.c index bb2853722..7e59d3412 100644 --- a/libnemo-private/nemo-action.c +++ b/libnemo-private/nemo-action.c @@ -925,20 +925,37 @@ nemo_action_new (const gchar *name, if (deps != NULL) { guint i = 0; for (i = 0; i < g_strv_length (deps); i++) { - if (g_path_is_absolute (deps[i])) { - if (!g_file_test (deps[i], G_FILE_TEST_EXISTS)) { + gboolean reverse, found; + + reverse = g_str_has_prefix (deps[i], "!"); + found = FALSE; + + const gchar *prg_name = reverse ? deps[i] + 1 : deps[i]; + + if (g_path_is_absolute (prg_name)) { + if (g_file_test (prg_name, G_FILE_TEST_EXISTS)) { + found = TRUE; + } + } else { + gchar *p = g_find_program_in_path (prg_name); + if (p != NULL) { + found = TRUE; + g_free (p); + } + } + + if (reverse) { + if (found) { finish = FALSE; - DEBUG ("Missing action dependency: %s", deps[i]); + DEBUG ("Missing action reverse dependency: %s", deps[i]); + break; } } else { - gchar *p = g_find_program_in_path (deps[i]); - if (p == NULL) { + if (!found) { finish = FALSE; DEBUG ("Missing action dependency: %s", deps[i]); - g_free (p); break; } - g_free (p); } } }