ExcludeBox

1. Overview

The ExcludeBox module manages custom RSYNC include and exclude patterns.

Its principal responsibilities are:

  • Displays editable filter rules
  • Adds files and folders through GTK choosers
  • Supports include and exclude semantics
  • Reorders and removes patterns
  • Persists the final user exclusion list

2. Class Structure and Dependencies

public class ExcludeBox : 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.ListBox listbox – GTK list used to render selectable rows
  • Gtk.Window parent_window – parent GTK window used for transient dialogs
  • UsersBox users_box – per-user inclusion settings page
  • Gtk.Label lbl_message – descriptive page or result message
  • Gtk.ScrolledWindow scrolled – ScrolledWindow widget used by the interface

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.Entry – editable text fields
  • Gtk.ListBox – dynamic selectable rows
  • Gtk.ListBoxRow – custom list rows
  • Gtk.ScrolledWindow – scrollable content regions
  • Gtk.SizeGroup – consistent alignment across labels and values

Event-driven behavior is connected through signals such as:

changed
clicked
toggled

5. Initialization

ExcludeBox()

public ExcludeBox(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.exclude_list_default
  • App.exclude_list_home
  • App.exclude_list_user

7. Method Reference

set_users_box()

public void set_users_box(UsersBox _users_box)

Sets users box and updates dependent UI state.

init_listbox()

private void init_listbox()

Initializes listbox state and controls. It creates Gtk.ListBox, Gtk.ScrolledWindow where required.

create_pattern_row()

private Gtk.Widget create_pattern_row(string pattern)

Creates pattern row required by the workflow. It creates Gtk.Box, Gtk.CheckButton, Gtk.Entry, Gtk.ListBoxRow where required. It connects the changed, clicked, toggled signals.

update_row_pattern()

private void update_row_pattern(Gtk.ListBoxRow row, string text, bool include)

Updates row pattern to reflect the current state.

clear_listbox()

private void clear_listbox()

Implements the clear listbox operation.

move_row()

private void move_row(Gtk.ListBoxRow row, int delta)

Implements the move row operation.

remove_row()

private void remove_row(Gtk.ListBoxRow row)

Removes row from the interface, model, or filesystem. It reads or updates central state through App.exclude_list_user.

collect_patterns()

private Gee.ArrayList<string> collect_patterns()

Collects patterns from the visible controls.

apply_patterns()

private void apply_patterns(Gee.ArrayList<string> patterns)

Applies patterns to the active state. It reads or updates central state through App.exclude_list_user.

init_actions()

private void init_actions()

Initializes actions state and controls. It reads or updates central state through App.exclude_list_user. It creates Gtk.Box, Gtk.SizeGroup where required. It connects the clicked signal.

remove_clicked()

private void remove_clicked()

Removes clicked from the interface, model, or filesystem.

add_files_clicked()

private void add_files_clicked()

Adds or constructs files clicked for the current interface or model. It reads or updates central state through App.exclude_list_user.

add_folder_clicked()

private void add_folder_clicked()

Adds or constructs folder clicked for the current interface or model. It reads or updates central state through App.exclude_list_user.

browse_files()

private SList<string> browse_files()

Opens a GTK chooser for files.

browse_folder()

private SList<string> browse_folder()

Opens a GTK chooser for folder.

refresh_treeview()

public void refresh_treeview()

Rebuilds the visible list from the current model state. It reads or updates central state through App.exclude_list_user.

save_changes()

public void save_changes()

Copies UI selections into the central configuration and persists the result. It reads or updates central state through App.exclude_list_default, App.exclude_list_home, App.exclude_list_user.


8. External Resources and Paths

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

/***

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