Fix up the right panel, unfinished

This commit is contained in:
Marco Pesenti Gritti 2006-09-08 01:13:42 +02:00
parent d51a00eaec
commit d8d80854d6
2 changed files with 23 additions and 66 deletions

View File

@ -3,7 +3,7 @@ import gobject
import goocanvas import goocanvas
from frame.BottomPanel import BottomPanel from frame.BottomPanel import BottomPanel
#from frame.RightPanel import RightPanel from frame.RightPanel import RightPanel
from frame.TopPanel import TopPanel from frame.TopPanel import TopPanel
from frame.PanelWindow import PanelWindow from frame.PanelWindow import PanelWindow
@ -30,6 +30,13 @@ class Frame:
layout.set_constraints(panel, constraints) layout.set_constraints(panel, constraints)
self._model.add(panel) self._model.add(panel)
constraints = GridConstraints(15, 1, 1, 10)
self._create_window(constraints)
panel = RightPanel(shell, owner.get_friends())
layout.set_constraints(panel, constraints)
self._model.add(panel)
constraints = GridConstraints(0, 11, 16, 1) constraints = GridConstraints(0, 11, 16, 1)
self._create_window(constraints) self._create_window(constraints)
@ -41,10 +48,6 @@ class Frame:
constraints = GridConstraints(0, 1, 1, 10) constraints = GridConstraints(0, 1, 1, 10)
self._create_window(constraints) self._create_window(constraints)
# Right
constraints = GridConstraints(15, 1, 1, 10)
self._create_window(constraints)
self._screen_container.set_layout(self._screen_layout) self._screen_container.set_layout(self._screen_layout)
def _create_window(self, constraints): def _create_window(self, constraints):

View File

@ -3,16 +3,14 @@ import goocanvas
from frame.PanelWindow import PanelWindow from frame.PanelWindow import PanelWindow
from sugar.canvas.IconItem import IconItem from sugar.canvas.IconItem import IconItem
from sugar.canvas.IconColor import IconColor from sugar.canvas.IconColor import IconColor
from sugar.canvas.GridLayout import GridGroup
from sugar.presence import PresenceService from sugar.presence import PresenceService
class FriendsGroup(goocanvas.Group): class RightPanel(GridGroup):
N_BUDDIES = 10 def __init__(self, shell, friends):
GridGroup.__init__(self)
def __init__(self, shell, friends, width):
goocanvas.Group.__init__(self)
self._shell = shell self._shell = shell
self._friends = friends self._friends = friends
self._width = width
self._activity_ps = None self._activity_ps = None
self._joined_hid = -1 self._joined_hid = -1
self._left_hid = -1 self._left_hid = -1
@ -21,59 +19,24 @@ class FriendsGroup(goocanvas.Group):
self._pservice.connect('activity-appeared', self._pservice.connect('activity-appeared',
self.__activity_appeared_cb) self.__activity_appeared_cb)
self._buddies = []
i = 0
while i < FriendsGroup.N_BUDDIES:
self.add_child(self._create_placeholder(i))
self._buddies.append(None)
i += 1
shell.connect('activity-changed', self.__activity_changed_cb) shell.connect('activity-changed', self.__activity_changed_cb)
def add(self, buddy): def add(self, buddy):
i = 0 icon = IconItem(icon_name='stock-buddy',
while i < FriendsGroup.N_BUDDIES: color=IconColor(buddy.get_color()))
if self._buddies[i] == None: icon.connect('clicked', self.__buddy_clicked_cb, buddy)
self._add_buddy(buddy, i)
break constraints = GridConstraints(0, self.get_n_children() + 2, 1, 1)
i += 1 constraints.padding = 6
self._layout.set_constraints(item, constraints)
self.add_child(icon, i)
def remove(self, buddy): def remove(self, buddy):
i = 0 pass
while i < FriendsGroup.N_BUDDIES:
if self._buddies[i] == buddy.get_name():
self._remove_buddy(buddy, i)
break
i += 1
def clear(self): def clear(self):
i = 0 pass
while i < FriendsGroup.N_BUDDIES:
if self._buddies[i] != None:
self._remove_buddy(i)
i += 1
def _get_y(self, i):
return i * (self._width + 6)
def _add_buddy(self, buddy, i):
self.remove_child(i)
icon = IconItem(icon_name='stock-buddy',
color=IconColor(buddy.get_color()),
size=self._width, y=self._get_y(i))
icon.connect('clicked', self.__buddy_clicked_cb, buddy)
self.add_child(icon, i)
self._buddies[i] = buddy.get_name()
def _create_placeholder(self, i):
icon = IconItem(icon_name='stock-buddy', color=IconColor('white'),
y=self._get_y(i), size=self._width)
return icon
def _remove_buddy(self, i):
self.remove_child(i)
self.add_child(self._create_placeholder(i), i)
self._buddies[i] = None
def __activity_appeared_cb(self, pservice, activity_ps): def __activity_appeared_cb(self, pservice, activity_ps):
activity = self._shell.get_current_activity() activity = self._shell.get_current_activity()
@ -116,12 +79,3 @@ class FriendsGroup(goocanvas.Group):
def __buddy_clicked_cb(self, icon, buddy): def __buddy_clicked_cb(self, icon, buddy):
self._friends.add_buddy(buddy) self._friends.add_buddy(buddy)
class ActionsBar(goocanvas.Group):
def __init__(self, shell, width):
goocanvas.Group.__init__(self)
self._width = width
self._shell = shell
self._y = 0