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)
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)
#include <sys/stat.h>
#include <limits.h>
#include <unistd.h>
+#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;
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
%token <string> STRING ID
%token <integer> 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> decor
-%type <decor> decoritems classitem
+%type <decor> decoritems styleitem
%type <space> space
-%type <class> class classitems
-%type <hash> classes
+%type <style> style styleitems
+%type <hash> styles
%type <material> material_props
%type <realnum> opacity
%type <space> spaceconstraints
%type <vector> up anchor
+%type <dir> cursor
+%type <context> context
%%
theme_object : material_decl
| theme_objects theme_object
;
-theme : THEME ID LCB classes RCB {
+theme : THEME ID LCB styles RCB {
struct theme *out;
out = malloc(sizeof(struct theme));
out->name = $2;
- out->classes = $4;
+ out->styles = $4;
g_hash_table_insert(pc->target->themes, $2, out);
}
;
geometry : GEOMETRY LCB geometry_item RCB
;
-material_use : MATERIAL LB ID RB
+material_use : MATERIAL LB ID RB {
+ if (g_hash_table_lookup(pc->target->materials, $3) == NULL) {
+ snprintf(pc->error_buf, 4000, "No definition for material '%s'\n", $3);
+ obthemeerror(pc, pc->error_buf);
+ return 1;
+ }
+ }
;
-classitem : decor
+styleitem : decor
;
-classitems : /* empty */ { $$.tree = NULL; $$.name = NULL; }
- | classitems classitem {
+styleitems : /* empty */ { $$.tree = NULL; $$.name = NULL; }
+ | styleitems styleitem {
struct decor *out = malloc(sizeof(struct decor));
*out = $2;
$1.tree = g_slist_prepend($1.tree, out);
}
;
-classes : /* empty */ { $$ = g_hash_table_new(g_str_hash, g_str_equal); }
- | classes class {
- struct class *out = malloc(sizeof(struct class));
+styles : /* empty */ { $$ = g_hash_table_new(g_str_hash, g_str_equal); }
+ | styles style {
+ struct style *out = malloc(sizeof(struct style));
*out = $2;
$$ = $1;
g_hash_table_insert($1, out->name, out);
}
;
-class : CLASS ID LCB classitems RCB {
+style : STYLE ID LCB styleitems RCB {
$$ = $4;
$$.name = $2;
}
decoritems : /* empty */ {
memset(&$$, 0, sizeof($$));
$$.space.up.y = -1;
+ $$.cursor = OB_CURSOR_NONE;
}
| decoritems decor {
struct decor *out = malloc(sizeof(struct decor));
| decoritems material_use
| decoritems geometry
| decoritems texture
- | decoritems context
+ | decoritems context { $1.context = $2; }
| decoritems gradient
- | decoritems cursor
+ | decoritems cursor { $1.cursor = $2; }
;
;
texture : TEXTURE LCB RCB
;
-context : CONTEXT LB ID RB
+context : CONTEXT LB ID RB {
+ ObFrameContext frc;
+ frc = context_from_string($3);
+ if (frc == -1) {
+ snprintf(pc->error_buf, 4000, "Illegal context '%s'\n", $3);
+ obthemeerror(pc, pc->error_buf);
+ return 1;
+ }
+ }
;
-cursor : CURSOR LB ID RB
-
+cursor : CURSOR LB NORTH RB { $$ = OB_CURSOR_NORTH; }
+ | CURSOR LB NORTHEAST RB { $$ = OB_CURSOR_NORTHEAST; }
+ | CURSOR LB EAST RB { $$ = OB_CURSOR_EAST; }
+ | CURSOR LB SOUTHEAST RB { $$ = OB_CURSOR_SOUTHEAST; }
+ | CURSOR LB SOUTH RB { $$ = OB_CURSOR_SOUTH; }
+ | CURSOR LB SOUTHWEST RB { $$ = OB_CURSOR_SOUTHWEST; }
+ | CURSOR LB WEST RB { $$ = OB_CURSOR_WEST; }
+ | CURSOR LB NORTHWEST RB { $$ = OB_CURSOR_NORTHWEST; }
+// | CURSOR LB NONE RB { $$ = OB_CURSOR_NORTHEAST; }
+ | CURSOR LB UNCHANGED RB { $$ = OB_CURSOR_NONE; }
+ ;
gradient : GRADIENT LB ID RB
;