forked from nsf/bmpanel2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
widget-decor.c
49 lines (41 loc) · 1.33 KB
/
widget-decor.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "builtin-widgets.h"
static int create_widget_private(struct widget *w, struct config_format_entry *e,
struct config_format_tree *tree);
static void destroy_widget_private(struct widget *w);
static void draw(struct widget *w);
struct widget_interface decor_interface = {
.theme_name = "decor",
.size_type = WIDGET_SIZE_CONSTANT,
.create_widget_private = create_widget_private,
.destroy_widget_private = destroy_widget_private,
.draw = draw
};
/**************************************************************************
Decor interface
**************************************************************************/
static int create_widget_private(struct widget *w, struct config_format_entry *e,
struct config_format_tree *tree)
{
struct decor_widget *dw = xmallocz(sizeof(struct decor_widget));
dw->image = parse_image_part(e, tree, 1);
if (!dw->image) {
xfree(dw);
XWARNING("Failed to parse decor theme");
return -1;
}
w->width = image_width(dw->image);
w->private = dw;
return 0;
}
static void destroy_widget_private(struct widget *w)
{
struct decor_widget *dw = (struct decor_widget*)w->private;
cairo_surface_destroy(dw->image);
xfree(dw);
}
static void draw(struct widget *w)
{
struct decor_widget *dw = (struct decor_widget*)w->private;
cairo_t *cr = w->panel->cr;
blit_image(dw->image, cr, w->x, 0);
}