Ticket #1459: 0001-scale-only-if-bigger-than-bg.patch

File 0001-scale-only-if-bigger-than-bg.patch, 2.9 KB (added by trinidadg, 9 years ago)

Heres the patch solving this bug

  • screenbuil.py

    From a4a9062e3efe80627d7a9574351283cb02242b1f Mon Sep 17 00:00:00 2001
    From: Guillermo Trinidad <gui.trini@gmail.com>
    Date: Sat, 17 Jan 2015 14:22:33 -0200
    Subject: [PATCH] scale only if bigger than background 
    
    The activity used to always scale the characters to be as big as the background,
    not allowing the user to have smaller ones. With this patch,
    the character is only scaled if it is biggen than the background size.
    SL#1459   
    
    Signed-off-by: Guillermo Trinidad <gui.trini@gmail.com>
    ---
     screenbuil.py |   32 +++++++++++++++++++-------------
     1 file changed, 19 insertions(+), 13 deletions(-)
    
    diff --git a/screenbuil.py b/screenbuil.py
    index 29ed2b7..d57826e 100644
    a b class Screen(gtk.DrawingArea): 
    2626    def __init__(self):
    2727        gtk.DrawingArea.__init__(self)
    2828        self.gc = None  # initialized in realize-event handler
    29         self.width  = 0 # updated in size-allocate handler
    30         self.height = 0 # idem
     29        # self.width  = 0 # updated in size-allocate handler
     30        # self.height = 0 # idem
    3131        self.bgpixbuf = None
    3232        self.fgpixbuf = None
    33         self.connect('size-allocate', self.on_size_allocate)
     33        # self.connect('size-allocate', self.on_size_allocate)
    3434        self.connect('expose-event',  self.on_expose_event)
    3535        self.connect('realize',       self.on_realize)
    3636
    3737    def on_realize(self, widget):
    3838        self.gc = widget.window.new_gc()
    3939   
    40     def on_size_allocate(self, widget, allocation):
    41         self.height = self.width = min(allocation.width, allocation.height)
     40    # def on_size_allocate(self, widget, allocation):
     41        # self.height = self.width = min(allocation.width, allocation.height)
    4242   
    4343    def on_expose_event(self, widget, event):
    44         # This is where the drawing takes place
     44        # This is where the drawing takes placie
     45        allocation = self.get_allocation()
     46
     47        value = min(allocation.width, allocation.height)
     48
    4549        if self.bgpixbuf:
    4650            pixbuf = self.bgpixbuf
    47             if pixbuf.get_width != self.width:
    48                 pixbuf = theme.scale(pixbuf, self.width)
     51            if pixbuf.get_width != value:
     52                pixbuf = theme.scale(pixbuf, value)
    4953            widget.window.draw_pixbuf(self.gc, pixbuf, 0, 0, 0, 0, -1, -1, 0, 0)
    50 
    5154        if self.fgpixbuf:
    5255            pixbuf = self.fgpixbuf
    53             if pixbuf.get_width != self.width:
    54                 pixbuf = theme.scale(pixbuf, self.width)
    55             widget.window.draw_pixbuf(self.gc, pixbuf, 0, 0, 0, 0, -1, -1, 0, 0)
    56 
     56            if pixbuf.get_width() > value:
     57                pixbuf = theme.scale(pixbuf, value)
     58            width = height = pixbuf.get_width()
     59            x = (value-width)/2
     60            y = x
     61            widget.window.draw_pixbuf(self.gc, pixbuf, 0, 0, x, y, -1, -1, 0, 0)
     62     
    5763    def draw(self):
    5864        self.queue_draw()