X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=de%2Finit.c;h=bc771d08144a2407022505bf282c4e47bf7f0ac9;hb=aa64323a858db8436bb433862dc212ae4e13011d;hp=3e779b3f9886ff9f2d1472ce36833b10746a2742;hpb=8366314611bf30a0f31d25bf5f5023186fa87692;p=ion3.git diff --git a/de/init.c b/de/init.c index 3e779b3..bc771d0 100644 --- a/de/init.c +++ b/de/init.c @@ -1,7 +1,7 @@ /* * ion/de/init.c * - * Copyright (c) Tuomo Valkonen 1999-2006. + * Copyright (c) Tuomo Valkonen 1999-2007. * * Ion is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by @@ -28,6 +28,32 @@ #include "exports.h" +/*{{{ Style specifications */ + + +static bool get_spec(ExtlTab tab, const char *name, GrStyleSpec *spec, + char **pat_ret) +{ + char *str; + bool res; + + if(!extl_table_gets_s(tab, name, &str)) + return FALSE; + + res=gr_stylespec_load(spec, str); + + if(pat_ret==NULL) + free(str); + else + *pat_ret=str; + + return res; +} + + +/*}}}*/ + + /*{{{ Borders */ @@ -68,12 +94,33 @@ void de_get_border_style(uint *ret, ExtlTab tab) } +void de_get_border_sides(uint *ret, ExtlTab tab) +{ + char *style=NULL; + + if(!extl_table_gets_s(tab, "border_sides", &style)) + return; + + if(strcmp(style, "all")==0) + *ret=DEBORDER_ALL; + else if(strcmp(style, "tb")==0) + *ret=DEBORDER_TB; + else if(strcmp(style, "lr")==0) + *ret=DEBORDER_LR; + else + warn(TR("Unknown border side configuration \"%s\"."), style); + + free(style); +} + + void de_get_border(DEBorder *border, ExtlTab tab) { de_get_border_val(&(border->sh), tab, "shadow_pixels"); de_get_border_val(&(border->hl), tab, "highlight_pixels"); de_get_border_val(&(border->pad), tab, "padding_pixels"); de_get_border_style(&(border->style), tab); + de_get_border_sides(&(border->sides), tab); } @@ -141,15 +188,18 @@ void de_get_extra_cgrps(WRootWin *rootwin, DEStyle *style, ExtlTab tab) return; for(i=0; iextra_cgrps+i-nfailed);*/ - style->extra_cgrps[i-nfailed].spec=name; + style->extra_cgrps[i-nfailed].spec=spec; + de_get_colour_group(rootwin, style->extra_cgrps+i-nfailed, sub, style); @@ -237,6 +287,8 @@ void de_get_nonfont(WRootWin *rootwin, DEStyle *style, ExtlTab tab) } + + /*EXTL_DOC * Define a style for the root window \var{rootwin}. */ @@ -246,8 +298,9 @@ bool de_defstyle_rootwin(WRootWin *rootwin, const char *name, ExtlTab tab) DEStyle *style; char *fnt; uint n; + char *based_on_name; DEStyle *based_on=NULL; - char *based_on_name=NULL; + GrStyleSpec based_on_spec; if(name==NULL) return FALSE; @@ -257,18 +310,22 @@ bool de_defstyle_rootwin(WRootWin *rootwin, const char *name, ExtlTab tab) if(style==NULL) return FALSE; - if(extl_table_gets_s(tab, "based_on", &based_on_name)){ - based_on=de_get_style(rootwin, based_on_name); + if(get_spec(tab, "based_on", &based_on_spec, &based_on_name)){ + based_on=de_get_style(rootwin, &based_on_spec); + + gr_stylespec_unalloc(&based_on_spec); + if(based_on==style){ warn(TR("'based_on' for %s points back to the style itself."), name); }else if(based_on==NULL){ - warn(TR("Unknown base style \"%s\"."), based_on); + warn(TR("Unknown base style. \"%s\""), based_on_name); }else{ style->based_on=based_on; based_on->usecount++; /* Copy simple parameters */ } + free(based_on_name); }