Skip to content
API Documentation
BastionGuard™
bankgui-main.cpp File Reference

Go to the source code of this file.

Classes

class  BankGuiWindow

Functions

static bool load_lang_conf ()
int main (int argc, char *argv[])

Function Documentation

◆ load_lang_conf()

bool load_lang_conf ( )
static

Definition at line 235 of file bankgui-main.cpp.

236{
237 const std::string lang_conf = Glib::get_home_dir() + "/.config/BastionGuard/lang.conf";
238 std::ifstream f(lang_conf);
239 if (!f.is_open())
240 return false;
241
242 std::string line;
243 bool any = false;
244
245 while (std::getline(f, line)) {
246 if (line.empty() || line[0] == '#')
247 continue;
248
249 auto pos = line.find('=');
250 if (pos == std::string::npos)
251 continue;
252
253 std::string key = line.substr(0, pos);
254 std::string val = line.substr(pos + 1);
255
256 auto ltrim = [](std::string& s){
257 s.erase(0, s.find_first_not_of(" \t\r\n"));
258 };
259 auto rtrim = [](std::string& s){
260 s.erase(s.find_last_not_of(" \t\r\n") + 1);
261 };
262 ltrim(key); rtrim(key);
263 ltrim(val); rtrim(val);
264
265 if (!key.empty() && !val.empty()) {
266 setenv(key.c_str(), val.c_str(), 1);
267 any = true;
268 }
269 }
270
271 return any;
272}

References load_lang_conf().

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 274 of file bankgui-main.cpp.

275{
276 bool loaded = load_lang_conf();
277
278 std::setlocale(LC_ALL, "");
279
280
281 bindtextdomain("BastionGuard", LOCALEDIR);
282 bind_textdomain_codeset("BastionGuard", "UTF-8");
283 textdomain("BastionGuard");
284
285 if (loaded) {
286 std::cerr << _("[Lang] Config caricata da ~/.config/BastionGuard/lang.conf") << "\n";
287 } else {
288 std::cerr << _("[Lang] Nessuna config trovata, uso locale di sistema") << "\n";
289 }
290
291 auto app = Gtk::Application::create("org.BastionGuard.bankgui");
292 load_style();
293 return app->make_window_and_run<BankGuiWindow>(argc, argv);
294}
#define _(s)
static bool load_lang_conf()
#define LOCALEDIR
void load_style()

References _, load_lang_conf(), load_style(), LOCALEDIR, and main().