Complete transition to new spread layout.

This commit is contained in:
Marco Pesenti Gritti
2007-07-06 00:46:12 +02:00
parent cc11d5ebd5
commit f1ecb99207
5 changed files with 42 additions and 26 deletions
+9 -6
View File
@@ -19,21 +19,24 @@ import random
import hippo
import gobject
from sugar.graphics.spreadbox import SpreadBox
from sugar.graphics.spreadlayout import SpreadLayout
from sugar.graphics import units
from view.home.MyIcon import MyIcon
from view.home.FriendView import FriendView
class FriendsBox(SpreadBox):
class FriendsBox(hippo.CanvasBox):
__gtype_name__ = 'SugarFriendsBox'
def __init__(self, shell):
SpreadBox.__init__(self, background_color=0xe2e2e2ff)
hippo.CanvasBox.__init__(self, background_color=0xe2e2e2ff)
self._shell = shell
self._friends = {}
self._layout = SpreadLayout()
self.set_layout(self._layout)
self._my_icon = MyIcon(units.LARGE_ICON_SCALE)
self.set_center_item(self._my_icon)
self._layout.add_center(self._my_icon)
friends = self._shell.get_model().get_friends()
@@ -45,7 +48,7 @@ class FriendsBox(SpreadBox):
def add_friend(self, buddy_info):
icon = FriendView(self._shell, buddy_info)
self.add_item(icon)
self._layout.add(icon)
self._friends[buddy_info.get_key()] = icon
@@ -53,5 +56,5 @@ class FriendsBox(SpreadBox):
self.add_friend(buddy_info)
def _friend_removed_cb(self, data_model, key):
self.remove_item(self._friends[key])
self._layout.remove(self._friends[key])
del self._friends[key]
+11 -11
View File
@@ -215,8 +215,8 @@ class MeshBox(hippo.CanvasBox):
self._buddy_to_activity = {}
self._suspended = True
self.layout = SpreadLayout()
self.set_layout(self.layout)
self._layout = SpreadLayout()
self.set_layout(self._layout)
for buddy_model in self._model.get_buddies():
self._add_alone_buddy(buddy_model)
@@ -280,26 +280,26 @@ class MeshBox(hippo.CanvasBox):
if not mesh:
return
self._mesh = MeshDeviceView(mesh)
self.layout.add(self._mesh)
self._layout.add(self._mesh)
def _remove_mesh(self):
if not self._mesh:
return
self.layout.remove(self._mesh)
self._layout.remove(self._mesh)
self._mesh = None
def _add_alone_buddy(self, buddy_model):
icon = BuddyIcon(self._shell, buddy_model)
if buddy_model.is_owner():
self.layout.add_center(icon)
self._layout.add_center(icon)
else:
self.layout.add(icon)
self._layout.add(icon)
self._buddies[buddy_model.get_key()] = icon
def _remove_alone_buddy(self, buddy_model):
icon = self._buddies[buddy_model.get_key()]
self.layout.remove(icon)
self._layout.remove(icon)
del self._buddies[buddy_model.get_key()]
def _remove_buddy(self, buddy_model):
@@ -326,24 +326,24 @@ class MeshBox(hippo.CanvasBox):
def _add_activity(self, activity_model):
icon = ActivityView(self._shell, activity_model)
self.layout.add(icon)
self._layout.add(icon)
self._activities[activity_model.get_id()] = icon
def _remove_activity(self, activity_model):
icon = self._activities[activity_model.get_id()]
self.layout.remove(icon)
self._layout.remove(icon)
del self._activities[activity_model.get_id()]
def _add_access_point(self, ap_model):
icon = AccessPointView(ap_model)
self.layout.add(icon)
self._layout.add(icon)
self._access_points[ap_model.get_id()] = icon
def _remove_access_point(self, ap_model):
icon = self._access_points[ap_model.get_id()]
self.layout.remove(icon)
self._layout.remove(icon)
del self._access_points[ap_model.get_id()]
def suspend(self):
+7 -4
View File
@@ -19,7 +19,7 @@ import gobject
from sugar.graphics import units
from sugar.graphics import animator
from sugar.graphics.spreadbox import SpreadBox
from sugar.graphics.spreadlayout import SpreadLayout
from view.home.MyIcon import MyIcon
@@ -35,7 +35,7 @@ class _Animation(animator.Animation):
d = (self.end_scale - self.start_scale) * current
self._icon.props.scale = self.start_scale + d
class TransitionBox(SpreadBox):
class TransitionBox(hippo.CanvasBox):
__gtype_name__ = 'SugarTransitionBox'
__gsignals__ = {
@@ -44,12 +44,15 @@ class TransitionBox(SpreadBox):
}
def __init__(self):
SpreadBox.__init__(self, background_color=0xe2e2e2ff)
hippo.CanvasBox.__init__(self, background_color=0xe2e2e2ff)
self._scale = units.XLARGE_ICON_SCALE
self._layout = SpreadLayout()
self.set_layout(self._layout)
self._my_icon = MyIcon(self._scale)
self.set_center_item(self._my_icon)
self._layout.add_center(self._my_icon)
self._animator = animator.Animator(0.3)
self._animator.connect('completed', self._animation_completed_cb)