]> git.mdlowis.com Git - proto/labwc.git/commitdiff
config: support setting menu item font
authorJohan Malm <jgm323@gmail.com>
Fri, 20 Aug 2021 19:27:52 +0000 (20:27 +0100)
committerJohan Malm <jgm323@gmail.com>
Fri, 20 Aug 2021 19:27:52 +0000 (20:27 +0100)
In rc.xml, support

<font place="MenuItem">
  <name></name>
  <size></size>
</font>

docs/labwc-config.5.scd
include/config/rcxml.h
src/config/rcxml.c

index a1eb5566c77b08bcb22aa5b58a558d41f8957571..7e7934d81d078db542138a36ff53855a8d9a3de5 100644 (file)
@@ -46,6 +46,7 @@ Configuration must be wrapped in a <labwc_config> root-node.
        The font to use for a specific element of a window, menu or OSD.
        Places can be any of:
        - ActiveWindow - titlebar of active window
+       - MenuItem - menu item (currently only root menu)
        If no place attribute is provided, the setting will be applied to all
        places.
 
@@ -53,7 +54,7 @@ Configuration must be wrapped in a <labwc_config> root-node.
        Describes font name. Default is sans.
 
 *<theme><font place=""><size>*
-       Font size in pixels. Default is 8.
+       Font size in pixels. Default is 10.
 
 # KEYBOARD
 
index 188ea5bd1ebebcf93e3e36ae27046ca32c806a2e..0743330145fcac346ca9cbd55eca22c065e4fba6 100644 (file)
@@ -14,7 +14,9 @@ struct rcxml {
        char *theme_name;
        int corner_radius;
        char *font_name_activewindow;
+       char *font_name_menuitem;
        int font_size_activewindow;
+       int font_size_menuitem;
        struct wl_list keybinds;
 };
 
index e76adea613bfd8a13b60090836c4dc4caeb12fd9..fefd9baabd40edc6d5e15c9683e6a0325f8f3a95 100644 (file)
@@ -25,7 +25,7 @@ static struct keybind *current_keybind;
 enum font_place {
        FONT_PLACE_UNKNOWN = 0,
        FONT_PLACE_ACTIVEWINDOW,
-       FONT_PLACE_INACTIVEWINDOW,
+       FONT_PLACE_MENUITEM,
        /* TODO: Add all places based on Openbox's rc.xml */
 };
 
@@ -89,8 +89,10 @@ fill_font(char *nodename, char *content, enum font_place place)
                 */
                if (!strcmp(nodename, "name")) {
                        rc.font_name_activewindow = strdup(content);
+                       rc.font_name_menuitem = strdup(content);
                } else if (!strcmp(nodename, "size")) {
                        rc.font_size_activewindow = atoi(content);
+                       rc.font_size_menuitem = atoi(content);
                }
                break;
        case FONT_PLACE_ACTIVEWINDOW:
@@ -100,6 +102,13 @@ fill_font(char *nodename, char *content, enum font_place place)
                        rc.font_size_activewindow = atoi(content);
                }
                break;
+       case FONT_PLACE_MENUITEM:
+               if (!strcmp(nodename, "name")) {
+                       rc.font_name_menuitem = strdup(content);
+               } else if (!strcmp(nodename, "size")) {
+                       rc.font_size_menuitem = atoi(content);
+               }
+               break;
 
        /* TODO: implement for all font places */
 
@@ -116,8 +125,8 @@ enum_font_place(const char *place)
        }
        if (!strcasecmp(place, "ActiveWindow")) {
                return FONT_PLACE_ACTIVEWINDOW;
-       } else if (!strcasecmp(place, "InactiveWindow")) {
-               return FONT_PLACE_INACTIVEWINDOW;
+       } else if (!strcasecmp(place, "MenuItem")) {
+               return FONT_PLACE_MENUITEM;
        }
        return FONT_PLACE_UNKNOWN;
 }
@@ -248,6 +257,7 @@ rcxml_init()
        rc.xdg_shell_server_side_deco = true;
        rc.corner_radius = 8;
        rc.font_size_activewindow = 10;
+       rc.font_size_menuitem = 10;
 }
 
 static void
@@ -281,6 +291,9 @@ post_processing(void)
        if (!rc.font_name_activewindow) {
                rc.font_name_activewindow = strdup("sans");
        }
+       if (!rc.font_name_menuitem) {
+               rc.font_name_menuitem = strdup("sans");
+       }
 }
 
 static void
@@ -352,6 +365,7 @@ void
 rcxml_finish(void)
 {
        zfree(rc.font_name_activewindow);
+       zfree(rc.font_name_menuitem);
        zfree(rc.theme_name);
 
        struct keybind *k, *k_tmp;