230 likes | 320 Views
OLPC & Sugarlabs. The NZ Volunteers. Sugar is written in Python. Hacking Sugar. XO-1 /usr/share/sugar/shell/view/home/favoritesview.py XO-1.5 /usr/lib/python2.6/site-packages/jarabe/desktop/favoritesview.py
E N D
OLPC & Sugarlabs The NZ Volunteers
Hacking Sugar XO-1/usr/share/sugar/shell/view/home/favoritesview.pyXO-1.5/usr/lib/python2.6/site-packages/jarabe/desktop/favoritesview.py _LAYOUT_MAP = {RING_LAYOUT: favoriteslayout.RingLayout,#BOX_LAYOUT: favoriteslayout.BoxLayout,#TRIANGLE_LAYOUT: favoriteslayout.TriangleLayout,#SUNFLOWER_LAYOUT: favoriteslayout.SunflowerLayout,RANDOM_LAYOUT: favoriteslayout.RandomLayout}
Spiral View - favoriteslayout.py class MyLayout(RingLayout): __gtype_name__ = 'MyLayout' icon_name = 'view-mylayout' profile_key = 'my-layout' def __init__(self): RingLayout.__init__(self) def _calculate_radius_and_icon_size(self, children_count): return None, style.STANDARD_ICON_SIZE def _calculate_position(self, radius, icon_size, index, children_count): width, height = self.box.get_allocation() # angle decreases as the radius increases angle = index * (2 * math.pi / (12.0 + index / 6.0)) - math.pi / 2 # radius is proportional to index/children_count myminimum = _MINIMUM_RADIUS * .67 newradius = ((_MAXIMUM_RADIUS - myminimum)*(index*1.1)/children_count)+myminimum x = newradius * math.cos(angle) + (width - icon_size) / 2 y = newradius * math.sin(angle) + (height - icon_size - style.GRID_CELL_SIZE) / 2 return x, y
Sprial View (part 2) - favoritesview.py RING_LAYOUT, BOX_LAYOUT, TRIANGLE_LAYOUT, SUNFLOWER_LAYOUT, MY_LAYOUT, RANDOM_LAYOUT = \xrange(6)_LAYOUT_MAP = {RING_LAYOUT: favoriteslayout.RingLayout,BOX_LAYOUT: favoriteslayout.BoxLayout,TRIANGLE_LAYOUT: favoriteslayout.TriangleLayout,SUNFLOWER_LAYOUT: favoriteslayout.SunflowerLayout,MY_LAYOUT: favoriteslayout.MyLayout,RANDOM_LAYOUT: favoriteslayout.RandomLayout}
How can you help? • Join a volunteer group • Download Sugar and try it out - tell your friends • Tweet about OLPC and Sugar • Make a donation
More Information • wiki.laptop.org - OLPC wiki • wiki.sugarlabs.org - Sugarlabs Wiki • www.laptop.org.nz - NZ OLPC Volunteers