]> Dogcows Code - chaz/openbox/commitdiff
READ_INT macro.
authorDave Foster <daf@minuslab.net>
Thu, 30 Aug 2007 19:46:53 +0000 (15:46 -0400)
committerMikael Magnusson <mikachu@gmail.com>
Thu, 14 Oct 2010 13:28:01 +0000 (15:28 +0200)
obrender/theme.c

index dfd79985def0e2767b62bade9ac32cde8a269387..8af2fbe67de0192a8b47f0bc83b11705c51febe7 100644 (file)
@@ -63,6 +63,11 @@ static RrFont *get_font(RrFont *target, RrFont **default_font,
     }
 }
 
+#define READ_INT(x_resstr, x_var, x_min, x_max, x_def) \
+    if (!read_int(db, x_resstr, & x_var) || \
+            x_var < x_min || x_var > x_max) \
+        x_var = x_def;
+
 RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
                     gboolean allow_fallback,
                     RrFont *active_window_font, RrFont *inactive_window_font,
@@ -178,51 +183,21 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
     theme->osd_font_unhilite = get_font(inactive_osd_font, &default_font,inst);
 
     /* load direct dimensions */
-    if ((!read_int(db, "menu.overlap.x", &theme->menu_overlap_x) &&
-         !read_int(db, "menu.overlap", &theme->menu_overlap_x)) ||
-        theme->menu_overlap_x < -100 || theme->menu_overlap_x > 100)
-        theme->menu_overlap_x = 0;
-    if ((!read_int(db, "menu.overlap.y", &theme->menu_overlap_y) &&
-         !read_int(db, "menu.overlap", &theme->menu_overlap_y)) ||
-        theme->menu_overlap_y < -100 || theme->menu_overlap_y > 100)
-        theme->menu_overlap_y = 0;
-    if (!read_int(db, "window.handle.width", &theme->handle_height) ||
-        theme->handle_height < 0 || theme->handle_height > 100)
-        theme->handle_height = 6;
-    if (!read_int(db, "padding.width", &theme->paddingx) ||
-        theme->paddingx < 0 || theme->paddingx > 100)
-        theme->paddingx = 3;
-    if (!read_int(db, "padding.height", &theme->paddingy) ||
-        theme->paddingy < 0 || theme->paddingy > 100)
-        theme->paddingy = theme->paddingx;
-    if (!read_int(db, "border.width", &theme->fbwidth) ||
-        theme->fbwidth < 0 || theme->fbwidth > 100)
-        theme->fbwidth = 1;
-    /* menu border width inherits from the frame border width */
-    if (!read_int(db, "menu.border.width", &theme->mbwidth) ||
-        theme->mbwidth < 0 || theme->mbwidth > 100)
-        theme->mbwidth = theme->fbwidth;
-    /* osd border width inherits from the frame border width */
-    if (!read_int(db, "osd.border.width", &theme->obwidth) ||
-        theme->obwidth < 0 || theme->obwidth > 100)
-        theme->obwidth = theme->fbwidth;
-    if (!read_int(db, "window.client.padding.width", &theme->cbwidthx) ||
-        theme->cbwidthx < 0 || theme->cbwidthx > 100)
-        theme->cbwidthx = theme->paddingx;
-    if (!read_int(db, "window.client.padding.height", &theme->cbwidthy) ||
-        theme->cbwidthy < 0 || theme->cbwidthy > 100)
-        theme->cbwidthy = theme->cbwidthx;
-    if (!read_int(db, "menu.separator.width", &theme->menu_sep_width) ||
-        theme->menu_sep_width < 1 || theme->menu_sep_width > 100)
-        theme->menu_sep_width = 1;
-    if (!read_int(db, "menu.separator.padding.width",
-                  &theme->menu_sep_paddingx) ||
-        theme->menu_sep_paddingx < 0 || theme->menu_sep_paddingx > 100)
-        theme->menu_sep_paddingx = 6;
-    if (!read_int(db, "menu.separator.padding.height",
-                  &theme->menu_sep_paddingy) ||
-        theme->menu_sep_paddingy < 0 || theme->menu_sep_paddingy > 100)
-        theme->menu_sep_paddingy = 3;
+
+    /* TODO: Need fallback for menu.overlap */
+    READ_INT("menu.overlap.x", theme->menu_overlap_x, -100, 100, 0);  
+    READ_INT("menu.overlap.y", theme->menu_overlap_y, -100, 100, 0);  
+    READ_INT("window.handle.width", theme->handle_height, 0, 100, 6);
+    READ_INT("padding.width", theme->paddingx, 0, 100, 3);
+    READ_INT("padding.height", theme->paddingy, 0, 100, theme->paddingx);
+    READ_INT("border.width", theme->fbwidth, 0, 100, 1);
+    READ_INT("menu.border.width", theme->mbwidth, 0, 100, theme->fbwidth);
+    READ_INT("osd.border.width", theme->obwidth, 0, 100, theme->fbwidth);
+    READ_INT("window.client.padding.width", theme->cbwidthx, 0, 100, theme->paddingx);
+    READ_INT("window.client.padding.height", theme->cbwidthy, 0, 100, theme->cbwidthx);
+    READ_INT("menu.separator.width", theme->menu_sep_width, 1, 100, 1);
+    READ_INT("menu.separator.padding.width", theme->menu_sep_paddingx, 0, 100, 6);
+    READ_INT("menu.separator.padding.height", theme->menu_sep_paddingy, 0, 100, 3);
 
     /* load colors */
     if (!read_color(db, inst,
This page took 0.028591 seconds and 4 git commands to generate.