r7059 - in bigboard/trunk/bigboard: . stocks/people
- From: commits mugshot org
- To: online-desktop-list gnome org
- Subject: r7059 - in bigboard/trunk/bigboard: . stocks/people
- Date: Fri, 14 Dec 2007 15:00:20 -0600 (CST)
Author: hp
Date: 2007-12-14 15:00:20 -0600 (Fri, 14 Dec 2007)
New Revision: 7059
Modified:
bigboard/trunk/bigboard/people_tracker.py
bigboard/trunk/bigboard/stocks/people/PeopleStock.py
bigboard/trunk/bigboard/stocks/people/peoplewidgets.py
Log:
merge buddies into contacts that correspond to the buddies; fix the stuck grab issue for the people stock
Modified: bigboard/trunk/bigboard/people_tracker.py
===================================================================
--- bigboard/trunk/bigboard/people_tracker.py 2007-12-14 20:26:26 UTC (rev 7058)
+++ bigboard/trunk/bigboard/people_tracker.py 2007-12-14 21:00:20 UTC (rev 7059)
@@ -345,7 +345,7 @@
for resource in resources:
if resource.class_id == "online-desktop:/p/o/buddy" and resource not in self.__resources:
- resource.connect(self.__buddy_user_changed, "user")
+ resource.connect(self.__buddy_user_changed, "user")
self.__resources = resources
self.__update_resolved()
@@ -373,13 +373,13 @@
old_resolved = self.__resolved
self.__resolved = resolved
- for resource in old_resolved:
- if resource not in self.__resolved:
- self.emit('removed', resource)
+ for person in old_resolved:
+ if person not in self.__resolved:
+ self.emit('removed', person)
- for resource in self.__resolved:
- if resource not in old_resolved:
- self.emit('added', resource)
+ for person in self.__resolved:
+ if person not in old_resolved:
+ self.emit('added', person)
def __buddy_user_changed(self, resource):
self.__update_resolved()
@@ -421,6 +421,99 @@
def __iter__(self):
return self.__items.itervalues()
+## used to allow some resources in a person set to hide others
+class RemoveDuplicatesPersonSet(PersonSet):
+ def __init__(self, source):
+ PersonSet.__init__(self)
+ self.__source = source
+ self.__source.connect('added', self.__on_added)
+ self.__source.connect('removed', self.__on_removed)
+
+ self.__not_included = set()
+ self.__included = set()
+
+ for item in self.__source:
+ self.__on_added(self, self.__source, item)
+
+ def __on_added(self, source, item):
+ ## if we are hidden by anything included, then
+ ## we are not included
+ is_hidden = False
+ for included in self.__included:
+ if self.__is_hidden_by(item, included):
+ is_hidden = True
+ break
+
+ if is_hidden:
+ self.__not_included.add(item)
+ else:
+ ## if we are not hidden, then see if we hide something
+ ## else and add ourselves to the included set
+
+ items_we_hide = []
+ for included in self.__included:
+ if self.__is_hidden_by(included, item):
+ items_we_hide.append(included)
+
+ self.__included.add(item)
+ self.emit('added', item)
+
+ ## remove stuff we hide
+ for hidden in items_we_hide:
+ self.__included.remove(hidden)
+ self.__not_included.add(hidden)
+ self.emit('removed', hidden)
+
+ def __on_removed(self, source, item):
+ ## if we weren't included anyhow, nothing to do
+ if item in self.__not_included:
+ self.__not_included.remove(item)
+ return
+
+ ## if we were included, we might have been hiding
+ ## something else, so we need to see if anything in
+ ## not_included is now included
+ if item in self.__included:
+ self.__included.remove(item)
+ self.emit('removed', item)
+
+ maybe_now_included = []
+ for hidden in self.__not_included:
+ if self.__is_hidden_by(hidden, item):
+ # this item was hidden by us, but
+ # may also be hidden by something else
+ maybe_now_included.append(hidden)
+
+ for maybe_included in maybe_now_included:
+ include = True
+ for may_hide in self.__included:
+ if self.__is_hidden_by(maybe_included, may_hide):
+ include = False
+ break
+ if include:
+ self.__not_included.remove(maybe_included)
+ self.__included.add(maybe_included)
+ self.emit('added', maybe_included)
+
+
+ def __is_hidden_by(self, hidden, hider):
+ ## the eventual idea is that contacts hide IM buddies they
+ ## correspond to (buddies are merged into contacts)
+
+ ## lame hack for testing, since buddies and contacts made from
+ ## buddies have the same display name
+ if hidden.display_name == hider.display_name and hider.is_contact:
+ return True
+ else:
+ return False
+
+ def __str__(self):
+ return str(self.__included)
+
+ def __iter__(self):
+ return self.__included.__iter__()
+
+
class PeopleTracker(Singleton):
"""Singleton object for tracking available users and contacts
@@ -441,7 +534,7 @@
self.xmpp_people = SinglePersonSet()
self.local_people = SinglePersonSet()
- self.people = UnionPersonSet(self.contacts, self.aim_people, self.xmpp_people, self.local_people)
+ self.people = RemoveDuplicatesPersonSet(UnionPersonSet(self.contacts, self.aim_people, self.xmpp_people, self.local_people))
if self.__model.ready:
self.__on_ready()
Modified: bigboard/trunk/bigboard/stocks/people/PeopleStock.py
===================================================================
--- bigboard/trunk/bigboard/stocks/people/PeopleStock.py 2007-12-14 20:26:26 UTC (rev 7058)
+++ bigboard/trunk/bigboard/stocks/people/PeopleStock.py 2007-12-14 21:00:20 UTC (rev 7059)
@@ -105,8 +105,10 @@
def __on_person_removed(self, list, person):
self.__remove_person(person, self.__person_box, self.__person_items)
- def __close_slideout(self, *args):
+ def __close_slideout(self, object=None, action_taken=False):
if self.__slideout:
+ if action_taken:
+ self._panel.action_taken()
self.__slideout.destroy()
self.__slideout = None
self.__slideout_item = None
@@ -121,7 +123,9 @@
self.__slideout_item = item
coords = item.get_screen_coords()
- self.__slideout.slideout_from(coords[0] + item.get_allocation()[0] + 4, coords[1])
+ if not self.__slideout.slideout_from(coords[0] + item.get_allocation()[0] + 4, coords[1]):
+ self.__close_slideout()
+ return
p = ProfileItem(item.get_person(),
border=1,
@@ -129,6 +133,7 @@
self.__slideout.get_root().append(p)
p.connect("close", self.__close_slideout)
+ self.__slideout.connect("close", self.__close_slideout)
return True
Modified: bigboard/trunk/bigboard/stocks/people/peoplewidgets.py
===================================================================
--- bigboard/trunk/bigboard/stocks/people/peoplewidgets.py 2007-12-14 20:26:26 UTC (rev 7058)
+++ bigboard/trunk/bigboard/stocks/people/peoplewidgets.py 2007-12-14 21:00:20 UTC (rev 7059)
@@ -448,7 +448,7 @@
class ProfileItem(hippo.CanvasBox):
__gsignals__ = {
- "close": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ())
+ "close": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (bool,))
}
def __init__(self, person, **kwargs):
@@ -596,10 +596,11 @@
else:
_logger.debug("not removing from network")
- dialog.connect("response", lambda dialog, response_id: remove_from_network_response(dialog, response_id, self.person))
-
- self.emit("close")
+ dialog.connect("response", lambda dialog, response_id: remove_from_network_response(dialog, response_id, self.person))
+ # action_taken = False to leave the stock open which seems nicer in this case
+ self.emit("close", False)
+
dialog.show()
def __create_contact(self, addressType, address):
@@ -617,6 +618,9 @@
elif self.person.xmpp:
self.__create_contact('xmpp', self.person.xmpp)
+ # action_taken = False to leave the stock open which seems nicer in this case
+ self.emit("close", False)
+
def __update_contact_status(self, person):
self.__contact_status_box.remove_all()
try:
@@ -691,18 +695,18 @@
self.__address_box.append(xmpp)
def __on_activate_web(self, canvas_item):
- self.emit("close")
+ self.emit("close", True)
libbig.show_url(self.person.resource.user.homeUrl)
def __on_activate_email(self, canvas_item):
- self.emit("close")
+ self.emit("close", True)
# email should probably cgi.escape except it breaks if you escape the @
os.spawnlp(os.P_NOWAIT, 'gnome-open', 'gnome-open', 'mailto:' + self.person.resource.email)
def __on_activate_aim(self, canvas_item):
- self.emit("close")
+ self.emit("close", True)
_open_aim(self.person.aim)
def __on_activate_xmpp(self, canvas_item):
- self.emit("close")
+ self.emit("close", True)
_open_xmpp(self.person.xmpp)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]