[quick-lounge-applet] set the working directory to the some directory of the terminal command
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [quick-lounge-applet] set the working directory to the some directory of the terminal command
- Date: Fri, 22 Oct 2010 19:02:39 +0000 (UTC)
commit 72a16a113a3ad5fae0c87c9e60aabecec00d2102
Author: Paolo Bacchilega <paobac src gnome org>
Date: Mon Sep 6 09:40:57 2010 +0200
set the working directory to the some directory of the terminal command
src/file-utils.c | 32 ++++++++++++++++++++++++++++++--
1 files changed, 30 insertions(+), 2 deletions(-)
---
diff --git a/src/file-utils.c b/src/file-utils.c
index b65edc7..51c7cdf 100644
--- a/src/file-utils.c
+++ b/src/file-utils.c
@@ -793,8 +793,36 @@ _g_desktop_entry_launch (GKeyFile *desktop_entry,
GError *error = NULL;
path = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_PATH, NULL);
- if (path == NULL)
- g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_PATH, g_get_home_dir ());
+ if (path == NULL) {
+ if (g_key_file_get_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_TERMINAL, NULL)) {
+ char *exec;
+
+ exec = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_EXEC, NULL);
+ if (exec == NULL)
+ exec = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_TRY_EXEC, NULL);
+
+ if (exec != NULL) {
+ char *first_space;
+ char *command;
+
+ first_space = strchr (exec, ' ');
+ if (first_space != NULL)
+ command = g_strndup (exec, first_space - exec);
+ else
+ command = g_strdup (exec);
+ path = g_path_get_dirname (command);
+
+ g_free (command);
+ g_free (exec);
+ }
+ }
+
+ if (path == NULL)
+ path = g_strdup (g_get_home_dir ());
+
+ g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_PATH, path);
+ }
+
g_free (path);
app_info = g_desktop_app_info_new_from_keyfile (key_file);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]