]> Dogcows Code - chaz/openbox/blobdiff - render/theme.c
rename osx to mirrorhorizontal and split to splitvertical, this will make all themes...
[chaz/openbox] / render / theme.c
index 40ec1c57b6a1d4501d246f16080c77caaa4ecaaf..b1cce15bc29ba5627f31d1a01d1c59ce6b33e115 100644 (file)
@@ -1,6 +1,7 @@
 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
 
    theme.c for the Openbox window manager
+   Copyright (c) 2006        Mikael Magnusson
    Copyright (c) 2003        Ben Jansens
 
    This program is free software; you can redistribute it and/or modify
@@ -30,9 +31,9 @@
 #include <stdlib.h>
 #include <string.h>
 
-static XrmDatabase loaddb(RrTheme *theme, char *name);
-static gboolean read_int(XrmDatabase db, char *rname, int *value);
-static gboolean read_string(XrmDatabase db, char *rname, char **value);
+static XrmDatabase loaddb(RrTheme *theme, gchar *name);
+static gboolean read_int(XrmDatabase db, gchar *rname, gint *value);
+static gboolean read_string(XrmDatabase db, gchar *rname, gchar **value);
 static gboolean read_color(XrmDatabase db, const RrInstance *inst,
                            gchar *rname, RrColor **value);
 static gboolean read_mask(const RrInstance *inst,
@@ -90,11 +91,6 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name)
     theme->a_clear = RrAppearanceNew(inst, 0);
     theme->a_clear_tex = RrAppearanceNew(inst, 1);
 
-    theme->app_hilite_bg = RrAppearanceNew(inst, 0);
-    theme->app_unhilite_bg = RrAppearanceNew(inst, 0);
-    theme->app_hilite_label = RrAppearanceNew(inst, 1);
-    theme->app_unhilite_label = RrAppearanceNew(inst, 1);
-
     if (name) {
         db = loaddb(theme, name);
         if (db == NULL) {
@@ -308,11 +304,11 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name)
     } else {
         {
             guchar data[] = { 0x7f, 0x7f, 0x7f, 0x41, 0x41, 0x41, 0x7f };
-            theme->max_mask = RrPixmapMaskNew(inst, 7, 7, (char*)data);
+            theme->max_mask = RrPixmapMaskNew(inst, 7, 7, (gchar*)data);
         }
         {
             guchar data[] = { 0x7c, 0x44, 0x47, 0x47, 0x7f, 0x1f, 0x1f };
-            theme->max_toggled_mask = RrPixmapMaskNew(inst, 7, 7, (char*)data);
+            theme->max_toggled_mask = RrPixmapMaskNew(inst, 7, 7, (gchar*)data);
         }
         theme->max_pressed_mask = RrPixmapMaskCopy(theme->max_mask);
         theme->max_disabled_mask = RrPixmapMaskCopy(theme->max_mask);
@@ -337,7 +333,7 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name)
     } else {
         {
             guchar data[] = { 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x7f };
-            theme->iconify_mask = RrPixmapMaskNew(inst, 7, 7, (char*)data);
+            theme->iconify_mask = RrPixmapMaskNew(inst, 7, 7, (gchar*)data);
         }
         theme->iconify_pressed_mask = RrPixmapMaskCopy(theme->iconify_mask);
         theme->iconify_disabled_mask = RrPixmapMaskCopy(theme->iconify_mask);
@@ -369,12 +365,12 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name)
     } else {
         {
             guchar data[] = { 0x63, 0x63, 0x00, 0x00, 0x00, 0x63, 0x63 };
-            theme->desk_mask = RrPixmapMaskNew(inst, 7, 7, (char*)data);
+            theme->desk_mask = RrPixmapMaskNew(inst, 7, 7, (gchar*)data);
         }
         {
             guchar data[] = { 0x00, 0x36, 0x36, 0x08, 0x36, 0x36, 0x00 };
             theme->desk_toggled_mask = RrPixmapMaskNew(inst, 7, 7,
-                                                       (char*)data);
+                                                       (gchar*)data);
         }
         theme->desk_pressed_mask = RrPixmapMaskCopy(theme->desk_mask);
         theme->desk_disabled_mask = RrPixmapMaskCopy(theme->desk_mask);
@@ -402,12 +398,12 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name)
     } else {
         {
             guchar data[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00 };
-            theme->shade_mask = RrPixmapMaskNew(inst, 7, 7, (char*)data);
+            theme->shade_mask = RrPixmapMaskNew(inst, 7, 7, (gchar*)data);
         }
         {
             guchar data[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x7f };
             theme->shade_toggled_mask = RrPixmapMaskNew(inst, 7, 7,
-                                                        (char*)data);
+                                                        (gchar*)data);
         }
         theme->shade_pressed_mask = RrPixmapMaskCopy(theme->shade_mask);
         theme->shade_disabled_mask = RrPixmapMaskCopy(theme->shade_mask);
