diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-24 17:50:44 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-24 17:50:44 +0200 |
commit | fd17eeda7afc59a3e6613aeb28727248732351e9 (patch) | |
tree | e5d6defb65df3a3cabd1f1401742232c3fa8e03c /src/app.c | |
parent | 5f9199d081a47241fefed7b2af1f53f4995b62ab (diff) |
Source Sans Pro and Iosevka as font options
Allow the UI and monospace fonts to be used as page content fonts.
Diffstat (limited to 'src/app.c')
-rw-r--r-- | src/app.c | 35 |
1 files changed, 27 insertions, 8 deletions
@@ -987,18 +987,27 @@ static void updatePrefsThemeButtons_(iWidget *d) { | |||
987 | } | 987 | } |
988 | } | 988 | } |
989 | 989 | ||
990 | static void updateColorThemeButton_(iLabelWidget *button, int theme) { | 990 | static void updateDropdownSelection_(iLabelWidget *dropButton, const char *selectedCommand) { |
991 | const char *mode = strstr(cstr_String(id_Widget(as_Widget(button))), ".dark") ? "dark" : "light"; | 991 | iForEach(ObjectList, i, children_Widget(findChild_Widget(as_Widget(dropButton), "menu"))) { |
992 | const char *command = format_CStr("doctheme.%s.set arg:%d", mode, theme); | ||
993 | iForEach(ObjectList, i, children_Widget(findChild_Widget(as_Widget(button), "menu"))) { | ||
994 | iLabelWidget *item = i.object; | 992 | iLabelWidget *item = i.object; |
995 | if (!cmp_String(command_LabelWidget(item), command)) { | 993 | const iBool isSelected = endsWith_String(command_LabelWidget(item), selectedCommand); |
996 | updateText_LabelWidget(button, text_LabelWidget(item)); | 994 | setFlags_Widget(as_Widget(item), selected_WidgetFlag, isSelected); |
997 | break; | 995 | if (isSelected) { |
996 | updateText_LabelWidget(dropButton, text_LabelWidget(item)); | ||
998 | } | 997 | } |
999 | } | 998 | } |
1000 | } | 999 | } |
1001 | 1000 | ||
1001 | static void updateColorThemeButton_(iLabelWidget *button, int theme) { | ||
1002 | // const char *mode = strstr(cstr_String(id_Widget(as_Widget(button))), ".dark") | ||
1003 | // ? "dark" : "light"; | ||
1004 | updateDropdownSelection_(button, format_CStr(".set arg:%d", theme)); | ||
1005 | } | ||
1006 | |||
1007 | static void updateFontButton_(iLabelWidget *button, int font) { | ||
1008 | updateDropdownSelection_(button, format_CStr(".set arg:%d", font)); | ||
1009 | } | ||
1010 | |||
1002 | static iBool handlePrefsCommands_(iWidget *d, const char *cmd) { | 1011 | static iBool handlePrefsCommands_(iWidget *d, const char *cmd) { |
1003 | if (equal_Command(cmd, "prefs.dismiss") || equal_Command(cmd, "preferences")) { | 1012 | if (equal_Command(cmd, "prefs.dismiss") || equal_Command(cmd, "preferences")) { |
1004 | setUiScale_Window(get_Window(), | 1013 | setUiScale_Window(get_Window(), |
@@ -1050,6 +1059,14 @@ static iBool handlePrefsCommands_(iWidget *d, const char *cmd) { | |||
1050 | updateColorThemeButton_(findChild_Widget(d, "prefs.doctheme.light"), arg_Command(cmd)); | 1059 | updateColorThemeButton_(findChild_Widget(d, "prefs.doctheme.light"), arg_Command(cmd)); |
1051 | return iFalse; | 1060 | return iFalse; |
1052 | } | 1061 | } |
1062 | else if (equal_Command(cmd, "font.set")) { | ||
1063 | updateFontButton_(findChild_Widget(d, "prefs.font"), arg_Command(cmd)); | ||
1064 | return iFalse; | ||
1065 | } | ||
1066 | else if (equal_Command(cmd, "headingfont.set")) { | ||
1067 | updateFontButton_(findChild_Widget(d, "prefs.headingfont"), arg_Command(cmd)); | ||
1068 | return iFalse; | ||
1069 | } | ||
1053 | else if (equal_Command(cmd, "prefs.ostheme.changed")) { | 1070 | else if (equal_Command(cmd, "prefs.ostheme.changed")) { |
1054 | postCommandf_App("ostheme arg:%d", arg_Command(cmd)); | 1071 | postCommandf_App("ostheme arg:%d", arg_Command(cmd)); |
1055 | } | 1072 | } |
@@ -1518,7 +1535,7 @@ iBool handleCommand_App(const char *cmd) { | |||
1518 | } | 1535 | } |
1519 | else if (equal_Command(cmd, "preferences")) { | 1536 | else if (equal_Command(cmd, "preferences")) { |
1520 | iWidget *dlg = makePreferences_Widget(); | 1537 | iWidget *dlg = makePreferences_Widget(); |
1521 | updatePrefsThemeButtons_(dlg); | 1538 | updatePrefsThemeButtons_(dlg); |
1522 | setText_InputWidget(findChild_Widget(dlg, "prefs.downloads"), &d->prefs.downloadDir); | 1539 | setText_InputWidget(findChild_Widget(dlg, "prefs.downloads"), &d->prefs.downloadDir); |
1523 | setToggle_Widget(findChild_Widget(dlg, "prefs.hoverlink"), d->prefs.hoverLink); | 1540 | setToggle_Widget(findChild_Widget(dlg, "prefs.hoverlink"), d->prefs.hoverLink); |
1524 | setToggle_Widget(findChild_Widget(dlg, "prefs.smoothscroll"), d->prefs.smoothScrolling); | 1541 | setToggle_Widget(findChild_Widget(dlg, "prefs.smoothscroll"), d->prefs.smoothScrolling); |
@@ -1554,6 +1571,8 @@ iBool handleCommand_App(const char *cmd) { | |||
1554 | setToggle_Widget(findChild_Widget(dlg, "prefs.centershort"), d->prefs.centerShortDocs); | 1571 | setToggle_Widget(findChild_Widget(dlg, "prefs.centershort"), d->prefs.centerShortDocs); |
1555 | updateColorThemeButton_(findChild_Widget(dlg, "prefs.doctheme.dark"), d->prefs.docThemeDark); | 1572 | updateColorThemeButton_(findChild_Widget(dlg, "prefs.doctheme.dark"), d->prefs.docThemeDark); |
1556 | updateColorThemeButton_(findChild_Widget(dlg, "prefs.doctheme.light"), d->prefs.docThemeLight); | 1573 | updateColorThemeButton_(findChild_Widget(dlg, "prefs.doctheme.light"), d->prefs.docThemeLight); |
1574 | updateFontButton_(findChild_Widget(dlg, "prefs.font"), d->prefs.font); | ||
1575 | updateFontButton_(findChild_Widget(dlg, "prefs.headingfont"), d->prefs.headingFont); | ||
1557 | setFlags_Widget( | 1576 | setFlags_Widget( |
1558 | findChild_Widget( | 1577 | findChild_Widget( |
1559 | dlg, format_CStr("prefs.saturation.%d", (int) (d->prefs.saturation * 3.99f))), | 1578 | dlg, format_CStr("prefs.saturation.%d", (int) (d->prefs.saturation * 3.99f))), |