From c010d279fb682bca605d78b98f1cf56423530b64 Mon Sep 17 00:00:00 2001 From: Clement Lefebvre Date: Thu, 9 May 2013 11:02:08 +0100 Subject: [PATCH] Fixed some icons getting too big/small (use bitcoin-qt to reproduce) --- .../linuxmint/mintMenu/plugins/easybuttons.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py b/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py index 059efdb..5eb4dbd 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py +++ b/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py @@ -51,7 +51,8 @@ class IconManager(GObject.GObject): theme.connect("changed", self.themeChanged ) - def getIcon( self, iconName, iconSize ): + def getIcon( self, iconName, iconSize ): + if not iconName: return None @@ -72,8 +73,19 @@ class IconManager(GObject.GObject): realIconName = iconName if iconFileName and not canSetByName and os.path.exists( iconFileName ): - pb = GdkPixbuf.Pixbuf.new_from_file_at_size( iconFileName, iconSize, iconSize ) - image = Gtk.Image.new_from_pixbuf(pb) + icon = GdkPixbuf.Pixbuf.new_from_file_at_size( iconFileName, iconSize, iconSize ) + + # if the actual icon size is to far from the desired size resize it + if icon and (( icon.get_width() - iconSize ) > 5 or ( icon.get_height() - iconSize ) > 5): + if icon.get_width() > icon.get_height(): + newIcon = icon.scale_simple( iconSize, icon.get_height() * iconSize / icon.get_width(), GdkPixbuf.InterpType.BILINEAR ) + else: + newIcon = icon.scale_simple( icon.get_width() * iconSize / icon.get_height(), iconSize, GdkPixbuf.InterpType.BILINEAR ) + del icon + icon = newIcon + + image = Gtk.Image.new_from_pixbuf(icon) + elif canSetByName: image = Gtk.Image() icon_found = False