Source

controlcenter / user_add / user_mod.py

Full commit
#!/usr/bin/env python

#    This file is part of controlcenter.
#
#    controlcenter is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License v2 as published by
#    the Free Software Foundation.
#
#    controlcenter is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with controlcenter.  If not, see <http://www.gnu.org/licenses/>.


__author__ = 'Moises Henriquez'
__author_email__ = 'moc.liamg]ta[xnl.E0M'.replace(']ta[', '@')[::-1]

import gtk
from user_add import Account as Account
from user_add import Tab as Tab
from user_add import SectionLabel as SectionLabel
from user_add import LineLabel as LineLabel

def _(str): return str
class Win(gtk.Window):
    '''User add/edit window
        Arguments:
            account:    An Account object representing the account to be edited'''
    def __init__(self, account = None):
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
        self.account = account
        if not self.account: self.account = Account()
        body = gtk.VBox()
        self.add(body)
        self.notebook = gtk.Notebook()
        body.pack_start(self.notebook, True, True, 2)
        self.load_basic_information()
        self.load_privilege_information()
        
    def load_basic_information(self):
        tab = BasicInfo(account = self.account)
        self.notebook.append_page(tab, tab.label)
    def load_privilege_information(self):
        tab = PrivilegeInfo(account = self.account)
        self.notebook.append_page(tab, tab.label)
        
class PrivilegeInfo(Tab):
    
    def __init__(self, account = None):
        Tab.__init__(self, _('Account Privileges'))
        banner = SectionLabel(_('User Privileges'))
        self.pack_start(banner, False, False, 2)
        
        

class BasicInfo(Tab):
    def __init__(self, account = None):
        self.account = account
        Tab.__init__(self, _('Basic Information'))
        banner = SectionLabel(_('Basic Information'))
        self.pack_start(banner, False, False, 4)
        line_login = gtk.HBox()
        login_label = LineLabel(_('Login Name'))
        login_txt = gtk.Entry()
        login_txt.set_property('sensitive', False)
        login_txt.set_text(self.account.login)
        line_login.pack_start(login_label, False, False, 2)
        line_login.pack_start(login_txt, True, True, 2)
        self.pack_start(line_login, False, False, 4)
        
        line_name = gtk.HBox()
        name_label = LineLabel(_('Real Name'))
        name_txt = gtk.Entry()
        name_txt.set_text(self.account.name)
        
        self.pack_start(line_name, False, False, 4)
        line_name.pack_start(name_label, False, False, 2)
        line_name.pack_start(name_txt, True, True, 2)
        
        spacer = gtk.Label()
        self.pack_start(spacer, False, False, 4)
        
        pass_sec = SectionLabel(_('Change Password'))
        self.pack_start(pass_sec, False, False, 4)
        
        line_pass1 = gtk.HBox()
        pass1_label = LineLabel(_('Enter Password'))
        pass1_txt = gtk.Entry()
        pass1_txt.set_property('visibility', False)
        line_pass1.pack_start(pass1_label, False, False, 2)
        line_pass1.pack_start(pass1_txt, True, True, 2)
        self.pack_start(line_pass1, False, False, 4)
        
        line_pass2 = gtk.HBox()
        pass2_label = LineLabel(_('Verify Password'))
        pass2_txt = gtk.Entry()
        pass2_txt.set_property('visibility', False)
        line_pass2.pack_start(pass2_label, False, False, 2)
        line_pass2.pack_start(pass2_txt, True, True, 2)
        self.pack_start(line_pass2, False, False, 4)