Split shell in model/view, cleanup things a lot
This commit is contained in:
@@ -33,30 +33,30 @@ class InviteItem(IconItem):
|
||||
return self._invite
|
||||
|
||||
class BottomPanel(CanvasBox):
|
||||
def __init__(self, grid, shell, invites):
|
||||
def __init__(self, grid, shell_model):
|
||||
CanvasBox.__init__(self, grid, CanvasBox.HORIZONTAL, 1)
|
||||
|
||||
self._shell = shell
|
||||
self._shell_model = shell_model
|
||||
self._invite_to_item = {}
|
||||
self._invites = invites
|
||||
self._invites = shell_model.get_invites()
|
||||
|
||||
registry = conf.get_activity_registry()
|
||||
for activity in registry.list_activities():
|
||||
if activity.get_show_launcher():
|
||||
self.add_activity(activity)
|
||||
|
||||
for invite in invites:
|
||||
for invite in self._invites:
|
||||
self.add_invite(invite)
|
||||
invites.connect('invite-added', self.__invite_added_cb)
|
||||
invites.connect('invite-removed', self.__invite_removed_cb)
|
||||
self._invites.connect('invite-added', self.__invite_added_cb)
|
||||
self._invites.connect('invite-removed', self.__invite_removed_cb)
|
||||
|
||||
def __activity_clicked_cb(self, icon):
|
||||
self._shell.start_activity(icon.get_bundle_id())
|
||||
self._shell_model.start_activity(icon.get_bundle_id())
|
||||
|
||||
def __invite_clicked_cb(self, icon):
|
||||
self._invites.remove_invite(icon.get_invite())
|
||||
self._shell.join_activity(icon.get_bundle_id(),
|
||||
icon.get_activity_id())
|
||||
self._shell_model.join_activity(icon.get_bundle_id(),
|
||||
icon.get_activity_id())
|
||||
|
||||
def __invite_added_cb(self, invites, invite):
|
||||
self.add_invite(invite)
|
||||
|
||||
@@ -9,9 +9,11 @@ from frame.PanelWindow import PanelWindow
|
||||
from sugar.canvas.Grid import Grid
|
||||
|
||||
class Frame:
|
||||
def __init__(self, shell, owner):
|
||||
def __init__(self, shell):
|
||||
self._windows = []
|
||||
|
||||
shell_model = shell.get_model()
|
||||
|
||||
model = goocanvas.CanvasModelSimple()
|
||||
root = model.get_root_item()
|
||||
|
||||
@@ -21,7 +23,7 @@ class Frame:
|
||||
grid.set_constraints(bg, 0, 0, 80, 60)
|
||||
root.add_child(bg)
|
||||
|
||||
panel = BottomPanel(grid, shell, owner.get_invites())
|
||||
panel = BottomPanel(grid, shell_model)
|
||||
grid.set_constraints(panel, 5, 55)
|
||||
root.add_child(panel)
|
||||
|
||||
@@ -34,7 +36,7 @@ class Frame:
|
||||
panel_window = PanelWindow(grid, model, 0, 0, 80, 5)
|
||||
self._windows.append(panel_window)
|
||||
|
||||
panel = RightPanel(grid, shell, owner.get_friends())
|
||||
panel = RightPanel(grid, shell_model)
|
||||
grid.set_constraints(panel, 75, 5)
|
||||
root.add_child(panel)
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@ from FriendIcon import FriendIcon
|
||||
from Friends import Friend
|
||||
|
||||
class RightPanel(CanvasBox):
|
||||
def __init__(self, grid, shell, friends):
|
||||
def __init__(self, grid, shell_model):
|
||||
CanvasBox.__init__(self, grid, CanvasBox.VERTICAL, 1)
|
||||
self._shell = shell
|
||||
self._friends = friends
|
||||
self._shell_model = shell_model
|
||||
self._friends = shell_model.get_friends()
|
||||
self._activity_ps = None
|
||||
self._joined_hid = -1
|
||||
self._left_hid = -1
|
||||
@@ -21,11 +21,11 @@ class RightPanel(CanvasBox):
|
||||
self._pservice.connect('activity-appeared',
|
||||
self.__activity_appeared_cb)
|
||||
|
||||
shell.connect('activity-changed', self.__activity_changed_cb)
|
||||
shell_model.connect('activity-changed', self.__activity_changed_cb)
|
||||
|
||||
def add(self, buddy):
|
||||
friend = Friend(buddy.get_name(), buddy.get_color())
|
||||
icon = FriendIcon(self._shell, friend)
|
||||
icon = FriendIcon(self._shell_model, 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.get_current_activity()
|
||||
activity = self._shell_model.get_current_activity()
|
||||
if activity and activity_ps.get_id() == activity.get_id():
|
||||
self._set_activity_ps(activity_ps)
|
||||
|
||||
|
||||
@@ -58,7 +58,8 @@ class TopPanel(goocanvas.Group):
|
||||
self._shell.set_zoom_level(level)
|
||||
|
||||
def __share_clicked_cb(self, item):
|
||||
activity = self._shell.get_current_activity()
|
||||
shell_model = self._shell.get_model()
|
||||
activity = shell_model.get_current_activity()
|
||||
if activity != None:
|
||||
activity.share()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user