summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-09-21 18:25:09 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-09-21 18:25:09 +0300
commit9c8cbd5cd300900617f1b3e8f67a9cd6f08624ee (patch)
treec522705013eb9409bdce862a4a0c15a8b06a82cc
parent35b5ff92a5ab7d49bde2e572fc8d5de5367fb0db (diff)
Preferences: Line width, 1st paragraph; tab switch keys
-rw-r--r--src/app.c24
-rw-r--r--src/ui/documentwidget.c3
-rw-r--r--src/ui/util.c42
3 files changed, 53 insertions, 16 deletions
diff --git a/src/app.c b/src/app.c
index 839e8e65..3ec65ecd 100644
--- a/src/app.c
+++ b/src/app.c
@@ -153,6 +153,8 @@ static iString *serializePrefs_App_(const iApp *d) {
153 if (isMaximized) { 153 if (isMaximized) {
154 appendFormat_String(str, "~window.maximize\n"); 154 appendFormat_String(str, "~window.maximize\n");
155 } 155 }
156#else
157 iUnused(isMaximized);
156#endif 158#endif
157 } 159 }
158 if (isVisible_Widget(sidebar)) { 160 if (isVisible_Widget(sidebar)) {
@@ -164,6 +166,8 @@ static iString *serializePrefs_App_(const iApp *d) {
164 appendFormat_String(str, "sidebar.mode arg:%d\n", mode_SidebarWidget(sidebar)); 166 appendFormat_String(str, "sidebar.mode arg:%d\n", mode_SidebarWidget(sidebar));
165 appendFormat_String(str, "uiscale arg:%f\n", uiScale_Window(d->window)); 167 appendFormat_String(str, "uiscale arg:%f\n", uiScale_Window(d->window));
166 appendFormat_String(str, "zoom.set arg:%d\n", d->prefs.zoomPercent); 168 appendFormat_String(str, "zoom.set arg:%d\n", d->prefs.zoomPercent);
169 appendFormat_String(str, "linewidth.set arg:%d\n", d->prefs.lineWidth);
170 appendFormat_String(str, "biglede.set arg:%d\n", d->prefs.bigFirstParagraph);
167 appendFormat_String(str, "theme.set arg:%d auto:1\n", d->prefs.theme); 171 appendFormat_String(str, "theme.set arg:%d auto:1\n", d->prefs.theme);
168 appendFormat_String(str, "ostheme arg:%d\n", d->prefs.useSystemTheme); 172 appendFormat_String(str, "ostheme arg:%d\n", d->prefs.useSystemTheme);
169 appendFormat_String(str, "saturation.set arg:%d\n", (int) ((d->prefs.saturation * 100) + 0.5f)); 173 appendFormat_String(str, "saturation.set arg:%d\n", (int) ((d->prefs.saturation * 100) + 0.5f));
@@ -845,6 +849,16 @@ iBool handleCommand_App(const char *cmd) {
845 d->prefs.useSystemTheme = arg_Command(cmd); 849 d->prefs.useSystemTheme = arg_Command(cmd);
846 return iTrue; 850 return iTrue;
847 } 851 }
852 else if (equal_Command(cmd, "linewidth.set")) {
853 d->prefs.lineWidth = iMax(20, arg_Command(cmd));
854 postCommand_App("document.layout.changed");
855 return iTrue;
856 }
857 else if (equal_Command(cmd, "prefs.biglede.changed")) {
858 d->prefs.bigFirstParagraph = arg_Command(cmd) != 0;
859 postCommand_App("document.layout.changed");
860 return iTrue;
861 }
848 else if (equal_Command(cmd, "saturation.set")) { 862 else if (equal_Command(cmd, "saturation.set")) {
849 d->prefs.saturation = (float) arg_Command(cmd) / 100.0f; 863 d->prefs.saturation = (float) arg_Command(cmd) / 100.0f;
850 postCommandf_App("theme.changed auto:1"); 864 postCommandf_App("theme.changed auto:1");
@@ -963,6 +977,16 @@ iBool handleCommand_App(const char *cmd) {
963 setToggle_Widget(findChild_Widget(dlg, "prefs.retainwindow"), d->prefs.retainWindowSize); 977 setToggle_Widget(findChild_Widget(dlg, "prefs.retainwindow"), d->prefs.retainWindowSize);
964 setText_InputWidget(findChild_Widget(dlg, "prefs.uiscale"), 978 setText_InputWidget(findChild_Widget(dlg, "prefs.uiscale"),
965 collectNewFormat_String("%g", uiScale_Window(d->window))); 979 collectNewFormat_String("%g", uiScale_Window(d->window)));
980 setFlags_Widget(
981 findChild_Widget(dlg, format_CStr("prefs.linewidth.%d", d->prefs.lineWidth)),
982 selected_WidgetFlag,
983 iTrue);
984 setToggle_Widget(findChild_Widget(dlg, "prefs.biglede"), d->prefs.bigFirstParagraph);
985 setFlags_Widget(
986 findChild_Widget(
987 dlg, format_CStr("prefs.saturation.%d", (int) (d->prefs.saturation * 3.99f))),
988 selected_WidgetFlag,
989 iTrue);
966 setText_InputWidget(findChild_Widget(dlg, "prefs.proxy.http"), 990 setText_InputWidget(findChild_Widget(dlg, "prefs.proxy.http"),
967 schemeProxy_App(range_CStr("http"))); 991 schemeProxy_App(range_CStr("http")));
968 setText_InputWidget(findChild_Widget(dlg, "prefs.proxy.gopher"), 992 setText_InputWidget(findChild_Widget(dlg, "prefs.proxy.gopher"),
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 69dde8c7..2fc5c548 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -1075,6 +1075,9 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
1075 invalidate_DocumentWidget_(d); 1075 invalidate_DocumentWidget_(d);
1076 refresh_Widget(w); 1076 refresh_Widget(w);
1077 } 1077 }
1078 else if (equal_Command(cmd, "document.layout.changed") && document_App() == d) {
1079 updateSize_DocumentWidget(d);
1080 }
1078 else if (equal_Command(cmd, "tabs.changed")) { 1081 else if (equal_Command(cmd, "tabs.changed")) {
1079 d->showLinkNumbers = iFalse; 1082 d->showLinkNumbers = iFalse;
1080 if (cmp_String(id_Widget(w), suffixPtr_Command(cmd, "id")) == 0) { 1083 if (cmp_String(id_Widget(w), suffixPtr_Command(cmd, "id")) == 0) {
diff --git a/src/ui/util.c b/src/ui/util.c
index c341a11d..a6329180 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -29,6 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29#include "gmutil.h" 29#include "gmutil.h"
30#include "labelwidget.h" 30#include "labelwidget.h"
31#include "inputwidget.h" 31#include "inputwidget.h"
32#include "keys.h"
32#include "widget.h" 33#include "widget.h"
33#include "text.h" 34#include "text.h"
34#include "window.h" 35#include "window.h"
@@ -404,6 +405,7 @@ static iBool tabSwitcher_(iWidget *tabs, const char *cmd) {
404 } 405 }
405 tabIndex += (equal_Command(cmd, "tabs.next") ? +1 : -1); 406 tabIndex += (equal_Command(cmd, "tabs.next") ? +1 : -1);
406 showTabPage_Widget(tabs, child_Widget(pages, iWrap(tabIndex, 0, childCount_Widget(pages)))); 407 showTabPage_Widget(tabs, child_Widget(pages, iWrap(tabIndex, 0, childCount_Widget(pages))));
408 refresh_Widget(tabs);
407 return iTrue; 409 return iTrue;
408 } 410 }
409 return iFalse; 411 return iFalse;
@@ -816,7 +818,7 @@ iWidget *makeToggle_Widget(const char *id) {
816 return toggle; 818 return toggle;
817} 819}
818 820
819static iWidget *appendTwoColumnPage_(iWidget *tabs, const char *title, iWidget **headings, 821static iWidget *appendTwoColumnPage_(iWidget *tabs, const char *title, int shortcut, iWidget **headings,
820 iWidget **values) { 822 iWidget **values) {
821 iWidget *page = new_Widget(); 823 iWidget *page = new_Widget();
822 setFlags_Widget(page, arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag | 824 setFlags_Widget(page, arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag |
@@ -829,7 +831,7 @@ static iWidget *appendTwoColumnPage_(iWidget *tabs, const char *title, iWidget *
829 *values = addChildFlags_Widget( 831 *values = addChildFlags_Widget(
830 columns, iClob(new_Widget()), arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag); 832 columns, iClob(new_Widget()), arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag);
831 addChildFlags_Widget(page, iClob(new_Widget()), expand_WidgetFlag); 833 addChildFlags_Widget(page, iClob(new_Widget()), expand_WidgetFlag);
832 appendTabPage_Widget(tabs, page, title, 0, 0); 834 appendTabPage_Widget(tabs, page, title, shortcut, shortcut ? KMOD_PRIMARY : 0);
833 return page; 835 return page;
834} 836}
835 837
@@ -845,6 +847,12 @@ static void expandInputFieldWidth_(iInputWidget *input) {
845 right_Rect(bounds_Widget(page)) - left_Rect(bounds_Widget(constAs_Widget(input))); 847 right_Rect(bounds_Widget(page)) - left_Rect(bounds_Widget(constAs_Widget(input)));
846} 848}
847 849
850static void addRadioButton_(iWidget *parent, const char *id, const char *label, const char *cmd) {
851 setId_Widget(
852 addChildFlags_Widget(parent, iClob(new_LabelWidget(label, 0, 0, cmd)), radio_WidgetFlag),
853 id);
854}
855
848iWidget *makePreferences_Widget(void) { 856iWidget *makePreferences_Widget(void) {
849 iWidget *dlg = makeSheet_Widget("prefs"); 857 iWidget *dlg = makeSheet_Widget("prefs");
850 addChildFlags_Widget(dlg, 858 addChildFlags_Widget(dlg,
@@ -853,7 +861,7 @@ iWidget *makePreferences_Widget(void) {
853 iWidget *tabs = makeTabs_Widget(dlg); 861 iWidget *tabs = makeTabs_Widget(dlg);
854 iWidget *headings, *values; 862 iWidget *headings, *values;
855 /* General preferences. */ { 863 /* General preferences. */ {
856 appendTwoColumnPage_(tabs, "General", &headings, &values); 864 appendTwoColumnPage_(tabs, "General", '1', &headings, &values);
857 addChild_Widget(headings, iClob(makeHeading_Widget("Downloads folder:"))); 865 addChild_Widget(headings, iClob(makeHeading_Widget("Downloads folder:")));
858 setId_Widget(addChild_Widget(values, iClob(new_InputWidget(0))), "prefs.downloads"); 866 setId_Widget(addChild_Widget(values, iClob(new_InputWidget(0))), "prefs.downloads");
859 makeTwoColumnHeading_("WINDOW", headings, values); 867 makeTwoColumnHeading_("WINDOW", headings, values);
@@ -876,23 +884,23 @@ iWidget *makePreferences_Widget(void) {
876 setId_Widget(addChild_Widget(values, iClob(new_InputWidget(8))), "prefs.uiscale"); 884 setId_Widget(addChild_Widget(values, iClob(new_InputWidget(8))), "prefs.uiscale");
877 } 885 }
878 /* Layout. */ { 886 /* Layout. */ {
879 appendTwoColumnPage_(tabs, "Layout", &headings, &values); 887 appendTwoColumnPage_(tabs, "Layout", '2', &headings, &values);
880 addChild_Widget(headings, iClob(makeHeading_Widget("Line width:"))); 888 addChild_Widget(headings, iClob(makeHeading_Widget("Line width:")));
881 iWidget *widths = new_Widget(); 889 iWidget *widths = new_Widget();
882 /* Line widths. */ { 890 /* Line widths. */ {
883 addChild_Widget(widths, iClob(new_LabelWidget("\u20132", 0, 0, "linewidth.set arg:-2"))); 891 addRadioButton_(widths, "prefs.linewidth.30", "\u20132", "linewidth.set arg:30");
884 addChild_Widget(widths, iClob(new_LabelWidget("\u20131", 0, 0, "linewidth.set arg:-1"))); 892 addRadioButton_(widths, "prefs.linewidth.35", "\u20131", "linewidth.set arg:35");
885 addChild_Widget(widths, iClob(new_LabelWidget("Normal", 0, 0, "linewidth.set arg:0"))); 893 addRadioButton_(widths, "prefs.linewidth.40", "Normal", "linewidth.set arg:40");
886 addChild_Widget(widths, iClob(new_LabelWidget("+1", 0, 0, "linewidth.set arg:1"))); 894 addRadioButton_(widths, "prefs.linewidth.45", "+1", "linewidth.set arg:45");
887 addChild_Widget(widths, iClob(new_LabelWidget("+2", 0, 0, "linewidth.set arg:2"))); 895 addRadioButton_(widths, "prefs.linewidth.50", "+2", "linewidth.set arg:50");
888 addChild_Widget(widths, iClob(new_LabelWidget("Window", 0, 0, "linewidth.set arg:1000"))); 896 addRadioButton_(widths, "prefs.linewidth.1000", "Window", "linewidth.set arg:1000");
889 } 897 }
890 addChildFlags_Widget(values, iClob(widths), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); 898 addChildFlags_Widget(values, iClob(widths), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag);
891 addChild_Widget(headings, iClob(makeHeading_Widget("Big 1st paragaph:"))); 899 addChild_Widget(headings, iClob(makeHeading_Widget("Big 1st paragaph:")));
892 addChild_Widget(values, iClob(makeToggle_Widget("prefs.biglede"))); 900 addChild_Widget(values, iClob(makeToggle_Widget("prefs.biglede")));
893 } 901 }
894 /* Colors. */ { 902 /* Colors. */ {
895 appendTwoColumnPage_(tabs, "Colors", &headings, &values); 903 appendTwoColumnPage_(tabs, "Colors", '3', &headings, &values);
896 addChild_Widget(headings, iClob(makeHeading_Widget("Dark theme:"))); 904 addChild_Widget(headings, iClob(makeHeading_Widget("Dark theme:")));
897 addChild_Widget(values, iClob(new_LabelWidget("Colorful", 0, 0, 0))); 905 addChild_Widget(values, iClob(new_LabelWidget("Colorful", 0, 0, 0)));
898 addChild_Widget(headings, iClob(makeHeading_Widget("Light theme:"))); 906 addChild_Widget(headings, iClob(makeHeading_Widget("Light theme:")));
@@ -900,15 +908,15 @@ iWidget *makePreferences_Widget(void) {
900 addChild_Widget(headings, iClob(makeHeading_Widget("Saturation:"))); 908 addChild_Widget(headings, iClob(makeHeading_Widget("Saturation:")));
901 iWidget *sats = new_Widget(); 909 iWidget *sats = new_Widget();
902 /* Saturation levels. */ { 910 /* Saturation levels. */ {
903 addChild_Widget(sats, iClob(new_LabelWidget("Full", 0, 0, "saturation.set arg:100"))); 911 addRadioButton_(sats, "prefs.saturation.3", "Full", "saturation.set arg:100");
904 addChild_Widget(sats, iClob(new_LabelWidget("Reduced", 0, 0, "saturation.set arg:66"))); 912 addRadioButton_(sats, "prefs.saturation.2", "Reduced", "saturation.set arg:66");
905 addChild_Widget(sats, iClob(new_LabelWidget("Minimal", 0, 0, "saturation.set arg:33"))); 913 addRadioButton_(sats, "prefs.saturation.1", "Minimal", "saturation.set arg:33");
906 addChild_Widget(sats, iClob(new_LabelWidget("Monochrome", 0, 0, "saturation.set arg:0"))); 914 addRadioButton_(sats, "prefs.saturation.0", "Monochrome", "saturation.set arg:0");
907 } 915 }
908 addChildFlags_Widget(values, iClob(sats), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); 916 addChildFlags_Widget(values, iClob(sats), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag);
909 } 917 }
910 /* Proxies. */ { 918 /* Proxies. */ {
911 appendTwoColumnPage_(tabs, "Proxies", &headings, &values); 919 appendTwoColumnPage_(tabs, "Proxies", '4', &headings, &values);
912 addChild_Widget(headings, iClob(makeHeading_Widget("Gopher proxy:"))); 920 addChild_Widget(headings, iClob(makeHeading_Widget("Gopher proxy:")));
913 setId_Widget(addChild_Widget(values, iClob(new_InputWidget(0))), "prefs.proxy.gopher"); 921 setId_Widget(addChild_Widget(values, iClob(new_InputWidget(0))), "prefs.proxy.gopher");
914 addChild_Widget(headings, iClob(makeHeading_Widget("HTTP proxy:"))); 922 addChild_Widget(headings, iClob(makeHeading_Widget("HTTP proxy:")));
@@ -926,6 +934,8 @@ iWidget *makePreferences_Widget(void) {
926 addChild_Widget(div, iClob(new_LabelWidget("Dismiss", SDLK_ESCAPE, 0, "prefs.dismiss"))); 934 addChild_Widget(div, iClob(new_LabelWidget("Dismiss", SDLK_ESCAPE, 0, "prefs.dismiss")));
927 } 935 }
928 addChild_Widget(dlg, iClob(div)); 936 addChild_Widget(dlg, iClob(div));
937 addAction_Widget(dlg, prevTab_KeyShortcut, "tabs.prev");
938 addAction_Widget(dlg, nextTab_KeyShortcut, "tabs.next");
929 addChild_Widget(get_Window()->root, iClob(dlg)); 939 addChild_Widget(get_Window()->root, iClob(dlg));
930 centerSheet_Widget(dlg); 940 centerSheet_Widget(dlg);
931 return dlg; 941 return dlg;