Pass around the shell so that groups can reuse the grid
This commit is contained in:
@@ -7,25 +7,26 @@ from view.home.MyIcon import MyIcon
|
||||
from view.FriendIcon import FriendIcon
|
||||
|
||||
class FriendsGroup(goocanvas.Group):
|
||||
def __init__(self, shell_model):
|
||||
def __init__(self, shell):
|
||||
goocanvas.Group.__init__(self)
|
||||
|
||||
self._shell_model = shell_model
|
||||
self._shell = shell
|
||||
self._icon_layout = IconLayout(1200, 900)
|
||||
self._friends = shell_model.get_friends()
|
||||
|
||||
me = MyIcon(100)
|
||||
me.translate(600 - (me.get_property('size') / 2),
|
||||
450 - (me.get_property('size') / 2))
|
||||
self.add_child(me)
|
||||
|
||||
for friend in self._friends:
|
||||
friends = self._shell.get_model().get_friends()
|
||||
|
||||
for friend in friends:
|
||||
self.add_friend(friend)
|
||||
|
||||
self._friends.connect('friend-added', self._friend_added_cb)
|
||||
friends.connect('friend-added', self._friend_added_cb)
|
||||
|
||||
def add_friend(self, friend):
|
||||
icon = FriendIcon(self._shell_model, friend)
|
||||
icon = FriendIcon(self._shell, friend)
|
||||
self.add_child(icon)
|
||||
self._icon_layout.add_icon(icon)
|
||||
|
||||
|
||||
@@ -4,14 +4,14 @@ from view.home.DonutItem import DonutItem
|
||||
from view.home.MyIcon import MyIcon
|
||||
|
||||
class TasksItem(DonutItem):
|
||||
def __init__(self, shell_model):
|
||||
def __init__(self, shell):
|
||||
DonutItem.__init__(self, 250)
|
||||
|
||||
self._items = {}
|
||||
|
||||
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)
|
||||
shell_model = shell.get_model()
|
||||
shell_model.connect('activity_opened', self.__activity_opened_cb)
|
||||
shell_model.connect('activity_closed', self.__activity_closed_cb)
|
||||
|
||||
def __activity_opened_cb(self, model, activity):
|
||||
self._add(activity)
|
||||
@@ -39,10 +39,10 @@ class TasksItem(DonutItem):
|
||||
activity.present()
|
||||
|
||||
class HomeGroup(goocanvas.Group):
|
||||
def __init__(self, shell_model):
|
||||
def __init__(self, shell):
|
||||
goocanvas.Group.__init__(self)
|
||||
|
||||
tasks = TasksItem(shell_model)
|
||||
tasks = TasksItem(shell)
|
||||
tasks.translate(600, 450)
|
||||
self.add_child(tasks)
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ from view.home.FriendsGroup import FriendsGroup
|
||||
import sugar
|
||||
|
||||
class HomeWindow(gtk.Window):
|
||||
def __init__(self, shell_model):
|
||||
def __init__(self, shell):
|
||||
gtk.Window.__init__(self)
|
||||
self._shell_model = shell_model
|
||||
self._shell = shell
|
||||
|
||||
self.realize()
|
||||
self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DESKTOP)
|
||||
@@ -23,8 +23,8 @@ 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(HomeGroup(shell))
|
||||
self._add_page(FriendsGroup(shell))
|
||||
self._add_page(MeshGroup())
|
||||
|
||||
def _add_page(self, group):
|
||||
|
||||
Reference in New Issue
Block a user