RestoreDeviceBox

1. Overview

The RestoreDeviceBox module maps snapshot mount points to restore target devices.

Its principal responsibilities are:

  • Builds device selectors for root, home, boot, and other system mounts
  • Refreshes the block-device inventory
  • Validates BTRFS layouts
  • Mounts selected targets before restoration
  • Initializes bootloader options

2. Class Structure and Dependencies

public class RestoreDeviceBox : 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.Box infobar_location – Box widget used by the interface
  • Gtk.Label lbl_infobar_location – label used to display infobar location information
  • Gtk.Box option_box – container or reusable widget for option
  • Gtk.Label lbl_header_subvol – label used to display header subvol information
  • bool show_volume_name – Boolean state for show volume name
  • Gtk.SizeGroup sg_mount_point – size group used to align mount point controls
  • Gtk.SizeGroup sg_device – size group used to align device controls
  • Gtk.SizeGroup sg_mount_options – size group used to align mount options controls
  • 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.ComboBoxText – text-based selection controls
  • Gtk.SizeGroup – consistent alignment across labels and values

Event-driven behavior is connected through signals such as:

changed
clicked

5. Initialization

RestoreDeviceBox()

public RestoreDeviceBox(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.mirror_system, App.update_partitions. It creates Gtk.Box, Gtk.SizeGroup 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.check_btrfs_layout
  • App.dst_home
  • App.dst_root
  • App.grub_device
  • App.init_boot_options
  • App.init_mount_list
  • App.mirror_system
  • App.mount_list
  • App.mount_target_devices
  • App.partitions
  • App.reinstall_grub2
  • App.sys_root
  • App.update_partitions

7. Method Reference

refresh()

public void refresh(bool reset_device_selections = true)

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

create_device_selection_options()

private void create_device_selection_options(bool reset_device_selections)

Creates device selection options required by the workflow. It reads or updates central state through App.init_mount_list, App.mount_list.

add_device_selection_option()

private void add_device_selection_option(MountEntry entry)

Adds or constructs device selection option for the current interface or model. It creates Gtk.Box where required.

add_device_combo()

private Gtk.ComboBoxText add_device_combo(Gtk.Box box, MountEntry entry)

Adds or constructs device combo for the current interface or model. It reads or updates central state through App.dst_root, App.init_boot_options, App.partitions. It creates Gtk.ComboBoxText where required. It connects the changed signal.

add_boot_options()

private void add_boot_options()

Adds or constructs boot options for the current interface or model. It creates Gtk.Box where required. It connects the clicked signal.

create_infobar_location()

private void create_infobar_location()

Creates infobar location required by the workflow. It creates Gtk.Box where required.

check_and_mount_devices()

public bool check_and_mount_devices()

Checks and mount devices and returns the validation result. It reads or updates central state through App.check_btrfs_layout, App.dst_home, App.dst_root, App.grub_device, App.mirror_system, App.mount_list, App.mount_target_devices, App.reinstall_grub2.


8. External Resources and Paths

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

/
/home
/boot
Failed to mount devices

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.