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: Implementation. The file contains 231 lines and belongs to the dialogs/LanguageDialog.cpp path.
The companion file is dialogs/LanguageDialog.hpp.
2. Component Responsibilities
- Implement the behavior declared by the corresponding header or entry-point contract.
- 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:
LanguageDialog.hppgdkmm/pixbuf.h../Resource.hppglibmm/i18n.hunistd.hlinux/limits.h
System and library dependencies:
fstreamiostreamsstream
4. Signals and Event Integration
The file exposes or connects the following signal-related elements:
closeBtn->signal_clicked().connect([this]() { hide(); });signal_response().connect([this](int response) {
GTK-facing callbacks must execute on the main UI context. Components with worker threads use dispatchers or idle callbacks to cross the thread boundary.
5. Functions and Methods
The file exposes or implements 6 detected function or method signatures.
1. availableLanguages
const std::vector<LanguageDialog::LangEntry>& LanguageDialog::availableLanguages()
Implements the available languages operation declared by this component.
2. LanguageDialog
LanguageDialog::LanguageDialog(const std::string& configFile, const std::string& currentLang) : Gtk::Dialog() , m_configFile(configFile) , m_selected(currentLang)
Implements the language dialog operation declared by this component.
3. buildHeaderBar
void LanguageDialog::buildHeaderBar()
Builds and configures the header bar user-interface or internal structure.
4. buildUI
void LanguageDialog::buildUI(const std::string& currentLang)
Builds and configures the ui user-interface or internal structure.
5. onApply
void LanguageDialog::onApply()
Handles the apply callback or user event.
6. saveLangToConfig
bool LanguageDialog::saveLangToConfig(const std::string& lang)
Serializes or persists lang to config.
6. Filesystem, IPC, Network, and Command Interfaces
Relevant literal paths, endpoints, or resource locations include:
/proc/self/exe
Relevant command or protocol construction lines include:
ssize_t len = ::readlink("/proc/self/exe", exe, sizeof(exe) - 1);
7. 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
8. Runtime and Security Considerations
- Rewrites only the language preference while preserving unrelated configuration entries.
- Uses /proc/self/exe to restart the same installed executable.
9. Error Handling and Operational Notes
- Exceptions are caught locally in one or more operations to prevent application-wide termination.
- Diagnostic failures are written to standard error or the GLib logging channel.
- Boolean-returning operations use
falseto report recoverable failure.
10. Source Integrity
Relative source path: dialogs/LanguageDialog.cpp
SHA-256:
1286c90cb76301bb530fb7c6c50e6e259df17d4138c383806671edad44618464
11. 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.
