1. Overview
GTK dialog for selecting the interface locale, persisting the chosen value in settings.ini, updating gettext-related environment variables, and restarting the application so translated resources are reloaded consistently.
File role: Header Interface. The file contains 52 lines and belongs to the dialogs/LanguageDialog.hpp path.
The companion file is dialogs/LanguageDialog.cpp.
2. Component Responsibilities
- Declare the component API, owned state, callbacks, and data structures.
- Populate the supported language list
- Select the current language
- Update the language key in the configuration file
- Apply locale environment variables
- Inform the user that a restart is required
- Re-execute the current application binary
3. Dependencies and Integration
Project-level dependencies:
gtkmm.h
System and library dependencies:
stringvector
4. Declared Types
LanguageDialog
Declares a class derived from or associated with public Gtk::Dialog.
LangEntry
Declares a struct.
5. Constants and Fixed Configuration
The file declares or uses the following fixed values:
static const std::vector<LangEntry>& availableLanguages();
6. Owned State and UI Members
User-interface members
Gtk::ComboBoxText m_combo;
Data and configuration state
std::string code;std::string label;std::string m_configFile;std::string m_selected;
7. Functions and Methods
The file exposes or implements 7 detected function or method signatures.
1. LanguageDialog
explicit LanguageDialog(const std::string& configFile, const std::string& currentLang)
Implements the language dialog operation declared by this component.
2. availableLanguages
static const std::vector<LangEntry>& availableLanguages()
Implements the available languages operation declared by this component.
3. buildHeaderBar
void buildHeaderBar()
Builds and configures the header bar user-interface or internal structure.
4. buildUI
void buildUI(const std::string& currentLang)
Builds and configures the ui user-interface or internal structure.
5. onApply
void onApply()
Handles the apply callback or user event.
6. saveLangToConfig
bool saveLangToConfig(const std::string& lang)
Serializes or persists lang to config.
7. selectedLanguage
std::string selectedLanguage() const
Implements the selected language operation declared by this component.
8. Runtime Flow
- Populate the supported language list
- Select the current language
- Update the language key in the configuration file
- Apply locale environment variables
- Inform the user that a restart is required
- Re-execute the current application binary
9. Runtime and Security Considerations
- Rewrites only the language preference while preserving unrelated configuration entries.
- Uses /proc/self/exe to restart the same installed executable.
10. Error Handling and Operational Notes
- Exceptions are caught locally in one or more operations to prevent application-wide termination.
11. Source Integrity
Relative source path: dialogs/LanguageDialog.hpp
SHA-256:
8d38f134473fd7f6f9283c61a689dbaead155a278935e655e10858155bd47e1f
12. Licensing
The source header identifies this component as distributed under the GNU General Public License version 3. BastionGuard branding and trademarks remain subject to the notices stated in the source file.
