2006-08-28 14:58:21 +02:00
|
|
|
import goocanvas
|
|
|
|
|
2006-08-23 11:52:18 +02:00
|
|
|
from panel.Panel import Panel
|
2006-08-28 14:58:21 +02:00
|
|
|
from sugar.canvas.IconItem import IconItem
|
2006-08-28 18:40:41 +02:00
|
|
|
from sugar.canvas.IconColor import IconColor
|
|
|
|
from sugar.presence import PresenceService
|
|
|
|
|
|
|
|
class BuddyIcon(IconItem):
|
|
|
|
def __init__(self, buddy, **kwargs):
|
|
|
|
IconItem.__init__(self, icon_name='stock-buddy',
|
|
|
|
color=buddy.get_color(), **kwargs)
|
|
|
|
|
|
|
|
class FriendsGroup(goocanvas.Group):
|
|
|
|
def __init__(self, shell, width):
|
|
|
|
goocanvas.Group.__init__(self)
|
|
|
|
|
|
|
|
i = 0
|
|
|
|
while i < 10:
|
|
|
|
icon = IconItem(icon_name='stock-buddy',
|
|
|
|
color=IconColor('white'),
|
|
|
|
y=i * (width + 6), size=width)
|
|
|
|
self.add_child(icon)
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
shell.connect('activity-changed', self.__activity_changed_cb)
|
|
|
|
|
|
|
|
def __activity_changed_cb(self, group, activity):
|
|
|
|
print 'Changed'
|
2006-08-28 14:58:21 +02:00
|
|
|
|
|
|
|
class ActionsBar(goocanvas.Group):
|
|
|
|
def __init__(self, shell, width):
|
|
|
|
goocanvas.Group.__init__(self)
|
|
|
|
self._width = width
|
|
|
|
self._shell = shell
|
|
|
|
|
|
|
|
self._y = 0
|
|
|
|
|
|
|
|
icon = IconItem(icon_name='stock-share', size=self._width)
|
|
|
|
icon.connect('clicked', self.__share_clicked_cb)
|
|
|
|
self.add_icon(icon)
|
|
|
|
|
|
|
|
icon = IconItem(icon_name='stock-invite', size=self._width)
|
|
|
|
icon.connect('clicked', self.__invite_clicked_cb)
|
|
|
|
self.add_icon(icon)
|
|
|
|
|
|
|
|
icon = IconItem(icon_name='stock-chat', size=self._width)
|
|
|
|
icon.connect('clicked', self.__chat_clicked_cb)
|
|
|
|
self.add_icon(icon)
|
|
|
|
|
|
|
|
def add_icon(self, icon):
|
|
|
|
icon.set_property('y', self._y)
|
2006-08-28 16:53:29 +02:00
|
|
|
self._y += (self._width + 6)
|
2006-08-28 14:58:21 +02:00
|
|
|
self.add_child(icon)
|
|
|
|
|
|
|
|
def __share_clicked_cb(self, item):
|
2006-08-28 15:10:31 +02:00
|
|
|
activity = self._shell.get_current_activity()
|
|
|
|
if activity != None:
|
|
|
|
activity.share()
|
2006-08-28 14:58:21 +02:00
|
|
|
|
|
|
|
def __invite_clicked_cb(self, item):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def __chat_clicked_cb(self, item):
|
|
|
|
pass
|
2006-08-23 11:52:18 +02:00
|
|
|
|
|
|
|
class FriendsPanel(Panel):
|
|
|
|
def __init__(self, shell):
|
|
|
|
Panel.__init__(self)
|
2006-08-28 14:58:21 +02:00
|
|
|
self._shell = shell
|
|
|
|
|
|
|
|
def construct(self):
|
|
|
|
Panel.construct(self)
|
|
|
|
|
2006-08-28 18:40:41 +02:00
|
|
|
root = self.get_root()
|
|
|
|
|
2006-08-28 14:58:21 +02:00
|
|
|
actions_bar = ActionsBar(self._shell, self.get_width())
|
2006-08-28 18:40:41 +02:00
|
|
|
root.add_child(actions_bar)
|
|
|
|
|
|
|
|
friends_group = FriendsGroup(self._shell, self.get_width())
|
|
|
|
friends_group.translate(0, 150)
|
|
|
|
root.add_child(friends_group)
|