DeleteWindow

1. Overview

The DeleteWindow module implements the multi-step graphical workflow for snapshot deletion.

Its principal responsibilities are:

  • Collects selected snapshots
  • Runs the deletion page
  • Shows the final result
  • Supports embedded and standalone modes

2. Class Structure and Dependencies

public class DeleteWindow : Gtk.Window

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 vbox_main – primary vertical layout container
  • Gtk.Stack page_stack – GTK stack containing workflow pages
  • int current_page – index of the currently active workflow page
  • Gtk.Box bbox_action – Box widget used by the interface
  • SnapshotListBox snapshot_list_box – container or reusable widget for snapshot list
  • DeleteBox delete_box – container or reusable widget for delete
  • DeleteFinishBox delete_finish_box – container or reusable widget for delete finish
  • Gtk.Button btn_prev – button used to trigger the corresponding prev action
  • Gtk.Button btn_next – button used to trigger the corresponding next action
  • Gtk.Button btn_hide – button used to trigger the corresponding hide action
  • Gtk.Button btn_cancel – button used to trigger the corresponding cancel action
  • Gtk.Button btn_close – button used to trigger the corresponding close action
  • uint tmr_init – numeric state for tmr init
  • int def_width – numeric state for def width
  • int def_height – numeric state for def height
  • bool success – Boolean state for success
  • bool embedded_mode – whether the component is hosted inside another window
  • Gee.ArrayList<Gtk.Image> themed_img_list – collection of themed img list items
  • Gee.ArrayList<string> themed_img_name – collection of themed img name items
  • Gee.ArrayList<int> themed_img_size – collection of themed img size items

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.Stack – multi-page content navigation

Event-driven behavior is connected through signals such as:

clicked
close_request

5. Initialization

DeleteWindow()

public DeleteWindow(bool embedded = false)

Initializes the class instance, creates its GTK controls, and prepares the initial state. It creates Gtk.Box, Gtk.Label, Gtk.Stack where required. It connects the close_request signal.


6. Workflow Pages and Enumerations

Tabs

The enumeration defines the following states:

SNAPSHOT_LIST
DELETE
DELETE_FINISH

These values provide stable identifiers for navigation, validation, and page-specific initialization.


7. Central Controller Integration

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

  • App.delete_file_task
  • App.delete_list
  • App.thread_delete_running

8. Operational Workflow

  1. Load repository snapshots into SnapshotListBox
  2. Validate that at least one snapshot is selected
  3. Copy selections into the central delete list
  4. Run DeleteBox until the worker finishes
  5. Display DeleteFinishBox

9. Method Reference

init_delayed()

private bool init_delayed()

Performs initialization scheduled after the window has been presented.

on_close_request()

private bool on_close_request()

Handles a request to close the window and coordinates cleanup or state persistence.

create_actions()

private void create_actions()

Creates action buttons and connects their callbacks. It reads or updates central state through App.delete_file_task, App.delete_list. It creates Gtk.Box where required. It connects the clicked signal.

action_buttons_set_initial_visibility()

private void action_buttons_set_initial_visibility(bool visible)

Implements the action buttons set initial visibility operation.

go_first()

private void go_first()

Moves the workflow to its first page. It reads or updates central state through App.delete_list, App.thread_delete_running.

go_prev()

private void go_prev()

Moves to the previous valid workflow page.

go_next()

private void go_next()

Validates the current state and advances to the next workflow page. It reads or updates central state through App.delete_list.

initialize_tab()

private void initialize_tab()

Refreshes and initializes the page that has just become active.

validate_current_tab()

private bool validate_current_tab()

Validates the active workflow page before navigation continues.

set_page()

private void set_page(int page)

Activates a specific workflow page and updates navigation state.

detach_root_widget()

public Gtk.Widget detach_root_widget()

Detaches and returns the component root widget for embedding in another window.

themed_icon()

private Gtk.Image themed_icon(string icon_name, int size)

Creates a themed GTK image at the requested size.

reload_themed_icons()

public void reload_themed_icons()

Reloads icons after a theme change.


10. External Resources and Paths

The component does not directly define protected filesystem paths or external command strings.


11. 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. Read or update central backup and restore state through the global controller

12. Runtime and Security Considerations

  • Shared controller state: the component reads and modifies the global App controller used by the surrounding workflow.
  • Signal-driven behavior: GTK callbacks update the model and interface when controls are activated or changed.
  • Reusable presentation: the component can be hosted as a standalone window or embedded inside the main navigation stack.

13. Implementation Considerations

  • Global coupling: the class depends on the process-wide App object rather than receiving a controller through dependency injection.
  • Embedding contract: parent containers must use detach_root_widget() only after the window has initialized its root widget.

14. Licensing

The source header contains the following copyright notices:

Copyright 2012-2018 Tony George <teejeetech@gmail.com>

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