Split shell in model/view, cleanup things a lot
This commit is contained in:
@@ -7,12 +7,12 @@ from home.MyIcon import MyIcon
|
||||
from FriendIcon import FriendIcon
|
||||
|
||||
class FriendsGroup(goocanvas.Group):
|
||||
def __init__(self, shell, friends):
|
||||
def __init__(self, shell_model):
|
||||
goocanvas.Group.__init__(self)
|
||||
|
||||
self._shell = shell
|
||||
self._shell_model = shell_model
|
||||
self._icon_layout = IconLayout(1200, 900)
|
||||
self._friends = friends
|
||||
self._friends = shell_model.get_friends()
|
||||
|
||||
me = MyIcon(100)
|
||||
me.translate(600 - (me.get_property('size') / 2),
|
||||
@@ -22,10 +22,10 @@ class FriendsGroup(goocanvas.Group):
|
||||
for friend in self._friends:
|
||||
self.add_friend(friend)
|
||||
|
||||
friends.connect('friend-added', self._friend_added_cb)
|
||||
self._friends.connect('friend-added', self._friend_added_cb)
|
||||
|
||||
def add_friend(self, friend):
|
||||
icon = FriendIcon(self._shell, friend)
|
||||
icon = FriendIcon(self._shell_model, friend)
|
||||
self.add_child(icon)
|
||||
self._icon_layout.add_icon(icon)
|
||||
|
||||
|
||||
@@ -4,19 +4,19 @@ from home.DonutItem import DonutItem
|
||||
from home.MyIcon import MyIcon
|
||||
|
||||
class TasksItem(DonutItem):
|
||||
def __init__(self, shell):
|
||||
def __init__(self, shell_model):
|
||||
DonutItem.__init__(self, 250)
|
||||
|
||||
self._items = {}
|
||||
|
||||
self._shell = shell
|
||||
self._shell.connect('activity_opened', self.__activity_opened_cb)
|
||||
self._shell.connect('activity_closed', self.__activity_closed_cb)
|
||||
self._shell_model = shell_model
|
||||
self._shell_model.connect('activity_opened', self.__activity_opened_cb)
|
||||
self._shell_model.connect('activity_closed', self.__activity_closed_cb)
|
||||
|
||||
def __activity_opened_cb(self, shell, activity):
|
||||
def __activity_opened_cb(self, model, activity):
|
||||
self._add(activity)
|
||||
|
||||
def __activity_closed_cb(self, shell, activity):
|
||||
def __activity_closed_cb(self, model, activity):
|
||||
self._remove(activity)
|
||||
|
||||
def _remove(self, activity):
|
||||
@@ -27,6 +27,7 @@ class TasksItem(DonutItem):
|
||||
def _add(self, activity):
|
||||
icon_name = activity.get_icon_name()
|
||||
icon_color = activity.get_icon_color()
|
||||
print 'Add activity %s' % icon_color.to_string()
|
||||
|
||||
item = self.add_piece(100 / 8, icon_name, icon_color)
|
||||
item.get_icon().connect('clicked',
|
||||
@@ -39,10 +40,10 @@ class TasksItem(DonutItem):
|
||||
activity.present()
|
||||
|
||||
class HomeGroup(goocanvas.Group):
|
||||
def __init__(self, shell):
|
||||
def __init__(self, shell_model):
|
||||
goocanvas.Group.__init__(self)
|
||||
|
||||
tasks = TasksItem(shell)
|
||||
tasks = TasksItem(shell_model)
|
||||
tasks.translate(600, 450)
|
||||
self.add_child(tasks)
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ from home.FriendsGroup import FriendsGroup
|
||||
import sugar
|
||||
|
||||
class HomeWindow(gtk.Window):
|
||||
def __init__(self, shell):
|
||||
def __init__(self, shell_model):
|
||||
gtk.Window.__init__(self)
|
||||
self._shell = shell
|
||||
self._shell_model = shell_model
|
||||
|
||||
self.realize()
|
||||
self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DESKTOP)
|
||||
@@ -23,6 +23,10 @@ class HomeWindow(gtk.Window):
|
||||
self.add(self._nb)
|
||||
self._nb.show()
|
||||
|
||||
self._add_page(HomeGroup(shell_model))
|
||||
self._add_page(FriendsGroup(shell_model))
|
||||
self._add_page(MeshGroup())
|
||||
|
||||
def _add_page(self, group):
|
||||
view = CanvasView()
|
||||
self._nb.append_page(view)
|
||||
@@ -37,11 +41,6 @@ class HomeWindow(gtk.Window):
|
||||
root.add_child(bg)
|
||||
root.add_child(group)
|
||||
|
||||
def set_owner(self, owner):
|
||||
self._add_page(HomeGroup(self._shell))
|
||||
self._add_page(FriendsGroup(self._shell, owner.get_friends()))
|
||||
self._add_page(MeshGroup(self._shell))
|
||||
|
||||
def set_zoom_level(self, level):
|
||||
if level == sugar.ZOOM_HOME:
|
||||
self._nb.set_current_page(0)
|
||||
|
||||
@@ -32,9 +32,8 @@ class ActivityItem(IconItem):
|
||||
return self._service
|
||||
|
||||
class MeshGroup(goocanvas.Group):
|
||||
def __init__(self, shell):
|
||||
def __init__(self):
|
||||
goocanvas.Group.__init__(self)
|
||||
self._shell = shell
|
||||
self._icon_layout = IconLayout(1200, 900)
|
||||
self._activities = {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user