1. Overview
The TerminalWindow module provides embedded terminal execution window for BastionGuard Backup. It hosts a VTE terminal, launches a shell or executable script, monitors child completion, and optionally blocks while processing GTK events.
The implementation is written in Vala and uses GLib/GIO together with the application utility namespaces required by the file.
2. Dependencies and Integration
The module imports:
GtkGeeTeeJee.LoggingTeeJee.FileSystemTeeJee.JsonHelperTeeJee.ProcessHelperTeeJee.GtkHelperTeeJee.SystemTeeJee.Misc
Key runtime integrations include:
- GTK – graphical widgets, dialogs, images, event processing, or window lifecycle
- VTE – embedded terminal and child-process display
3. Declared Types
3.1 TerminalWindow
public class TerminalWindow : Gtk.Window
This class encapsulates the state and operations described by this source file.
4. State, Properties, Constants, and Signals
Public and protected state
public bool is_running– Boolean state controlling or reporting running.
Internal state
private Gtk.Box vbox_main– GTK/VTE presentation object retained by the component.private Vte.Terminal term– GTK/VTE presentation object retained by the component.private int def_width– Runtime state used by the module.private int def_height– Runtime state used by the module.private Pid child_pid– Process identifier used by the module.private Gtk.Window parent_win– GTK/VTE presentation object retained by the component.
5. Public API and Operational Methods
5.1 TerminalWindow.with_parent()
public TerminalWindow.with_parent(Gtk.Window? parent)
Initializes the object state, allocates required collections or widgets, and applies constructor parameters.
5.2 init_window()
public void init_window ()
Initializes window and prepares it for use.
- Interacts with GTK/VTE objects and must execute UI changes on the graphical main context.
5.3 start_shell()
public void start_shell()
Starts the configured operation and updates its runtime state.
- Executes an external process or generated shell command and uses its return status as part of the result.
- Interacts with GTK/VTE objects and must execute UI changes on the graphical main context.
- Catches runtime errors locally and reports them through the logging layer or return value.
5.4 execute_script()
public void execute_script(string script_path, bool wait = false)
Spawns the supplied executable script inside the VTE terminal, monitors child exit, and optionally waits while continuing to process GTK events.
- Executes an external process or generated shell command and uses its return status as part of the result.
- Interacts with GTK/VTE objects and must execute UI changes on the graphical main context.
- Catches runtime errors locally and reports them through the logging layer or return value.
- Contains a polling loop with an explicit sleep interval.
5.5 script_exit()
public void script_exit(int status)
Implements the script exit operation for this module.
6. Filesystem Paths and Resource Locations
The source references the following absolute or template paths:
/bin/sh
Some values are templates completed at runtime with application names, process IDs, device identifiers, or file names.
7. External Commands and System Interfaces
The module constructs, checks, or parses commands containing:
/bin/sh
Execution success is determined from command exit status and, where applicable, parsed standard output or standard error.
8. Operational Flow
- Initialize object state, widgets, regular expressions, paths, or generated scripts.
- Apply the requested operation and update runtime or persistent state.
9. Error Handling and Diagnostics
- GLib and filesystem exceptions are caught locally in the operations that can fail.
- The TeeJee logging layer records errors, debug state, generated commands, and operational messages.
10. Runtime and Security Considerations
- External commands: command availability, quoting, locale, privileges, and output format can affect behavior.
- Polling: synchronous wait loops can delay shutdown or block the caller when the underlying operation does not complete.
- GTK lifecycle: widgets and local main loops require a valid graphical context and careful close/destroy handling.
11. Licensing
The source is distributed under the GNU General Public License version 2 or any later version.
The source header identifies:
Copyright 2012-2018 Tony George <teejeetech@gmail.com>
