ImportDialog

1. Overview

The ImportDialog module presents detected compatible snapshots and runs the import operation.

Its principal responsibilities are:

  • Displays detected repository and snapshot information
  • Allows optional removal of the source configuration
  • Runs migration through TimeshiftImporter
  • Reports import progress and results

2. Class Structure and Dependencies

public class ImportDialog : Gtk.Dialog

The source imports:

  • GLib
  • Gtk
  • BastionGuardImport

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:

  • TimeshiftDetectResult detected – result returned by the repository-detection subsystem
  • Gtk.CheckButton remove_config_check – CheckButton widget used by the interface
  • Gtk.ListBox snapshot_list – list of snapshots displayed by the import dialog
  • Gtk.Label status_label – Label widget used by the interface
  • Gtk.Button import_btn – Button widget used by the interface
  • Gtk.Button skip_btn – Button widget used by the interface
  • Gtk.Spinner spinner – activity indicator shown while an operation is running

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.Frame – grouped content cards
  • Gtk.Label – headings, descriptions, and status text
  • Gtk.ListBox – dynamic selectable rows
  • Gtk.ListBoxRow – custom list rows
  • Gtk.ScrolledWindow – scrollable content regions
  • Gtk.Spinner – indeterminate activity indicators

Event-driven behavior is connected through signals such as:

import_completed

5. Initialization

ImportDialog()

public ImportDialog(Gtk.Window parent, TimeshiftDetectResult detected)

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


6. Central Controller Integration

The module does not directly access the global App controller and instead operates through its own inputs or child objects.


7. Operational Workflow

  1. Display the detected configuration and snapshot inventory
  2. Collect the optional source-configuration removal choice
  3. Disable controls and show a spinner during migration
  4. Run TimeshiftImporter.migrate()
  5. Report success or failure and close the dialog

8. Method Reference

build_ui()

private void build_ui()

Constructs the complete GTK widget hierarchy for the component. It creates Gtk.Box, Gtk.CheckButton, Gtk.Frame, Gtk.Label, Gtk.ListBox, Gtk.ScrolledWindow where required.

populate_snapshot_list()

private void populate_snapshot_list()

Implements the populate snapshot list operation. It creates Gtk.Box, Gtk.Label, Gtk.ListBoxRow where required.

on_response()

private void on_response(int response_id)

Event handler for response. The long-running work is delegated to a background thread.

check_and_show_if_needed()

public static void check_and_show_if_needed(Gtk.Window parent)

Checks and show if needed and returns the validation result. It connects the import_completed signal. The long-running work is delegated to a background thread.


9. External Resources and Paths

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

/etc/bastionguard-backup/bastionguard-backup.json

10. Data and Event Flow

  1. Construct the component and initialize its child controls
  2. React to GTK signals generated by navigation, selections, and action controls
  3. Run long-running work through the component worker path

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

12. Implementation Considerations

  • Worker result state: completion and success are communicated through shared fields that must remain consistent with the worker lifecycle.

13. Licensing

The source header contains the following copyright notices:

Copyright (C) 2025–2026 Calogero Scarnà

The file is distributed under the GNU General Public License version 2 or later.