RestoreBox

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:

  • Gtk
  • Gee
  • XApp
  • TeeJee.Logging
  • TeeJee.FileSystem
  • TeeJee.JsonHelper
  • TeeJee.ProcessHelper
  • TeeJee.GtkHelper
  • TeeJee.System
  • TeeJee.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 heading
  • Gtk.Spinner spinner – activity indicator shown while an operation is running
  • Gtk.Label lbl_msg – primary operation message label
  • Gtk.Label lbl_status – detailed status label
  • Gtk.Label lbl_remaining – estimated remaining-time label
  • Gtk.ProgressBar progressbar – visual progress indicator for a long-running task
  • Gtk.Label lbl_unchanged – label used to display unchanged information
  • Gtk.Label lbl_created – label used to display created information
  • Gtk.Label lbl_deleted – label used to display deleted information
  • Gtk.Label lbl_modified – label used to display modified information
  • Gtk.Label lbl_checksum – label used to display checksum information
  • Gtk.Label lbl_size – label used to display size information
  • Gtk.Label lbl_timestamp – label used to display timestamp information
  • Gtk.Label lbl_permissions – label used to display permissions information
  • Gtk.Label lbl_owner – label used to display owner information
  • Gtk.Label lbl_group – label used to display group information
  • Gtk.Window parent_window – parent GTK window used for transient dialogs
  • bool 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 containers
  • Gtk.ProgressBar – operation progress
  • Gtk.SizeGroup – consistent alignment across labels and values
  • Gtk.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_run
  • App.progress_text
  • App.restore_current_system
  • App.restore_snapshot
  • App.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

  1. Construct the component and initialize its child controls
  2. Read or update central backup and restore state through the global controller
  3. 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 App controller 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 App object 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.