[gnome-builder] terminal: give launcher access to IdeContext
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] terminal: give launcher access to IdeContext
- Date: Tue, 30 Apr 2019 21:01:26 +0000 (UTC)
commit f4df5264f47dbda8fee8bbb980bdded58b0d5e49
Author: Christian Hergert <chergert redhat com>
Date: Tue Apr 30 14:01:13 2019 -0700
terminal: give launcher access to IdeContext
So that we can setup the default directory correctly.
src/libide/terminal/ide-terminal-launcher.c | 8 +++++++-
src/libide/terminal/ide-terminal-launcher.h | 2 +-
src/libide/terminal/ide-terminal-page.c | 16 +++++++++++++++-
src/plugins/terminal/gbp-terminal-workspace-addin.c | 3 ++-
4 files changed, 25 insertions(+), 4 deletions(-)
---
diff --git a/src/libide/terminal/ide-terminal-launcher.c b/src/libide/terminal/ide-terminal-launcher.c
index c38769296..eb591c2cd 100644
--- a/src/libide/terminal/ide-terminal-launcher.c
+++ b/src/libide/terminal/ide-terminal-launcher.c
@@ -627,12 +627,18 @@ ide_terminal_launcher_set_title (IdeTerminalLauncher *self,
* Returns: (transfer full): a newly created #IdeTerminalLauncher
*/
IdeTerminalLauncher *
-ide_terminal_launcher_new (void)
+ide_terminal_launcher_new (IdeContext *context)
{
IdeTerminalLauncher *self;
+ g_autoptr(GFile) workdir = NULL;
+
+ g_return_val_if_fail (IDE_IS_CONTEXT (context), NULL);
+
+ workdir = ide_context_ref_workdir (context);
self = g_object_new (IDE_TYPE_TERMINAL_LAUNCHER, NULL);
self->kind = LAUNCHER_KIND_HOST;
+ self->cwd = g_file_get_path (workdir);
return g_steal_pointer (&self);
}
diff --git a/src/libide/terminal/ide-terminal-launcher.h b/src/libide/terminal/ide-terminal-launcher.h
index c991f6153..8abd50245 100644
--- a/src/libide/terminal/ide-terminal-launcher.h
+++ b/src/libide/terminal/ide-terminal-launcher.h
@@ -30,7 +30,7 @@ IDE_AVAILABLE_IN_3_34
G_DECLARE_FINAL_TYPE (IdeTerminalLauncher, ide_terminal_launcher, IDE, TERMINAL_LAUNCHER, GObject)
IDE_AVAILABLE_IN_3_34
-IdeTerminalLauncher *ide_terminal_launcher_new (void);
+IdeTerminalLauncher *ide_terminal_launcher_new (IdeContext *context);
IDE_AVAILABLE_IN_3_34
IdeTerminalLauncher *ide_terminal_launcher_new_for_debug (void);
IDE_AVAILABLE_IN_3_34
diff --git a/src/libide/terminal/ide-terminal-page.c b/src/libide/terminal/ide-terminal-page.c
index 2aff2eaf2..68d4e9fa2 100644
--- a/src/libide/terminal/ide-terminal-page.c
+++ b/src/libide/terminal/ide-terminal-page.c
@@ -332,6 +332,19 @@ ide_terminal_page_connect_terminal (IdeTerminalPage *self,
}
}
+static void
+ide_terminal_page_context_set (GtkWidget *widget,
+ IdeContext *context)
+{
+ IdeTerminalPage *self = (IdeTerminalPage *)widget;
+
+ g_assert (IDE_IS_TERMINAL_PAGE (self));
+ g_assert (!context || IDE_IS_CONTEXT (context));
+
+ if (self->launcher == NULL && context != NULL)
+ self->launcher = ide_terminal_launcher_new (context);
+}
+
static void
ide_terminal_page_finalize (GObject *object)
{
@@ -466,7 +479,6 @@ ide_terminal_page_init (IdeTerminalPage *self)
{
GtkStyleContext *style_context;
- self->launcher = ide_terminal_launcher_new ();
self->respawn_on_exit = TRUE;
self->manage_spawn = TRUE;
@@ -499,6 +511,8 @@ ide_terminal_page_init (IdeTerminalPage *self)
style_context_changed (style_context, self);
gtk_widget_set_can_focus (GTK_WIDGET (self->terminal_top), TRUE);
+
+ ide_widget_set_context_handler (self, ide_terminal_page_context_set);
}
void
diff --git a/src/plugins/terminal/gbp-terminal-workspace-addin.c
b/src/plugins/terminal/gbp-terminal-workspace-addin.c
index 896032bfe..b118c56eb 100644
--- a/src/plugins/terminal/gbp-terminal-workspace-addin.c
+++ b/src/plugins/terminal/gbp-terminal-workspace-addin.c
@@ -134,7 +134,8 @@ new_terminal_activate (GSimpleAction *action,
}
else
{
- launcher = ide_terminal_launcher_new ();
+ IdeContext *context = ide_widget_get_context (GTK_WIDGET (self->workspace));
+ launcher = ide_terminal_launcher_new (context);
}
if (!(surface = ide_workspace_get_surface_by_name (self->workspace, "editor")) &&
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]