[gnome-builder] terminal: copy URI of previous terminal when possible
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] terminal: copy URI of previous terminal when possible
- Date: Tue, 30 Apr 2019 21:13:46 +0000 (UTC)
commit 5c274d61231f1d67d605c97f605999118b11f63c
Author: Christian Hergert <chergert redhat com>
Date: Tue Apr 30 14:13:21 2019 -0700
terminal: copy URI of previous terminal when possible
If we are currently focused on a terminal, we want to copy the GNOME
Terminal behavior of opening the new terminal in the same directory.
src/plugins/terminal/gbp-terminal-workspace-addin.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
---
diff --git a/src/plugins/terminal/gbp-terminal-workspace-addin.c
b/src/plugins/terminal/gbp-terminal-workspace-addin.c
index b118c56eb..ba8b283bc 100644
--- a/src/plugins/terminal/gbp-terminal-workspace-addin.c
+++ b/src/plugins/terminal/gbp-terminal-workspace-addin.c
@@ -110,11 +110,20 @@ new_terminal_activate (GSimpleAction *action,
IdeSurface *surface;
IdeRuntime *runtime = NULL;
const gchar *name;
+ IdePage *current_page;
+ const gchar *uri = NULL;
g_assert (IDE_IS_MAIN_THREAD ());
g_assert (G_IS_SIMPLE_ACTION (action));
g_assert (GBP_IS_TERMINAL_WORKSPACE_ADDIN (self));
+ /* If we are creating a new terminal while we already have a terminal
+ * focused, then try to copy some details from that terminal.
+ */
+ if ((current_page = ide_workspace_get_most_recent_page (self->workspace)) &&
+ IDE_IS_TERMINAL_PAGE (current_page))
+ uri = ide_terminal_page_get_current_directory_uri (IDE_TERMINAL_PAGE (current_page));
+
name = g_action_get_name (G_ACTION (action));
if (ide_str_equal0 (name, "new-terminal-in-runtime"))
@@ -163,7 +172,16 @@ new_terminal_activate (GSimpleAction *action,
}
if (cwd != NULL)
- ide_terminal_launcher_set_cwd (launcher, cwd);
+ {
+ ide_terminal_launcher_set_cwd (launcher, cwd);
+ }
+ else if (uri != NULL)
+ {
+ g_autoptr(GFile) file = g_file_new_for_uri (uri);
+
+ if (g_file_is_native (file))
+ ide_terminal_launcher_set_cwd (launcher, g_file_peek_path (file));
+ }
page = g_object_new (IDE_TYPE_TERMINAL_PAGE,
"launcher", launcher,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]