From ce8fe45cbf81b351b6802c25563b60e418d271cf Mon Sep 17 00:00:00 2001 From: "Johannes M. Griebler" Date: Fri, 14 Oct 2016 18:12:09 +0200 Subject: [PATCH] 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. --- config.def.h | 2 ++ settings.c | 10 +++++++--- settings.h | 3 ++- x.c | 9 +++++---- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/config.def.h b/config.def.h index 3f00209..d91e495 100644 --- a/config.def.h +++ b/config.def.h @@ -56,6 +56,8 @@ char *dmenu = "/usr/bin/dmenu"; char *browser = "/usr/bin/firefox"; +int max_icon_size = 32; + /* paths to default icons */ char *icon_folders = "/usr/share/icons/gnome/16x16/status/:/usr/share/icons/gnome/16x16/devices/"; diff --git a/settings.c b/settings.c index c05545e..54baea4 100644 --- a/settings.c +++ b/settings.c @@ -179,8 +179,8 @@ void load_settings(char *cmdline_config_path) "Max amount of notifications kept in history"); settings.show_indicators = option_get_bool("global", "show_indicators", "-show_indicators", - show_indicators, - "Show indicators for actions \"(A)\" and URLs \"(U)\""); + show_indicators, + "Show indicators for actions \"(A)\" and URLs \"(U)\""); settings.separator_height = option_get_int("global", "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 = option_get_string("global", "icon_folders", "-icon_folders", icon_folders, "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->format = ini_get_string(cur_section, "format", r->format); 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 diff --git a/settings.h b/settings.h index c8b9631..f5b8a0a 100644 --- a/settings.h +++ b/settings.h @@ -29,7 +29,7 @@ typedef struct _settings { float bounce_freq; int sticky_history; int history_length; - int show_indicators; + int show_indicators; int verbosity; int word_wrap; int ignore_newline; @@ -49,6 +49,7 @@ typedef struct _settings { char **dmenu_cmd; char *browser; enum icon_position_t icon_position; + int max_icon_size; char *icon_folders; enum follow_mode f_mode; bool always_run_script; diff --git a/x.c b/x.c index 65fa442..c370eb2 100644 --- a/x.c +++ b/x.c @@ -404,15 +404,16 @@ static colored_layout *r_init_shared(cairo_t *c, notification *n) int w = gdk_pixbuf_get_width(pixbuf); int h = gdk_pixbuf_get_height(pixbuf); int larger = w > h ? w : h; - int max_size = 24; - if (larger > max_size) { + if (settings.max_icon_size && larger > settings.max_icon_size) { if (w >= h) { 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); } else { 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); } }