SnapshotBackendBox

1. Overview

The SnapshotBackendBox module selects the snapshot engine used by BastionGuard Backup.

Its principal responsibilities are:

  • Offers RSYNC and BTRFS choices
  • Checks BTRFS tool availability
  • Explains backend characteristics
  • Selects a suitable default repository after backend changes

2. Class Structure and Dependencies

public class SnapshotBackendBox : Gtk.Box

The source imports:

  • Gtk
  • Gee
  • 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.CheckButton opt_rsync – CheckButton widget used by the interface
  • Gtk.CheckButton opt_btrfs – CheckButton widget used by the interface
  • Gtk.Label lbl_description – label used to display description information
  • Gtk.Window parent_window – parent GTK window used for transient dialogs

4. User Interface Composition

The module directly constructs the following GTK widget types:

  • Gtk.Box – layout containers
  • Gtk.CheckButton – Boolean or mutually exclusive choices
  • Gtk.Expander – collapsible explanatory content
  • Gtk.Label – headings, descriptions, and status text
  • Gtk.ScrolledWindow – scrollable content regions

Event-driven behavior is connected through signals such as:

toggled

5. Initialization

SnapshotBackendBox()

public SnapshotBackendBox(Gtk.Window _parent_window)

Initializes the class instance, creates its GTK controls, and prepares the initial state.


6. Central Controller Integration

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

  • App.btrfs_mode
  • App.try_select_default_device_for_backup

7. Method Reference

build_ui()

private void build_ui()

Constructs the complete GTK widget hierarchy for the component. It creates Gtk.Box where required.

add_opt_rsync()

private void add_opt_rsync(Gtk.Box hbox)

Adds or constructs opt rsync for the current interface or model. It reads or updates central state through App.btrfs_mode. It creates Gtk.CheckButton where required. It connects the toggled signal.

add_opt_btrfs()

private void add_opt_btrfs(Gtk.Box hbox)

Adds or constructs opt btrfs for the current interface or model. It reads or updates central state through App.btrfs_mode. It creates Gtk.CheckButton where required. It connects the toggled signal.

check_for_btrfs_tools()

private bool check_for_btrfs_tools()

Checks for btrfs tools and returns the validation result.

add_description()

private void add_description()

Adds or constructs description for the current interface or model. It creates Gtk.Expander, Gtk.Label, Gtk.ScrolledWindow where required.

update_description()

private void update_description()

Updates description to reflect the current state.

init_backend()

public void init_backend()

Initializes backend state and controls. It reads or updates central state through App.try_select_default_device_for_backup.

refresh()

public void refresh()

Reloads current application state and updates the visible controls. It reads or updates central state through App.btrfs_mode.


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. Load the current model state into the interface
  3. React to GTK signals generated by navigation, selections, and action controls
  4. Read or update central backup and restore state through the global controller

10. Runtime and Security Considerations

  • 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

  • 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.