[Xfce4-commits] <garcon:master> Check for TryExec in garcon_menu_item_get_element_visible.
Nick Schermer
nick at xfce.org
Sun Aug 16 18:06:11 CEST 2009
Updating branch refs/heads/master
to 44be78065c4bdec5540dcd05eeff13d651a73990 (commit)
from d36ce8d8f3a352a3d2e1fb0e704f2105d0a64daf (commit)
commit 44be78065c4bdec5540dcd05eeff13d651a73990
Author: Nick Schermer <nick at xfce.org>
Date: Sun Aug 16 13:53:48 2009 +0200
Check for TryExec in garcon_menu_item_get_element_visible.
garcon/garcon-menu-item.c | 27 ++++++++++++++++++++++++---
1 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/garcon/garcon-menu-item.c b/garcon/garcon-menu-item.c
index 2e852d2..34fc472 100644
--- a/garcon/garcon-menu-item.c
+++ b/garcon/garcon-menu-item.c
@@ -1275,7 +1275,11 @@ garcon_menu_item_get_element_icon_name (GarconMenuElement *element)
gboolean
garcon_menu_item_get_element_visible (GarconMenuElement *element)
{
- GarconMenuItem *item;
+ GarconMenuItem *item;
+ const gchar *try_exec;
+ gchar **mt;
+ gboolean result = TRUE;
+ gchar *command;
g_return_val_if_fail (GARCON_IS_MENU_ITEM (element), FALSE);
@@ -1286,9 +1290,26 @@ garcon_menu_item_get_element_visible (GarconMenuElement *element)
else if (garcon_menu_item_get_no_display (item))
return FALSE;
- /* TODO Check TryExec as well */
+ /* Check the TryExec field */
+ try_exec = garcon_menu_item_get_try_exec (item);
+ if (try_exec != NULL && g_shell_parse_argv (try_exec, NULL, &mt, NULL))
+ {
+ /* Check if we have an absolute path to an existing file */
+ result = g_file_test (mt[0], G_FILE_TEST_EXISTS);
+
+ /* Else, we may have a program in $PATH */
+ if (!result)
+ {
+ command = g_find_program_in_path (mt[0]);
+ result = (command != NULL);
+ g_free (command);
+ }
+
+ /* Cleanup */
+ g_strfreev (mt);
+ }
- return TRUE;
+ return result;
}
More information about the Xfce4-commits
mailing list