another checkpoint
authorroot <root@Thermopile.lan>
Thu, 13 May 2010 20:54:44 +0000 (16:54 -0400)
committerroot <root@Thermopile.lan>
Thu, 13 May 2010 20:54:44 +0000 (16:54 -0400)
Makefile
obtheme.l
obtheme.y
theme.obtheme

index 481d4f5..29e9aa5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 CFLAGS=-g -Wall -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include \
        -I../openbox/openbox -I../openbox -I/usr/include/pango-1.0 \
-       -I/usr/include/freetype2
+       -I/usr/include/freetype2 -I../openbox/obrender
 
 .PRECIOUS: %.tab.h %.lex.c %.tab.c
 
index f5eaed7..889e6ad 100644 (file)
--- a/obtheme.l
+++ b/obtheme.l
@@ -6,6 +6,7 @@
 #include <glib.h>
 #include "frame.h"
 #include "misc.h"
+#include "render.h"
 #include "obtheme.h"
 #include "obtheme.tab.h"
 
index e064e1c..4ebd13d 100644 (file)
--- a/obtheme.y
+++ b/obtheme.y
@@ -12,6 +12,7 @@
 #include <unistd.h>
 #include "frame.h"
 #include "misc.h"
+#include "render.h"
 #include "obtheme.h"
 #include "obtheme.tab.h"
 
@@ -56,6 +57,35 @@ static ObFrameContext context_from_string(char *str)
        return -1;
 }
 
+struct gradient_table_item {
+       char *name;
+       RrSurfaceColorType val;
+};
+
+struct gradient_table_item gradients[RR_SURFACE_NUM_TYPES] = {
+       {"none", RR_SURFACE_NONE},
+       {"parentrel", RR_SURFACE_PARENTREL},
+       {"solid", RR_SURFACE_SOLID},
+       {"split", RR_SURFACE_SPLIT_VERTICAL},
+       {"horizontal", RR_SURFACE_HORIZONTAL},
+       {"vertical", RR_SURFACE_VERTICAL},
+       {"diagonal", RR_SURFACE_DIAGONAL},
+       {"cross_diagonal", RR_SURFACE_CROSS_DIAGONAL},
+       {"pyramid", RR_SURFACE_PYRAMID},
+       {"mirror_horizontal", RR_SURFACE_MIRROR_HORIZONTAL},
+};
+
+static RrSurfaceColorType gradient_from_string(char *str)
+{
+       int i;
+
+       for (i = 0; i < RR_SURFACE_NUM_TYPES; i++)
+               if (strcmp(gradients[i].name, str) == 1)
+                       return gradients[i].val;
+
+       return -1;
+}
+
 struct parser_control *parser_init(struct obthemedata *otd)
 {
        struct parser_control *out;
@@ -87,6 +117,7 @@ void parser_finish(struct parser_control *c)
        struct vector vector;
        ObCursor dir;
        ObFrameContext context;
+       RrSurfaceColorType gradient;
 }
 
 %token NORTH NORTHEAST EAST SOUTHEAST SOUTH SOUTHWEST
@@ -111,6 +142,7 @@ void parser_finish(struct parser_control *c)
 %type <vector> up anchor
 %type <dir> cursor
 %type <context> context
+%type <gradient> gradient
 %%
 
 theme_object   : material_decl
@@ -134,10 +166,8 @@ opacity            : OPACITY LB NUMBER RB { $$ = $3; }
                ;
 
 material_props : /* empty */ { memset(&$$, 0, sizeof($$)); }
-               | material_props opacity {
-                       $$ = $1;
-                       $$.opacity = $2;
-               }
+               | material_props opacity { $$ = $1; $$.opacity = $2;}
+               | material_props gradient
                ;
 
 material_decl  : MATERIAL ID LCB material_props RCB {
@@ -234,7 +264,6 @@ decoritems  : /* empty */ {
                | decoritems geometry
                | decoritems texture
                | decoritems context { $1.context = $2; }
-               | decoritems gradient
                | decoritems cursor { $1.cursor = $2; }
                ;
 
@@ -271,7 +300,14 @@ cursor             : CURSOR LB NORTH RB { $$ = OB_CURSOR_NORTH; }
 //             | CURSOR LB NONE RB { $$ = OB_CURSOR_NORTHEAST; }
                | CURSOR LB UNCHANGED RB { $$ = OB_CURSOR_NONE; }
                ;
-gradient       : GRADIENT LB ID RB
+gradient       : GRADIENT LB ID RB {
+                       $$ = gradient_from_string($3);
+                       if ($$ == -1) {
+                               snprintf(pc->error_buf, 4000, "No gradient named '%s'\n", $3);
+                               obthemeerror(pc, pc->error_buf);
+                               return 1;
+                       }
+               }
                ;
 
 %%
index c02e21a..af8d033 100644 (file)
@@ -6,6 +6,11 @@ material flat {
        opacity(1)
 }
 
+material grad {
+       opacity(1)
+       gradient(split)
+}
+
 material none {
 }
 
@@ -13,7 +18,7 @@ theme awesome {
        style regular_window {
                decor clientwindow {
                        space {
-                               anchor(10 9 8)
+                               anchor(0 0 0)
                                up(1 0 0)
                        }
                        geometry {
@@ -29,7 +34,6 @@ theme awesome {
                                //      box (0, 0, 0) to (100% of $CLIENT, 100%, 0)
                                }
                                material(flat)
-                               gradient(split)
 //texture {
                                decor title {
                                        geometry {