Menu icon: Scale svg files to 22px to prevent them from getting too big

This commit is contained in:
Clement Lefebvre 2016-06-22 15:35:57 +01:00
parent 0bbb37f1cc
commit 79f2e2f4f0
2 changed files with 10 additions and 5 deletions

View File

@ -551,13 +551,17 @@ class MenuWin( object ):
self.do_image(self.buttonIcon, False)
def do_image(self, image_file, saturate):
pixbuf = GdkPixbuf.Pixbuf.new_from_file(image_file)
if image_file.endswith(".svg"):
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(image_file, -1, 22)
else:
pixbuf = GdkPixbuf.Pixbuf.new_from_file(image_file)
if saturate:
GdkPixbuf.Pixbuf.saturate_and_pixelate(pixbuf, pixbuf, 1.5, False)
self.button_icon.set_from_pixbuf(pixbuf)
def createPanelButton( self ):
self.button_icon = Gtk.Image.new_from_file( self.buttonIcon )
self.button_icon = Gtk.Image()
self.do_image(self.buttonIcon, False)
self.systemlabel = Gtk.Label(label= "%s " % self.buttonText )
if os.path.exists("/etc/linuxmint/info"):
import commands
@ -656,7 +660,7 @@ class MenuWin( object ):
def updateButton( self ):
self.systemlabel.set_text( self.buttonText )
self.button_icon.clear()
self.button_icon.set_from_file( self.buttonIcon )
self.do_image(self.buttonIcon, False)
self.sizeButton()
def bind_hot_key (self):

View File

@ -5,7 +5,7 @@ import sys
import gi
gi.require_version("Gtk", "2.0")
from gi.repository import Gtk, Gdk
from gi.repository import Gtk, Gdk, GdkPixbuf
import keybinding
@ -343,7 +343,8 @@ class mintMenuConfig( object ):
def setButtonIcon( self, value ):
self.buttonIconChooser.set_filename(value)
self.buttonIconImage.set_from_file(value)
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(value, -1, 22)
self.buttonIconImage.set_from_pixbuf(pixbuf)
def getShowButtonIcon( self ):
return not self.showButtonIcon.get_active()