Index: modules/menu/desktop-menu-dentry.c =================================================================== --- modules/menu/desktop-menu-dentry.c (revision 21998) +++ modules/menu/desktop-menu-dentry.c (working copy) @@ -66,7 +66,7 @@ static const char *dentry_keywords [] = { "Name", "Comment", "Icon", "Hidden", "StartupNotify", - "Categories", "OnlyShowIn", "Exec", "Terminal", + "Categories", "OnlyShowIn", "Exec", "TryExec", "Terminal", "NoDisplay", "GenericName", }; @@ -276,12 +276,37 @@ return submenu; } +static void +menu_cleanup_executable(gchar *string) +{ + gchar *p; + + if (!string) + return; + + if((p = strchr(string, ' '))) + *p = 0; + + if (string[0] == '"') { + int i; + + for (i = 1; string[i-1] != '\0'; ++i) { + if (string[i] != '"') + string[i-1] = string[i]; + else { + string[i-1] = '\0'; + break; + } + } + } +} + static gboolean menu_dentry_parse_dentry(XfceDesktopMenu *desktop_menu, XfceDesktopEntry *de, MenuPathType pathtype, gboolean is_legacy, const gchar *extra_cat) { gchar *categories = NULL, *hidden = NULL, *onlyshowin = NULL; - gchar *nodisplay = NULL; + gchar *nodisplay = NULL, *tryexec = NULL; gchar *path = NULL, *exec = NULL, *p; GtkWidget *mi = NULL, *menu; gint i, menu_pos; @@ -304,29 +329,28 @@ if(nodisplay && !g_ascii_strcasecmp(nodisplay, "true")) goto cleanup; + xfce_desktop_entry_get_string(de, "TryExec", FALSE, &tryexec); + menu_cleanup_executable(tryexec); + if (tryexec) + { + p = g_find_program_in_path(tryexec); + if(!p) + goto cleanup; + g_free(p); + } + /* check for blacklisted item */ xfce_desktop_entry_get_string(de, "Exec", FALSE, &exec); if(!exec) goto cleanup; - if((p = strchr(exec, ' '))) - *p = 0; + /* filter out quotes around the command (yeah, people do that!) */ - if (exec[0] == '"') { - int i; - - for (i = 1; exec[i-1] != '\0'; ++i) { - if (exec[i] != '"') - exec[i-1] = exec[i]; - else { - exec[i-1] = '\0'; - break; - } - } - } - + menu_cleanup_executable(exec); + if(blacklist && g_hash_table_lookup(blacklist, exec)) goto cleanup; +#if 0 if (!g_path_is_absolute (exec)) { p = g_find_program_in_path(exec); @@ -334,9 +358,9 @@ goto cleanup; g_free(p); } +#endif - xfce_desktop_entry_get_string (de, "Categories", TRUE, &categories); - + xfce_desktop_entry_get_string (de, "Categories", TRUE, &categories); if(categories || !is_legacy) { /* hack: leave out items that look like they are KDE control panels */ if(categories && strstr(categories, ";X-KDE-")) @@ -482,6 +506,8 @@ g_free(hidden); if(categories) g_free(categories); + if(tryexec) + g_free(tryexec); if(exec) g_free(exec); if(path)