~doctormo/gdm-commmunity-greeter/efl

« back to all changes in this revision

Viewing changes to GdmGreeter/login.py

  • Committer: Martin Owens
  • Date: 2011-05-25 20:33:29 UTC
  • Revision ID: doctormo@gmail.com-20110525203329-tm4cayb7ucpxy1h0
Fix usability issues:

 * Users click on user shouldn't wait to press enter too
 * Users pressing enter with partially complete usersnames should work
 * Registration finished should give users information.

Show diffs side-by-side

added added

removed removed

Lines of Context:
117
117
        """Event for removing users."""
118
118
        logging.warn("Removing User: '%s'" % uid)
119
119
 
120
 
    def name_changed(self, Widget):
 
120
    def name_changed(self, widget):
121
121
        """Event handler for username textbox, keypress"""
122
 
        content = Widget.get_text()
 
122
        content = widget.get_text()
123
123
        if len(content) >= self.search.get_minimum_key_length():
124
124
            matches = self.generate_matches(content)
125
125
            # Take the user from the last match or from an exact match
126
126
            if len(matches) == 1:
 
127
                if content.lower() == matches[0].lower():
 
128
                    self.name_activated(widget)
127
129
                name = matches[0]
128
130
            else:
129
131
                name = content
142
144
 
143
145
    def name_activated(self, widget):
144
146
        """Event handler for full name textbox, on enter"""
145
 
        widget.set_sensitive(False)
146
147
        name = widget.get_text()
 
148
        matches = self.generate_matches(name)
 
149
        # Don't do anything if the name is too short.
147
150
        if len(name) < self.search.get_minimum_key_length():
148
151
            return
 
152
        # If we only have one match in the shown list, then
 
153
        # Replace the text in the box and return.
 
154
        if len(matches) == 1 and matches[0].lower() != name.lower():
 
155
            return widget.set_text(str(matches[0]))
 
156
        # Disable the box for a login
 
157
        widget.set_sensitive(False)
149
158
        user = self.users.get_user_by_name(name)
150
159
        if user:
151
160
            self.service.AnswerQuery(user['user'])
152
161
        else:
 
162
            if name == name.lower():
 
163
                name = name.title()
153
164
            register = self.load_window('register', real_name=name,
154
165
                users=self.users._users, callback=self.cancel)
155
166