diff options
author | Debarshi Ray <debarshir@gnome.org> | 2019-06-18 19:47:14 +0200 |
---|---|---|
committer | Debarshi Ray <debarshir@gnome.org> | 2019-06-18 19:47:14 +0200 |
commit | 50048b71f4bad7a522f86ae8fafcaec4c04391f0 (patch) | |
tree | aca041a9da0efdc46c8e0d72bb4522ee49187a39 | |
parent | b2bedf6ed7baebf00de3ebcf5e8467799100aea5 (diff) | |
download | gnome-terminal-wip/rishi/container-escape-sequence.tar.gz |
window: Preserve current toolbox, if any, when opening a new terminalwip/rishi/container-escape-sequence
This relies on toolbox(1) emitting a terminal escape sequence that
advertises the name of the current toolbox container.
https://gitlab.freedesktop.org/terminal-wg/specifications/issues/17
-rw-r--r-- | src/terminal-window.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/terminal-window.c b/src/terminal-window.c index 19198f49..994d801a 100644 --- a/src/terminal-window.c +++ b/src/terminal-window.c @@ -344,7 +344,10 @@ action_new_terminal_cb (GSimpleAction *action, TerminalApp *app; TerminalSettingsList *profiles_list; gs_unref_object GSettings *profile = NULL; + const char *container_name; + const char *container_runtime; gs_free char *new_working_directory = NULL; + gs_strfreev char **override_command = NULL; gboolean can_toggle = FALSE; g_assert (TERMINAL_IS_WINDOW (window)); @@ -399,9 +402,21 @@ action_new_terminal_cb (GSimpleAction *action, if (mode == TERMINAL_NEW_TERMINAL_MODE_WINDOW) window = terminal_app_new_window (app, 0); + container_name = vte_terminal_get_current_container_name (VTE_TERMINAL (priv->active_screen)); + container_runtime = vte_terminal_get_current_container_runtime (VTE_TERMINAL (priv->active_screen)); + if (g_strcmp0 (container_runtime, "toolbox") == 0 && container_name != NULL && container_name[0] != '\0') + { + gs_free_error GError *error = NULL; + gs_free char *override_command_str = NULL; + + override_command_str = g_strdup_printf ("toolbox enter --container %s", container_name); + if (!g_shell_parse_argv (override_command_str, NULL, &override_command, &error)) + g_printerr ("Failed to parse '%s': %s\n", override_command_str, error->message); + } + new_working_directory = terminal_screen_get_current_dir (priv->active_screen); terminal_app_new_terminal (app, window, profile, NULL /* use profile encoding */, - NULL, NULL, + override_command, NULL, new_working_directory, terminal_screen_get_initial_environment (priv->active_screen), 1.0); |