simplify update

This commit is contained in:
Julien Danjou 2008-01-02 15:01:30 +01:00
parent 1b48166ad5
commit 2f19bab193
1 changed files with 5 additions and 11 deletions

View File

@ -34,15 +34,6 @@ typedef struct
XColor bg; XColor bg;
} Data; } Data;
static void
update(Widget *widget, char *text)
{
Data *d = widget->data;
if (d->text)
p_delete(&d->text);
d->text = a_strdup(text);
}
static int static int
textbox_draw(Widget *widget, DrawCtx *ctx, int offset, textbox_draw(Widget *widget, DrawCtx *ctx, int offset,
int used __attribute__ ((unused))) int used __attribute__ ((unused)))
@ -68,7 +59,10 @@ textbox_draw(Widget *widget, DrawCtx *ctx, int offset,
static void static void
textbox_tell(Widget *widget, char *command) textbox_tell(Widget *widget, char *command)
{ {
update(widget, command); Data *d = widget->data;
if (d->text)
p_delete(&d->text);
d->text = a_strdup(command);
} }
Widget * Widget *
@ -103,7 +97,7 @@ textbox_new(Statusbar *statusbar, cfg_t *config)
if(!w->font) if(!w->font)
w->font = globalconf.screens[statusbar->screen].font; w->font = globalconf.screens[statusbar->screen].font;
update(w, cfg_getstr(config, "text")); d->text = a_strdup(cfg_getstr(config, "text"));
return w; return w;
} }
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80