@@ -430,7 +426,7 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name)
     } else {
         {
             guchar data[] = { 0x63, 0x77, 0x3e, 0x1c, 0x3e, 0x77, 0x63 };
-            theme->close_mask = RrPixmapMaskNew(inst, 7, 7, (char*)data);
+            theme->close_mask = RrPixmapMaskNew(inst, 7, 7, (gchar*)data);
         }
         theme->close_pressed_mask = RrPixmapMaskCopy(theme->close_mask);
         theme->close_disabled_mask = RrPixmapMaskCopy(theme->close_mask);
@@ -439,7 +435,7 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name)
 
     if (!read_mask(inst, "bullet.xbm", theme, &theme->menu_bullet_mask)) {
         guchar data[] = { 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x01 };
-        theme->menu_bullet_mask = RrPixmapMaskNew(inst, 4, 7, (char*)data);
+        theme->menu_bullet_mask = RrPixmapMaskNew(inst, 4, 7, (gchar*)data);
     }
 
     /* read the decoration textures */
@@ -489,26 +485,14 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name)
         set_default_appearance(theme->a_menu_selected);
 
     /* read the appearances for rendering non-decorations */
-    if (!read_appearance(db, inst,
-                         "window.active.title.bg", theme->app_hilite_bg,
-                         FALSE))
-        set_default_appearance(theme->app_hilite_bg);
-    if (!read_appearance(db, inst,
-                         "window.active.label.bg", theme->app_hilite_label,
-                         TRUE))
-        set_default_appearance(theme->app_hilite_label);
+    theme->app_hilite_bg = RrAppearanceCopy(theme->a_focused_title);
+    theme->app_hilite_label = RrAppearanceCopy(theme->a_focused_label);
     if (theme->a_focused_label->surface.grad != RR_SURFACE_PARENTREL)
         theme->app_hilite_fg = RrAppearanceCopy(theme->a_focused_label);
     else
         theme->app_hilite_fg = RrAppearanceCopy(theme->a_focused_title);
-    if (!read_appearance(db, inst,
-                         "window.inactive.title.bg", theme->app_unhilite_bg,
-                         FALSE))
-        set_default_appearance(theme->app_unhilite_bg);
-    if (!read_appearance(db, inst,
-                         "window.inactive.label.bg", theme->app_unhilite_label,
-                         TRUE))
-        set_default_appearance(theme->app_unhilite_label);
+    theme->app_unhilite_bg = RrAppearanceCopy(theme->a_unfocused_title);
+    theme->app_unhilite_label = RrAppearanceCopy(theme->a_unfocused_label);
     if (theme->a_unfocused_label->surface.grad != RR_SURFACE_PARENTREL)
         theme->app_unhilite_fg = RrAppearanceCopy(theme->a_unfocused_label);
     else
@@ -517,17 +501,17 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name)
     /* read buttons textures */
     if (!read_appearance(db, inst,
                          "window.active.button.disabled.bg",
-                        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.inactive.button.disabled.bg",
-                        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.active.button.pressed.bg",
-                        theme->a_focused_pressed_max,
+                         theme->a_focused_pressed_max,
                          TRUE))
         set_default_appearance(theme->a_focused_pressed_max);
     if (!read_appearance(db, inst,
@@ -921,7 +905,7 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name)
             theme->padding * 2;
     }
     theme->button_size = theme->label_height - 2;
-    theme->grip_width = theme->title_height * 1.5;
+    theme->grip_width = 25;
 
     return theme;
 }
@@ -1062,7 +1046,7 @@ void RrThemeFree(RrTheme *theme)
     }
 }
 
-static XrmDatabase loaddb(RrTheme *theme, char *name)
+static XrmDatabase loaddb(RrTheme *theme, gchar *name)
 {
     GSList *it;
     XrmDatabase db = NULL;
@@ -1102,10 +1086,10 @@ static XrmDatabase loaddb(RrTheme *theme, char *name)
     return db;
 }
 
