Branch: refs/heads/master Author: Enrico Tröger enrico.troeger@uvena.de Committer: Enrico Tröger enrico.troeger@uvena.de Date: Mon, 27 Apr 2020 21:11:08 UTC Commit: acb8b852d0a0cec1d0b626275063173e0026fe63 https://github.com/geany/geany-plugins/commit/acb8b852d0a0cec1d0b62627506317...
Log Message: ----------- TreeBrowser: Port spawning external commands to the spawn API
Port "Open Externally" and "Open in terminal" actions to the spawn API for better support on Windows. Also remove unnecessary hard-coded "cmd" command on Windows and use the configured command instead.
Closes #556.
Modified Paths: -------------- treebrowser/src/treebrowser.c
Modified: treebrowser/src/treebrowser.c 33 lines changed, 9 insertions(+), 24 deletions(-) =================================================================== @@ -59,7 +59,7 @@ static gboolean flag_on_expand_refresh = FALSE; # define CONFIG_OPEN_EXTERNAL_CMD_DEFAULT "xdg-open '%d'" # define CONFIG_OPEN_TERMINAL_DEFAULT "xterm" #else -# define CONFIG_OPEN_EXTERNAL_CMD_DEFAULT "explorer '%d'" +# define CONFIG_OPEN_EXTERNAL_CMD_DEFAULT "explorer %d" # define CONFIG_OPEN_TERMINAL_DEFAULT "cmd" #endif
@@ -412,18 +412,6 @@ get_default_dir(void) return g_get_current_dir(); }
-static gchar * -get_terminal(void) -{ - gchar *terminal; -#ifdef G_OS_WIN32 - terminal = g_strdup("cmd"); -#else - terminal = g_strdup(CONFIG_OPEN_TERMINAL); -#endif - return terminal; -} - static gboolean treebrowser_checkdir(gchar *directory) { @@ -996,7 +984,7 @@ on_menu_current_path(GtkMenuItem *menuitem, gpointer *user_data) }
static void -on_menu_open_externally(GtkMenuItem *menuitem, gchar *uri) +on_menu_open_externally(GtkMenuItem *menuitem, const gchar *uri) { gchar *cmd, *locale_cmd, *dir, *c; GString *cmd_str = g_string_new(CONFIG_OPEN_EXTERNAL_CMD); @@ -1009,7 +997,7 @@ on_menu_open_externally(GtkMenuItem *menuitem, gchar *uri)
cmd = g_string_free(cmd_str, FALSE); locale_cmd = utils_get_locale_from_utf8(cmd); - if (! g_spawn_command_line_async(locale_cmd, &error)) + if (! spawn_async(dir, locale_cmd, NULL, NULL, NULL, &error)) { c = strchr(cmd, ' '); if (c != NULL) @@ -1025,19 +1013,16 @@ on_menu_open_externally(GtkMenuItem *menuitem, gchar *uri) }
static void -on_menu_open_terminal(GtkMenuItem *menuitem, gchar *uri) +on_menu_open_terminal(GtkMenuItem *menuitem, const gchar *uri) { - gchar *argv[2] = {NULL, NULL}; - argv[0] = get_terminal(); - + gchar *cwd; if (g_file_test(uri, G_FILE_TEST_EXISTS)) - uri = g_file_test(uri, G_FILE_TEST_IS_DIR) ? g_strdup(uri) : g_path_get_dirname(uri); + cwd = g_file_test(uri, G_FILE_TEST_IS_DIR) ? g_strdup(uri) : g_path_get_dirname(uri); else - uri = g_strdup(addressbar_last_address); + cwd = g_strdup(addressbar_last_address);
- g_spawn_async(uri, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL); - g_free(uri); - g_free(argv[0]); + spawn_async(cwd, CONFIG_OPEN_TERMINAL, NULL, NULL, NULL, NULL); + g_free(cwd); }
static void
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
plugins-commits@lists.geany.org