]> git.mdlowis.com Git - proto/labwc.git/commitdiff
rcxml: allow <theme><font> without place="" attribute
authorJohan Malm <jgm323@gmail.com>
Mon, 19 Jul 2021 19:46:32 +0000 (20:46 +0100)
committerJohan Malm <jgm323@gmail.com>
Mon, 19 Jul 2021 19:46:32 +0000 (20:46 +0100)
The construct below will set the font for all supported places. Currently
that's only ActiveWindow, but is likely to include InactiveWindow,
MenuHeader, MenuItem and OnScreenDisplay at some point.

<theme>
  <font>
    <name></name>
    <size></size>
  </font>
</theme>

docs/rc.xml
src/config/rcxml.c

index 1202058099835254cfc5b69f2f41d09d2989841d..dbe834d43f89d9184023d67de061f25f4e2bd015 100644 (file)
@@ -8,7 +8,7 @@
   <theme>
     <name></name>
     <cornerRadius>8</cornerRadius>
-    <font place="ActiveWindow"><name>Sans</name><size>10</size></font>
+    <font><name>Sans</name><size>12</size></font>
   </theme>
 
   <focus>
index c40e28497e92d6100821fe8915e08d743bf72319..7c3546771b3e6468aae60455da577d9791bd36e3 100644 (file)
@@ -80,14 +80,30 @@ fill_font(char *nodename, char *content, enum font_place place)
        }
        string_truncate_at_pattern(nodename, ".font.theme");
 
+       switch (place) {
+       case FONT_PLACE_UNKNOWN:
+               /*
+                * If <theme><font></font></theme> is used without a place=""
+                * attribute, we set all font variables
+                */
+               if (!strcmp(nodename, "name")) {
+                       rc.font_name_activewindow = strdup(content);
+               } else if (!strcmp(nodename, "size")) {
+                       rc.font_size_activewindow = atoi(content);
+               }
+               break;
+       case FONT_PLACE_ACTIVEWINDOW:
+               if (!strcmp(nodename, "name")) {
+                       rc.font_name_activewindow = strdup(content);
+               } else if (!strcmp(nodename, "size")) {
+                       rc.font_size_activewindow = atoi(content);
+               }
+               break;
+
        /* TODO: implement for all font places */
-       if (place != FONT_PLACE_ACTIVEWINDOW) {
-               return;
-       }
-       if (!strcmp(nodename, "name")) {
-               rc.font_name_activewindow = strdup(content);
-       } else if (!strcmp(nodename, "size")) {
-               rc.font_size_activewindow = atoi(content);
+
+       default:
+               break;
        }
 }
 
@@ -108,7 +124,7 @@ enum_font_place(const char *place)
 static void
 entry(xmlNode *node, char *nodename, char *content)
 {
-       /* current <theme><font place=""></theme> */
+       /* current <theme><font place=""></font></theme> */
        static enum font_place font_place = FONT_PLACE_UNKNOWN;
 
        if (!nodename) {