BootOptionsBox

1. Overview

The BootOptionsBox module configures bootloader and initramfs operations for a restore.

Its principal responsibilities are:

  • Lists suitable GRUB target devices
  • Controls GRUB reinstallation
  • Controls initramfs regeneration and boot-menu updates
  • Synchronizes selections with the central restore state

2. Class Structure and Dependencies

public class BootOptionsBox : 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 option_box – container or reusable widget for option
  • Gtk.ComboBoxText cmb_grub_dev – combo box used to select grub dev
  • Gee.ArrayList<Device?> grub_devices – collection of grub devices items
  • Gtk.CheckButton chk_reinstall_grub – check button controlling reinstall grub
  • Gtk.CheckButton chk_update_initramfs – check button controlling update initramfs
  • Gtk.CheckButton chk_update_grub – check button controlling update grub
  • 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

Event-driven behavior is connected through signals such as:

changed
toggled

5. Initialization

BootOptionsBox()

public BootOptionsBox(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.grub_device
  • App.mirror_system
  • App.reinstall_grub2
  • App.snapshot_to_restore
  • App.update_grub
  • App.update_initramfs

7. Method Reference

add_bootloader_options()

private void add_bootloader_options()

Adds or constructs bootloader options for the current interface or model. It creates Gtk.Box, Gtk.ComboBoxText where required. It connects the changed signal.

add_chk_reinstall_grub()

private void add_chk_reinstall_grub()

Adds or constructs chk reinstall grub for the current interface or model. It reads or updates central state through App.reinstall_grub2. It connects the toggled signal.

add_chk_update_initramfs()

private void add_chk_update_initramfs(Gtk.Box hbox)

Adds or constructs chk update initramfs for the current interface or model. It reads or updates central state through App.update_initramfs. It connects the toggled signal.

add_chk_update_grub()

private void add_chk_update_grub(Gtk.Box hbox)

Adds or constructs chk update grub for the current interface or model. It reads or updates central state through App.update_grub. It connects the toggled signal.

save_grub_device_selection()

private void save_grub_device_selection()

Saves grub device selection into the application model or persistent configuration. It reads or updates central state through App.grub_device, App.reinstall_grub2.

refresh_options()

private void refresh_options()

Refreshes options from the current application state. It reads or updates central state through App.mirror_system, App.reinstall_grub2, App.snapshot_to_restore, App.update_grub, App.update_initramfs.

refresh_cmb_grub_dev()

private void refresh_cmb_grub_dev()

Refreshes cmb grub dev from the current application state.

cmb_grub_dev_select_default()

private void cmb_grub_dev_select_default()

Implements the cmb grub dev select default operation. It reads or updates central state through App.grub_device.


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
  5. Persist the final selections when the workflow is accepted or closed

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.