From 1070c0e142f6064b7db2dd285503282a13a70857 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 13 May 2010 13:59:22 -0400 Subject: [PATCH] checkpoint --- Makefile | 4 ++- main.c | 12 +++---- obtheme.h | 8 +++-- obtheme.l | 14 +++++++- obtheme.y | 111 +++++++++++++++++++++++++++++++++++++++++++++++----------- theme.obtheme | 19 ++++++---- 6 files changed, 131 insertions(+), 37 deletions(-) diff --git a/Makefile b/Makefile index 610580e..481d4f5 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ -CFLAGS=-g -Wall -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include +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 .PRECIOUS: %.tab.h %.lex.c %.tab.c diff --git a/main.c b/main.c index b93ef08..0e54d18 100644 --- a/main.c +++ b/main.c @@ -13,13 +13,13 @@ static void decor_print(gpointer data, gpointer user_data) g_slist_foreach(decor->children, decor_print, NULL); } -static void class_print(gpointer key, gpointer value, gpointer user_data) +static void style_print(gpointer key, gpointer value, gpointer user_data) { - char *classname = key; - struct class *class = value; + char *stylename = key; + struct style *style = value; - printf(" Class %s\n", classname); - g_slist_foreach(class->tree, decor_print, NULL); + printf(" style %s\n", stylename); + g_slist_foreach(style->tree, decor_print, NULL); } static void theme_print(gpointer key, gpointer value, gpointer user_data) @@ -27,7 +27,7 @@ static void theme_print(gpointer key, gpointer value, gpointer user_data) char *name = key; struct theme *thm = value; printf("name = %s\n", name); - g_hash_table_foreach(thm->classes, class_print, NULL); + g_hash_table_foreach(thm->styles, style_print, NULL); } static void material_print(gpointer key, gpointer value, gpointer user_data) diff --git a/obtheme.h b/obtheme.h index 6c67788..d98d335 100644 --- a/obtheme.h +++ b/obtheme.h @@ -2,6 +2,8 @@ #define __THEME_PARSE_H__ #include +#include "frame.h" +#include "misc.h" #undef YY_DECL #define YY_DECL int obthemelex(YYSTYPE *yylval, struct parser_control *pc) @@ -18,7 +20,7 @@ struct material { float opacity; }; -struct class { +struct style { char *name; GSList *tree; }; @@ -30,7 +32,7 @@ struct obthemedata { struct theme { char *name; - GHashTable *classes; + GHashTable *styles; }; struct vector { @@ -48,6 +50,8 @@ struct decor { char *name; GSList *children; struct space space; + ObDirection cursor; + ObFrameContext context; }; struct parser_control { diff --git a/obtheme.l b/obtheme.l index c87dc4d..f5eaed7 100644 --- a/obtheme.l +++ b/obtheme.l @@ -4,6 +4,8 @@ #include #include #include +#include "frame.h" +#include "misc.h" #include "obtheme.h" #include "obtheme.tab.h" @@ -115,12 +117,22 @@ material return MATERIAL; gradient return GRADIENT; context return CONTEXT; cursor return CURSOR; -class return CLASS; +style return STYLE; up return UP; anchor return ANCHOR; opacity return OPACITY; shapeof return SHAPEOF; texture return TEXTURE; +NORTH return NORTH; +NORTHEAST return NORTHEAST; +EAST return EAST; +SOUTHEAST return SOUTHEAST; +SOUTH return SOUTH; +SOUTHWEST return SOUTHWEST; +WEST return WEST; +NORTHWEST return NORTHWEST; +NONE return NONE; +UNCHANGED return UNCHANGED; 0x[0-9A-Z]+ yylval->integer = strtol(yytext, (char **)NULL, 16); return NUMBER; [0-9]+ yylval->integer = atoi(yytext); return NUMBER; diff --git a/obtheme.y b/obtheme.y index 2146130..e064e1c 100644 --- a/obtheme.y +++ b/obtheme.y @@ -10,11 +10,52 @@ #include #include #include +#include "frame.h" +#include "misc.h" #include "obtheme.h" #include "obtheme.tab.h" YY_DECL; +struct context_table_item { + char *name; + ObFrameContext val; +}; + +/* some of these contexts don't make any sense for a theme... */ +static struct context_table_item contexts[OB_FRAME_NUM_CONTEXTS] = { + {"none", OB_FRAME_CONTEXT_NONE}, + {"desktop", OB_FRAME_CONTEXT_DESKTOP}, + {"root", OB_FRAME_CONTEXT_ROOT}, + {"client", OB_FRAME_CONTEXT_CLIENT}, + {"titlebar", OB_FRAME_CONTEXT_TITLEBAR}, + {"frame", OB_FRAME_CONTEXT_FRAME}, + {"blcorner", OB_FRAME_CONTEXT_BLCORNER}, + {"brcorner", OB_FRAME_CONTEXT_BRCORNER}, + {"tlcorner", OB_FRAME_CONTEXT_TLCORNER}, + {"trcorner", OB_FRAME_CONTEXT_TRCORNER}, + {"top", OB_FRAME_CONTEXT_TOP}, + {"bottom", OB_FRAME_CONTEXT_BOTTOM}, + {"left", OB_FRAME_CONTEXT_LEFT}, + {"right", OB_FRAME_CONTEXT_RIGHT}, + {"maximize", OB_FRAME_CONTEXT_MAXIMIZE}, + {"alldesktops", OB_FRAME_CONTEXT_ALLDESKTOPS}, + {"shade", OB_FRAME_CONTEXT_SHADE}, + {"iconify", OB_FRAME_CONTEXT_ICONIFY}, + {"icon", OB_FRAME_CONTEXT_ICON}, + {"close", OB_FRAME_CONTEXT_CLOSE}, + {"moveresize", OB_FRAME_CONTEXT_MOVE_RESIZE} +}; + +static ObFrameContext context_from_string(char *str) +{ + int i; + for (i = 0; i < OB_FRAME_NUM_CONTEXTS; i++) + if (strcmp(contexts[i].name, str) == 1) + return contexts[i].val; + return -1; +} + struct parser_control *parser_init(struct obthemedata *otd) { struct parser_control *out; @@ -40,12 +81,16 @@ void parser_finish(struct parser_control *c) struct space space; struct theme theme; struct material material; - struct class class; + struct style style; GSList *list; GHashTable *hash; struct vector vector; + ObCursor dir; + ObFrameContext context; } +%token NORTH NORTHEAST EAST SOUTHEAST SOUTH SOUTHWEST +%token WEST NORTHWEST NONE UNCHANGED %token LCB RCB LB RB %token LEFT_ARROW RIGHT_ARROW DOUBLE_ARROW %token SEMICOLON AT COLON DEFAULT NOT @@ -53,17 +98,19 @@ void parser_finish(struct parser_control *c) %token STRING ID %token NUMBER SUBST BULK BIG LITTLE %token THEME FRAME SPACE GEOMETRY MATERIAL GRADIENT -%token CONTEXT CURSOR UP ANCHOR CLASS TEXTURE OPACITY +%token CONTEXT CURSOR UP ANCHOR STYLE TEXTURE OPACITY %token SHAPEOF DECOR %type decor -%type decoritems classitem +%type decoritems styleitem %type space -%type class classitems -%type classes +%type