2 * iconbox.c - icon widget
4 * Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 extern AwesomeConf globalconf
;
34 iconbox_draw(Widget
*widget
, DrawCtx
*ctx
, int offset
,
35 int used
__attribute__ ((unused
)))
37 Data
*d
= widget
->data
;
38 Area area
= draw_get_image_size(d
->image
);
41 widget
->area
.width
= ((double) widget
->statusbar
->height
/ area
.height
) * area
.width
;
43 widget
->area
.width
= area
.width
;
45 widget
->area
.height
= widget
->statusbar
->height
;
47 if(!widget
->user_supplied_x
)
48 widget
->area
.x
= widget_calculate_offset(widget
->statusbar
->width
,
53 if(!widget
->user_supplied_y
)
56 draw_image(ctx
, widget
->area
.x
, widget
->area
.y
,
57 d
->resize
? widget
->statusbar
->height
: 0, d
->image
);
59 return widget
->area
.width
;
63 iconbox_tell(Widget
*widget
, char *command
)
65 Data
*d
= widget
->data
;
69 d
->image
= a_strdup(command
);
73 iconbox_new(Statusbar
*statusbar
, cfg_t
*config
)
79 widget_common_new(w
, statusbar
, config
);
80 w
->draw
= iconbox_draw
;
81 w
->tell
= iconbox_tell
;
82 w
->data
= d
= p_new(Data
, 1);
83 d
->image
= a_strdup(cfg_getstr(config
, "image"));
84 d
->resize
= cfg_getbool(config
, "resize");
88 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80