Log In
New Account
  
Home My Page Project Cloud Code Snippets Project Openings Hermes
Summary Lists News SCM
authorAndrew Flegg <andrew@bleb.org>
Tue, 8 Jun 2010 18:28:37 +0000 (19:28 +0100)
committerAndrew Flegg <andrew@bleb.org>
Tue, 8 Jun 2010 18:28:37 +0000 (19:28 +0100)
package/src/org/maemo/hermes/engine/twitter/provider.py

index 777faeb..3f2bfab 100644 (file)
@@ -1,4 +1,5 @@
 import gnome.gconf
+import gtk, hildon
 import org.maemo.hermes.engine.provider
 import org.maemo.hermes.engine.twitter.service
 import twitter
@@ -28,8 +29,62 @@ class Provider(org.maemo.hermes.engine.provider.Provider):
         """Whether or not this provider has any preferences. If it does not,
            open_preferences must NOT be called; as the behaviour is undetermined."""
            
-        return False # Going to use OAuth...
+        return True
+    
+    
+    # -----------------------------------------------------------------------
+    def open_preferences(self, parent):
+        """Show the username/password dialogue."""
+           
+        dialog = gtk.Dialog(self.get_name(), parent)
+        dialog.add_button(_('Disable'), gtk.RESPONSE_NO)
+        dialog.add_button(_('Enable'), gtk.RESPONSE_YES)
+
+        # -- Username...
+        #
+        hbox = gtk.HBox()
+        hbox.pack_start(gtk.Label(_("Username")))
+        
+        username = hildon.Entry(gtk.HILDON_SIZE_FINGER_HEIGHT)
+        username.set_property('is-focus', True)
+        username.set_property('hildon-input-mode', gtk.HILDON_GTK_INPUT_MODE_FULL)
+        # TODO Connect change signal: if blank, disable "Enable"
+        username.set_text(self._gconf.get_string("/apps/maemo/hermes/twitter_user") or '')
+
+        hbox.pack_start(username)
+        dialog.vbox.add(hbox)
+        
+        # -- Password...
+        #
+        hbox = gtk.HBox()
+        hbox.pack_start(gtk.Label(_("Password")))
+        
+        password = hildon.Entry(gtk.HILDON_SIZE_FINGER_HEIGHT)
+        password.set_property('hildon-input-mode', gtk.HILDON_GTK_INPUT_MODE_FULL | gtk.HILDON_GTK_INPUT_MODE_INVISIBLE)
+        # TODO Connect change signal: if blank, disable "Enable"
+        password.set_text(self._gconf.get_string("/apps/maemo/hermes/twitter_pwd") or '')
+        hbox.pack_start(password)
+        dialog.vbox.add(hbox)
+
+        # -- Run the dialogue...
+        #
+        dialog.show_all()
+        result = dialog.run()
+        dialog.hide()
+        if result == gtk.RESPONSE_CANCEL or result == gtk.RESPONSE_DELETE_EVENT:
+            return None
+        self._gconf.set_string("/apps/maemo/hermes/twitter_user", username.get_text())
+        self._gconf.set_string("/apps/maemo/hermes/twitter_pwd", password.get_text())
+        return result == gtk.RESPONSE_YES
+
 
+    # -----------------------------------------------------------------------
+    def get_account_detail(self):
+        """Return the Twitter username."""
+        
+        return self._gconf.get_string("/apps/maemo/hermes/twitter_user")
+    
     
     # -----------------------------------------------------------------------
     def service(self, gui_callback):

Terms of Use    Privacy Policy    Contribution Guidelines    Feedback

Powered By GForge Collaborative Development Environment