diff options
Diffstat (limited to 'src/app.c')
-rw-r--r-- | src/app.c | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -184,6 +184,8 @@ static iString *serializePrefs_App_(const iApp *d) { | |||
184 | appendFormat_String(str, "prefs.hoveroutline.changed arg:%d\n", d->prefs.hoverOutline); | 184 | appendFormat_String(str, "prefs.hoveroutline.changed arg:%d\n", d->prefs.hoverOutline); |
185 | appendFormat_String(str, "theme.set arg:%d auto:1\n", d->prefs.theme); | 185 | appendFormat_String(str, "theme.set arg:%d auto:1\n", d->prefs.theme); |
186 | appendFormat_String(str, "ostheme arg:%d\n", d->prefs.useSystemTheme); | 186 | appendFormat_String(str, "ostheme arg:%d\n", d->prefs.useSystemTheme); |
187 | appendFormat_String(str, "doctheme.dark.set arg:%d\n", d->prefs.docThemeDark); | ||
188 | appendFormat_String(str, "doctheme.light.set arg:%d\n", d->prefs.docThemeLight); | ||
187 | appendFormat_String(str, "saturation.set arg:%d\n", (int) ((d->prefs.saturation * 100) + 0.5f)); | 189 | appendFormat_String(str, "saturation.set arg:%d\n", (int) ((d->prefs.saturation * 100) + 0.5f)); |
188 | appendFormat_String(str, "proxy.gopher address:%s\n", cstr_String(&d->prefs.gopherProxy)); | 190 | appendFormat_String(str, "proxy.gopher address:%s\n", cstr_String(&d->prefs.gopherProxy)); |
189 | appendFormat_String(str, "proxy.http address:%s\n", cstr_String(&d->prefs.httpProxy)); | 191 | appendFormat_String(str, "proxy.http address:%s\n", cstr_String(&d->prefs.httpProxy)); |
@@ -700,6 +702,18 @@ static void updatePrefsThemeButtons_(iWidget *d) { | |||
700 | } | 702 | } |
701 | } | 703 | } |
702 | 704 | ||
705 | static void updateColorThemeButton_(iLabelWidget *button, int theme) { | ||
706 | const char *mode = strstr(cstr_String(id_Widget(as_Widget(button))), ".dark") ? "dark" : "light"; | ||
707 | const char *command = format_CStr("doctheme.%s.set arg:%d", mode, theme); | ||
708 | iForEach(ObjectList, i, children_Widget(findChild_Widget(as_Widget(button), "menu"))) { | ||
709 | iLabelWidget *item = i.object; | ||
710 | if (!cmp_String(command_LabelWidget(item), command)) { | ||
711 | updateText_LabelWidget(button, label_LabelWidget(item)); | ||
712 | break; | ||
713 | } | ||
714 | } | ||
715 | } | ||
716 | |||
703 | static iBool handlePrefsCommands_(iWidget *d, const char *cmd) { | 717 | static iBool handlePrefsCommands_(iWidget *d, const char *cmd) { |
704 | if (equal_Command(cmd, "prefs.dismiss") || equal_Command(cmd, "preferences")) { | 718 | if (equal_Command(cmd, "prefs.dismiss") || equal_Command(cmd, "preferences")) { |
705 | setUiScale_Window(get_Window(), | 719 | setUiScale_Window(get_Window(), |
@@ -720,6 +734,14 @@ static iBool handlePrefsCommands_(iWidget *d, const char *cmd) { | |||
720 | destroy_Widget(d); | 734 | destroy_Widget(d); |
721 | return iTrue; | 735 | return iTrue; |
722 | } | 736 | } |
737 | else if (equal_Command(cmd, "doctheme.dark.set")) { | ||
738 | updateColorThemeButton_(findChild_Widget(d, "prefs.doctheme.dark"), arg_Command(cmd)); | ||
739 | return iFalse; | ||
740 | } | ||
741 | else if (equal_Command(cmd, "doctheme.light.set")) { | ||
742 | updateColorThemeButton_(findChild_Widget(d, "prefs.doctheme.light"), arg_Command(cmd)); | ||
743 | return iFalse; | ||
744 | } | ||
723 | else if (equal_Command(cmd, "prefs.ostheme.changed")) { | 745 | else if (equal_Command(cmd, "prefs.ostheme.changed")) { |
724 | postCommandf_App("ostheme arg:%d", arg_Command(cmd)); | 746 | postCommandf_App("ostheme arg:%d", arg_Command(cmd)); |
725 | } | 747 | } |
@@ -908,6 +930,16 @@ iBool handleCommand_App(const char *cmd) { | |||
908 | d->prefs.useSystemTheme = arg_Command(cmd); | 930 | d->prefs.useSystemTheme = arg_Command(cmd); |
909 | return iTrue; | 931 | return iTrue; |
910 | } | 932 | } |
933 | else if (equal_Command(cmd, "doctheme.dark.set")) { | ||
934 | d->prefs.docThemeDark = arg_Command(cmd); | ||
935 | postCommand_App("theme.changed auto:1"); | ||
936 | return iTrue; | ||
937 | } | ||
938 | else if (equal_Command(cmd, "doctheme.light.set")) { | ||
939 | d->prefs.docThemeLight = arg_Command(cmd); | ||
940 | postCommand_App("theme.changed auto:1"); | ||
941 | return iTrue; | ||
942 | } | ||
911 | else if (equal_Command(cmd, "linewidth.set")) { | 943 | else if (equal_Command(cmd, "linewidth.set")) { |
912 | d->prefs.lineWidth = iMax(20, arg_Command(cmd)); | 944 | d->prefs.lineWidth = iMax(20, arg_Command(cmd)); |
913 | postCommand_App("document.layout.changed"); | 945 | postCommand_App("document.layout.changed"); |
@@ -1060,6 +1092,8 @@ iBool handleCommand_App(const char *cmd) { | |||
1060 | iTrue); | 1092 | iTrue); |
1061 | setToggle_Widget(findChild_Widget(dlg, "prefs.biglede"), d->prefs.bigFirstParagraph); | 1093 | setToggle_Widget(findChild_Widget(dlg, "prefs.biglede"), d->prefs.bigFirstParagraph); |
1062 | setToggle_Widget(findChild_Widget(dlg, "prefs.sideicon"), d->prefs.sideIcon); | 1094 | setToggle_Widget(findChild_Widget(dlg, "prefs.sideicon"), d->prefs.sideIcon); |
1095 | updateColorThemeButton_(findChild_Widget(dlg, "prefs.doctheme.dark"), d->prefs.docThemeDark); | ||
1096 | updateColorThemeButton_(findChild_Widget(dlg, "prefs.doctheme.light"), d->prefs.docThemeLight); | ||
1063 | setFlags_Widget( | 1097 | setFlags_Widget( |
1064 | findChild_Widget( | 1098 | findChild_Widget( |
1065 | dlg, format_CStr("prefs.saturation.%d", (int) (d->prefs.saturation * 3.99f))), | 1099 | dlg, format_CStr("prefs.saturation.%d", (int) (d->prefs.saturation * 3.99f))), |