Move Facebook's "Clear authorisation" button to a clickable button in
authorAndrew Flegg <andrew@bleb.org>
Tue, 8 Jun 2010 18:36:39 +0000 (19:36 +0100)
committerAndrew Flegg <andrew@bleb.org>
Tue, 8 Jun 2010 18:36:39 +0000 (19:36 +0100)
the dialogue. This is a better UI, and will be consistent with LinkedIn.

package/src/org/maemo/hermes/engine/facebook/provider.py

index a6a0554..820ef26 100644 (file)
@@ -63,7 +63,6 @@ class Provider(org.maemo.hermes.engine.provider.Provider):
         """Open the preferences for this provider as a child of the 'parent' widget."""
 
         dialog = gtk.Dialog(self.get_name(), parent)
-        dialog.add_button(_('Clear'), gtk.RESPONSE_OK)
         dialog.add_button(_('Disable'), gtk.RESPONSE_NO)
         dialog.add_button(_('Enable'), gtk.RESPONSE_YES)
         
@@ -71,25 +70,34 @@ class Provider(org.maemo.hermes.engine.provider.Provider):
         checkbox.set_label(_('Create birthday-only contacts'))
         checkbox.set_active(self._gc.get_bool('/apps/maemo/hermes/facebook_birthday_only'))
         dialog.vbox.add(checkbox)
-        dialog.vbox.add(gtk.Label("\n" + _('Note: authentication via web page') + "\n\n\n"))
+        dialog.vbox.add(gtk.Label("\n" + _('Note: authentication via web page') + "\n"))
         
-        while True:
-            dialog.show_all()
-            result = dialog.run()
-            dialog.hide()
-            if result == gtk.RESPONSE_CANCEL or result == gtk.RESPONSE_DELETE_EVENT:
-                return None
-            elif result == gtk.RESPONSE_OK:
-                self._gc.unset('/apps/maemo/hermes/facebook_session_key')
-                self._gc.unset('/apps/maemo/hermes/facebook_secret_key')
-                self._gc.unset('/apps/maemo/hermes/facebook_uid')
-                self._gc.unset('/apps/maemo/hermes/facebook_user')
-            else:
-                break
+        clear = hildon.Button(gtk.HILDON_SIZE_FINGER_HEIGHT,
+                              hildon.BUTTON_ARRANGEMENT_VERTICAL,
+                              title = _("Clear authorisation"))
+        clear.connect('clicked', self._clear_auth)
+        dialog.vbox.add(clear)
+        
+        dialog.show_all()
+        result = dialog.run()
+        dialog.hide()
+        if result == gtk.RESPONSE_CANCEL or result == gtk.RESPONSE_DELETE_EVENT:
+            return None
     
         self._gc.set_bool('/apps/maemo/hermes/facebook_birthday_only', checkbox.get_active())
         return result == gtk.RESPONSE_YES
+
+
+    # -----------------------------------------------------------------------
+    def _clear_auth(self, event):
+        """Clear Facebook authorisation information. Triggered by pressing
+           the 'clear' button in the preferences dialogue."""
         
+        self._gc.unset('/apps/maemo/hermes/facebook_session_key')
+        self._gc.unset('/apps/maemo/hermes/facebook_secret_key')
+        self._gc.unset('/apps/maemo/hermes/facebook_uid')
+        self._gc.unset('/apps/maemo/hermes/facebook_user')
+
     
     # -----------------------------------------------------------------------
     def service(self, gui_callback):