Merge branch 'master' of git+ssh://dcbw@crank.laptop.org/git/sugar

This commit is contained in:
Dan Williams 2006-06-16 15:25:25 -04:00
commit 38565321d5
4 changed files with 47 additions and 17 deletions

View File

@ -31,6 +31,9 @@ class BrowserActivity(activity.Activity):
self._share_service = None
self._model = None
def get_default_type(self):
return _BROWSER_ACTIVITY_TYPE
def _update_shared_location(self):
address = self.embed.get_address()
self._model.set_value('address', address)

View File

@ -9,7 +9,6 @@ from sugar.p2p import network
PRESENCE_SERVICE_TYPE = "_presence_olpc._tcp"
class Buddy(gobject.GObject):
"""Represents another person on the network and keeps track of the
activities and resources they make available for sharing."""

View File

@ -9,7 +9,8 @@ class PresenceWindow(gtk.Window):
_MODEL_COL_NICK = 0
_MODEL_COL_ICON = 1
_MODEL_COL_BUDDY = 2
_MODEL_COL_VISIBLE = 3
def __init__(self, activity_container):
gtk.Window.__init__(self, gtk.WINDOW_POPUP)
@ -23,6 +24,18 @@ class PresenceWindow(gtk.Window):
self._setup_ui()
def _is_buddy_visible(self, buddy):
activity_type = self._activity.get_default_type()
buddy.get_service_of_type(activity, activity_type)
def _update_buddies_visibility(self):
for row in self._buddy_store:
row[_MODEL_COL_VISIBLE] = self._is_buddy_visible(row[_MODEL_COL_BUDDY])
def set_activity(self, activity):
self._activity = activity
self._update_buddies_visibility()
def _setup_ui(self):
vbox = gtk.VBox(False, 6)
vbox.set_border_width(12)
@ -32,9 +45,12 @@ class PresenceWindow(gtk.Window):
vbox.pack_start(label, False)
label.show()
self._buddy_list_model = gtk.ListStore(gobject.TYPE_STRING,
gtk.gdk.Pixbuf,
gobject.TYPE_PYOBJECT)
self._buddy_store = gtk.ListStore(gobject.TYPE_STRING,
gtk.gdk.Pixbuf,
gobject.TYPE_PYOBJECT,
bool)
self._buddy_list_model = self._buddy_store.filter_new()
self._buddy_list_model.set_visible_column(self._MODEL_COL_VISIBLE)
sw = gtk.ScrolledWindow()
sw.set_shadow_type(gtk.SHADOW_IN)
@ -107,9 +123,18 @@ class PresenceWindow(gtk.Window):
aniter = self._buddy_list_model.append(None)
self._buddy_list_model.set(aniter,
self._MODEL_COL_NICK, buddy.get_nick_name(),
self._MODEL_COL_BUDDY, buddy)
self._MODEL_COL_BUDDY, buddy,
self._MODEL_COL_VISIBLE, self._is_buddy_visible(buddy))
buddy.connect('icon-changed', self.__buddy_icon_changed_cb)
buddy.connect('service-added', self.__buddy_service_added_cb)
buddy.connect('service-removed', self.__buddy_service_removed_cb)
def __buddy_service_added_cb(self, buddy, service):
self._update_buddies_visibility()
def __buddy_service_remove_cb(self, buddy, service):
self._update_buddies_visibility()
def _on_buddy_disappeared_cb(self, pservice, buddy):
aniter = self._get_iter_for_buddy(buddy)
if aniter:

View File

@ -250,6 +250,16 @@ class ActivityContainer(dbus.service.Object):
# Create our owner service
self._owner = ShellOwner()
self._presence_window = PresenceWindow(self)
self._presence_window.set_transient_for(self.window)
wm = WindowManager(self._presence_window)
wm.set_width(0.15, WindowManager.SCREEN_RELATIVE)
wm.set_height(1.0, WindowManager.SCREEN_RELATIVE)
wm.set_position(WindowManager.LEFT)
wm.manage()
def show(self):
self.window.show()
@ -259,6 +269,9 @@ class ActivityContainer(dbus.service.Object):
def __focus_error_cb(self, error):
pass
def set_current_activity(self, activity):
self.current_activity = activity
self._presence_window.set_activity(activity)
def notebook_tab_changed(self, notebook, page, page_number):
#print "in notebook_tab_changed"
@ -272,7 +285,7 @@ class ActivityContainer(dbus.service.Object):
self.current_activity.peer_service.lost_focus(reply_handler = self.__focus_reply_cb, error_handler = self.__focus_error_cb)
if self.has_activity(new_activity):
self.current_activity = new_activity
self.set_current_activity(new_activity)
if self.current_activity != None:
if self.has_activity(self.current_activity):
@ -405,16 +418,6 @@ def main():
wm.show()
wm.manage()
presence_window = PresenceWindow(activity_container)
presence_window.set_transient_for(activity_container.window)
wm = WindowManager(presence_window)
wm.set_width(0.15, WindowManager.SCREEN_RELATIVE)
wm.set_height(1.0, WindowManager.SCREEN_RELATIVE)
wm.set_position(WindowManager.LEFT)
wm.manage()
group_chat = GroupChat()
group_chat.set_transient_for(activity_container.window)
group_chat.set_decorated(False)