2006-08-29 11:48:20 +02:00
|
|
|
import random
|
|
|
|
|
|
|
|
import goocanvas
|
|
|
|
|
2006-09-04 21:34:54 +02:00
|
|
|
import conf
|
2006-08-29 11:48:20 +02:00
|
|
|
from sugar.canvas.IconItem import IconItem
|
2006-09-15 13:23:21 +02:00
|
|
|
from view.home.IconLayout import IconLayout
|
2006-09-25 16:01:11 +02:00
|
|
|
from view.BuddyIcon import BuddyIcon
|
2006-08-30 13:14:37 +02:00
|
|
|
|
2006-08-29 11:48:20 +02:00
|
|
|
class MeshGroup(goocanvas.Group):
|
2006-09-25 16:01:11 +02:00
|
|
|
def __init__(self, shell, menu_shell):
|
2006-08-29 11:48:20 +02:00
|
|
|
goocanvas.Group.__init__(self)
|
2006-09-15 15:28:18 +02:00
|
|
|
|
|
|
|
self._shell = shell
|
2006-09-25 16:01:11 +02:00
|
|
|
self._menu_shell = menu_shell
|
|
|
|
self._model = shell.get_model().get_mesh()
|
|
|
|
self._layout = IconLayout(shell.get_grid())
|
2006-09-15 15:28:18 +02:00
|
|
|
|
2006-09-25 16:01:11 +02:00
|
|
|
for buddy_model in self._model.get_buddies():
|
|
|
|
self._add_buddy(buddy_model)
|
2006-09-12 12:19:20 +02:00
|
|
|
|
2006-09-25 16:01:11 +02:00
|
|
|
self._model.connect('buddy-added', self._buddy_added_cb)
|
2006-09-04 17:00:45 +02:00
|
|
|
|
2006-09-25 16:01:11 +02:00
|
|
|
def _buddy_added_cb(self, model, buddy_model):
|
|
|
|
self._add_buddy(buddy_model)
|
2006-09-04 17:00:45 +02:00
|
|
|
|
2006-09-25 16:01:11 +02:00
|
|
|
def _add_buddy(self, buddy_model):
|
|
|
|
icon = BuddyIcon(self._shell, self._menu_shell, buddy_model)
|
|
|
|
self.add_child(icon)
|
|
|
|
self._layout.add_icon(icon)
|