api = LinkedInApi(gconf = self._gc)
dialog = gtk.Dialog(self.get_name(), parent)
dialog.add_button(_('Disable'), gtk.RESPONSE_NO)
- dialog.add_button(_('Enable'), gtk.RESPONSE_YES)
+ enable = dialog.add_button(_('Enable'), gtk.RESPONSE_YES)
button = hildon.Button(gtk.HILDON_SIZE_FINGER_HEIGHT,
hildon.BUTTON_ARRANGEMENT_VERTICAL)
- self._handle_button(None, api, button)
- button.connect('clicked', self._handle_button, api, button)
+ self._handle_button(None, api, button, enable)
+ button.connect('clicked', self._handle_button, api, button, enable)
dialog.vbox.add(gtk.Label(""))
dialog.vbox.add(button)
# -----------------------------------------------------------------------
- def _handle_button(self, e, api, button):
+ def _handle_button(self, e, api, button, enable):
"""Ensure the button state is correct."""
authenticated = api.get_access_token_from_gconf() is not None
authenticated = api.get_access_token_from_gconf() is not None
button.set_title(authenticated and _("Clear authorisation") or _("Authorise"))
+ enable.set_sensitive(authenticated)
# -----------------------------------------------------------------------
dialog = gtk.Dialog(self.get_name(), parent)
dialog.add_button(_('Disable'), gtk.RESPONSE_NO)
- dialog.add_button(_('Enable'), gtk.RESPONSE_YES)
+ enable = dialog.add_button(_('Enable'), gtk.RESPONSE_YES)
# -- 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)
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)
+ # -- Enable is only available if both populated...
+ #
+ def _check_fields(e, p):
+ enable.set_sensitive(e.get_text() != '' and p.get_text() != '')
+ username.connect('changed', _check_fields, password)
+ password.connect('changed', _check_fields, username)
+ _check_fields(username, password)
+
# -- Run the dialogue...
#
dialog.show_all()