Hi, I am launching processes (scripts to be precise) in the background of an app. I want the user to be able to follow the output of these processes.
Currently, I have a hacky solution: a Vte.Terminal on which spawn_sync is called. It gets added to the widget tree once, inlined a navigation stack.
I want to redesign this for the terminal to be shown in a popup, so it can be shown in multiple places of the navigation stack. With AdwDialog that requires the terminal widget to be able to be destroyed and recreated. So a split between widget and processes management object is needed.
From the docs it was not clear to me whether Vte.Pty can be used for that. What I am currently doing is:
Vte.Pty.spawn_async for the processes
Vte.Terminal with set_pty as the widget
This seems to kind of work, but has the significant downside that the scrollback history is not preserved. Every VteTerminal consumes the PTY’s output, so the next time a terminal is opened it is blank.
I have played around trying to counter this by reading the scrollback upon Vte.Terminal destruction and using VteTermina.feed upon construction. However, this seems hacky and also does not work as no further output gets written.
So my question is, is using a VtePty even the correct approach for my issue? Or do I have to use lower level GLib functions and feed fds to a VteTerminal?
Is the output of those programs so complex that you even require a full terminal? In the past I was just feeding the output into a TextView (styled to look like a terminal) which was usually enough.
The processes are dependant on arbitrary configured scripts (sounds bad, but it’s a generic installer so kind of required). They are not intended to receive input, so a text view might work.
Any chance the project you wrote this for is publically available so I can take a peek?
Okay I found a different solution. I now store the terminal in a hidden GtkStackPage while the dialog is not shown and move it back and forth from there. Still hacky but works without any warnings and can handle any script output.