Add cfg_getposition() and cie to ease libconfuse compatibility

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-03-19 11:58:43 +01:00
parent 19656fc36d
commit 7b1ce042de
4 changed files with 27 additions and 4 deletions

View File

@ -119,6 +119,24 @@ cfg_value_free(void *value)
p_delete(&value);
}
Position
cfg_opt_getnposition(cfg_opt_t *opt, unsigned int oindex)
{
return * (Position *) cfg_opt_getnptr(opt, oindex);
}
Position
cfg_getnposition(cfg_t *cfg, const char *name, unsigned int oindex)
{
return cfg_opt_getnposition(cfg_getopt(cfg, name), oindex);
}
Position
cfg_getposition(cfg_t *cfg, const char *name)
{
return cfg_getnposition(cfg, name, 0);
}
cfg_opt_t titlebar_opts[] =
{
CFG_POSITION((char *) "position", (char *) "auto", CFGF_NONE),

View File

@ -28,6 +28,10 @@ cfg_t * cfg_new(void);
char * config_file(void);
int config_check(const char *);
Position cfg_opt_getnposition(cfg_opt_t *, unsigned int);
Position cfg_getnposition(cfg_t *, const char *, unsigned int);
Position cfg_getposition(cfg_t *, const char *);
#endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

View File

@ -275,7 +275,7 @@ create_widgets(cfg_t* cfg_statusbar, Statusbar *statusbar)
static void
config_section_titlebar_init(cfg_t *cfg_titlebar, Titlebar *tb)
{
tb->position = tb->dposition = *(Position *) cfg_getptr(cfg_titlebar, "position");
tb->position = tb->dposition = cfg_getposition(cfg_titlebar, "position");
tb->text_align = * (Alignment *) cfg_getptr(cfg_titlebar, "text_align");
}
@ -373,7 +373,7 @@ config_parse_screen(cfg_t *cfg, int screen)
statusbar = p_new(Statusbar, 1);
cfgsectmp = cfg_getnsec(cfg_screen, "statusbar", i);
statusbar->position = statusbar->dposition =
* (Position *) cfg_getptr(cfgsectmp, "position");
cfg_getposition(cfgsectmp, "position");
statusbar->height = cfg_getint(cfgsectmp, "height");
statusbar->width = cfg_getint(cfgsectmp, "width");
statusbar->name = a_strdup(cfg_title(cfgsectmp));

View File

@ -20,10 +20,11 @@
*
*/
#include "common/draw.h"
#include "widget.h"
#include "screen.h"
#include "common/util.h"
#include "common/draw.h"
#include "common/configopts.h"
extern AwesomeConf globalconf;
@ -403,7 +404,7 @@ graph_new(Statusbar *statusbar, cfg_t *config)
return w;
}
d->grow = *(Position *) cfg_getptr(config, "grow");
d->grow = cfg_getposition(config, "grow");
if(d->grow != Left && d->grow != Right)
{
warn("graph widget: 'grow' argument must be 'left' or 'right'\n");