changeset 3176:f0879d15c5b7

Renamed subStyleInheritance to subStyleUpdate and added font checks
author unexist
date Tue, 31 Jan 2012 16:11:04 +0100
parents 3049382ee3fe
children fed05405e015
files src/subtle/ruby.c src/subtle/style.c src/subtle/subtle.h
diffstat 3 files changed, 47 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/src/subtle/ruby.c	Fri Jan 20 00:30:49 2012 +0100
+++ b/src/subtle/ruby.c	Tue Jan 31 16:11:04 2012 +0100
@@ -970,8 +970,8 @@
 {
   int i;
 
-  /* Inherit style values */
-  subStyleInheritance();
+  /* Update style values */
+  subStyleUpdate();
 
   /* Check and update grabs */
   if(0 == subtle->grabs->ndata)
--- a/src/subtle/style.c	Fri Jan 20 00:30:49 2012 +0100
+++ b/src/subtle/style.c	Tue Jan 31 16:11:04 2012 +0100
@@ -47,25 +47,27 @@
   /* Inherit font */
   if(NULL == s1->font) s1->font = s2->font;
 
-  /* Check max height of style */
-  if(s1->font && (s1 != &subtle->styles.clients ||
-      s1 != &subtle->styles.subtle))
+  if(s1->font)
     {
-      int height = STYLE_HEIGHT((*s1)) + s1->font->height;
-
-      if(height > subtle->ph) subtle->ph = height;
-    }
+      /* Check max height of style */
+      if(s1 != &subtle->styles.clients || s1 != &subtle->styles.subtle)
+        {
+          int height = STYLE_HEIGHT((*s1)) + s1->font->height;
 
-  /* Update separator width after font */
-  if(s1->font && s1->separator)
-    {
-      s1->separator->width = subSharedTextWidth(subtle->dpy,
-        s1->font, s1->separator->string,
-        strlen(s1->separator->string), NULL, NULL, True);
+          if(height > subtle->ph) subtle->ph = height;
+        }
 
-      /* Add style width to calculate that only once */
-      if(0 < s1->separator->width)
-        s1->separator->width += STYLE_WIDTH((*s1));
+      /* Update separator width after font */
+      if(s1->separator)
+        {
+          s1->separator->width = subSharedTextWidth(subtle->dpy,
+            s1->font, s1->separator->string,
+            strlen(s1->separator->string), NULL, NULL, True);
+
+          /* Add style width to calculate it only once */
+          if(0 < s1->separator->width)
+            s1->separator->width += STYLE_WIDTH((*s1));
+        }
     }
 
   /* Check nested styles */
@@ -91,6 +93,20 @@
     }
 } /* }}} */
 
+/* StyleFont {{{ */
+static void
+StyleFont(SubStyle *s,
+  const char *name)
+{
+  /* Check if style exists and font is defined */
+  if(s && !s->font)
+    {
+      subSubtleLogError("Cannot find a font definition for style `%s'\n", name); \
+      subSubtleFinish();
+      exit(-1); \
+    }
+} /* }}} */
+
 /* Public */
 
  /** subStyleNew {{{
@@ -264,12 +280,12 @@
 
 /* All */
 
- /** subStyleInheritance {{{
+ /** subStyleUpdate {{{
   * Inherit style values from all
   **/
 
 void
-subStyleInheritance(void)
+subStyleUpdate(void)
 {
   /* Inherit styles */
   StyleInherit(&subtle->styles.views,     &subtle->styles.all);
@@ -277,7 +293,16 @@
   StyleInherit(&subtle->styles.sublets,   &subtle->styles.all);
   StyleInherit(&subtle->styles.separator, &subtle->styles.all);
 
-  subSubtleLogDebugSubtle("Inheritance\n");
+  /* Check font */
+  StyleFont(&(subtle->styles.title),     "title");
+  StyleFont(&(subtle->styles.separator), "separator");
+  StyleFont(&(subtle->styles.sublets),   "sublets");
+  StyleFont(subtle->styles.occupied,     "occupied");
+  StyleFont(subtle->styles.focus,        "focus");
+  StyleFont(subtle->styles.viewsep,      "view separator");
+  StyleFont(subtle->styles.subletsep,    "sublet separator");
+
+  subSubtleLogDebugSubtle("Update\n");
 } /* }}} */
 
 // vim:ts=2:bs=2:sw=2:et:fdm=marker
--- a/src/subtle/subtle.h	Fri Jan 20 00:30:49 2012 +0100
+++ b/src/subtle/subtle.h	Tue Jan 31 16:11:04 2012 +0100
@@ -902,7 +902,7 @@
 void subStyleReset(SubStyle *s, int val);                         ///< Reset style values to given val
 void subStyleMerge(SubStyle *s1, SubStyle *s2);                   ///< Merge style values
 void subStyleKill(SubStyle *s);                                   ///< Kill style
-void subStyleInheritance(void);                                   ///< Inherit values
+void subStyleUpdate(void);                                        ///< Update values
 /* }}} */
 
 /* subtle.c {{{ */