SmbShareDialog

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:

  • Gtk
  • Gee
  • TeeJee.Logging
  • TeeJee.FileSystem
  • TeeJee.GtkHelper
  • 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.Entry entry_server – text entry used for server
  • Gtk.Entry entry_share – text entry used for share
  • Gtk.Entry entry_subpath – text entry used for subpath
  • Gtk.Entry entry_user – text entry used for user
  • Gtk.Entry entry_password – text entry used for password
  • Gtk.Entry entry_domain – text entry used for domain
  • Gtk.Entry entry_label – text entry used for label
  • Gtk.CheckButton chk_anonymous – check button controlling anonymous
  • Gtk.CheckButton chk_remember – check button controlling remember
  • Gtk.Label lbl_status – detailed status label
  • Gtk.Button btn_connect – button used to trigger the corresponding connect action
  • Gtk.Button btn_cancel – button used to trigger the corresponding cancel action
  • SmbShare? result_share – runtime reference for result share
  • GLib.MainLoop? loop – runtime reference for loop
  • bool ok_pressed – Boolean state for ok pressed

4. User Interface Composition

The module directly constructs the following GTK widget types:

  • Gtk.Box – layout containers
  • Gtk.Button – action and navigation buttons
  • Gtk.CheckButton – Boolean or mutually exclusive choices
  • Gtk.Entry – editable text fields
  • Gtk.Grid – aligned form fields
  • Gtk.Label – headings, descriptions, and status text
  • Gtk.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

  1. Collect share and authentication fields
  2. Disable credential fields when anonymous access is selected
  3. Validate required values
  4. Attempt to construct and connect the SmbShare
  5. 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

  1. Construct the component and initialize its child controls
  2. 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.