https://wiki.sugarlabs.org/index.php?title=User:Walter/favoriteslayout.py&feed=atom&action=history
User:Walter/favoriteslayout.py - Revision history
2024-03-29T15:49:14Z
Revision history for this page on the wiki
MediaWiki 1.35.2
https://wiki.sugarlabs.org/index.php?title=User:Walter/favoriteslayout.py&diff=49186&oldid=prev
Patrol: moved Walter is a wanker 2/favoriteslayout.py to User:Walter/favoriteslayout.py over redirect: revert
2010-03-01T18:26:10Z
<p>moved <a href="/index.php?title=Walter_is_a_wanker_2/favoriteslayout.py&action=edit&redlink=1" class="new" title="Walter is a wanker 2/favoriteslayout.py (page does not exist)">Walter is a wanker 2/favoriteslayout.py</a> to <a href="/go/User:Walter/favoriteslayout.py" title="User:Walter/favoriteslayout.py">User:Walter/favoriteslayout.py</a> over redirect: revert</p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<tr class="diff-title" lang="en">
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 18:26, 1 March 2010</td>
</tr><tr><td colspan="2" class="diff-notice" lang="en"><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>
Patrol
https://wiki.sugarlabs.org/index.php?title=User:Walter/favoriteslayout.py&diff=49100&oldid=prev
Pmv2: moved User:Walter/favoriteslayout.py to Walter is a wanker 2/favoriteslayout.py: Walter is a wanker
2010-03-01T18:19:43Z
<p>moved <a href="/go/User:Walter/favoriteslayout.py" title="User:Walter/favoriteslayout.py">User:Walter/favoriteslayout.py</a> to <a href="/index.php?title=Walter_is_a_wanker_2/favoriteslayout.py&action=edit&redlink=1" class="new" title="Walter is a wanker 2/favoriteslayout.py (page does not exist)">Walter is a wanker 2/favoriteslayout.py</a>: Walter is a wanker</p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<tr class="diff-title" lang="en">
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 18:19, 1 March 2010</td>
</tr><tr><td colspan="2" class="diff-notice" lang="en"><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>
Pmv2
https://wiki.sugarlabs.org/index.php?title=User:Walter/favoriteslayout.py&diff=45665&oldid=prev
Patrol: moved Anal bleaching 3/favoriteslayout.py to User:Walter/favoriteslayout.py over redirect: revert
2010-02-21T23:03:03Z
<p>moved <a href="/index.php?title=Anal_bleaching_3/favoriteslayout.py&action=edit&redlink=1" class="new" title="Anal bleaching 3/favoriteslayout.py (page does not exist)">Anal bleaching 3/favoriteslayout.py</a> to <a href="/go/User:Walter/favoriteslayout.py" title="User:Walter/favoriteslayout.py">User:Walter/favoriteslayout.py</a> over redirect: revert</p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<tr class="diff-title" lang="en">
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 23:03, 21 February 2010</td>
</tr><tr><td colspan="2" class="diff-notice" lang="en"><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>
Patrol
https://wiki.sugarlabs.org/index.php?title=User:Walter/favoriteslayout.py&diff=44496&oldid=prev
Anal bleaching: moved User:Walter/favoriteslayout.py to Anal bleaching 3/favoriteslayout.py: Anal bleaching
2010-02-21T22:15:47Z
<p>moved <a href="/go/User:Walter/favoriteslayout.py" title="User:Walter/favoriteslayout.py">User:Walter/favoriteslayout.py</a> to <a href="/index.php?title=Anal_bleaching_3/favoriteslayout.py&action=edit&redlink=1" class="new" title="Anal bleaching 3/favoriteslayout.py (page does not exist)">Anal bleaching 3/favoriteslayout.py</a>: Anal bleaching</p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<tr class="diff-title" lang="en">
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 22:15, 21 February 2010</td>
</tr><tr><td colspan="2" class="diff-notice" lang="en"><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>
Anal bleaching
https://wiki.sugarlabs.org/index.php?title=User:Walter/favoriteslayout.py&diff=9611&oldid=prev
Walter at 23:31, 13 October 2008
2008-10-13T23:31:54Z
<p></p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 23:31, 13 October 2008</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">==/usr/share/sugar/shell/view/home/favoriteslayout.py==</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><pre></div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><pre></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div># Copyright (C) 2008 One Laptop Per Child</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div># Copyright (C) 2008 One Laptop Per Child</div></td></tr>
</table>
Walter
https://wiki.sugarlabs.org/index.php?title=User:Walter/favoriteslayout.py&diff=9602&oldid=prev
Walter: update for 0.82
2008-10-13T23:03:14Z
<p>update for 0.82</p>
<a href="https://wiki.sugarlabs.org/index.php?title=User:Walter/favoriteslayout.py&diff=9602&oldid=8677">Show changes</a>
Walter
https://wiki.sugarlabs.org/index.php?title=User:Walter/favoriteslayout.py&diff=8677&oldid=prev
Walter: User:Walter/favoritelayout.py moved to User:Walter/favoriteslayout.py
2008-09-10T04:50:02Z
<p><a href="/index.php?title=User:Walter/favoritelayout.py&action=edit&redlink=1" class="new" title="User:Walter/favoritelayout.py (page does not exist)">User:Walter/favoritelayout.py</a> moved to <a href="/go/User:Walter/favoriteslayout.py" title="User:Walter/favoriteslayout.py">User:Walter/favoriteslayout.py</a></p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<tr class="diff-title" lang="en">
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 04:50, 10 September 2008</td>
</tr><tr><td colspan="2" class="diff-notice" lang="en"><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>
Walter
https://wiki.sugarlabs.org/index.php?title=User:Walter/favoriteslayout.py&diff=8658&oldid=prev
Walter at 22:47, 9 September 2008
2008-09-09T22:47:24Z
<p></p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 22:47, 9 September 2008</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l223" >Line 223:</td>
<td colspan="2" class="diff-lineno">Line 223:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> # radius is proportional to index/children_count</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> # radius is proportional to index/children_count</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> myminimum = _MINIMUM_RADIUS * .667</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> myminimum = _MINIMUM_RADIUS * .667</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> newradius = ((radius - myminimum) * (index * 1.1) / children_count)</div></td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> newradius = ((radius - myminimum) * (index * 1.1) / children_count) <ins class="diffchange diffchange-inline">+</ins></div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> <del class="diffchange diffchange-inline">+ </del>myminimum</div></td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> myminimum</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> x = newradius * math.cos(angle) + (width - icon_size) / 2</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> x = newradius * math.cos(angle) + (width - icon_size) / 2</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> y = newradius * math.sin(angle) + (height - icon_size -</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> y = newradius * math.sin(angle) + (height - icon_size -</div></td></tr>
</table>
Walter
https://wiki.sugarlabs.org/index.php?title=User:Walter/favoriteslayout.py&diff=8657&oldid=prev
Walter at 22:44, 9 September 2008
2008-09-09T22:44:21Z
<p></p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 22:44, 9 September 2008</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l218" >Line 218:</td>
<td colspan="2" class="diff-lineno">Line 218:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> def _calculate_position(self, radius, icon_size, index, children_count):</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> def _calculate_position(self, radius, icon_size, index, children_count):</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> width, height = self.box.get_allocation()</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> width, height = self.box.get_allocation()</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> </div></td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline"> # angle decreases as the radius increases</ins></div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> <del class="diffchange diffchange-inline"># go around 2 times, e</del>.<del class="diffchange diffchange-inline">g</del>.<del class="diffchange diffchange-inline">, 4 pi</del></div></td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> <ins class="diffchange diffchange-inline">inc = 12</ins>.<ins class="diffchange diffchange-inline">0 + index / 6</ins>.<ins class="diffchange diffchange-inline">0</ins></div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> angle = index * (<del class="diffchange diffchange-inline">4 </del>* math.pi / <del class="diffchange diffchange-inline">children_count</del>) - math.pi / 2</div></td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> angle = index * (<ins class="diffchange diffchange-inline">2 </ins>* math.pi / <ins class="diffchange diffchange-inline">inc</ins>) - math.pi / 2</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> x = <del class="diffchange diffchange-inline">radius </del>* math.cos(angle) + (width - icon_size) / 2</div></td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline"> # radius is proportional to index/children_count</ins></div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> y = <del class="diffchange diffchange-inline">radius </del>* math.sin(angle) + (height - icon_size -</div></td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline"> myminimum = _MINIMUM_RADIUS * .667</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline"> newradius = ((radius - myminimum) * (index * 1.1) / children_count)</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline"> + myminimum</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> x = <ins class="diffchange diffchange-inline">newradius </ins>* math.cos(angle) + (width - icon_size) / 2</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> y = <ins class="diffchange diffchange-inline">newradius </ins>* math.sin(angle) + (height - icon_size -</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> style.GRID_CELL_SIZE) / 2</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> style.GRID_CELL_SIZE) / 2</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> return x, y</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> return x, y</div></td></tr>
</table>
Walter
https://wiki.sugarlabs.org/index.php?title=User:Walter/favoriteslayout.py&diff=8412&oldid=prev
Walter: New page: <pre> # Copyright (C) 2008 One Laptop Per Child # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published...
2008-08-27T20:01:50Z
<p>New page: <pre> # Copyright (C) 2008 One Laptop Per Child # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published...</p>
<p><b>New page</b></p><div><pre><br />
# Copyright (C) 2008 One Laptop Per Child<br />
#<br />
# This program is free software; you can redistribute it and/or modify<br />
# it under the terms of the GNU General Public License as published by<br />
# the Free Software Foundation; either version 2 of the License, or<br />
# (at your option) any later version.<br />
#<br />
# This program is distributed in the hope that it will be useful,<br />
# but WITHOUT ANY WARRANTY; without even the implied warranty of<br />
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br />
# GNU General Public License for more details.<br />
#<br />
# You should have received a copy of the GNU General Public License<br />
# along with this program; if not, write to the Free Software<br />
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA<br />
<br />
import logging<br />
import math<br />
import hashlib<br />
<br />
import gobject<br />
import gtk<br />
import hippo<br />
<br />
from sugar.graphics import style<br />
from sugar import activity<br />
<br />
from view.home.grid import Grid<br />
<br />
_logger = logging.getLogger('FavoritesLayout')<br />
<br />
_CELL_SIZE = 4<br />
_BASE_SCALE = 1000<br />
<br />
class FavoritesLayout(gobject.GObject, hippo.CanvasLayout):<br />
__gtype_name__ = 'FavoritesLayout'<br />
<br />
def __init__(self):<br />
gobject.GObject.__init__(self)<br />
self.box = None<br />
self.fixed_positions = {}<br />
<br />
def do_set_box(self, box):<br />
self.box = box<br />
<br />
def do_get_height_request(self, for_width):<br />
return 0, gtk.gdk.screen_height() - style.GRID_CELL_SIZE<br />
<br />
def do_get_width_request(self):<br />
return 0, gtk.gdk.screen_width()<br />
<br />
def compare_activities(self, icon_a, icon_b):<br />
return 0<br />
<br />
def append(self, icon, locked=False):<br />
self.box.insert_sorted(icon, 0, self.compare_activities)<br />
if hasattr(icon, 'fixed_position'):<br />
relative_x, relative_y = icon.fixed_position<br />
if relative_x >= 0 and relative_y >= 0:<br />
min_width_, width = self.box.get_width_request()<br />
min_height_, height = self.box.get_height_request(width)<br />
self.fixed_positions[icon] = \<br />
(int(relative_x * _BASE_SCALE / float(width)),<br />
int(relative_y * _BASE_SCALE / float(height)))<br />
<br />
def remove(self, icon):<br />
if icon in self.fixed_positions:<br />
del self.fixed_positions[icon]<br />
self.box.remove(icon)<br />
<br />
def move_icon(self, icon, x, y, locked=False):<br />
if icon not in self.box.get_children():<br />
raise ValueError('Child not in box.')<br />
<br />
if hasattr(icon, 'get_bundle_id') and hasattr(icon, 'get_version'):<br />
min_width_, width = self.box.get_width_request()<br />
min_height_, height = self.box.get_height_request(width)<br />
registry = activity.get_registry()<br />
registry.set_activity_position(<br />
icon.get_bundle_id(), icon.get_version(),<br />
x * width / float(_BASE_SCALE),<br />
y * height / float(_BASE_SCALE))<br />
self.fixed_positions[icon] = (x, y)<br />
<br />
def do_allocate(self, x, y, width, height, req_width, req_height,<br />
origin_changed):<br />
raise NotImplementedError()<br />
<br />
def allow_dnd(self):<br />
return False<br />
<br />
class RandomLayout(FavoritesLayout):<br />
__gtype_name__ = 'RandomLayout'<br />
<br />
def __init__(self):<br />
FavoritesLayout.__init__(self)<br />
<br />
min_width_, width = self.do_get_width_request()<br />
min_height_, height = self.do_get_height_request(width)<br />
<br />
self._grid = Grid(width / _CELL_SIZE, height / _CELL_SIZE)<br />
self._grid.connect('child-changed', self.__grid_child_changed_cb)<br />
<br />
def __grid_child_changed_cb(self, grid, child):<br />
child.emit_request_changed()<br />
<br />
def append(self, icon, locked=False):<br />
FavoritesLayout.append(self, icon, locked)<br />
<br />
min_width_, child_width = icon.get_width_request()<br />
min_height_, child_height = icon.get_height_request(child_width)<br />
min_width_, width = self.box.get_width_request()<br />
min_height_, height = self.box.get_height_request(width)<br />
<br />
if icon in self.fixed_positions:<br />
x, y = self.fixed_positions[icon]<br />
x = min(x, width - child_width)<br />
y = min(y, height - child_height)<br />
elif hasattr(icon, 'get_bundle_id'):<br />
name_hash = hashlib.md5(icon.get_bundle_id())<br />
x = int(name_hash.hexdigest()[:5], 16) % (width - child_width)<br />
y = int(name_hash.hexdigest()[-5:], 16) % (height - child_height)<br />
else:<br />
x = None<br />
y = None<br />
<br />
if x is None or y is None:<br />
self._grid.add(icon,<br />
child_width / _CELL_SIZE, child_height / _CELL_SIZE)<br />
else:<br />
self._grid.add(icon,<br />
child_width / _CELL_SIZE, child_height / _CELL_SIZE,<br />
x / _CELL_SIZE, y / _CELL_SIZE)<br />
<br />
def remove(self, icon):<br />
self._grid.remove(icon)<br />
FavoritesLayout.remove(self, icon)<br />
<br />
def move_icon(self, icon, x, y, locked=False):<br />
self._grid.move(icon, x / _CELL_SIZE, y / _CELL_SIZE, locked)<br />
FavoritesLayout.move_icon(self, icon, x, y, locked)<br />
<br />
def do_allocate(self, x, y, width, height, req_width, req_height,<br />
origin_changed):<br />
for child in self.box.get_layout_children():<br />
# We need to always get requests to not confuse hippo<br />
min_w_, child_width = child.get_width_request()<br />
min_h_, child_height = child.get_height_request(child_width)<br />
<br />
rect = self._grid.get_child_rect(child.item)<br />
child.allocate(rect.x * _CELL_SIZE,<br />
rect.y * _CELL_SIZE,<br />
child_width,<br />
child_height,<br />
origin_changed)<br />
<br />
def allow_dnd(self):<br />
return True<br />
<br />
_MINIMUM_RADIUS = style.XLARGE_ICON_SIZE / 2 + style.DEFAULT_SPACING + \<br />
style.STANDARD_ICON_SIZE * 2<br />
_MAXIMUM_RADIUS = (gtk.gdk.screen_height() - style.GRID_CELL_SIZE) / 2 - \<br />
style.STANDARD_ICON_SIZE - style.DEFAULT_SPACING<br />
<br />
class RingLayout(FavoritesLayout):<br />
__gtype_name__ = 'RingLayout'<br />
<br />
def __init__(self):<br />
FavoritesLayout.__init__(self)<br />
self._locked_children = {}<br />
<br />
def append(self, icon, locked=False):<br />
FavoritesLayout.append(self, icon, locked)<br />
if locked:<br />
child = self.box.find_box_child(icon)<br />
self._locked_children[child] = (0, 0)<br />
<br />
def remove(self, icon):<br />
child = self.box.find_box_child(icon)<br />
if child in self._locked_children:<br />
del self._locked_children[child]<br />
FavoritesLayout.remove(self, icon)<br />
<br />
def move_icon(self, icon, x, y, locked=False):<br />
FavoritesLayout.move_icon(self, icon, x, y, locked)<br />
if locked:<br />
child = self.box.find_box_child(icon)<br />
self._locked_children[child] = (x, y)<br />
<br />
def _calculate_radius_and_icon_size(self, children_count):<br />
angle = 2 * math.pi / children_count<br />
<br />
# what's the radius required without downscaling?<br />
distance = style.STANDARD_ICON_SIZE + style.DEFAULT_SPACING<br />
icon_size = style.STANDARD_ICON_SIZE<br />
<br />
if children_count == 1:<br />
radius = 0<br />
else:<br />
radius = math.sqrt(distance ** 2 /<br />
(math.sin(angle) ** 2 + (math.cos(angle) - 1) ** 2))<br />
<br />
if radius < _MINIMUM_RADIUS:<br />
# we can upscale, if we want<br />
icon_size += style.STANDARD_ICON_SIZE * \<br />
(0.5 * (_MINIMUM_RADIUS - radius) / _MINIMUM_RADIUS)<br />
radius = _MINIMUM_RADIUS<br />
elif radius > _MAXIMUM_RADIUS:<br />
radius = _MAXIMUM_RADIUS<br />
# need to downscale. what's the icon size required?<br />
distance = math.sqrt((radius * math.sin(angle)) ** 2 + \<br />
(radius * (math.cos(angle) - 1)) ** 2)<br />
icon_size = distance - style.DEFAULT_SPACING<br />
<br />
return radius, icon_size<br />
<br />
def _calculate_position(self, radius, icon_size, index, children_count):<br />
width, height = self.box.get_allocation()<br />
<br />
# go around 2 times, e.g., 4 pi<br />
angle = index * (4 * math.pi / children_count) - math.pi / 2<br />
x = radius * math.cos(angle) + (width - icon_size) / 2<br />
y = radius * math.sin(angle) + (height - icon_size -<br />
style.GRID_CELL_SIZE) / 2<br />
return x, y<br />
<br />
def _get_children_in_ring(self):<br />
children_in_ring = [child for child in self.box.get_layout_children() \<br />
if child not in self._locked_children]<br />
return children_in_ring<br />
<br />
def _update_icon_sizes(self):<br />
children_in_ring = self._get_children_in_ring()<br />
radius_, icon_size = \<br />
self._calculate_radius_and_icon_size(len(children_in_ring))<br />
<br />
for child in children_in_ring:<br />
child.item.props.size = icon_size<br />
<br />
def do_allocate(self, x, y, width, height, req_width, req_height,<br />
origin_changed):<br />
children_in_ring = self._get_children_in_ring()<br />
if children_in_ring:<br />
radius, icon_size = \<br />
self._calculate_radius_and_icon_size(len(children_in_ring))<br />
<br />
for n in range(len(children_in_ring)):<br />
child = children_in_ring[n]<br />
<br />
x, y = self._calculate_position(radius, icon_size, n,<br />
len(children_in_ring))<br />
# We need to always get requests to not confuse hippo<br />
min_w_, child_width = child.get_width_request()<br />
min_h_, child_height = child.get_height_request(child_width)<br />
<br />
child.allocate(int(x), int(y), child_width, child_height,<br />
origin_changed)<br />
<br />
# decrease the radius slightly with each icon<br />
radius -= 6;<br />
<br />
for child in self._locked_children.keys():<br />
x, y = self._locked_children[child]<br />
<br />
# We need to always get requests to not confuse hippo<br />
min_w_, child_width = child.get_width_request()<br />
min_h_, child_height = child.get_height_request(child_width)<br />
<br />
child.allocate(int(x), int(y), child_width, child_height,<br />
origin_changed)<br />
<br />
def compare_activities(self, icon_a, icon_b):<br />
if hasattr(icon_a, 'installation_time') and \<br />
hasattr(icon_b, 'installation_time'):<br />
return icon_b.installation_time - icon_a.installation_time<br />
else:<br />
return 0<br />
<br />
</pre></div>
Walter