From f42b11ac57c0bf1cb75f10ab931c540c09478058 Mon Sep 17 00:00:00 2001 From: Peter de Ridder Date: Sun, 13 Sep 2009 21:25:12 +0200 Subject: [PATCH] Use the Path entry from the .desktop file. The Path entry has priority over guessed working directory. --- thunar/thunar-file.c | 38 +++++++++++++++++++++----------------- 1 files changed, 21 insertions(+), 17 deletions(-) diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index 1e4297f..367f2c4 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -974,7 +974,7 @@ thunar_file_execute (ThunarFile *file, gchar *escaped_location; gchar **argv = NULL; gchar *exec; - gchar *directory; + gchar *directory = NULL; _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE); _thunar_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE); @@ -1014,6 +1014,8 @@ thunar_file_execute (ThunarFile *file, snotify = g_key_file_get_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY, NULL); + directory = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, + G_KEY_FILE_DESKTOP_KEY_PATH, NULL); result = thunar_exec_parse (exec, file_list, icon, name, location, terminal, NULL, &argv, error); @@ -1073,31 +1075,33 @@ thunar_file_execute (ThunarFile *file, if (G_LIKELY (result)) { - /* determine the working directory */ - if (G_LIKELY (file_list != NULL)) + /* use working directory from Path in the .desktop file if specified */ + if (G_LIKELY (directory == NULL)) { - /* use the directory of the first list item */ - parent = g_file_get_parent (file_list->data); - directory = (parent != NULL) ? thunar_g_file_get_location (parent) : NULL; - g_object_unref (parent); - } - else - { - /* use the directory of the executable file */ - parent = g_file_get_parent (file->gfile); - directory = (parent != NULL) ? thunar_g_file_get_location (parent) : NULL; - g_object_unref (parent); + /* determine the working directory */ + if (G_LIKELY (file_list != NULL)) + { + /* use the directory of the first list item */ + parent = g_file_get_parent (file_list->data); + directory = (parent != NULL) ? thunar_g_file_get_location (parent) : NULL; + g_object_unref (parent); + } + else + { + /* use the directory of the executable file */ + parent = g_file_get_parent (file->gfile); + directory = (parent != NULL) ? thunar_g_file_get_location (parent) : NULL; + g_object_unref (parent); + } } /* execute the command */ result = thunar_exec_on_screen (screen, directory, argv, NULL, G_SPAWN_SEARCH_PATH, snotify, icon, error); - - /* release the working directory */ - g_free (directory); } /* clean up */ + g_free (directory); g_strfreev (argv); g_free (location); -- 1.6.4.2