Ticket #3939: 0001-SnowflakeLayout-fix-remaining-issues.patch

File 0001-SnowflakeLayout-fix-remaining-issues.patch, 3.1 KB (added by erikos, 12 years ago)

Snowflakelayout, fix remaining issues

  • src/jarabe/desktop/snowflakelayout.py

    From 9253218586209b4d06663f04c26d3c270e39d07d Mon Sep 17 00:00:00 2001
    From: Simon Schampijer <simon@laptop.org>
    Date: Wed, 17 Oct 2012 09:38:10 +0200
    Subject: [PATCH shell] SnowflakeLayout: fix remaining issues
    
    - remove unneeded style call
    - size_request returns a GtkRequisition
    - use a Gdk.Rectangle to pass to size_allocate
    
    Signed-off-by: Simon Schampijer <simon@laptop.org>
    ---
     src/jarabe/desktop/snowflakelayout.py | 27 +++++++++++++++++++--------
     1 file changed, 19 insertions(+), 8 deletions(-)
    
    diff --git a/src/jarabe/desktop/snowflakelayout.py b/src/jarabe/desktop/snowflakelayout.py
    index 7b33ddd..5ad5f26 100644
    a b  
    1717import math
    1818
    1919from gi.repository import Gtk
     20from gi.repository import Gdk
    2021
    2122from sugar3.graphics import style
    2223
    class SnowflakeLayout(Gtk.Container): 
    3536        self._children = {}
    3637
    3738    def do_realize(self):
    38         # FIXME what is this for?
    3939        self.set_realized(True)
    4040        self.set_window(self.get_parent_window())
    41         self.style.attach(self.window)
    4241        for child in self._children.keys():
    4342            child.set_parent_window(self.get_parent_window())
    4443        self.queue_resize()
    class SnowflakeLayout(Gtk.Container): 
    7877        requisition.height = size
    7978
    8079    def do_size_allocate(self, allocation):
     80        self.set_allocation(allocation)
     81
    8182        r = self._get_radius()
    8283        index = 0
    8384
    8485        for child, centered in self._children.items():
    85             child_width, child_height = child.size_request()
    86             rect = (0, 0, child_width, child_height)
     86            child_request = child.size_request()
     87            child_width, child_height = \
     88                child_request.width, child_request.height
     89            rect = Gdk.Rectangle()
     90            rect.x = 0
     91            rect.y = 0
     92            rect.width = child_width
     93            rect.height = child_height
    8794
    8895            width = allocation.width - child_width
    8996            height = allocation.height - child_height
    class SnowflakeLayout(Gtk.Container): 
    110117        radius = int(_BASE_DISTANCE + _CHILDREN_FACTOR * self._nflakes)
    111118        for child, centered in self._children.items():
    112119            if centered:
    113                 child_w, child_h = child.size_request()
    114                 radius += max(child_w, child_h) / 2
     120                child_request = child.size_request()
     121                child_width, child_height = \
     122                    child_request.width, child_request.height
     123                radius += max(child_width, child_height) / 2
    115124
    116125        return radius
    117126
    118127    def _calculate_size(self):
    119128        thickness = 0
    120129        for child in self._children.keys():
    121             width, height = child.size_request()
    122             thickness = max(thickness, max(width, height))
     130            child_request = child.size_request()
     131            child_width, child_height = \
     132                child_request.width, child_request.height
     133            thickness = max(thickness, max(child_width, child_height))
    123134
    124135        return self._get_radius() * 2 + thickness