ScanPromptWindow.hpp

1. Overview

The ScanPromptWindow.hpp header defines the ScanPromptWindow class, a GTKmm-based dialog window used to prompt the user to initiate or cancel a security scan on a detected device or filesystem node. The component provides a simple, focused user interface that emits signals corresponding to user decisions.

Functionally, ScanPromptWindow provides:

  • User-facing prompt for initiating on-demand scans
  • Explicit accept/cancel interaction model
  • Signal-based notification of user actions
  • Lightweight, modal-style window design
  • Integration with higher-level scan orchestration logic

2. Dependencies and Includes

#include <gtkmm.h>
  • gtkmm.h – GTK4 C++ bindings for windowing, widgets, and signal handling

3. Class Declaration and Scope

class ScanPromptWindow : public Gtk::Window

The ScanPromptWindow class derives from Gtk::Window, making it suitable as a top-level prompt dialog within the desktop user interface.


4. Construction

4.1 Constructor

ScanPromptWindow(const std::string& devnode);

Initializes the prompt window for the specified device node or filesystem path, configuring labels and messages to reflect the target resource.


5. Public Interface

5.1 Scan Request Signal

sigc::signal<void()> signal_scan_requested();

Returns a signal that is emitted when the user confirms the scan operation by activating the “Scan” button.


5.2 Cancel Request Signal

sigc::signal<void()> signal_cancel_requested();

Returns a signal that is emitted when the user cancels the operation by activating the “Cancel” button.


6. Internal Signals

sigc::signal<void()> sig_scan_;
sigc::signal<void()> sig_cancel_;

Internal signal objects used to implement the public notification interface.


7. User Interface Components

Gtk::Box vbox {Gtk::Orientation::VERTICAL, 15};
Gtk::Label titleLabel;
Gtk::Label messageLabel;
Gtk::Button scanButton;
Gtk::Button cancelButton;
  • vbox – vertical layout container with spacing
  • titleLabel – title or heading text
  • messageLabel – explanatory message describing the scan request
  • scanButton – button used to confirm and start the scan
  • cancelButton – button used to abort the operation

8. Interaction Flow

A typical user interaction sequence is:

  • Application detects a new device or scan-worthy resource
  • ScanPromptWindow is instantiated with the corresponding device node
  • The window is presented to the user
  • User selects “Scan” or “Cancel”
  • The appropriate signal is emitted to the controller layer
  • The window is closed or hidden

9. Usability and Security Considerations

  • Modal behavior: in security-critical contexts, the window may be configured as modal to prevent bypass of the scan prompt
  • Clear messaging: labels should clearly explain the implications of scanning and cancellation to avoid user confusion
  • Signal ownership: returned signals are copies; callers should connect handlers promptly and manage lifetimes carefully
  • Input spoofing: ensure that device identifiers displayed to the user are sanitized and correctly mapped to real system resources
  • Accessibility: UI elements should follow accessibility guidelines (keyboard navigation, screen reader compatibility)
  • Fail-safe defaults: in unattended environments, consider defaulting to conservative behavior (automatic scanning)