1. Overview
The SnapshotListBox module renders, sorts, edits, and selects snapshots.
Its principal responsibilities are:
- Displays snapshot metadata in custom rows
- Supports multi-selection through check buttons
- Allows description editing
- Sorts by snapshot fields
- Exposes selected Snapshot objects to parent workflows
The file defines multiple cooperating classes:
- SnapshotRow – derives from
Gtk.ListBoxRow - SnapshotListBox – derives from
Gtk.Box
2. Class Structure and Dependencies
public class SnapshotRow : Gtk.ListBoxRow
public class SnapshotListBox : Gtk.Box
The source imports:
GtkGeeTeeJee.LoggingTeeJee.FileSystemTeeJee.JsonHelperTeeJee.ProcessHelperTeeJee.GtkHelperTeeJee.SystemTeeJee.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:
Snapshot snapshot– snapshot represented by a rowGtk.CheckButton check– selection control associated with a snapshot or optionGtk.Entry desc_entry– editable snapshot-description fieldGtk.ListBox treeview– ListBox widget used by the interfaceGtk.Window parent_window– parent GTK window used for transient dialogsGtk.ListBox listbox– GTK list used to render selectable rowsGtk.ScrolledWindow scrolled– ScrolledWindow widget used by the interfaceGtk.Box header_actions– Box widget used by the interfaceint sort_column_index– numeric state for sort column indexbool sort_desc– Boolean state for sort desc
4. User Interface Composition
The module directly constructs the following GTK widget types:
Gtk.Box– layout containersGtk.Button– action and navigation buttonsGtk.CheckButton– Boolean or mutually exclusive choicesGtk.Entry– editable text fieldsGtk.Label– headings, descriptions, and status textGtk.ListBox– dynamic selectable rowsGtk.ScrolledWindow– scrollable content regions
Event-driven behavior is connected through signals such as:
changed
clicked
row_activated
toggled
5. Initialization
SnapshotRow()
public SnapshotRow(Snapshot bak)
Initializes the class instance, creates its GTK controls, and prepares the initial state.
SnapshotListBox()
public SnapshotListBox(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_modeApp.btrfs_qgroups_enabledApp.repo
7. Operational Workflow
- Load snapshots from the active repository
- Create one SnapshotRow per snapshot
- Apply the selected sort column and direction
- Return checked rows to backup, restore, or deletion workflows
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.Entry, Gtk.Label where required. It connects the changed, toggled signals.
build_meta_text()
private string build_meta_text()
Builds the meta text portion of the interface. It reads or updates central state through App.btrfs_qgroups_enabled.
add_sort_button()
private void add_sort_button(string label, int column, bool default_desc)
Adds or constructs sort button for the current interface or model. It creates Gtk.Button where required. It connects the clicked signal.
hide_context_menu()
public void hide_context_menu()
Hides context menu.
clear_rows()
private void clear_rows()
Implements the clear rows operation.
refresh()
public void refresh()
Reloads current application state and updates the visible controls. It reads or updates central state through App.repo.
selected_snapshots()
public Gee.ArrayList<Snapshot> selected_snapshots()
Returns the currently selected snapshots.
9. External Resources and Paths
The component does not directly define protected filesystem paths or external command strings.
10. Data and Event Flow
- Construct the component and initialize its child controls
- Load the current model state into the interface
- React to GTK signals generated by navigation, selections, and action controls
- Read or update central backup and restore state through the global controller
11. Runtime and Security Considerations
- Shared controller state: the component reads and modifies the global
Appcontroller used by the surrounding workflow. - Signal-driven behavior: GTK callbacks update the model and interface when controls are activated or changed.
12. Implementation Considerations
- Global coupling: the class depends on the process-wide
Appobject rather than receiving a controller through dependency injection.
13. Licensing
The applicable licensing terms are defined by the source-file header and the containing BastionGuard Backup project.
