SettingsPage.hpp

1. Overview

GTK settings page for enabling protection and inspecting system integration. It tracks the daemon service, autostart desktop entry, saved preference, and backup state, and emits a signal when the user requests a protection change.

File role: Header Interface. The file contains 56 lines and belongs to the pages/SettingsPage.hpp path.

The companion file is pages/SettingsPage.cpp.


2. Component Responsibilities

  • Declare the component API, owned state, callbacks, and data structures.
  • Build service and integration status cards
  • Load the saved protection preference
  • Check whether the systemd service is enabled
  • Check primary and fallback autostart entries
  • Display saved, service, autostart, and backup status
  • Emit the requested protection state when the user applies changes

3. Dependencies and Integration

Project-level dependencies:

  • gtkmm.h

System and library dependencies:

  • string

4. Declared Types

SettingsPage

Declares a class derived from or associated with public Gtk::Box.


5. Owned State and UI Members

User-interface members

  • Gtk::ScrolledWindow m_scroll;
  • Gtk::Box m_content {Gtk::Orientation::VERTICAL, 16};
  • Gtk::Label m_title;
  • Gtk::Label m_intro;
  • Gtk::Frame m_serviceFrame;
  • Gtk::Box m_serviceBox {Gtk::Orientation::VERTICAL, 12};
  • Gtk::Switch m_enableSwitch;
  • Gtk::Label m_enableLabel;
  • Gtk::Label m_statusLabel;
  • Gtk::Label m_infoLabel;
  • Gtk::Button m_applyButton;
  • Gtk::Button m_refreshButton;
  • Gtk::Frame m_detailsFrame;
  • Gtk::Box m_detailsBox {Gtk::Orientation::VERTICAL, 8};
  • Gtk::Label m_savedPrefLabel;
  • Gtk::Label m_serviceStateLabel;
  • Gtk::Label m_autostartStateLabel;
  • Gtk::Label m_backupStateLabel;
  • Gtk::Label m_serviceTitle;
  • Gtk::Label m_serviceBadge;
  • Gtk::Label m_detailsTitle;
  • Gtk::Label m_detailsBadge;

Data and configuration state

  • bool m_updatingSwitch = false;
  • std::string m_configPath;
  • std::string m_backupPath;
  • bool m_savedEnabled = true;

6. Signals and Event Integration

The file exposes or connects the following signal-related elements:

  • sigc::signal<void(bool)>& signal_toggle_protection_requested() { return m_signalToggleProtectionRequested; }
  • sigc::signal<void(bool)> m_signalToggleProtectionRequested;

GTK-facing callbacks must execute on the main UI context. Components with worker threads use dispatchers or idle callbacks to cross the thread boundary.


7. Functions and Methods

The file exposes or implements 10 detected function or method signatures.

1. SettingsPage

SettingsPage()

Updates settings page and synchronizes dependent state.

2. setProtectionEnabled

void setProtectionEnabled(bool enabled)

Updates protection enabled and synchronizes dependent state.

3. setSystemIntegrationStatus

void setSystemIntegrationStatus(const std::string& text)

Updates system integration status and synchronizes dependent state.

4. refreshState

void refreshState()

Refreshes state from the authoritative system state.

5. buildUi

void buildUi()

Builds and configures the ui user-interface or internal structure.

6. loadPreference

void loadPreference()

Loads preference from its persistent or runtime source.

7. serviceEnabled

bool serviceEnabled() const

Implements the service enabled operation declared by this component.

8. autostartInstalled

bool autostartInstalled() const

Implements the autostart installed operation declared by this component.

9. backupExists

bool backupExists() const

Implements the backup exists operation declared by this component.

10. boolText

static std::string boolText(bool value)

Implements the bool text operation declared by this component.


8. Runtime Flow

  1. Build service and integration status cards
  2. Load the saved protection preference
  3. Check whether the systemd service is enabled
  4. Check primary and fallback autostart entries
  5. Display saved, service, autostart, and backup status
  6. Emit the requested protection state when the user applies changes

9. Runtime and Security Considerations

  • Separates saved preference from actual system service state.
  • Checks whether an autostart backup exists before reporting integration health.
  • Exposes a signal to the controller instead of directly owning all privileged changes.

10. Error Handling and Operational Notes

  • Errors are propagated through the return type, callbacks, or the owning controller.

11. Source Integrity

Relative source path: pages/SettingsPage.hpp

SHA-256:

0605aa9852241d566aeaed34857a5e28de07d18485f2849a84d579cc942d693c

12. Licensing

No standalone license block is present in this file. Licensing follows the surrounding BastionGuard Secure Connection project and its accompanying source notices.