[gnome-builder/wip/gtk4-port] libide/foundry: make set_pty() use a VtePty
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port] libide/foundry: make set_pty() use a VtePty
- Date: Wed, 22 Jun 2022 18:58:37 +0000 (UTC)
commit b273dfee4329720a15e1c512560d1635ce57f9c8
Author: Christian Hergert <chergert redhat com>
Date: Wed Jun 22 11:58:26 2022 -0700
libide/foundry: make set_pty() use a VtePty
We have access to VtePty from libide-foundry, so use that as a convenience
to reduce chances of API miss-use. Additionally, keep the fd variant for
cases where it might be necessary.
src/libide/foundry/ide-run-context.c | 33 ++++++++++++++++++----
src/libide/foundry/ide-run-context.h | 7 ++++-
.../terminal/gbp-terminal-workspace-addin.c | 2 +-
3 files changed, 35 insertions(+), 7 deletions(-)
---
diff --git a/src/libide/foundry/ide-run-context.c b/src/libide/foundry/ide-run-context.c
index 5d52c20fd..05527538a 100644
--- a/src/libide/foundry/ide-run-context.c
+++ b/src/libide/foundry/ide-run-context.c
@@ -813,16 +813,18 @@ ide_run_context_merge_unix_fd_map (IdeRunContext *self,
}
/**
- * ide_run_context_set_pty:
+ * ide_run_context_set_pty_fd:
* @self: an #IdeRunContext
- * @consumer_fd: the FD of the PTY controller
+ * @consumer_fd: the FD of the PTY consumer
*
* Sets up a PTY for the run context that will communicate with the
- * consumer. It is set for stdin/stdout/stderr.
+ * consumer. The consumer is the generally the widget that is rendering
+ * the PTY contents and the producer is the FD that is connected to the
+ * subprocess.
*/
void
-ide_run_context_set_pty (IdeRunContext *self,
- int consumer_fd)
+ide_run_context_set_pty_fd (IdeRunContext *self,
+ int consumer_fd)
{
int stdin_fd = -1;
int stdout_fd = -1;
@@ -860,3 +862,24 @@ ide_run_context_set_pty (IdeRunContext *self,
ide_run_context_take_fd (self, stdout_fd, STDOUT_FILENO);
ide_run_context_take_fd (self, stderr_fd, STDERR_FILENO);
}
+
+/**
+ * ide_run_context_set_pty:
+ * @self: a #IdeRunContext
+ *
+ * Sets the PTY for a run context.
+ */
+void
+ide_run_context_set_pty (IdeRunContext *self,
+ VtePty *pty)
+{
+ int consumer_fd;
+
+ g_return_if_fail (IDE_IS_RUN_CONTEXT (self));
+ g_return_if_fail (VTE_IS_PTY (pty));
+
+ consumer_fd = vte_pty_get_fd (pty);
+
+ if (consumer_fd != -1)
+ ide_run_context_set_pty_fd (self, consumer_fd);
+}
diff --git a/src/libide/foundry/ide-run-context.h b/src/libide/foundry/ide-run-context.h
index 8695448c7..abdc99d10 100644
--- a/src/libide/foundry/ide-run-context.h
+++ b/src/libide/foundry/ide-run-context.h
@@ -24,6 +24,8 @@
# error "Only <libide-foundry.h> can be included directly."
#endif
+#include <vte/vte.h>
+
#include <libide-threading.h>
G_BEGIN_DECLS
@@ -76,9 +78,12 @@ IDE_AVAILABLE_IN_ALL
void ide_run_context_set_cwd (IdeRunContext *self,
const char *cwd);
IDE_AVAILABLE_IN_ALL
-void ide_run_context_set_pty (IdeRunContext *self,
+void ide_run_context_set_pty_fd (IdeRunContext *self,
int consumer_fd);
IDE_AVAILABLE_IN_ALL
+void ide_run_context_set_pty (IdeRunContext *self,
+ VtePty *pty);
+IDE_AVAILABLE_IN_ALL
void ide_run_context_take_fd (IdeRunContext *self,
int source_fd,
int dest_fd);
diff --git a/src/plugins/terminal/gbp-terminal-workspace-addin.c
b/src/plugins/terminal/gbp-terminal-workspace-addin.c
index a6ae17d03..866faf3c1 100644
--- a/src/plugins/terminal/gbp-terminal-workspace-addin.c
+++ b/src/plugins/terminal/gbp-terminal-workspace-addin.c
@@ -258,7 +258,7 @@ on_run_manager_run (GbpTerminalWorkspaceAddin *self,
panel_widget_raise (PANEL_WIDGET (self->run_panel));
ide_run_context_push (run_context, NULL, NULL, NULL);
- ide_run_context_set_pty (run_context, vte_pty_get_fd (pty));
+ ide_run_context_set_pty (run_context, pty);
ide_run_context_setenv (run_context, "TERM", "xterm-256color");
ide_run_context_setenv (run_context, "INSIDE_GNOME_BUILDER", PACKAGE_VERSION);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]