1. Overview
The RestoreBox module executes and monitors snapshot restoration.
Its principal responsibilities are:
- Starts restoration through the central controller
- Displays RSYNC progress and file statistics
- Handles dry-run and real restoration modes
- Reports restoration completion
2. Class Structure and Dependencies
public class RestoreBox : Gtk.Box
The source imports:
GtkGeeXAppTeeJee.LoggingTeeJee.FileSystemTeeJee.JsonHelperTeeJee.ProcessHelperTeeJee.GtkHelperTeeJee.SystemTeeJee.Misc
The GTK inheritance and imported modules allow the component to participate in the application event loop, share the central backup state, and construct native GTK4 controls.
3. Primary Runtime State
The principal fields declared by the module include:
Gtk.Label lbl_header– page or result headingGtk.Spinner spinner– activity indicator shown while an operation is runningGtk.Label lbl_msg– primary operation message labelGtk.Label lbl_status– detailed status labelGtk.Label lbl_remaining– estimated remaining-time labelGtk.ProgressBar progressbar– visual progress indicator for a long-running taskGtk.Label lbl_unchanged– label used to display unchanged informationGtk.Label lbl_created– label used to display created informationGtk.Label lbl_deleted– label used to display deleted informationGtk.Label lbl_modified– label used to display modified informationGtk.Label lbl_checksum– label used to display checksum informationGtk.Label lbl_size– label used to display size informationGtk.Label lbl_timestamp– label used to display timestamp informationGtk.Label lbl_permissions– label used to display permissions informationGtk.Label lbl_owner– label used to display owner informationGtk.Label lbl_group– label used to display group informationGtk.Window parent_window– parent GTK window used for transient dialogsbool thread_is_running– Boolean state for thread is running
4. User Interface Composition
The module directly constructs the following GTK widget types:
Gtk.Box– layout containersGtk.ProgressBar– operation progressGtk.SizeGroup– consistent alignment across labels and valuesGtk.Spinner– indeterminate activity indicators
5. Initialization
RestoreBox()
public RestoreBox(Gtk.Window _parent_window)
Initializes the class instance, creates its GTK controls, and prepares the initial state. It reads or updates central state through App.dry_run. It creates Gtk.Box, Gtk.ProgressBar, Gtk.Spinner where required.
6. Central Controller Integration
The module reads or modifies the following Main controller members through the global App object:
App.dry_runApp.progress_textApp.restore_current_systemApp.restore_snapshotApp.task
7. Method Reference
add_count_label()
private Gtk.Label add_count_label(Gtk.Box box, string text, ref Gtk.SizeGroup? sg_label, ref Gtk.SizeGroup? sg_value, int add_margin_bottom = 0)
Adds or constructs count label for the current interface or model. It creates Gtk.Box, Gtk.SizeGroup where required.
restore()
public bool restore()
Implements the restore operation. It reads or updates central state through App.dry_run, App.progress_text, App.restore_current_system, App.task. The long-running work is delegated to a background thread.
restore_thread()
private void restore_thread()
Worker-thread routine that performs restore outside the immediate event callback. It reads or updates central state through App.restore_snapshot.
8. External Resources and Paths
The component does not directly define protected filesystem paths or external command strings.
9. Data and Event Flow
- Construct the component and initialize its child controls
- Read or update central backup and restore state through the global controller
- Run long-running work through the component worker path
10. Runtime and Security Considerations
- Thread coordination: long-running work is separated from immediate GTK callbacks and UI state must be refreshed on the main loop.
- Shared controller state: the component reads and modifies the global
Appcontroller used by the surrounding workflow. - Dry-run support: the interface can invoke validation or simulation paths without committing the final restore operation.
11. Implementation Considerations
- Polling loops: some operations wait synchronously while continuing to process GTK events.
- Worker result state: completion and success are communicated through shared fields that must remain consistent with the worker lifecycle.
- Global coupling: the class depends on the process-wide
Appobject rather than receiving a controller through dependency injection.
12. Licensing
The source header contains the following copyright notices:
Copyright 2012-2018 Tony George <teejeetech@gmail.com>
The file is distributed under the GNU General Public License version 2 or later.
