Skip to content

Commit

Permalink
icons: set widget svg icon size correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
johanmalm committed Aug 3, 2018
1 parent 2d8491e commit 877f09a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
11 changes: 5 additions & 6 deletions icon.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "sbuf.h"
#include "xpm-loader.h"
#include "cache.h"
#include "config.h"

#define DEBUG_THEMES 0

Expand All @@ -35,13 +36,11 @@ struct icon {
struct list_head icon_cache;

struct sbuf icon_theme;
int icon_size;

void icon_init(void)
{
INIT_LIST_HEAD(&icon_cache);
sbuf_init(&icon_theme);
icon_size = 22;
}

void icon_set_theme(const char *theme)
Expand All @@ -54,7 +53,6 @@ void icon_set_theme(const char *theme)

void icon_set_size(int size)
{
icon_size = size;
cache_set_icon_size(size);
}

Expand Down Expand Up @@ -154,7 +152,7 @@ void icon_set_name(const char *name)
list_add(&icon->list, &icon_cache);
}

cairo_surface_t *load_cairo_icon(const char *path)
cairo_surface_t *load_cairo_icon(const char *path, int icon_size)
{
if (strstr(path, ".png"))
return get_png_icon(path);
Expand Down Expand Up @@ -210,7 +208,7 @@ void icon_load(void)
sbuf_cpy(&path->name, icon->name);
list_add(&path->list, &icon_paths);
}
icon_find_all(&icon_paths, icon_size);
icon_find_all(&icon_paths, config.icon_size);
list_for_each_entry(path, &icon_paths, list) {
icon = (struct icon *)path->icon;
sbuf_cpy(&icon->path, path->path.buf);
Expand All @@ -234,7 +232,8 @@ void icon_load(void)
/* icon_load is run twice, so let's not duplicate effort */
if (icon->surface)
continue;
icon->surface = load_cairo_icon(icon->path.buf);
icon->surface = load_cairo_icon(icon->path.buf,
config.icon_size);
}

free(s.buf);
Expand Down
2 changes: 1 addition & 1 deletion icon.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extern void icon_init(void);
extern void icon_set_theme(const char *theme);
extern void icon_set_size(int size);
extern void icon_set_name(const char *name);
extern cairo_surface_t *load_cairo_icon(const char *path);
extern cairo_surface_t *load_cairo_icon(const char *path, int icon_size);
extern void icon_load(void);
extern cairo_surface_t *icon_get_surface(const char *name);
extern void icon_cleanup(void);
Expand Down
2 changes: 1 addition & 1 deletion widgets.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static enum widget_type parse_type(const char *field)
static void draw_icon(struct widget **w)
{
if (!(*w)->surface)
(*w)->surface = load_cairo_icon((*w)->content);
(*w)->surface = load_cairo_icon((*w)->content, (*w)->w);
if (!(*w)->surface)
return;
ui_insert_image((*w)->surface, (*w)->x, (*w)->y, (*w)->w);
Expand Down

0 comments on commit 877f09a

Please sign in to comment.