r7082 - bigboard/trunk/bigboard/stocks/people



Author: hp
Date: 2007-12-18 16:56:43 -0600 (Tue, 18 Dec 2007)
New Revision: 7082

Modified:
   bigboard/trunk/bigboard/stocks/people/peoplewidgets.py
Log:
add an option menu for choosing the address type being added

Modified: bigboard/trunk/bigboard/stocks/people/peoplewidgets.py
===================================================================
--- bigboard/trunk/bigboard/stocks/people/peoplewidgets.py	2007-12-18 22:42:18 UTC (rev 7081)
+++ bigboard/trunk/bigboard/stocks/people/peoplewidgets.py	2007-12-18 22:56:43 UTC (rev 7082)
@@ -824,9 +824,55 @@
 
         dialog.vbox.pack_start(hbox)
 
+        type_combo = gtk.combo_box_new_text()
+        type_combo.append_text('AIM')
+        type_combo.append_text('Email')
+        type_combo.append_text('GTalk/XMPP')
+        type_combo.set_active(0)
+
+        hbox = gtk.HBox(spacing=10)
+        hbox.pack_start(gtk.Label('Type:'), False, False)
+        hbox.pack_end(type_combo, True, True)
+        
+        hbox.show_all()
+
+        dialog.vbox.pack_start(hbox)
+
         dialog.add_buttons("Cancel", gtk.RESPONSE_CANCEL, "Add", gtk.RESPONSE_ACCEPT)
         dialog.set_default_response(gtk.RESPONSE_ACCEPT)
 
+
+        def combo_get_address_type(combo):
+            visible_type = type_combo.get_active_text()
+            addressType = None
+            if visible_type == 'Email':
+                addressType = 'email'
+            elif visible_type == 'AIM':
+                addressType = 'aim'
+            elif visible_type == 'GTalk/XMPP':
+                addressType = xmpp
+            else:
+                _logger.warn('Bug: unknown combox box text for address type')
+                if '@' in entry.get_text():
+                    addressType = 'email'
+                else:
+                    addressType = 'aim'
+
+            return addressType
+
+        def address_entry_changed(entry):
+            address = entry.get_text()
+            type = combo_get_address_type(type_combo)
+            
+            if '@' in address and type == 'aim':
+                type_combo.set_active(1) ## set to email if an @ is typed
+            elif '@' not in address and type == 'email':
+                type_combo.set_active(0) ## set to AIM if no @ is found
+
+            ## remember that @ can mean either email or xmpp
+
+        entry.connect('changed', address_entry_changed)
+
         def add_address_response(dialog, response_id, person):
             dialog.destroy()
 
@@ -834,13 +880,8 @@
                 _logger.debug("adding address for this person")
 
                 address = entry.get_text()
+                addressType = combo_get_address_type(type_combo)
 
-                ## FIXME have some UI for this
-                if '@' in address:
-                    addressType = 'email'
-                else:
-                    addressType = 'aim'
-
                 model = globals.get_data_model()
                 query = model.update(("http://mugshot.org/p/contacts";, "addContactAddress"),
                                      contact=person.resource, addressType=addressType, address=address)



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