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
|
|
17 | 17 | import math |
18 | 18 | |
19 | 19 | from gi.repository import Gtk |
| 20 | from gi.repository import Gdk |
20 | 21 | |
21 | 22 | from sugar3.graphics import style |
22 | 23 | |
… |
… |
class SnowflakeLayout(Gtk.Container): |
35 | 36 | self._children = {} |
36 | 37 | |
37 | 38 | def do_realize(self): |
38 | | # FIXME what is this for? |
39 | 39 | self.set_realized(True) |
40 | 40 | self.set_window(self.get_parent_window()) |
41 | | self.style.attach(self.window) |
42 | 41 | for child in self._children.keys(): |
43 | 42 | child.set_parent_window(self.get_parent_window()) |
44 | 43 | self.queue_resize() |
… |
… |
class SnowflakeLayout(Gtk.Container): |
78 | 77 | requisition.height = size |
79 | 78 | |
80 | 79 | def do_size_allocate(self, allocation): |
| 80 | self.set_allocation(allocation) |
| 81 | |
81 | 82 | r = self._get_radius() |
82 | 83 | index = 0 |
83 | 84 | |
84 | 85 | 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 |
87 | 94 | |
88 | 95 | width = allocation.width - child_width |
89 | 96 | height = allocation.height - child_height |
… |
… |
class SnowflakeLayout(Gtk.Container): |
110 | 117 | radius = int(_BASE_DISTANCE + _CHILDREN_FACTOR * self._nflakes) |
111 | 118 | for child, centered in self._children.items(): |
112 | 119 | 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 |
115 | 124 | |
116 | 125 | return radius |
117 | 126 | |
118 | 127 | def _calculate_size(self): |
119 | 128 | thickness = 0 |
120 | 129 | 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)) |
123 | 134 | |
124 | 135 | return self._get_radius() * 2 + thickness |