summaryrefslogtreecommitdiff
path: root/src/app.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/app.c')
-rw-r--r--src/app.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/app.c b/src/app.c
index 95345bda..d477abb5 100644
--- a/src/app.c
+++ b/src/app.c
@@ -208,6 +208,7 @@ static iString *serializePrefs_App_(const iApp *d) {
208 } 208 }
209 appendFormat_String(str, "sidebar2.mode arg:%d\n", mode_SidebarWidget(sidebar2)); 209 appendFormat_String(str, "sidebar2.mode arg:%d\n", mode_SidebarWidget(sidebar2));
210 } 210 }
211 appendFormat_String(str, "uilang id:%s\n", cstr_String(&d->prefs.uiLanguage));
211 appendFormat_String(str, "uiscale arg:%f\n", uiScale_Window(d->window)); 212 appendFormat_String(str, "uiscale arg:%f\n", uiScale_Window(d->window));
212 appendFormat_String(str, "prefs.dialogtab arg:%d\n", d->prefs.dialogTab); 213 appendFormat_String(str, "prefs.dialogtab arg:%d\n", d->prefs.dialogTab);
213 appendFormat_String(str, "font.set arg:%d\n", d->prefs.font); 214 appendFormat_String(str, "font.set arg:%d\n", d->prefs.font);
@@ -308,6 +309,11 @@ static void loadPrefs_App_(iApp *d) {
308 if (equal_Command(cmd, "uiscale")) { 309 if (equal_Command(cmd, "uiscale")) {
309 setUiScale_Window(get_Window(), argf_Command(cmd)); 310 setUiScale_Window(get_Window(), argf_Command(cmd));
310 } 311 }
312 else if (equal_Command(cmd, "uilang")) {
313 const char *id = cstr_Rangecc(range_Command(cmd, "id"));
314 setCStr_String(&d->prefs.uiLanguage, id);
315 setCurrent_Lang(id);
316 }
311 else if (equal_Command(cmd, "ca.file") || equal_Command(cmd, "ca.path")) { 317 else if (equal_Command(cmd, "ca.file") || equal_Command(cmd, "ca.path")) {
312 /* Background requests may be started before these commands would get 318 /* Background requests may be started before these commands would get
313 handled via the event loop. */ 319 handled via the event loop. */
@@ -1286,13 +1292,14 @@ static void updatePrefsThemeButtons_(iWidget *d) {
1286} 1292}
1287 1293
1288static void updateDropdownSelection_(iLabelWidget *dropButton, const char *selectedCommand) { 1294static void updateDropdownSelection_(iLabelWidget *dropButton, const char *selectedCommand) {
1289 iForEach(ObjectList, i, children_Widget(findChild_Widget(as_Widget(dropButton), "menu"))) { 1295 iWidget *menu = findChild_Widget(as_Widget(dropButton), "menu");
1296 iForEach(ObjectList, i, children_Widget(menu)) {
1290 if (isInstance_Object(i.object, &Class_LabelWidget)) { 1297 if (isInstance_Object(i.object, &Class_LabelWidget)) {
1291 iLabelWidget *item = i.object; 1298 iLabelWidget *item = i.object;
1292 const iBool isSelected = endsWith_String(command_LabelWidget(item), selectedCommand); 1299 const iBool isSelected = endsWith_String(command_LabelWidget(item), selectedCommand);
1293 setFlags_Widget(as_Widget(item), selected_WidgetFlag, isSelected); 1300 setFlags_Widget(as_Widget(item), selected_WidgetFlag, isSelected);
1294 if (isSelected) { 1301 if (isSelected) {
1295 updateText_LabelWidget(dropButton, text_LabelWidget(item)); 1302 updateText_LabelWidget(dropButton, sourceText_LabelWidget(item));
1296 } 1303 }
1297 } 1304 }
1298 } 1305 }
@@ -1300,8 +1307,6 @@ static void updateDropdownSelection_(iLabelWidget *dropButton, const char *selec
1300 1307
1301static void updateColorThemeButton_(iLabelWidget *button, int theme) { 1308static void updateColorThemeButton_(iLabelWidget *button, int theme) {
1302 if (!button) return; 1309 if (!button) return;
1303// const char *mode = strstr(cstr_String(id_Widget(as_Widget(button))), ".dark")
1304// ? "dark" : "light";
1305 updateDropdownSelection_(button, format_CStr(".set arg:%d", theme)); 1310 updateDropdownSelection_(button, format_CStr(".set arg:%d", theme));
1306} 1311}
1307 1312
@@ -1355,6 +1360,11 @@ static iBool handlePrefsCommands_(iWidget *d, const char *cmd) {
1355 postCommand_App("prefs.changed"); 1360 postCommand_App("prefs.changed");
1356 return iTrue; 1361 return iTrue;
1357 } 1362 }
1363 else if (equal_Command(cmd, "uilang")) {
1364 updateDropdownSelection_(findChild_Widget(d, "prefs.uilang"),
1365 cstr_String(string_Command(cmd, "id")));
1366 return iFalse;
1367 }
1358 else if (equal_Command(cmd, "quoteicon.set")) { 1368 else if (equal_Command(cmd, "quoteicon.set")) {
1359 const int arg = arg_Command(cmd); 1369 const int arg = arg_Command(cmd);
1360 setFlags_Widget(findChild_Widget(d, "prefs.quoteicon.0"), selected_WidgetFlag, arg == 0); 1370 setFlags_Widget(findChild_Widget(d, "prefs.quoteicon.0"), selected_WidgetFlag, arg == 0);
@@ -1532,6 +1542,15 @@ iBool handleCommand_App(const char *cmd) {
1532 d->prefs.dialogTab = arg_Command(cmd); 1542 d->prefs.dialogTab = arg_Command(cmd);
1533 return iTrue; 1543 return iTrue;
1534 } 1544 }
1545 else if (equal_Command(cmd, "uilang")) {
1546 const iString *lang = string_Command(cmd, "id");
1547 if (!equal_String(lang, &d->prefs.uiLanguage)) {
1548 set_String(&d->prefs.uiLanguage, lang);
1549 setCurrent_Lang(cstr_String(&d->prefs.uiLanguage));
1550 postCommand_App("lang.changed");
1551 }
1552 return iTrue;
1553 }
1535 else if (equal_Command(cmd, "translation.languages")) { 1554 else if (equal_Command(cmd, "translation.languages")) {
1536 d->prefs.langFrom = argLabel_Command(cmd, "from"); 1555 d->prefs.langFrom = argLabel_Command(cmd, "from");
1537 d->prefs.langTo = argLabel_Command(cmd, "to"); 1556 d->prefs.langTo = argLabel_Command(cmd, "to");
@@ -1891,6 +1910,7 @@ iBool handleCommand_App(const char *cmd) {
1891 setToggle_Widget(findChild_Widget(dlg, "prefs.hidetoolbarscroll"), d->prefs.hideToolbarOnScroll); 1910 setToggle_Widget(findChild_Widget(dlg, "prefs.hidetoolbarscroll"), d->prefs.hideToolbarOnScroll);
1892 setToggle_Widget(findChild_Widget(dlg, "prefs.ostheme"), d->prefs.useSystemTheme); 1911 setToggle_Widget(findChild_Widget(dlg, "prefs.ostheme"), d->prefs.useSystemTheme);
1893 setToggle_Widget(findChild_Widget(dlg, "prefs.customframe"), d->prefs.customFrame); 1912 setToggle_Widget(findChild_Widget(dlg, "prefs.customframe"), d->prefs.customFrame);
1913 updateDropdownSelection_(findChild_Widget(dlg, "prefs.uilang"), cstr_String(&d->prefs.uiLanguage));
1894 setToggle_Widget(findChild_Widget(dlg, "prefs.retainwindow"), d->prefs.retainWindowSize); 1914 setToggle_Widget(findChild_Widget(dlg, "prefs.retainwindow"), d->prefs.retainWindowSize);
1895 setText_InputWidget(findChild_Widget(dlg, "prefs.uiscale"), 1915 setText_InputWidget(findChild_Widget(dlg, "prefs.uiscale"),
1896 collectNewFormat_String("%g", uiScale_Window(d->window))); 1916 collectNewFormat_String("%g", uiScale_Window(d->window)));