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

@ -179,8 +179,8 @@ void load_settings(char *cmdline_config_path)
"Max amount of notifications kept in history"); "Max amount of notifications kept in history");
settings.show_indicators = settings.show_indicators =
option_get_bool("global", "show_indicators", "-show_indicators", option_get_bool("global", "show_indicators", "-show_indicators",
show_indicators, show_indicators,
"Show indicators for actions \"(A)\" and URLs \"(U)\""); "Show indicators for actions \"(A)\" and URLs \"(U)\"");
settings.separator_height = settings.separator_height =
option_get_int("global", "separator_height", option_get_int("global", "separator_height",
"-sep_height/-separator_height", separator_height, "-sep_height/-separator_height", separator_height,
@ -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");
@ -372,7 +376,7 @@ void load_settings(char *cmdline_config_path)
r->bg = ini_get_string(cur_section, "background", r->bg); r->bg = ini_get_string(cur_section, "background", r->bg);
r->format = ini_get_string(cur_section, "format", r->format); r->format = ini_get_string(cur_section, "format", r->format);
r->new_icon = ini_get_string(cur_section, "new_icon", r->new_icon); r->new_icon = ini_get_string(cur_section, "new_icon", r->new_icon);
r->script = ini_get_string(cur_section, "script", NULL); r->script = ini_get_string(cur_section, "script", NULL);
} }
#ifndef STATIC_CONFIG #ifndef STATIC_CONFIG

View File

@ -29,7 +29,7 @@ typedef struct _settings {
float bounce_freq; float bounce_freq;
int sticky_history; int sticky_history;
int history_length; int history_length;
int show_indicators; int show_indicators;
int verbosity; int verbosity;
int word_wrap; int word_wrap;
int ignore_newline; int ignore_newline;
@ -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);
} }
} }