2006-08-15 12:20:09 +02:00
|
|
|
import goocanvas
|
2006-07-14 15:47:42 +02:00
|
|
|
|
2006-08-26 11:47:02 +02:00
|
|
|
from home.DonutItem import DonutItem
|
2006-09-09 02:34:47 +02:00
|
|
|
from home.MyIcon import MyIcon
|
2006-08-23 13:09:10 +02:00
|
|
|
|
2006-08-17 11:47:41 +02:00
|
|
|
class TasksItem(DonutItem):
|
2006-09-15 12:40:22 +02:00
|
|
|
def __init__(self, shell_model):
|
2006-08-17 13:16:48 +02:00
|
|
|
DonutItem.__init__(self, 250)
|
2006-08-17 12:09:45 +02:00
|
|
|
|
|
|
|
self._items = {}
|
|
|
|
|
2006-09-15 12:40:22 +02:00
|
|
|
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)
|
2006-08-17 12:09:45 +02:00
|
|
|
|
2006-09-15 12:40:22 +02:00
|
|
|
def __activity_opened_cb(self, model, activity):
|
2006-08-17 14:23:52 +02:00
|
|
|
self._add(activity)
|
2006-08-17 12:09:45 +02:00
|
|
|
|
2006-09-15 12:40:22 +02:00
|
|
|
def __activity_closed_cb(self, model, activity):
|
2006-08-17 14:23:52 +02:00
|
|
|
self._remove(activity)
|
2006-08-17 12:09:45 +02:00
|
|
|
|
2006-08-17 14:23:52 +02:00
|
|
|
def _remove(self, activity):
|
|
|
|
item = self._items[activity.get_id()]
|
2006-08-17 14:42:29 +02:00
|
|
|
self.remove_piece(item)
|
2006-08-17 14:23:52 +02:00
|
|
|
del self._items[activity.get_id()]
|
2006-08-17 12:09:45 +02:00
|
|
|
|
2006-08-17 14:23:52 +02:00
|
|
|
def _add(self, activity):
|
|
|
|
icon_name = activity.get_icon_name()
|
2006-08-26 14:17:55 +02:00
|
|
|
icon_color = activity.get_icon_color()
|
2006-09-15 12:40:22 +02:00
|
|
|
print 'Add activity %s' % icon_color.to_string()
|
2006-08-17 14:42:29 +02:00
|
|
|
|
2006-08-29 16:29:56 +02:00
|
|
|
item = self.add_piece(100 / 8, icon_name, icon_color)
|
|
|
|
item.get_icon().connect('clicked',
|
|
|
|
self.__activity_icon_clicked_cb,
|
|
|
|
activity)
|
2006-08-17 14:42:29 +02:00
|
|
|
|
2006-08-17 14:23:52 +02:00
|
|
|
self._items[activity.get_id()] = item
|
2006-08-16 19:55:13 +02:00
|
|
|
|
2006-08-29 16:29:56 +02:00
|
|
|
def __activity_icon_clicked_cb(self, item, activity):
|
|
|
|
activity.present()
|
2006-08-29 14:39:34 +02:00
|
|
|
|
|
|
|
class HomeGroup(goocanvas.Group):
|
2006-09-15 12:40:22 +02:00
|
|
|
def __init__(self, shell_model):
|
2006-08-29 14:39:34 +02:00
|
|
|
goocanvas.Group.__init__(self)
|
|
|
|
|
2006-09-15 12:40:22 +02:00
|
|
|
tasks = TasksItem(shell_model)
|
2006-08-17 11:47:41 +02:00
|
|
|
tasks.translate(600, 450)
|
2006-08-29 11:48:20 +02:00
|
|
|
self.add_child(tasks)
|
2006-08-17 11:47:41 +02:00
|
|
|
|
2006-09-09 02:34:47 +02:00
|
|
|
me = MyIcon(150)
|
2006-08-31 22:29:31 +02:00
|
|
|
me.translate(600 - (me.get_property('size') / 2),
|
|
|
|
450 - (me.get_property('size') / 2))
|
2006-08-29 11:48:20 +02:00
|
|
|
self.add_child(me)
|