Add configuration option for icon scaling

The maximum size for icons can now be set with the max_icon_size option.
Setting its value to 0 will disable the scaling of icons.
This commit is contained in:
Johannes M. Griebler 2016-10-14 18:12:09 +02:00
parent 342a23548f
commit ce8fe45cbf
4 changed files with 16 additions and 8 deletions

View File

@ -56,6 +56,8 @@ char *dmenu = "/usr/bin/dmenu";
char *browser = "/usr/bin/firefox"; char *browser = "/usr/bin/firefox";
int max_icon_size = 32;
/* paths to default icons */ /* paths to default icons */
char *icon_folders = "/usr/share/icons/gnome/16x16/status/:/usr/share/icons/gnome/16x16/devices/"; char *icon_folders = "/usr/share/icons/gnome/16x16/status/:/usr/share/icons/gnome/16x16/devices/";

View File

@ -249,6 +249,10 @@ void load_settings(char *cmdline_config_path)
} }
} }
settings.max_icon_size =
option_get_int("global", "max_icon_size", "-max_icon_size", max_icon_size,
"Scale larger icons down to this size, set to 0 to disable");
settings.icon_folders = settings.icon_folders =
option_get_string("global", "icon_folders", "-icon_folders", icon_folders, option_get_string("global", "icon_folders", "-icon_folders", icon_folders,
"paths to default icons"); "paths to default icons");

View File

@ -49,6 +49,7 @@ typedef struct _settings {
char **dmenu_cmd; char **dmenu_cmd;
char *browser; char *browser;
enum icon_position_t icon_position; enum icon_position_t icon_position;
int max_icon_size;
char *icon_folders; char *icon_folders;
enum follow_mode f_mode; enum follow_mode f_mode;
bool always_run_script; bool always_run_script;

9
x.c
View File

@ -404,15 +404,16 @@ static colored_layout *r_init_shared(cairo_t *c, notification *n)
int w = gdk_pixbuf_get_width(pixbuf); int w = gdk_pixbuf_get_width(pixbuf);
int h = gdk_pixbuf_get_height(pixbuf); int h = gdk_pixbuf_get_height(pixbuf);
int larger = w > h ? w : h; int larger = w > h ? w : h;
int max_size = 24; if (settings.max_icon_size && larger > settings.max_icon_size) {
if (larger > max_size) {
if (w >= h) { if (w >= h) {
pixbuf = gdk_pixbuf_scale_simple(pixbuf, pixbuf = gdk_pixbuf_scale_simple(pixbuf,
max_size, (int) ((double) max_size / w * h), settings.max_icon_size,
(int) ((double) settings.max_icon_size / w * h),
GDK_INTERP_BILINEAR); GDK_INTERP_BILINEAR);
} else { } else {
pixbuf = gdk_pixbuf_scale_simple(pixbuf, pixbuf = gdk_pixbuf_scale_simple(pixbuf,
(int) ((double) max_size / h * w), max_size, (int) ((double) settings.max_icon_size / h * w),
settings.max_icon_size,
GDK_INTERP_BILINEAR); GDK_INTERP_BILINEAR);
} }
} }