From 99e54ef97111db6c456e7b6c72049659cadb399d Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Sat, 12 Jan 2008 21:53:58 +0100 Subject: [PATCH] use list functions for Tag --- config.c | 14 ++++++-------- config.h | 2 ++ tag.c | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/config.c b/config.c index 2bcdcf65..58381d85 100644 --- a/config.c +++ b/config.c @@ -398,11 +398,12 @@ config_parse_screen(cfg_t *cfg, int screen) } /* Tags */ - virtscreen->tags = tag = p_new(Tag, 1); - if(cfg_size(cfg_tags, "tag")) - for(i = 0; i < cfg_size(cfg_tags, "tag"); i++) + tag_list_init(&virtscreen->tags); + if((j = cfg_size(cfg_tags, "tag"))) + 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->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->ncol = cfg_getint(cfgsectmp, "ncol"); - if(i < cfg_size(cfg_tags, "tag") - 1) - tag = tag->next = p_new(Tag, 1); - else - tag->next = NULL; + tag_list_push(&virtscreen->tags, tag); } else { diff --git a/config.h b/config.h index a69a623b..b23d4892 100644 --- a/config.h +++ b/config.h @@ -232,6 +232,8 @@ struct Tag Tag *next; }; +DO_SLIST(Tag, tag, p_delete); + /** TagClientLink type */ typedef struct TagClientLink TagClientLink; struct TagClientLink diff --git a/tag.c b/tag.c index d4e37792..e9f0276d 100644 --- a/tag.c +++ b/tag.c @@ -414,18 +414,18 @@ uicb_tag_viewprev(int screen, char *arg __attribute__ ((unused))) void uicb_tag_create(int screen, char *arg) { - Tag *last_tag, *tag; + Tag *tag; if(!a_strlen(arg)) return; - for(last_tag = globalconf.screens[screen].tags; last_tag && last_tag->next; last_tag = last_tag->next); - last_tag->next = tag = p_new(Tag, 1); + tag = p_new(Tag, 1); tag->name = a_strdup(arg); tag->layout = globalconf.screens[screen].layouts; tag->mwfact = 0.5; tag->nmaster = 1; tag->ncol = 1; + tag_list_append(&globalconf.screens[screen].tags, tag); widget_invalidate_cache(screen, WIDGET_CACHE_TAGS); }