~leo.robol/lum/trunk

« back to all changes in this revision

Viewing changes to lum/interface/change_user_password_dialog.py

  • Committer: Leonardo Robol
  • Date: 2010-09-19 15:31:17 UTC
  • Revision ID: git-v1:281ceece5234622daba78fabf0efaf6cc893693c
Moved source to better suit setup.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#
2
 
# -*- coding: utf-8 -*-
3
 
#
4
 
 
5
 
import gtk, os
6
 
from utilities import show_error_dialog, _, create_builder
7
 
 
8
 
# Maximum number of tries for the password
9
 
max_tries = 3
10
 
 
11
 
class lumChangeUserPasswordDialog():
12
 
 
13
 
    def __init__(self, datapath, username, count = 0):
14
 
 
15
 
        # Create the gtk Builder and load interface files
16
 
        self.__builder = create_builder("LumChangeUserPasswordDialog.ui")
17
 
 
18
 
        self.__dialog = self.__builder.get_object("dialog")
19
 
        self.__datapath = datapath
20
 
        self.__username = username
21
 
        self.__count = count + 1
22
 
 
23
 
    def run(self):
24
 
 
25
 
        if self.__count > max_tries:
26
 
            show_error_dialog(_("Maximum number of tries reached, aborting."))
27
 
            return None
28
 
 
29
 
        # References to password entries
30
 
        pe1 = self.__builder.get_object("password_entry_1")
31
 
        pe2 = self.__builder.get_object("password_entry_2")
32
 
        
33
 
        if self.__dialog.run() == 1:
34
 
            pw1 = pe1.get_text()
35
 
            pw2 = pe2.get_text()
36
 
            if (pw1 != pw2):
37
 
                show_error_dialog(_("Passwords do not match"))
38
 
                self.__dialog.destroy()
39
 
                dialog = lumChangeUserPasswordDialog(self.__datapath, self.__username, self.__count)
40
 
                return dialog.run()
41
 
            else:
42
 
                self.__dialog.destroy()
43
 
                return pw1
44
 
        else:
45
 
            self.__dialog.destroy()
46
 
            return None
47
 
                
48