Display meshbox invite palette menu with colored activity icon #4624

This commit is contained in:
Simon Schampijer 2007-11-09 10:51:43 -05:00
parent 670722bc49
commit 9fa94bbe26
3 changed files with 24 additions and 9 deletions

1
NEWS
View File

@ -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

View File

@ -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)

View File

@ -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