BackupDeviceBox

1. Overview

The BackupDeviceBox module selects and validates the storage location used for snapshots.

Its principal responsibilities are:

  • Lists local Linux filesystems and their capacity
  • Highlights the currently selected repository
  • Validates BTRFS and RSYNC targets
  • Supports SMB shares through the dedicated share dialog
  • Refreshes device and repository state

2. Class Structure and Dependencies

public class BackupDeviceBox : 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.ListBox device_list – list of available repository devices and shares
  • Gtk.Box infobar_location – Box widget used by the interface
  • Gtk.Label lbl_infobar_location – label used to display infobar location information
  • Gtk.Label lbl_common – label used to display common 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.Label – headings, descriptions, and status text
  • Gtk.ListBox – dynamic selectable rows
  • Gtk.ListBoxRow – custom list rows
  • Gtk.ScrolledWindow – scrollable content regions

Event-driven behavior is connected through signals such as:

clicked
row_selected

5. Initialization

BackupDeviceBox()

public BackupDeviceBox(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.btrfs_mode, App.update_partitions. It creates Gtk.Box where required. It connects the clicked signal.


6. Central Controller Integration

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

  • App.btrfs_mode
  • App.live_system
  • App.partitions
  • App.repo
  • App.update_partitions

7. Method Reference

refresh()

public void refresh()

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

init_device_list()

private void init_device_list()

Initializes device list state and controls. It creates Gtk.ListBox, Gtk.ScrolledWindow where required. It connects the row_selected signal.

add_device_row()

private void add_device_row(Device dev, string kind)

Adds or constructs device row for the current interface or model. It creates Gtk.Box, Gtk.Label, Gtk.ListBoxRow where required.

update_selected_rows()

private void update_selected_rows()

Updates selected rows to reflect the current state. It reads or updates central state through App.repo.

init_infobar_location()

private void init_infobar_location()

Initializes infobar location state and controls. It creates Gtk.Box, Gtk.Label, Gtk.ScrolledWindow where required.

try_change_device()

private void try_change_device(Device dev)

Attempts to change device and handles validation failures. It reads or updates central state through App.btrfs_mode.

change_backup_device()

private void change_backup_device(Device pi)

Implements the change backup device operation. It reads or updates central state through App.btrfs_mode, App.partitions, App.repo, App.update_partitions.

check_backup_location()

private bool check_backup_location()

Checks backup location and returns the validation result. It reads or updates central state through App.live_system, App.repo.

device_list_refresh()

private void device_list_refresh()

Implements the device list refresh operation. It reads or updates central state through App.btrfs_mode, App.partitions, App.update_partitions.

append_child_volumes()

private void append_child_volumes(Device parent)

Implements the append child volumes operation. It reads or updates central state through App.btrfs_mode, App.partitions.

add_smb_row()

private void add_smb_row(SmbShare share)

Adds or constructs smb row for the current interface or model. It creates Gtk.Box, Gtk.Label, Gtk.ListBoxRow where required.

on_add_smb_share_clicked()

private void on_add_smb_share_clicked()

Event handler for add smb share clicked.

try_change_smb_share()

private void try_change_smb_share(SmbShare share)

Attempts to change smb share and handles validation failures. It reads or updates central state through App.btrfs_mode, App.repo.


8. External Resources and Paths

The source references the following relevant paths, command fragments, or resource identifiers:

Snapshots are saved to /bastionguard-backup-btrfs on selected partition. Other locations are not supported.
/
/dev/

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.
  • Device safety: device selections are validated before backup or restore operations continue.
  • 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 applicable licensing terms are defined by the source-file header and the containing BastionGuard Backup project.