new widget to draw icons from PNG image
This commit is contained in:
parent
55be368539
commit
3f3748d4bd
6
config.c
6
config.c
|
@ -332,6 +332,11 @@ config_parse(const char *confpatharg)
|
||||||
{
|
{
|
||||||
CFG_END()
|
CFG_END()
|
||||||
};
|
};
|
||||||
|
static cfg_opt_t widget_iconbox_opts[] =
|
||||||
|
{
|
||||||
|
CFG_STR((char *) "image", (char *) NULL, CFGF_NONE),
|
||||||
|
CFG_END()
|
||||||
|
};
|
||||||
static cfg_opt_t widget_textbox_opts[] =
|
static cfg_opt_t widget_textbox_opts[] =
|
||||||
{
|
{
|
||||||
CFG_STR((char *) "default", (char *) NULL, CFGF_NONE),
|
CFG_STR((char *) "default", (char *) NULL, CFGF_NONE),
|
||||||
|
@ -346,6 +351,7 @@ config_parse(const char *confpatharg)
|
||||||
CFG_SEC((char *) "taglist", widget_opts, CFGF_TITLE | CFGF_MULTI),
|
CFG_SEC((char *) "taglist", widget_opts, CFGF_TITLE | CFGF_MULTI),
|
||||||
CFG_SEC((char *) "focustitle", widget_opts, CFGF_TITLE | CFGF_MULTI),
|
CFG_SEC((char *) "focustitle", widget_opts, CFGF_TITLE | CFGF_MULTI),
|
||||||
CFG_SEC((char *) "layoutinfo", widget_opts, CFGF_TITLE | CFGF_MULTI),
|
CFG_SEC((char *) "layoutinfo", widget_opts, CFGF_TITLE | CFGF_MULTI),
|
||||||
|
CFG_SEC((char *) "iconbox", widget_iconbox_opts, CFGF_TITLE | CFGF_MULTI),
|
||||||
CFG_END()
|
CFG_END()
|
||||||
};
|
};
|
||||||
static cfg_opt_t tag_opts[] =
|
static cfg_opt_t tag_opts[] =
|
||||||
|
|
|
@ -7,7 +7,7 @@ RELEASE = "Productivity Breaker"
|
||||||
# additional layouts
|
# additional layouts
|
||||||
LAYOUTS = layouts/tile.c layouts/floating.c layouts/max.c layouts/fibonacci.c
|
LAYOUTS = layouts/tile.c layouts/floating.c layouts/max.c layouts/fibonacci.c
|
||||||
|
|
||||||
WIDGETS = widgets/taglist.c widgets/layoutinfo.c widgets/textbox.c widgets/focustitle.c
|
WIDGETS = widgets/taglist.c widgets/layoutinfo.c widgets/textbox.c widgets/focustitle.c widgets/iconbox.c
|
||||||
|
|
||||||
# paths
|
# paths
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
|
|
31
draw.c
31
draw.c
|
@ -149,6 +149,37 @@ drawcircle(DrawCtx *ctx, int x, int y, int r, Bool filled, XColor color)
|
||||||
cairo_surface_destroy(surface);
|
cairo_surface_destroy(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drawimage(DrawCtx *ctx, int x, int y, const char *filename)
|
||||||
|
{
|
||||||
|
cairo_surface_t *surface, *source;
|
||||||
|
cairo_t *cr;
|
||||||
|
|
||||||
|
source = cairo_xlib_surface_create(ctx->display, ctx->drawable, ctx->visual, ctx->width, ctx->height);
|
||||||
|
surface = cairo_image_surface_create_from_png(filename);
|
||||||
|
cr = cairo_create (source);
|
||||||
|
cairo_set_source_surface(cr, surface, x, y);
|
||||||
|
cairo_paint(cr);
|
||||||
|
|
||||||
|
cairo_destroy(cr);
|
||||||
|
cairo_surface_destroy(source);
|
||||||
|
cairo_surface_destroy(surface);
|
||||||
|
}
|
||||||
|
|
||||||
|
int draw_get_image_width(const char *filename)
|
||||||
|
{
|
||||||
|
int width;
|
||||||
|
cairo_surface_t *surface;
|
||||||
|
|
||||||
|
surface = cairo_image_surface_create_from_png(filename);
|
||||||
|
cairo_image_surface_get_width(surface);
|
||||||
|
width = cairo_image_surface_get_width(surface);
|
||||||
|
cairo_surface_destroy(surface);
|
||||||
|
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Drawable
|
Drawable
|
||||||
draw_rotate(DrawCtx *ctx, int screen, double angle, int tx, int ty)
|
draw_rotate(DrawCtx *ctx, int screen, double angle, int tx, int ty)
|
||||||
{
|
{
|
||||||
|
|
2
draw.h
2
draw.h
|
@ -41,6 +41,8 @@ void draw_free_context(DrawCtx*);
|
||||||
void drawtext(DrawCtx *, int, int, int, int, XftFont *, const char *, XColor fg, XColor bg);
|
void drawtext(DrawCtx *, int, int, int, int, XftFont *, const char *, XColor fg, XColor bg);
|
||||||
void drawrectangle(DrawCtx *, int, int, int, int, Bool, XColor);
|
void drawrectangle(DrawCtx *, int, int, int, int, Bool, XColor);
|
||||||
void drawcircle(DrawCtx *, int, int, int, Bool, XColor);
|
void drawcircle(DrawCtx *, int, int, int, Bool, XColor);
|
||||||
|
void drawimage(DrawCtx *, int, int, const char *);
|
||||||
|
int draw_get_image_width(const char *filename);
|
||||||
Drawable draw_rotate(DrawCtx *, int, double, int, int);
|
Drawable draw_rotate(DrawCtx *, int, double, int, int);
|
||||||
unsigned short textwidth(DrawCtx *, XftFont *, char *);
|
unsigned short textwidth(DrawCtx *, XftFont *, char *);
|
||||||
unsigned short textwidth_primitive(Display*, XftFont*, char*);
|
unsigned short textwidth_primitive(Display*, XftFont*, char*);
|
||||||
|
|
4
widget.c
4
widget.c
|
@ -11,6 +11,7 @@ const NameFuncLink WidgetList[] =
|
||||||
{"layoutinfo", layoutinfo_new},
|
{"layoutinfo", layoutinfo_new},
|
||||||
{"focustitle", focustitle_new},
|
{"focustitle", focustitle_new},
|
||||||
{"textbox", textbox_new},
|
{"textbox", textbox_new},
|
||||||
|
{"iconbox", iconbox_new},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -28,7 +29,8 @@ calculate_alignments(Widget *widget)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(widget)
|
if(widget)
|
||||||
for(; widget; widget = widget->next){
|
for(; widget; widget = widget->next)
|
||||||
|
{
|
||||||
if (widget->alignment == AlignFlex)
|
if (widget->alignment == AlignFlex)
|
||||||
warn("Multiple flex widgets in panel -"
|
warn("Multiple flex widgets in panel -"
|
||||||
" ignoring flex for all but the first.");
|
" ignoring flex for all but the first.");
|
||||||
|
|
1
widget.h
1
widget.h
|
@ -18,6 +18,7 @@ WidgetConstructor layoutinfo_new;
|
||||||
WidgetConstructor taglist_new;
|
WidgetConstructor taglist_new;
|
||||||
WidgetConstructor textbox_new;
|
WidgetConstructor textbox_new;
|
||||||
WidgetConstructor focustitle_new;
|
WidgetConstructor focustitle_new;
|
||||||
|
WidgetConstructor iconbox_new;
|
||||||
|
|
||||||
UICB_PROTO(uicb_widget_tell);
|
UICB_PROTO(uicb_widget_tell);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue