diff --git a/Makefile.am b/Makefile.am index 6b38cba26..7e07670cf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -34,6 +34,7 @@ WIDGETS += widgets/focusicon.c WIDGETS += widgets/progressbar.c WIDGETS += widgets/tasklist.c WIDGETS += widgets/graph.c +WIDGETS += widgets/emptybox.c WIDGETS += widgets/common.c diff --git a/common/configopts.c b/common/configopts.c index 5d768d472..2af53c43b 100644 --- a/common/configopts.c +++ b/common/configopts.c @@ -317,6 +317,21 @@ cfg_opt_t widget_textbox_opts[] = CFG_SEC((char *) "style", style_opts, CFGF_NONE), CFG_AWESOME_END() }; +/** This section defines emptybox widget options. */ +cfg_opt_t widget_emptybox_opts[] = +{ + /** X coordinate, do not set for auto. */ + CFG_INT((char *) "x", 0xffffffff, CFGF_NONE), + /** Y coordinate, do not set for auto. */ + CFG_INT((char *) "y", 0xffffffff, CFGF_NONE), + /** Mouse bindings. */ + CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI), + /** Widget width. Set to 0 for auto. */ + CFG_INT((char *) "width", 0, CFGF_NONE), + /** Style to use for drawing. */ + CFG_SEC((char *) "style", style_opts, CFGF_NONE), + CFG_AWESOME_END() +}; /** This section defines tasklist widget options */ cfg_opt_t widget_tasklist_opts[] = { @@ -441,6 +456,8 @@ cfg_opt_t statusbar_opts[] = CFG_INT((char *) "width", 0, CFGF_NONE), /** Textbox widget(s). */ CFG_SEC((char *) "textbox", widget_textbox_opts, CFGF_TITLE | CFGF_MULTI | CFGF_NO_TITLE_DUPES), + /** Emptybox widget(s). */ + CFG_SEC((char *) "emptybox", widget_emptybox_opts, CFGF_TITLE | CFGF_MULTI | CFGF_NO_TITLE_DUPES), /** Taglist widget(s). */ CFG_SEC((char *) "taglist", widget_taglist_opts, CFGF_TITLE | CFGF_MULTI | CFGF_NO_TITLE_DUPES), /** Layoutinfo widget(s). */ @@ -715,6 +732,7 @@ cfg_new(void) /* Check integers values > 1 */ cfg_set_validate_func(cfg, "screen|tags|tag|ncol", config_validate_supone_int); + cfg_set_validate_func(cfg, "screen|statusbar|emptybox|width", config_validate_supone_int); /* Check float values */ cfg_set_validate_func(cfg, "screen|general|mwfact_lower_limit", config_validate_zero_one_float); diff --git a/widget.h b/widget.h index d31a43a75..c7c1f4bf8 100644 --- a/widget.h +++ b/widget.h @@ -42,6 +42,7 @@ void widget_common_new(Widget*, Statusbar *, cfg_t *); WidgetConstructor layoutinfo_new; WidgetConstructor taglist_new; WidgetConstructor textbox_new; +WidgetConstructor emptybox_new; WidgetConstructor iconbox_new; WidgetConstructor focusicon_new; WidgetConstructor progressbar_new; diff --git a/widgets/emptybox.c b/widgets/emptybox.c new file mode 100644 index 000000000..6bfb290fa --- /dev/null +++ b/widgets/emptybox.c @@ -0,0 +1,74 @@ +/* + * emptybox.c - empty widget + * + * Copyright © 2008 Julien Danjou + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include "widget.h" +#include "common/configopts.h" + +extern AwesomeConf globalconf; + +typedef struct +{ + style_t style; +} Data; + +static int +emptybox_draw(Widget *widget, DrawCtx *ctx, int offset, + int used __attribute__ ((unused))) +{ + Data *d = widget->data; + + if(!widget->user_supplied_x) + widget->area.x = widget_calculate_offset(widget->statusbar->width, + widget->area.width, + offset, + widget->alignment); + if(!widget->user_supplied_y) + widget->area.y = 0; + + draw_rectangle(ctx, widget->area, 1.0, True, d->style.bg); + + return widget->area.width; +} + +Widget * +emptybox_new(Statusbar *statusbar, cfg_t *config) +{ + Widget *w; + Data *d; + + w = p_new(Widget, 1); + widget_common_new(w, statusbar, config); + w->draw = emptybox_draw; + w->alignment = cfg_getalignment(config, "align"); + + w->data = d = p_new(Data, 1); + + draw_style_init(globalconf.display, statusbar->phys_screen, + cfg_getsec(config, "style"), + &d->style, + &globalconf.screens[statusbar->screen].styles.normal); + + w->area.width = cfg_getint(config, "width"); + w->area.height = statusbar->height; + + return w; +} +// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80