diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-09-21 18:25:09 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-09-21 18:25:09 +0300 |
commit | 9c8cbd5cd300900617f1b3e8f67a9cd6f08624ee (patch) | |
tree | c522705013eb9409bdce862a4a0c15a8b06a82cc /src/ui/util.c | |
parent | 35b5ff92a5ab7d49bde2e572fc8d5de5367fb0db (diff) |
Preferences: Line width, 1st paragraph; tab switch keys
Diffstat (limited to 'src/ui/util.c')
-rw-r--r-- | src/ui/util.c | 42 |
1 files changed, 26 insertions, 16 deletions
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 | ||
819 | static iWidget *appendTwoColumnPage_(iWidget *tabs, const char *title, iWidget **headings, | 821 | static 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 | ||
850 | static 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 | |||
848 | iWidget *makePreferences_Widget(void) { | 856 | iWidget *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; |