This commit is contained in:
Jonas Berlin 2017-09-29 11:58:10 +03:00
parent 9e29406bb5
commit ab3b5c2805
4 changed files with 24 additions and 12 deletions

View File

@ -65,6 +65,7 @@ struct settings defaults = {
.browser = "/usr/bin/firefox", .browser = "/usr/bin/firefox",
.min_icon_size = 0,
.max_icon_size = 0, .max_icon_size = 0,
/* paths to default icons */ /* paths to default icons */

View File

@ -116,19 +116,23 @@ GdkPixbuf *icon_pixbuf_scale(GdkPixbuf *pixbuf)
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 landscape = w > h;
int orig_larger = landscape ? w : h;
double larger = orig_larger;
double smaller = landscape ? h : w;
if (settings.min_icon_size && smaller < settings.min_icon_size) {
larger = larger / smaller * settings.min_icon_size;
smaller = settings.min_icon_size;
}
if (settings.max_icon_size && larger > settings.max_icon_size) { if (settings.max_icon_size && larger > settings.max_icon_size) {
int scaled_w = settings.max_icon_size; smaller = smaller / larger * settings.max_icon_size;
int scaled_h = settings.max_icon_size; larger = settings.max_icon_size;
if (w >= h) }
scaled_h = (settings.max_icon_size * h) / w; if ((int) larger != orig_larger) {
else GdkPixbuf *scaled;
scaled_w = (settings.max_icon_size * w) / h; scaled = gdk_pixbuf_scale_simple(pixbuf,
(int) (landscape ? larger : smaller),
GdkPixbuf *scaled = gdk_pixbuf_scale_simple( (int) (landscape ? smaller : larger),
pixbuf,
scaled_w,
scaled_h,
GDK_INTERP_BILINEAR); GDK_INTERP_BILINEAR);
g_object_unref(pixbuf); g_object_unref(pixbuf);
pixbuf = scaled; pixbuf = scaled;

View File

@ -423,6 +423,12 @@ void load_settings(char *cmdline_config_path)
g_free(c); g_free(c);
} }
settings.min_icon_size = option_get_int(
"global",
"min_icon_size", "-min_icon_size", defaults.min_icon_size,
"Scale smaller icons up to this size, set to 0 to disable. If max_icon_size also specified, that has the final say."
);
settings.max_icon_size = option_get_int( settings.max_icon_size = option_get_int(
"global", "global",
"max_icon_size", "-max_icon_size", defaults.max_icon_size, "max_icon_size", "-max_icon_size", defaults.max_icon_size,

View File

@ -75,6 +75,7 @@ struct settings {
char *browser; char *browser;
char **browser_cmd; char **browser_cmd;
enum icon_position icon_position; enum icon_position icon_position;
int min_icon_size;
int max_icon_size; int max_icon_size;
char *icon_path; char *icon_path;
enum follow_mode f_mode; enum follow_mode f_mode;