From 75c7d04adf88127d16de0f8573fc6a4a3b7ab4f6 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Sun, 30 Dec 2007 14:49:03 +0100 Subject: [PATCH] allow textbox to have special width --- config.c | 1 + widgets/textbox.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/config.c b/config.c index e3220f42..89662e0c 100644 --- a/config.c +++ b/config.c @@ -517,6 +517,7 @@ config_parse(const char *confpatharg) static cfg_opt_t widget_textbox_focus_opts[] = { CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI), + CFG_INT((char *) "width", 0, CFGF_NONE), CFG_STR((char *) "text", (char *) NULL, CFGF_NONE), CFG_STR((char *) "fg", (char *) NULL, CFGF_NONE), CFG_STR((char *) "bg", (char *) NULL, CFGF_NONE), diff --git a/widgets/textbox.c b/widgets/textbox.c index 4dec1257..4ebef872 100644 --- a/widgets/textbox.c +++ b/widgets/textbox.c @@ -48,7 +48,9 @@ textbox_draw(Widget *widget, DrawCtx *ctx, int offset, { Data *d = widget->data; - widget->width = textwidth(widget->font, d->text); + if(!widget->width) + widget->width = textwidth(widget->font, d->text); + widget->location = widget_calculate_offset(widget->statusbar->width, widget->width, offset, @@ -91,6 +93,8 @@ textbox_new(Statusbar *statusbar, cfg_t *config) else d->bg = globalconf.screens[statusbar->screen].colors_normal[ColBG]; + w->width = cfg_getint(config, "width"); + if((buf = cfg_getstr(config, "font"))) w->font = XftFontOpenName(globalconf.display, get_phys_screen(statusbar->screen), buf);