Example #1
0
    def __init__(self, server):
        """
        Constructor
        
        @param server - the server which needs a password
        """
        gtk.Dialog.__init__(self, 'RCON Password needed!', None,\
                              gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)

        self.server = server
        #buttons
        okbutton = gtk.Button('OK')
        cancelbutton = gtk.Button('Cancel')

        okbutton.connect("clicked", self.on_ok_clicked)
        cancelbutton.connect("clicked", self.on_cancel_clicked)

        self.action_area.pack_start(cancelbutton, False, False)
        self.action_area.pack_start(okbutton, False, False)

        #content area
        desc_label = gtk.Label('Please enter the RCON password for:')
        namelabel = gtk.Label('Servername: ' + server.getName())
        addresslabel = gtk.Label('Serveraddress: ' + server.getaddress())
        self.passentry = gtk.Entry()
        self.passentry.set_visibility(False)
        self.passentry.set_text('')
        self.remembercheckbutton = gtk.CheckButton('remember password')
        self.remembercheckbutton.set_active(False)

        self.vbox.pack_start(desc_label, False, False)
        self.vbox.pack_start(namelabel, False, False)
        self.vbox.pack_start(addresslabel, False, False)
        self.vbox.pack_start(self.passentry, False, False)
        self.vbox.pack_start(self.remembercheckbutton, False, False)

        #check if there is a stored rcon pw for the server
        fm = FileManager()
        rconpws = fm.get_rcon_passwords()
        if server.getaddress() in rconpws:
            pw = rconpws[server.getaddress()]

            self.passentry.set_text(pw)
            self.remembercheckbutton.set_active(True)

        self.show_all()
Example #2
0
    def on_ok_clicked(self, widget):
        """
            Callback of the OK button
            """
        #get the entered password
        self.server.rconpass = self.passentry.get_text()

        #store the password if checkbox is active
        if self.remembercheckbutton.get_active():
            fm = FileManager()
            rconpws = fm.get_rcon_passwords()
            rconpws[self.server.getaddress()] = self.server.rconpass
            fm.save_rcon_passwords()

        #display the rcon window
        rconwin = RconWindow(self.server)
        rconwin.show_now()
        self.destroy()