use list functions for Tag

This commit is contained in:
Julien Danjou 2008-01-12 21:53:58 +01:00
parent feac2caa81
commit 99e54ef971
3 changed files with 11 additions and 11 deletions

View File

@ -398,11 +398,12 @@ config_parse_screen(cfg_t *cfg, int screen)
} }
/* Tags */ /* Tags */
virtscreen->tags = tag = p_new(Tag, 1); tag_list_init(&virtscreen->tags);
if(cfg_size(cfg_tags, "tag")) if((j = cfg_size(cfg_tags, "tag")))
for(i = 0; i < cfg_size(cfg_tags, "tag"); i++) for(--j; j >= 0; j--)
{ {
cfgsectmp = cfg_getnsec(cfg_tags, "tag", i); tag = p_new(Tag, 1);
cfgsectmp = cfg_getnsec(cfg_tags, "tag", j);
tag->name = a_strdup(cfg_title(cfgsectmp)); tag->name = a_strdup(cfg_title(cfgsectmp));
tag->selected = False; tag->selected = False;
tag->was_selected = False; tag->was_selected = False;
@ -417,10 +418,7 @@ config_parse_screen(cfg_t *cfg, int screen)
tag->nmaster = cfg_getint(cfgsectmp, "nmaster"); tag->nmaster = cfg_getint(cfgsectmp, "nmaster");
tag->ncol = cfg_getint(cfgsectmp, "ncol"); tag->ncol = cfg_getint(cfgsectmp, "ncol");
if(i < cfg_size(cfg_tags, "tag") - 1) tag_list_push(&virtscreen->tags, tag);
tag = tag->next = p_new(Tag, 1);
else
tag->next = NULL;
} }
else else
{ {

View File

@ -232,6 +232,8 @@ struct Tag
Tag *next; Tag *next;
}; };
DO_SLIST(Tag, tag, p_delete);
/** TagClientLink type */ /** TagClientLink type */
typedef struct TagClientLink TagClientLink; typedef struct TagClientLink TagClientLink;
struct TagClientLink struct TagClientLink

6
tag.c
View File

@ -414,18 +414,18 @@ uicb_tag_viewprev(int screen, char *arg __attribute__ ((unused)))
void void
uicb_tag_create(int screen, char *arg) uicb_tag_create(int screen, char *arg)
{ {
Tag *last_tag, *tag; Tag *tag;
if(!a_strlen(arg)) if(!a_strlen(arg))
return; return;
for(last_tag = globalconf.screens[screen].tags; last_tag && last_tag->next; last_tag = last_tag->next); tag = p_new(Tag, 1);
last_tag->next = tag = p_new(Tag, 1);
tag->name = a_strdup(arg); tag->name = a_strdup(arg);
tag->layout = globalconf.screens[screen].layouts; tag->layout = globalconf.screens[screen].layouts;
tag->mwfact = 0.5; tag->mwfact = 0.5;
tag->nmaster = 1; tag->nmaster = 1;
tag->ncol = 1; tag->ncol = 1;
tag_list_append(&globalconf.screens[screen].tags, tag);
widget_invalidate_cache(screen, WIDGET_CACHE_TAGS); widget_invalidate_cache(screen, WIDGET_CACHE_TAGS);
} }