1. Overview
The SmbShareDialog module collects and validates SMB repository connection details.
Its principal responsibilities are:
- Accepts server, share, subpath, credentials, domain, and label
- Supports anonymous access
- Can request credential persistence
- Attempts the SMB connection before returning a share object
2. Class Structure and Dependencies
public class SmbShareDialog : Gtk.Window
The source imports:
GtkGeeTeeJee.LoggingTeeJee.FileSystemTeeJee.GtkHelperTeeJee.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.Entry entry_server– text entry used for serverGtk.Entry entry_share– text entry used for shareGtk.Entry entry_subpath– text entry used for subpathGtk.Entry entry_user– text entry used for userGtk.Entry entry_password– text entry used for passwordGtk.Entry entry_domain– text entry used for domainGtk.Entry entry_label– text entry used for labelGtk.CheckButton chk_anonymous– check button controlling anonymousGtk.CheckButton chk_remember– check button controlling rememberGtk.Label lbl_status– detailed status labelGtk.Button btn_connect– button used to trigger the corresponding connect actionGtk.Button btn_cancel– button used to trigger the corresponding cancel actionSmbShare? result_share– runtime reference for result shareGLib.MainLoop? loop– runtime reference for loopbool ok_pressed– Boolean state for ok pressed
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.Grid– aligned form fieldsGtk.Label– headings, descriptions, and status textGtk.Separator– visual section separators
Event-driven behavior is connected through signals such as:
activate
clicked
toggled
5. Initialization
SmbShareDialog()
public SmbShareDialog(Gtk.Window? parent, SmbShare? prefill = null)
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
- Collect share and authentication fields
- Disable credential fields when anonymous access is selected
- Validate required values
- Attempt to construct and connect the SmbShare
- Return the accepted share or null when cancelled
8. Method Reference
build_ui()
private void build_ui()
Constructs the complete GTK widget hierarchy for the component. It creates Gtk.Box, Gtk.Button, Gtk.CheckButton, Gtk.Grid, Gtk.Label, Gtk.Separator where required. It connects the activate, clicked, toggled signals.
add_row()
private Gtk.Entry add_row(Gtk.Grid grid, int row, string label_text, string placeholder)
Adds or constructs row for the current interface or model. It creates Gtk.Entry, Gtk.Label where required.
update_anonymous_state()
private void update_anonymous_state()
Updates anonymous state to reflect the current state.
show_error()
private void show_error(string text)
Displays error to the user.
on_connect_clicked()
private void on_connect_clicked()
Event handler for connect clicked.
quit_loop()
private void quit_loop()
Stops loop and closes the associated workflow.
run_dialog()
public static SmbShare? run_dialog(Gtk.Window? parent, SmbShare? prefill = null)
Implements the run dialog operation.
9. External Resources and Paths
The source references the following relevant paths, command fragments, or resource identifiers:
/
//
10. Data and Event Flow
- Construct the component and initialize its child controls
- React to GTK signals generated by navigation, selections, and action controls
11. Runtime and Security Considerations
- Device safety: device selections are validated before backup or restore operations continue.
- Credential handling: authentication values are collected only when required by the selected connection mode.
- Signal-driven behavior: GTK callbacks update the model and interface when controls are activated or changed.
12. Implementation Considerations
- Nested or manual event loop: the component explicitly controls a GLib main loop instead of relying only on
Gtk.Application.
13. Licensing
The source header contains the following copyright notices:
Copyright 2025-2026 Calogero Scarnà — BastionGuard Backup
The file is distributed under the GNU General Public License version 2 or later.