-static char *create_class_name(char *rname)
+static gchar *create_class_name(gchar *rname)
 {
-    char *rclass = g_strdup(rname);
-    char *p = rclass;
+    gchar *rclass = g_strdup(rname);
+    gchar *p = rclass;
 
     while (TRUE) {
         *p = toupper(*p);
@@ -1117,16 +1101,16 @@ static char *create_class_name(char *rname)
     return rclass;
 }
 
-static gboolean read_int(XrmDatabase db, char *rname, int *value)
+static gboolean read_int(XrmDatabase db, gchar *rname, gint *value)
 {
     gboolean ret = FALSE;
-    char *rclass = create_class_name(rname);
-    char *rettype, *end;
+    gchar *rclass = create_class_name(rname);
+    gchar *rettype, *end;
     XrmValue retvalue;
   
     if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
         retvalue.addr != NULL) {
-        *value = (int)strtol(retvalue.addr, &end, 10);
+        *value = (gint)strtol(retvalue.addr, &end, 10);
         if (end != retvalue.addr)
             ret = TRUE;
     }
@@ -1135,11 +1119,11 @@ static gboolean read_int(XrmDatabase db, char *rname, int *value)
     return ret;
 }
 
-static gboolean read_string(XrmDatabase db, char *rname, char **value)
+static gboolean read_string(XrmDatabase db, gchar *rname, gchar **value)
 {
     gboolean ret = FALSE;
-    char *rclass = create_class_name(rname);
-    char *rettype;
+    gchar *rclass = create_class_name(rname);
+    gchar *rettype;
     XrmValue retvalue;
   
     if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
@@ -1156,8 +1140,8 @@ static gboolean read_color(XrmDatabase db, const RrInstance *inst,
                            gchar *rname, RrColor **value)
 {
     gboolean ret = FALSE;
-    char *rclass = create_class_name(rname);
-    char *rettype;
+    gchar *rclass = create_class_name(rname);
+    gchar *rettype;
     XrmValue retvalue;
   
     if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
@@ -1178,15 +1162,15 @@ static gboolean read_mask(const RrInstance *inst,
                           RrPixmapMask **value)
 {
     gboolean ret = FALSE;
-    char *s;
-    int hx, hy; /* ignored */
-    unsigned int w, h;
-    unsigned char *b;
+    gchar *s;
+    gint hx, hy; /* ignored */
+    guint w, h;
+    guchar *b;
 
     s = g_build_filename(theme->path, maskname, NULL);
     if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) == BitmapSuccess) {
         ret = TRUE;
-        *value = RrPixmapMaskNew(inst, w, h, (char*)b);
+        *value = RrPixmapMaskNew(inst, w, h, (gchar*)b);
         XFree(b);
     }
     g_free(s);
@@ -1199,7 +1183,7 @@ static void parse_appearance(gchar *tex, RrSurfaceColorType *grad,
                              gboolean *interlaced, gboolean *border,
                              gboolean allow_trans)
 {
-    char *t;
+    gchar *t;
 
     /* convert to all lowercase */
     for (t = tex; *t != '\0'; ++t)
@@ -1213,10 +1197,14 @@ static void parse_appearance(gchar *tex, RrSurfaceColorType *grad,
                 *grad = RR_SURFACE_CROSS_DIAGONAL;
             else if (strstr(tex, "pyramid") != NULL)
                 *grad = RR_SURFACE_PYRAMID;
+            else if (strstr(tex, "mirrorhorizontal") != NULL)
+                *grad = RR_SURFACE_MIRROR_HORIZONTAL;
             else if (strstr(tex, "horizontal") != NULL)
                 *grad = RR_SURFACE_HORIZONTAL;
             else if (strstr(tex, "vertical") != NULL)
                 *grad = RR_SURFACE_VERTICAL;
+            else if (strstr(tex, "splitvertical") != NULL)
+                *grad = RR_SURFACE_SPLIT_VERTICAL;
             else
                 *grad = RR_SURFACE_DIAGONAL;
         } else {
@@ -1229,7 +1217,7 @@ static void parse_appearance(gchar *tex, RrSurfaceColorType *grad,
             *relief = RR_RELIEF_FLAT;
         else
             *relief = RR_RELIEF_RAISED;
-       
+
         *border = FALSE;
         if (*relief == RR_RELIEF_FLAT) {
             if (strstr(tex, "border") != NULL)
@@ -1254,9 +1242,9 @@ static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
                                 gboolean allow_trans)
 {
     gboolean ret = FALSE;
-    char *rclass = create_class_name(rname);
-    char *cname, *ctoname, *bcname, *icname;
-    char *rettype;
+    gchar *rclass = create_class_name(rname);
+    gchar *cname, *ctoname, *bcname, *icname;
+    gchar *rettype;
     XrmValue retvalue;
 
     cname = g_strconcat(rname, ".color", NULL);
This page took 0.031646 seconds and 4 git commands to generate.