From 9fa94bbe267e83898ab55ac2e4bdeaafe5a5aacc Mon Sep 17 00:00:00 2001 From: Simon Schampijer Date: Fri, 9 Nov 2007 10:51:43 -0500 Subject: [PATCH 1/2] Display meshbox invite palette menu with colored activity icon #4624 --- NEWS | 1 + lib/sugar/graphics/menuitem.py | 2 +- shell/view/BuddyMenu.py | 30 ++++++++++++++++++++++-------- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index 7825e575..c4ecf3a4 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,4 @@ +* Display meshbox invite palette menu with colored activity icon #4624 * Always checkin to the DS from a new file. (tomeu) Snapshot c682a5e241 diff --git a/lib/sugar/graphics/menuitem.py b/lib/sugar/graphics/menuitem.py index 5b457a53..1b908434 100644 --- a/lib/sugar/graphics/menuitem.py +++ b/lib/sugar/graphics/menuitem.py @@ -19,7 +19,7 @@ import gtk from sugar.graphics.icon import Icon class MenuItem(gtk.ImageMenuItem): - def __init__(self, text_label, icon_name=None): + def __init__(self, text_label=None, icon_name=None): gtk.ImageMenuItem.__init__(self, text_label) if icon_name: icon = Icon(icon_name=icon_name, icon_size=gtk.ICON_SIZE_MENU) diff --git a/shell/view/BuddyMenu.py b/shell/view/BuddyMenu.py index 227f7891..a31f6233 100644 --- a/shell/view/BuddyMenu.py +++ b/shell/view/BuddyMenu.py @@ -22,6 +22,7 @@ import hippo from sugar.graphics.palette import Palette from sugar.graphics.menuitem import MenuItem +from sugar.graphics.icon import Icon from sugar.presence import presenceservice class BuddyMenu(Palette): @@ -89,20 +90,33 @@ class BuddyMenu(Palette): self.menu.append(menu_item) menu_item.show() - self._invite_menu = MenuItem(_('Invite')) + self._invite_menu = MenuItem('') self._invite_menu.connect('activate', self._invite_friend_cb) self.menu.append(self._invite_menu) - self._invite_menu.show() - + home_model = shell_model.get_home() home_model.connect('active-activity-changed', self._cur_activity_changed_cb) - - def _cur_activity_changed_cb(self, home_model, activity_model): - if activity_model is not None: - self._invite_menu.show() - else: + activity = home_model.get_active_activity() + self._update_invite_menu(activity) + + def _update_invite_menu(self, activity): + if activity is None: self._invite_menu.hide() + else: + title = activity.get_title() + label = self._invite_menu.get_children()[0] + label.set_text(_('Invite to %s') % title) + + icon = Icon(file=activity.get_icon_path()) + icon.props.xo_color = activity.get_icon_color() + self._invite_menu.set_image(icon) + icon.show() + + self._invite_menu.show() + + def _cur_activity_changed_cb(self, home_model, activity_model): + self._update_invite_menu(activity_model) def _buddy_icon_changed_cb(self, buddy): pass From 213259233d27d2b83747a42dfc9e2f3bfdbae07c Mon Sep 17 00:00:00 2001 From: Simon Schampijer Date: Fri, 9 Nov 2007 10:52:05 -0500 Subject: [PATCH 2/2] Update News --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index c4ecf3a4..8c32fc60 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -* Display meshbox invite palette menu with colored activity icon #4624 +* Display meshbox invite palette menu with colored activity icon #4624 (erikos) * Always checkin to the DS from a new file. (tomeu) Snapshot c682a5e241