BackupBox

1. Overview

The BackupBox module runs and monitors snapshot creation inside the graphical backup workflow.

Its principal responsibilities are:

  • Starts the snapshot operation through the central controller
  • Displays progress, transfer statistics, current status, and remaining time
  • Supports pause and resume for the active RSYNC task
  • Handles BTRFS and RSYNC progress models

2. Class Structure and Dependencies

public class BackupBox : 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.Box details_box – container or reusable widget for details
  • 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
  • bool thread_status_success – Boolean state for thread status success

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

BackupBox()

public BackupBox(Gtk.Window _parent_window)

Initializes the class instance, creates its GTK controls, and prepares the initial state. It creates Gtk.Box where required.


6. Central Controller Integration

The module reads or modifies the following Main controller members through the global App object:

  • App.btrfs_mode
  • App.create_snapshot
  • App.progress_text
  • App.space_check_task
  • App.task

7. Method Reference

add_progress_area()

private void add_progress_area()

Adds or constructs progress area for the current interface or model. It creates Gtk.Box, Gtk.ProgressBar, Gtk.Spinner where required.

pause()

public void pause()

Implements the pause operation.

resume()

public void resume()

Implements the resume operation.

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.

take_snapshot()

public bool take_snapshot()

Implements the take snapshot operation. It reads or updates central state through App.btrfs_mode, App.progress_text, App.space_check_task, App.task. The long-running work is delegated to a background thread.

take_snapshot_thread()

private void take_snapshot_thread()

Worker-thread routine that performs take snapshot outside the immediate event callback. It reads or updates central state through App.create_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.
  • Signal-driven behavior: GTK callbacks update the model and interface when controls are activated or changed.

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.