r6954 - in bigboard/trunk/bigboard: . stocks/people



Author: hp
Date: 2007-12-04 14:44:14 -0600 (Tue, 04 Dec 2007)
New Revision: 6954

Modified:
   bigboard/trunk/bigboard/people_tracker.py
   bigboard/trunk/bigboard/stocks/people/peoplewidgets.py
Log:
enable GTalk/XMPP IM status link, and fix sorting by status which was broken due to change to contacts instead of users

Modified: bigboard/trunk/bigboard/people_tracker.py
===================================================================
--- bigboard/trunk/bigboard/people_tracker.py	2007-12-04 20:19:04 UTC (rev 6953)
+++ bigboard/trunk/bigboard/people_tracker.py	2007-12-04 20:44:14 UTC (rev 6954)
@@ -421,7 +421,7 @@
 def sort_people(a,b):
     if a.is_contact:
         try:
-            statusA = a.resource.status
+            statusA = a.resource.user.status
         except AttributeError:
             statusA = 0
     else:
@@ -429,7 +429,7 @@
 
     if b.is_contact:
         try:
-            statusB = b.resource.status
+            statusB = b.resource.user.status
         except AttributeError:
             statusB = 0
     else:

Modified: bigboard/trunk/bigboard/stocks/people/peoplewidgets.py
===================================================================
--- bigboard/trunk/bigboard/stocks/people/peoplewidgets.py	2007-12-04 20:19:04 UTC (rev 6953)
+++ bigboard/trunk/bigboard/stocks/people/peoplewidgets.py	2007-12-04 20:44:14 UTC (rev 6954)
@@ -21,8 +21,8 @@
     os.spawnlp(os.P_NOWAIT, 'gnome-open', 'gnome-open', 'aim:goim?screenname=' + cgi.escape(aim))
 
 def _open_xmpp(xmpp):
-    # FIXME
-    pass
+    # FIXME, is there some less hardcoded way to do this?
+    os.spawnlp(os.P_NOWAIT, 'purple-remote', 'purple-remote', 'jabber:goim?screenname=' + cgi.escape(xmpp))
 
 def _open_webdav(url):
     # We pass around WebDAV URL's using the standard http:// scheme, but nautilus wants dav://
@@ -56,7 +56,7 @@
                                       size_mode=hippo.CANVAS_SIZE_ELLIPSIZE_END)
         self.__details_box.append(self.__name)
 
-        self.__presence_box = CanvasHBox()
+        self.__presence_box = CanvasHBox(spacing=4)
         self.__details_box.append(self.__presence_box)
         
         self.__statuses = []
@@ -68,6 +68,7 @@
         self.__pressed = False
 
         self.__aim_icon = None
+        self.__xmpp_icon = None
 
         self.__current_track = None
         self.__current_track_timeout = None
@@ -91,9 +92,11 @@
         self.person.connect('icon-url-changed', self.__update)
         
         self.person.connect('aim-buddy-changed', self.__update_aim_buddy)
+        self.person.connect('xmpp-buddy-changed', self.__update_xmpp_buddy)
         
         self.__update(self.person)
         self.__update_aim_buddy(self.person)
+        self.__update_xmpp_buddy(self.person)
 
     def __update_color(self):
         if self.__pressed:
@@ -146,6 +149,16 @@
                 self.__aim_icon.destroy()
                 self.__aim_icon = None
 
+    def __update_xmpp_buddy(self, person):
+        if person.xmpp_buddy:
+            if not self.__xmpp_icon:
+                self.__xmpp_icon = XMPPIcon(person.xmpp_buddy)
+                self.__presence_box.append(self.__xmpp_icon)
+        else:
+            if self.__xmpp_icon:
+                self.__xmpp_icon.destroy()
+                self.__xmpp_icon = None
+
     def __timeout_track(self):
         self.__current_track_timeout = None
         self.__update_current_track(self.person.resource)
@@ -241,29 +254,58 @@
     def __launch_browser(self):
         libbig.show_url(self.__acct.link)
 
-class AimIcon(hippo.CanvasText, DataBoundItem):
+class IMIcon(hippo.CanvasLink, DataBoundItem):
     def __init__(self, buddy):
-        hippo.CanvasText.__init__(self)
+        hippo.CanvasLink.__init__(self)
         DataBoundItem.__init__(self, buddy)
         
-        self.connect("activated", self.__open_aim)
-        self.set_clickable(True)
+        self.connect("activated", self.__on_activated)
 
         self.connect_resource(self.__update)
         self.__update(self.resource)
-        
+
+    def _get_protocol_name(self):
+        raise Exception("implement me")
+
+    def _start_conversation(self):
+        raise Exception("implement me")
+
     def __update(self, buddy):
-        if buddy.status == "Available":
-            markup = "<b>AIM</b> "
-        else:
-            markup = "AIM "
-        self.set_property("markup", markup)
+        text = "%s (%s)" % (self._get_protocol_name(), buddy.status)
+        self.set_property("text", text)
         self.set_property("tooltip", "Chat with %s (%s)" % (buddy.name, buddy.status,))
+        self.set_clickable(buddy.isOnline)
+
+    def __on_activated(self, object):
+        self._start_conversation()
+
+
+class AimIcon(IMIcon):
+    def __init__(self, buddy):
+        IMIcon.__init__(self, buddy)        
         
-    def __open_aim(self, object):
+    def _get_protocol_name(self):
+        return "AIM"
+
+    def _start_conversation(self):
         _open_aim(self.resource.name)
         return True
 
+class XMPPIcon(IMIcon):
+    def __init__(self, buddy):
+        IMIcon.__init__(self, buddy)        
+        
+    def _get_protocol_name(self):
+        if 'gmail.com' in self.resource.name:
+            return "GTalk"
+        else:
+            return "XMPP"
+
+    def _start_conversation(self):
+        _open_xmpp(self.resource.name)
+        return True
+
+
 #
 # The CanvasText item thinks that you always want the full text as the tooltip when
 # ellipsized, but we are doing our own "tooltip" that is cooler and contains album art
@@ -275,7 +317,7 @@
     def do_get_tooltip(self,x,y,for_area):
         return ""
 
-gobject.type_register(NoTooltipText)    
+gobject.type_register(NoTooltipText)
     
 class TrackItem(hippo.CanvasBox, DataBoundItem):
     __gsignals__ = {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]