]> Dogcows Code - chaz/openbox/blobdiff - render/theme.c
dont allow parentrelative on top-level appearances
[chaz/openbox] / render / theme.c
index a7da009b01488af135a906e5d4c61236f1a27740..a8a3eda2cb8a57e27f507781d03118c996226fe5 100644 (file)
@@ -16,7 +16,8 @@ static gboolean read_mask(const RrInstance *inst,
                           gchar *maskname, RrTheme *theme,
                           RrPixmapMask **value);
 static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
-                                gchar *rname, RrAppearance *value);
+                                gchar *rname, RrAppearance *value,
+                                gboolean allow_trans);
 static void set_default_appearance(RrAppearance *a);
 
 RrTheme* RrThemeNew(const RrInstance *inst, gchar *name)
@@ -63,8 +64,9 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name)
     if (name) {
        db = loaddb(theme, name);
         if (db == NULL) {
-           g_warning("Failed to load the theme '%s'", name);
-           g_message("Falling back to the default: '%s'", DEFAULT_THEME);
+           g_warning("Failed to load the theme '%s'\n"
+                      "Falling back to the default: '%s'",
+                      name, DEFAULT_THEME);
        } else
             theme->name = g_path_get_basename(name);
     }
@@ -256,83 +258,106 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name)
 
     /* read the decoration textures */
     if (!read_appearance(db, inst,
-                         "window.title.focus", theme->a_focused_title))
+                         "window.title.focus", theme->a_focused_title,
+                         FALSE))
        set_default_appearance(theme->a_focused_title);
     if (!read_appearance(db, inst,
-                         "window.title.unfocus", theme->a_unfocused_title))
+                         "window.title.unfocus", theme->a_unfocused_title,
+                         FALSE))
        set_default_appearance(theme->a_unfocused_title);
     if (!read_appearance(db, inst,
-                         "window.label.focus", theme->a_focused_label))
+                         "window.label.focus", theme->a_focused_label,
+                         TRUE))
        set_default_appearance(theme->a_focused_label);
     if (!read_appearance(db, inst,
-                         "window.label.unfocus", theme->a_unfocused_label))
+                         "window.label.unfocus", theme->a_unfocused_label,
+                         TRUE))
        set_default_appearance(theme->a_unfocused_label);
     if (!read_appearance(db, inst,
-                         "window.handle.focus", theme->a_focused_handle))
+                         "window.handle.focus", theme->a_focused_handle,
+                         FALSE))
        set_default_appearance(theme->a_focused_handle);
     if (!read_appearance(db, inst,
-                         "window.handle.unfocus",theme->a_unfocused_handle))
+                         "window.handle.unfocus",theme->a_unfocused_handle,
+                         FALSE))
        set_default_appearance(theme->a_unfocused_handle);
     if (!read_appearance(db, inst,
-                         "window.grip.focus", theme->a_focused_grip))
+                         "window.grip.focus", theme->a_focused_grip,
+                         TRUE))
        set_default_appearance(theme->a_focused_grip);
     if (!read_appearance(db, inst,
-                         "window.grip.unfocus", theme->a_unfocused_grip))
+                         "window.grip.unfocus", theme->a_unfocused_grip,
+                         TRUE))
        set_default_appearance(theme->a_unfocused_grip);
     if (!read_appearance(db, inst,
-                         "menu.frame", theme->a_menu))
+                         "menu.frame", theme->a_menu,
+                         FALSE))
        set_default_appearance(theme->a_menu);
     if (!read_appearance(db, inst,
-                         "menu.title", theme->a_menu_title))
+                         "menu.title", theme->a_menu_title,
+                         FALSE))
        set_default_appearance(theme->a_menu_title);
     if (!read_appearance(db, inst,
-                         "menu.hilite", theme->a_menu_hilite))
+                         "menu.hilite", theme->a_menu_hilite,
+                         TRUE))
        set_default_appearance(theme->a_menu_hilite);
 
     /* read the appearances for rendering non-decorations */
     if (!read_appearance(db, inst,
-                         "window.title.focus", theme->app_hilite_bg))
+                         "window.title.focus", theme->app_hilite_bg,
+                         FALSE))
         set_default_appearance(theme->app_hilite_bg);
     if (!read_appearance(db, inst,
-                         "window.label.focus", theme->app_hilite_label))
+                         "window.label.focus", theme->app_hilite_label,
+                         TRUE))
         set_default_appearance(theme->app_hilite_label);
     if (!read_appearance(db, inst,
-                         "window.title.unfocus", theme->app_unhilite_bg))
+                         "window.title.unfocus", theme->app_unhilite_bg,
+                         FALSE))
         set_default_appearance(theme->app_unhilite_bg);
     if (!read_appearance(db, inst,
-                         "window.label.unfocus", theme->app_unhilite_label))
+                         "window.label.unfocus", theme->app_unhilite_label,
+                         TRUE))
         set_default_appearance(theme->app_unhilite_label);
 
     /* read buttons textures */
     if (!read_appearance(db, inst,
                          "window.button.disabled.focus",
-                        theme->a_disabled_focused_max))
+                        theme->a_disabled_focused_max,
+                         TRUE))
         set_default_appearance(theme->a_disabled_focused_max);
     if (!read_appearance(db, inst,
                          "window.button.disabled.unfocus",
-                        theme->a_disabled_unfocused_max))
+                        theme->a_disabled_unfocused_max,
+                         TRUE))
         set_default_appearance(theme->a_disabled_unfocused_max);
     if (!read_appearance(db, inst,
                          "window.button.pressed.focus",
-                        theme->a_focused_pressed_max))
+                        theme->a_focused_pressed_max,
+                         TRUE))
        if (!read_appearance(db, inst,
                              "window.button.pressed",
-                             theme->a_focused_pressed_max))
+                             theme->a_focused_pressed_max,
+                         TRUE))
            set_default_appearance(theme->a_focused_pressed_max);
     if (!read_appearance(db, inst,
                          "window.button.pressed.unfocus",
-                        theme->a_unfocused_pressed_max))
+                        theme->a_unfocused_pressed_max,
+                         TRUE))
        if (!read_appearance(db, inst,
                              "window.button.pressed",
-                            theme->a_unfocused_pressed_max))
+                            theme->a_unfocused_pressed_max,
+                             TRUE))
            set_default_appearance(theme->a_unfocused_pressed_max);
     if (!read_appearance(db, inst,
                          "window.button.focus",
-                        theme->a_focused_unpressed_max))
+                        theme->a_focused_unpressed_max,
+                         TRUE))
        set_default_appearance(theme->a_focused_unpressed_max);
     if (!read_appearance(db, inst,
                          "window.button.unfocus",
-                        theme->a_unfocused_unpressed_max))
+                        theme->a_unfocused_unpressed_max,
+                         TRUE))
        set_default_appearance(theme->a_unfocused_unpressed_max);
 
     theme->a_disabled_focused_close =
