Replace Menu for Palette.

This commit is contained in:
Tomeu Vizoso
2007-07-01 12:55:10 +02:00
parent aa5d6af260
commit 4aee850af7
13 changed files with 172 additions and 282 deletions
+2 -2
View File
@@ -25,13 +25,13 @@ from model import bundleregistry
from view.BuddyIcon import BuddyIcon
class FriendView(hippo.CanvasBox):
def __init__(self, shell, menu_shell, buddy, **kwargs):
def __init__(self, shell, buddy, **kwargs):
hippo.CanvasBox.__init__(self, **kwargs)
self._pservice = presenceservice.get_instance()
self._buddy = buddy
self._buddy_icon = BuddyIcon(shell, menu_shell, buddy)
self._buddy_icon = BuddyIcon(shell, buddy)
self._buddy_icon.props.scale = units.LARGE_ICON_SCALE
self.append(self._buddy_icon)
+2 -3
View File
@@ -26,11 +26,10 @@ from view.home.FriendView import FriendView
class FriendsBox(SpreadBox):
__gtype_name__ = 'SugarFriendsBox'
def __init__(self, shell, menu_shell):
def __init__(self, shell):
SpreadBox.__init__(self, background_color=0xe2e2e2ff)
self._shell = shell
self._menu_shell = menu_shell
self._friends = {}
self._my_icon = MyIcon(units.LARGE_ICON_SCALE)
@@ -45,7 +44,7 @@ class FriendsBox(SpreadBox):
friends.connect('friend-removed', self._friend_removed_cb)
def add_friend(self, buddy_info):
icon = FriendView(self._shell, self._menu_shell, buddy_info)
icon = FriendView(self._shell, buddy_info)
self.add_item(icon)
self._friends[buddy_info.get_key()] = icon
+2 -5
View File
@@ -124,20 +124,17 @@ class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
def release(self):
pass
# TODO: Most or all of it should move to CanvasIcon.
class HomeMyIcon(MyIcon):
_POPUP_PALETTE_DELAY = 100
def __init__(self, shell, scale):
MyIcon.__init__(self, scale)
self._shell = shell
self._palette = Palette(profile.get_nick_name())
self._palette.props.invoker = CanvasInvoker(self)
self.set_tooltip(profile.get_nick_name())
shutdown_menu_item = gtk.MenuItem(_('Shutdown'))
shutdown_menu_item.connect('activate', self._shutdown_activate_cb)
self._palette.append_menu_item(shutdown_menu_item)
self.get_palette().append_menu_item(shutdown_menu_item)
shutdown_menu_item.show()
def _shutdown_activate_cb(self, menuitem):
+2 -3
View File
@@ -18,7 +18,6 @@ import gtk
import hippo
import cairo
from sugar.graphics.menushell import MenuShell
from sugar.graphics import units
import sugar
@@ -54,8 +53,8 @@ class HomeWindow(gtk.Window):
self.connect('focus-out-event', self._focus_out_cb)
self._home_box = HomeBox(shell)
self._friends_box = FriendsBox(shell, MenuShell(self))
self._mesh_box = MeshBox(shell, MenuShell(self))
self._friends_box = FriendsBox(shell)
self._mesh_box = MeshBox(shell)
self._transition_box = TransitionBox()
self._canvas.set_root(self._home_box)
+5 -6
View File
@@ -163,7 +163,7 @@ class MeshDeviceView(PulsingIcon):
]
class ActivityView(SnowflakeBox):
def __init__(self, shell, menu_shell, model):
def __init__(self, shell, model):
SnowflakeBox.__init__(self)
self._shell = shell
@@ -197,11 +197,10 @@ class ActivityView(SnowflakeBox):
self._shell.join_activity(bundle_id, self._model.get_id())
class MeshBox(SpreadBox):
def __init__(self, shell, menu_shell):
def __init__(self, shell):
SpreadBox.__init__(self, background_color=0xe2e2e2ff)
self._shell = shell
self._menu_shell = menu_shell
self._model = shell.get_model().get_mesh()
self._buddies = {}
self._activities = {}
@@ -281,7 +280,7 @@ class MeshBox(SpreadBox):
self._mesh = None
def _add_alone_buddy(self, buddy_model):
icon = BuddyIcon(self._shell, self._menu_shell, buddy_model)
icon = BuddyIcon(self._shell, buddy_model)
if buddy_model.is_owner():
self.set_center_item(icon)
else:
@@ -313,11 +312,11 @@ class MeshBox(SpreadBox):
else:
activity = self._activities[activity_model.get_id()]
icon = BuddyIcon(self._shell, self._menu_shell, buddy_model)
icon = BuddyIcon(self._shell, buddy_model)
activity.add_buddy_icon(buddy_model.get_key(), icon)
def _add_activity(self, activity_model):
icon = ActivityView(self._shell, self._menu_shell, activity_model)
icon = ActivityView(self._shell, activity_model)
self.add_item(icon)
self._activities[activity_model.get_id()] = icon