summaryrefslogtreecommitdiff
path: root/src/app.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-11-20 14:09:08 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-11-20 14:09:08 +0200
commitdf0e00463c5b55f89471720c1bf4d83e1f428aae (patch)
tree00f39e4c7d7308e5b1d65473a538c691181abefa /src/app.c
parentc998b25d4d428e860520bb8fa4fd5450c1b865fd (diff)
Preferences: Added a Gemini proxy
Diffstat (limited to 'src/app.c')
-rw-r--r--src/app.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/app.c b/src/app.c
index 02c69d64..f2741ee6 100644
--- a/src/app.c
+++ b/src/app.c
@@ -193,6 +193,7 @@ static iString *serializePrefs_App_(const iApp *d) {
193 appendFormat_String(str, "doctheme.dark.set arg:%d\n", d->prefs.docThemeDark); 193 appendFormat_String(str, "doctheme.dark.set arg:%d\n", d->prefs.docThemeDark);
194 appendFormat_String(str, "doctheme.light.set arg:%d\n", d->prefs.docThemeLight); 194 appendFormat_String(str, "doctheme.light.set arg:%d\n", d->prefs.docThemeLight);
195 appendFormat_String(str, "saturation.set arg:%d\n", (int) ((d->prefs.saturation * 100) + 0.5f)); 195 appendFormat_String(str, "saturation.set arg:%d\n", (int) ((d->prefs.saturation * 100) + 0.5f));
196 appendFormat_String(str, "proxy.gemini address:%s\n", cstr_String(&d->prefs.geminiProxy));
196 appendFormat_String(str, "proxy.gopher address:%s\n", cstr_String(&d->prefs.gopherProxy)); 197 appendFormat_String(str, "proxy.gopher address:%s\n", cstr_String(&d->prefs.gopherProxy));
197 appendFormat_String(str, "proxy.http address:%s\n", cstr_String(&d->prefs.httpProxy)); 198 appendFormat_String(str, "proxy.http address:%s\n", cstr_String(&d->prefs.httpProxy));
198 appendFormat_String(str, "downloads path:%s\n", cstr_String(&d->prefs.downloadDir)); 199 appendFormat_String(str, "downloads path:%s\n", cstr_String(&d->prefs.downloadDir));
@@ -616,13 +617,16 @@ enum iColorTheme colorTheme_App(void) {
616const iString *schemeProxy_App(iRangecc scheme) { 617const iString *schemeProxy_App(iRangecc scheme) {
617 iApp *d = &app_; 618 iApp *d = &app_;
618 const iString *proxy = NULL; 619 const iString *proxy = NULL;
619 if (equalCase_Rangecc(scheme, "gopher")) { 620 if (equalCase_Rangecc(scheme, "gemini")) {
621 proxy = &d->prefs.geminiProxy;
622 }
623 else if (equalCase_Rangecc(scheme, "gopher")) {
620 proxy = &d->prefs.gopherProxy; 624 proxy = &d->prefs.gopherProxy;
621 } 625 }
622 if (equalCase_Rangecc(scheme, "http") || equalCase_Rangecc(scheme, "https")) { 626 else if (equalCase_Rangecc(scheme, "http") || equalCase_Rangecc(scheme, "https")) {
623 proxy = &d->prefs.httpProxy; 627 proxy = &d->prefs.httpProxy;
624 } 628 }
625 return !isEmpty_String(proxy) ? proxy : NULL; 629 return isEmpty_String(proxy) ? NULL : proxy;
626} 630}
627 631
628int run_App(int argc, char **argv) { 632int run_App(int argc, char **argv) {
@@ -744,10 +748,12 @@ static iBool handlePrefsCommands_(iWidget *d, const char *cmd) {
744 isSelected_Widget(findChild_Widget(d, "prefs.smoothscroll"))); 748 isSelected_Widget(findChild_Widget(d, "prefs.smoothscroll")));
745 postCommandf_App("ostheme arg:%d", 749 postCommandf_App("ostheme arg:%d",
746 isSelected_Widget(findChild_Widget(d, "prefs.ostheme"))); 750 isSelected_Widget(findChild_Widget(d, "prefs.ostheme")));
747 postCommandf_App("proxy.http address:%s", 751 postCommandf_App("proxy.gemini address:%s",
748 cstr_String(text_InputWidget(findChild_Widget(d, "prefs.proxy.http")))); 752 cstr_String(text_InputWidget(findChild_Widget(d, "prefs.proxy.gemini"))));
749 postCommandf_App("proxy.gopher address:%s", 753 postCommandf_App("proxy.gopher address:%s",
750 cstr_String(text_InputWidget(findChild_Widget(d, "prefs.proxy.gopher")))); 754 cstr_String(text_InputWidget(findChild_Widget(d, "prefs.proxy.gopher"))));
755 postCommandf_App("proxy.http address:%s",
756 cstr_String(text_InputWidget(findChild_Widget(d, "prefs.proxy.http"))));
751 const iWidget *tabs = findChild_Widget(d, "prefs.tabs"); 757 const iWidget *tabs = findChild_Widget(d, "prefs.tabs");
752 postCommandf_App("prefs.dialogtab arg:%u", 758 postCommandf_App("prefs.dialogtab arg:%u",
753 tabPageIndex_Widget(tabs, currentTabPage_Widget(tabs))); 759 tabPageIndex_Widget(tabs, currentTabPage_Widget(tabs)));
@@ -1024,6 +1030,10 @@ iBool handleCommand_App(const char *cmd) {
1024 postCommandf_App("theme.changed auto:1"); 1030 postCommandf_App("theme.changed auto:1");
1025 return iTrue; 1031 return iTrue;
1026 } 1032 }
1033 else if (equal_Command(cmd, "proxy.gemini")) {
1034 setCStr_String(&d->prefs.geminiProxy, suffixPtr_Command(cmd, "address"));
1035 return iTrue;
1036 }
1027 else if (equal_Command(cmd, "proxy.gopher")) { 1037 else if (equal_Command(cmd, "proxy.gopher")) {
1028 setCStr_String(&d->prefs.gopherProxy, suffixPtr_Command(cmd, "address")); 1038 setCStr_String(&d->prefs.gopherProxy, suffixPtr_Command(cmd, "address"));
1029 return iTrue; 1039 return iTrue;
@@ -1177,10 +1187,9 @@ iBool handleCommand_App(const char *cmd) {
1177 dlg, format_CStr("prefs.saturation.%d", (int) (d->prefs.saturation * 3.99f))), 1187 dlg, format_CStr("prefs.saturation.%d", (int) (d->prefs.saturation * 3.99f))),
1178 selected_WidgetFlag, 1188 selected_WidgetFlag,
1179 iTrue); 1189 iTrue);
1180 setText_InputWidget(findChild_Widget(dlg, "prefs.proxy.http"), 1190 setText_InputWidget(findChild_Widget(dlg, "prefs.proxy.gemini"), &d->prefs.geminiProxy);
1181 schemeProxy_App(range_CStr("http"))); 1191 setText_InputWidget(findChild_Widget(dlg, "prefs.proxy.gopher"), &d->prefs.gopherProxy);
1182 setText_InputWidget(findChild_Widget(dlg, "prefs.proxy.gopher"), 1192 setText_InputWidget(findChild_Widget(dlg, "prefs.proxy.http"), &d->prefs.httpProxy);
1183 schemeProxy_App(range_CStr("gopher")));
1184 iWidget *tabs = findChild_Widget(dlg, "prefs.tabs"); 1193 iWidget *tabs = findChild_Widget(dlg, "prefs.tabs");
1185 showTabPage_Widget(tabs, tabPage_Widget(tabs, d->prefs.dialogTab)); 1194 showTabPage_Widget(tabs, tabPage_Widget(tabs, d->prefs.dialogTab));
1186 setCommandHandler_Widget(dlg, handlePrefsCommands_); 1195 setCommandHandler_Widget(dlg, handlePrefsCommands_);