@@ -787,7 +812,8 @@ static gboolean read_mask(const RrInstance *inst,
 
 static void parse_appearance(gchar *tex, RrSurfaceColorType *grad,
                              RrReliefType *relief, RrBevelType *bevel,
-                             gboolean *interlaced, gboolean *border)
+                             gboolean *interlaced, gboolean *border,
+                             gboolean allow_trans)
 {
     char *t;
 
@@ -795,7 +821,7 @@ static void parse_appearance(gchar *tex, RrSurfaceColorType *grad,
     for (t = tex; *t != '\0'; ++t)
        *t = g_ascii_tolower(*t);
 
-    if (strstr(tex, "parentrelative") != NULL) {
+    if (allow_trans && strstr(tex, "parentrelative") != NULL) {
        *grad = RR_SURFACE_PARENTREL;
     } else {
        if (strstr(tex, "gradient") != NULL) {
@@ -840,7 +866,8 @@ static void parse_appearance(gchar *tex, RrSurfaceColorType *grad,
 
 
 static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
-                           gchar *rname, RrAppearance *value)
+                                gchar *rname, RrAppearance *value,
+                                gboolean allow_trans)
 {
     gboolean ret = FALSE;
     char *rclass = create_class_name(rname), *cname, *ctoname, *bcname;
@@ -858,7 +885,8 @@ static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
                         &value->surface.relief,
                         &value->surface.bevel,
                         &value->surface.interlaced,
-                        &value->surface.border);
+                        &value->surface.border,
+                         allow_trans);
        if (!read_color(db, inst, cname, &value->surface.primary))
            value->surface.primary = RrColorNew(inst, 0, 0, 0);
        if (!read_color(db, inst, ctoname, &value->surface.secondary))
This page took 0.024947 seconds and 4 git commands to generate.