2006-08-23 11:52:18 +02:00
|
|
|
import gtk
|
|
|
|
import goocanvas
|
2006-09-04 21:34:54 +02:00
|
|
|
import logging
|
2006-08-23 11:52:18 +02:00
|
|
|
|
2006-09-04 21:34:54 +02:00
|
|
|
import conf
|
2006-08-23 11:52:18 +02:00
|
|
|
from sugar.canvas.IconItem import IconItem
|
2006-08-23 21:03:17 +02:00
|
|
|
from sugar.canvas.IconColor import IconColor
|
2006-09-04 17:00:45 +02:00
|
|
|
from sugar.presence import PresenceService
|
2006-09-07 15:11:51 +02:00
|
|
|
from sugar.canvas.GridLayout import GridGroup
|
2006-09-09 11:43:52 +02:00
|
|
|
from sugar.canvas.GridBox import GridBox
|
2006-08-23 11:52:18 +02:00
|
|
|
|
|
|
|
class ActivityItem(IconItem):
|
2006-09-07 15:11:51 +02:00
|
|
|
def __init__(self, activity):
|
2006-08-25 17:24:39 +02:00
|
|
|
icon_name = activity.get_icon()
|
2006-09-07 15:11:51 +02:00
|
|
|
IconItem.__init__(self, icon_name=icon_name, color=IconColor('white'))
|
2006-08-23 11:52:18 +02:00
|
|
|
self._activity = activity
|
|
|
|
|
2006-09-04 17:00:45 +02:00
|
|
|
def get_bundle_id(self):
|
2006-08-23 11:52:18 +02:00
|
|
|
return self._activity.get_id()
|
|
|
|
|
2006-09-04 17:00:45 +02:00
|
|
|
class InviteItem(IconItem):
|
2006-09-07 15:11:51 +02:00
|
|
|
def __init__(self, invite):
|
2006-09-04 17:00:45 +02:00
|
|
|
IconItem.__init__(self, icon_name=invite.get_icon(),
|
2006-09-07 15:11:51 +02:00
|
|
|
color=invite.get_color())
|
2006-09-04 17:00:45 +02:00
|
|
|
self._invite = invite
|
|
|
|
|
|
|
|
def get_activity_id(self):
|
|
|
|
return self._invite.get_activity_id()
|
|
|
|
|
|
|
|
def get_bundle_id(self):
|
|
|
|
return self._invite.get_bundle_id()
|
|
|
|
|
2006-09-09 11:43:52 +02:00
|
|
|
class BottomPanel(GridBox):
|
2006-09-07 15:11:51 +02:00
|
|
|
def __init__(self, shell, invites):
|
2006-09-09 11:43:52 +02:00
|
|
|
GridBox.__init__(self, GridBox.HORIZONTAL, 14, 6)
|
2006-08-23 11:52:18 +02:00
|
|
|
|
|
|
|
self._shell = shell
|
|
|
|
|
|
|
|
registry = conf.get_activity_registry()
|
|
|
|
for activity in registry.list_activities():
|
|
|
|
if activity.get_show_launcher():
|
|
|
|
self.add_activity(activity)
|
|
|
|
|
2006-09-04 17:00:45 +02:00
|
|
|
for invite in invites:
|
|
|
|
self.add_invite(invite)
|
|
|
|
invites.connect('invite-added', self.__invite_added_cb)
|
|
|
|
|
|
|
|
def __activity_clicked_cb(self, icon):
|
|
|
|
self._shell.start_activity(icon.get_bundle_id())
|
|
|
|
|
|
|
|
def __invite_clicked_cb(self, icon):
|
|
|
|
self._shell.join_activity(icon.get_bundle_id(),
|
|
|
|
icon.get_activity_id())
|
|
|
|
|
|
|
|
def __invite_added_cb(self, invites, invite):
|
|
|
|
self.add_invite(invite)
|
|
|
|
|
2006-08-23 11:52:18 +02:00
|
|
|
def add_activity(self, activity):
|
2006-09-07 15:11:51 +02:00
|
|
|
item = ActivityItem(activity)
|
2006-09-04 17:00:45 +02:00
|
|
|
item.connect('clicked', self.__activity_clicked_cb)
|
|
|
|
self.add_child(item)
|
|
|
|
|
|
|
|
def add_invite(self, invite):
|
2006-09-07 15:11:51 +02:00
|
|
|
item = InviteItem(invite)
|
2006-09-04 17:00:45 +02:00
|
|
|
item.connect('clicked', self.__invite_clicked_cb)
|
2006-08-23 11:52:18 +02:00
|
|
|
self.add_child(item)
|