Pass around the shell so that groups can reuse the grid

This commit is contained in:
Marco Pesenti Gritti
2006-09-15 14:24:26 +02:00
parent 5f99dcf9a5
commit 844216585a
10 changed files with 53 additions and 45 deletions
+4 -4
View File
@@ -33,12 +33,12 @@ class InviteItem(IconItem):
return self._invite
class BottomPanel(CanvasBox):
def __init__(self, grid, shell_model):
CanvasBox.__init__(self, grid, CanvasBox.HORIZONTAL, 1)
def __init__(self, shell):
CanvasBox.__init__(self, shell.get_grid(), CanvasBox.HORIZONTAL, 1)
self._shell_model = shell_model
self._shell_model = shell.get_model()
self._invite_to_item = {}
self._invites = shell_model.get_invites()
self._invites = self._shell_model.get_invites()
registry = conf.get_activity_registry()
for activity in registry.list_activities():
+4 -6
View File
@@ -12,31 +12,29 @@ class Frame:
def __init__(self, shell):
self._windows = []
shell_model = shell.get_model()
model = goocanvas.CanvasModelSimple()
root = model.get_root_item()
grid = Grid()
grid = shell.get_grid()
bg = goocanvas.Rect(fill_color="#4f4f4f", line_width=0)
grid.set_constraints(bg, 0, 0, 80, 60)
root.add_child(bg)
panel = BottomPanel(grid, shell_model)
panel = BottomPanel(shell)
grid.set_constraints(panel, 5, 55)
root.add_child(panel)
panel_window = PanelWindow(grid, model, 0, 55, 80, 5)
self._windows.append(panel_window)
panel = TopPanel(grid, shell)
panel = TopPanel(shell)
root.add_child(panel)
panel_window = PanelWindow(grid, model, 0, 0, 80, 5)
self._windows.append(panel_window)
panel = RightPanel(grid, shell_model)
panel = RightPanel(shell)
grid.set_constraints(panel, 75, 5)
root.add_child(panel)
+7 -7
View File
@@ -8,10 +8,9 @@ from view.FriendIcon import FriendIcon
from model.Friends import Friend
class RightPanel(CanvasBox):
def __init__(self, grid, shell_model):
CanvasBox.__init__(self, grid, CanvasBox.VERTICAL, 1)
self._shell_model = shell_model
self._friends = shell_model.get_friends()
def __init__(self, shell):
CanvasBox.__init__(self, shell.get_grid(), CanvasBox.VERTICAL, 1)
self._shell = shell
self._activity_ps = None
self._joined_hid = -1
self._left_hid = -1
@@ -21,11 +20,12 @@ class RightPanel(CanvasBox):
self._pservice.connect('activity-appeared',
self.__activity_appeared_cb)
shell_model.connect('activity-changed', self.__activity_changed_cb)
shell.get_model().connect('activity-changed',
self.__activity_changed_cb)
def add(self, buddy):
friend = Friend(buddy.get_name(), buddy.get_color())
icon = FriendIcon(self._shell_model, friend)
icon = FriendIcon(self._shell, friend)
icon.set_popup_distance(1)
self.set_constraints(icon, 3, 3)
self.add_child(icon)
@@ -42,7 +42,7 @@ class RightPanel(CanvasBox):
self._buddies = {}
def __activity_appeared_cb(self, pservice, activity_ps):
activity = self._shell_model.get_current_activity()
activity = self._shell.get_model().get_current_activity()
if activity and activity_ps.get_id() == activity.get_id():
self._set_activity_ps(activity_ps)
+5 -4
View File
@@ -5,14 +5,15 @@ from sugar.canvas.IconItem import IconItem
import sugar
class TopPanel(goocanvas.Group):
def __init__(self, grid, shell):
def __init__(self, shell):
goocanvas.Group.__init__(self)
self._grid = grid
self._shell = shell
grid = shell.get_grid()
box = CanvasBox(grid, CanvasBox.HORIZONTAL, 1)
self._grid.set_constraints(box, 5, 0)
grid.set_constraints(box, 5, 0)
self.add_child(box)
icon = IconItem(icon_name='stock-zoom-activity')
@@ -36,7 +37,7 @@ class TopPanel(goocanvas.Group):
box.add_child(icon)
box = CanvasBox(grid, CanvasBox.HORIZONTAL, 1)
self._grid.set_constraints(box, 60, 0)
grid.set_constraints(box, 60, 0)
self.add_child(box)
icon = IconItem(icon_name='stock-share')