From 56d7e1654a8e697d7aa453a065c28e151d3cab6b Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Sat, 12 Jan 2008 21:39:41 +0100 Subject: [PATCH] use list functions for statusbar --- config.c | 27 ++++++++++++--------------- config.h | 2 ++ 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/config.c b/config.c index 37dcc302f..2bcdcf65c 100644 --- a/config.c +++ b/config.c @@ -292,6 +292,7 @@ config_parse_screen(cfg_t *cfg, int screen) *cfg_layouts, *cfg_padding, *cfgsectmp; VirtScreen *virtscreen = &globalconf.screens[screen]; unsigned int i; + int j; int phys_screen = get_phys_screen(screen); snprintf(buf, sizeof(buf), "%d", screen); @@ -350,22 +351,18 @@ config_parse_screen(cfg_t *cfg, int screen) /* Statusbar */ - if(cfg_size(cfg_screen, "statusbar")) + statusbar_list_init(&virtscreen->statusbar); + for(j = cfg_size(cfg_screen, "statusbar") - 1; j >= 0; j--) { - virtscreen->statusbar = statusbar = p_new(Statusbar, 1); - for(i = 0; i < cfg_size(cfg_screen, "statusbar"); i++) - { - cfgsectmp = cfg_getnsec(cfg_screen, "statusbar", i); - statusbar->position = statusbar->dposition = - statusbar_get_position_from_str(cfg_getstr(cfgsectmp, "position")); - statusbar->height = cfg_getint(cfgsectmp, "height"); - statusbar->width = cfg_getint(cfgsectmp, "width"); - statusbar->name = a_strdup(cfg_title(cfgsectmp)); - create_widgets(cfgsectmp, statusbar); - - if(i < cfg_size(cfg_screen, "statusbar") - 1) - statusbar = statusbar->next = p_new(Statusbar, 1); - } + statusbar = p_new(Statusbar, 1); + cfgsectmp = cfg_getnsec(cfg_screen, "statusbar", j); + statusbar->position = statusbar->dposition = + statusbar_get_position_from_str(cfg_getstr(cfgsectmp, "position")); + statusbar->height = cfg_getint(cfgsectmp, "height"); + statusbar->width = cfg_getint(cfgsectmp, "width"); + statusbar->name = a_strdup(cfg_title(cfgsectmp)); + create_widgets(cfgsectmp, statusbar); + statusbar_list_append(&virtscreen->statusbar, statusbar); } /* Layouts */ diff --git a/config.h b/config.h index 3454df21d..a69a623b0 100644 --- a/config.h +++ b/config.h @@ -161,6 +161,8 @@ struct Statusbar Statusbar *next; }; +DO_SLIST(Statusbar, statusbar, p_delete); + typedef struct Client Client; struct Client {