Account_modification_window dosn't take a dict as argument but he name of the account

This commit is contained in:
Yann Leboulanger 2005-04-14 23:00:25 +00:00
parent 60f2ef8adc
commit a4b334cd03
2 changed files with 65 additions and 82 deletions

View File

@ -908,41 +908,35 @@ class Account_modification_window:
proxyport_entry = self.xml.get_widget('proxyport_entry') proxyport_entry = self.xml.get_widget('proxyport_entry')
self.on_checkbutton_toggled(widget, [proxyhost_entry, proxyport_entry]) self.on_checkbutton_toggled(widget, [proxyhost_entry, proxyport_entry])
def init_account(self, infos): def init_account(self):
"""Initialize window with defaults values""" """Initialize window with defaults values"""
if infos.has_key('accname'): self.xml.get_widget('name_entry').set_text(self.account)
self.xml.get_widget('name_entry').set_text(infos['accname']) jid = gajim.config.get_per('accounts', self.account, 'name') + '@' + \
if infos.has_key('jid'): gajim.config.get_per('accounts', self.account, 'hostname')
self.xml.get_widget('jid_entry').set_text(infos['jid']) self.xml.get_widget('jid_entry').set_text(jid)
if infos.has_key('savepass'): self.xml.get_widget('save_password_checkbutton').set_active( \
self.xml.get_widget('save_password_checkbutton').set_active(\ gajim.config.get_per('accounts', self.account, 'savepass'))
infos['savepass']) if gajim.config.get_per('accounts', self.account, 'savepass'):
if infos['savepass']: password_entry = self.xml.get_widget('password_entry')
password_entry = self.xml.get_widget('password_entry') password_entry.set_sensitive(True)
password_entry.set_sensitive(True) password_entry.set_text(gajim.config.get_per('accounts', self.account,\
if infos.has_key('password'): 'password'))
password_entry.set_text(infos['password']) self.xml.get_widget('resource_entry').set_text(gajim.config.get_per( \
if infos.has_key('resource'): 'accounts', self.account, 'resource'))
self.xml.get_widget('resource_entry').set_text(infos['resource']) self.xml.get_widget('priority_spinbutton').set_value(gajim.config.\
if infos.has_key('priority'): get_per('accounts', self.account, 'priority'))
self.xml.get_widget('priority_spinbutton').set_value(infos['priority'])
use_proxy = False use_proxy = gajim.config.get_per('accounts', self.account, 'use_proxy')
if infos.has_key('use_proxy'): self.xml.get_widget('use_proxy_checkbutton').set_active(use_proxy)
if infos['use_proxy'] != 0:
use_proxy = True
self.xml.get_widget('use_proxy_checkbutton').\
set_active(infos['use_proxy'])
self.xml.get_widget('proxyhost_entry').set_sensitive(use_proxy) self.xml.get_widget('proxyhost_entry').set_sensitive(use_proxy)
self.xml.get_widget('proxyport_entry').set_sensitive(use_proxy) self.xml.get_widget('proxyport_entry').set_sensitive(use_proxy)
if infos.has_key('proxyhost'): self.xml.get_widget('proxyhost_entry').set_text(gajim.config.get_per( \
self.xml.get_widget('proxyhost_entry').set_text(infos['proxyhost']) 'accounts', self.account, 'proxyhost'))
if infos.has_key('proxyport'): self.xml.get_widget('proxyport_entry').set_text(str(gajim.config.get_per(\
self.xml.get_widget('proxyport_entry').set_text(str(\ 'accounts', self.account, 'proxyport')))
infos['proxyport']))
gpg_key_label = self.xml.get_widget('gpg_key_label') gpg_key_label = self.xml.get_widget('gpg_key_label')
@ -950,31 +944,31 @@ class Account_modification_window:
gpg_key_label.set_text('GPG is not usable on this computer') gpg_key_label.set_text('GPG is not usable on this computer')
self.xml.get_widget('gpg_choose_button').set_sensitive(False) self.xml.get_widget('gpg_choose_button').set_sensitive(False)
else: else:
if infos.has_key('keyid'): if gajim.config.get_per('accounts', self.account, 'keyid') and \
if infos['keyid'] and gajim.config.get('usegpg'): gajim.config.get('usegpg'):
gpg_key_label.set_text(infos['keyid']) gpg_key_label.set_text(gajim.config.get_per('accounts', \
if infos.has_key('keyname'): self.account, 'keyid'))
self.xml.get_widget('gpg_name_label').set_text(infos['keyname']) self.xml.get_widget('gpg_name_label').set_text(gajim.config.\
gpg_save_password_checkbutton = \ get_per('accounts', self.account, 'keyname'))
self.xml.get_widget('gpg_save_password_checkbutton') gpg_save_password_checkbutton = \
gpg_save_password_checkbutton.set_sensitive(True) self.xml.get_widget('gpg_save_password_checkbutton')
if infos.has_key('savegpgpass'): gpg_save_password_checkbutton.set_sensitive(True)
gpg_save_password_checkbutton.set_active(infos['savegpgpass']) gpg_save_password_checkbutton.set_active(gajim.config.get_per( \
if infos['savegpgpass']: 'accounts', self.account, 'savegpgpass'))
gpg_password_entry = self.xml.get_widget('gpg_password_entry') if gajim.config.get_per('accounts', self.account, 'savegpgpass'):
gpg_password_entry.set_sensitive(True) gpg_password_entry = self.xml.get_widget('gpg_password_entry')
if infos.has_key('gpgpassword'): gpg_password_entry.set_sensitive(True)
gpg_password_entry.set_text(infos['gpgpassword']) gpg_password_entry.set_text(gajim.config.get_per('accounts', \
if infos.has_key('autoconnect'): self.account, 'gpgpassword'))
self.xml.get_widget('autoconnect_checkbutton').set_active(\ self.xml.get_widget('autoconnect_checkbutton').set_active(gajim.config.\
infos['autoconnect']) get_per('accounts', self.account, 'autoconnect'))
if infos.has_key('sync_with_global_status'): self.xml.get_widget('sync_with_global_status_checkbutton').set_active( \
self.xml.get_widget('sync_with_global_status_checkbutton').set_active(\ gajim.config.get_per('accounts', self.account, \
infos['sync_with_global_status']) 'sync_with_global_status'))
if infos.has_key('no_log_for'): list_no_log_for = gajim.config.get_per('accounts', self.account, \
list_no_log_for = infos['no_log_for'].split() 'no_log_for').split()
if infos['accname'] in list_no_log_for: if self.account in list_no_log_for:
self.xml.get_widget('log_history_checkbutton').set_active(0) self.xml.get_widget('log_history_checkbutton').set_active(0)
def on_save_button_clicked(self, widget): def on_save_button_clicked(self, widget):
"""When save button is clicked: Save information in config file""" """When save button is clicked: Save information in config file"""
@ -996,14 +990,15 @@ class Account_modification_window:
if self.xml.get_widget('autoconnect_checkbutton').get_active(): if self.xml.get_widget('autoconnect_checkbutton').get_active():
autoconnect = 1 autoconnect = 1
if not self.infos.has_key('no_log_for'): if self.account:
self.infos['no_log_for'] = '' list_no_log_for = gajim.config.get_per('accounts', self.account, \
list_no_log_for = self.infos['no_log_for'].split() 'no_log_for').split()
else:
list_no_log_for = []
if self.account in list_no_log_for: if self.account in list_no_log_for:
list_no_log_for.remove(self.account) list_no_log_for.remove(self.account)
if not self.xml.get_widget('log_history_checkbutton').get_active(): if not self.xml.get_widget('log_history_checkbutton').get_active():
list_no_log_for.append(name) list_no_log_for.append(name)
self.infos['no_log_for'] = ' '.join(list_no_log_for)
sync_with_global_status = 0 sync_with_global_status = 0
if self.xml.get_widget('sync_with_global_status_checkbutton').\ if self.xml.get_widget('sync_with_global_status_checkbutton').\
@ -1109,7 +1104,7 @@ class Account_modification_window:
gajim.config.set_per('accounts', name, 'sync_with_global_status', \ gajim.config.set_per('accounts', name, 'sync_with_global_status', \
sync_with_global_status) sync_with_global_status)
gajim.config.set_per('accounts', name, 'no_log_for', \ gajim.config.set_per('accounts', name, 'no_log_for', \
self.infos['no_log_for']) ' '.join(list_no_log_for))
if save_password: if save_password:
gajim.connections[name].password = password gajim.connections[name].password = password
#refresh accounts window #refresh accounts window
@ -1148,7 +1143,7 @@ class Account_modification_window:
gajim.config.set_per('accounts', name, 'gpgpassword', gpg_password) gajim.config.set_per('accounts', name, 'gpgpassword', gpg_password)
gajim.config.set_per('accounts', name, 'sync_with_global_status', True) gajim.config.set_per('accounts', name, 'sync_with_global_status', True)
gajim.config.set_per('accounts', name, 'no_log_for', \ gajim.config.set_per('accounts', name, 'no_log_for', \
self.infos['no_log_for']) ' '.join(list_no_log_for))
if save_password: if save_password:
gajim.connections[name].password = password gajim.connections[name].password = password
#update variables #update variables
@ -1294,14 +1289,12 @@ class Account_modification_window:
password_entry.set_sensitive(False) password_entry.set_sensitive(False)
password_entry.set_text('') password_entry.set_text('')
#infos must be a dictionnary def __init__(self, plugin, account = ''):
def __init__(self, plugin, infos):
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'account_modification_window', APP) self.xml = gtk.glade.XML(GTKGUI_GLADE, 'account_modification_window', APP)
self.window = self.xml.get_widget('account_modification_window') self.window = self.xml.get_widget('account_modification_window')
self.plugin = plugin self.plugin = plugin
self.account = '' self.account = account
self.modify = False self.modify = False
self.infos = infos
self.xml.get_widget('gpg_key_label').set_text('No key selected') self.xml.get_widget('gpg_key_label').set_text('No key selected')
self.xml.get_widget('gpg_name_label').set_text('') self.xml.get_widget('gpg_name_label').set_text('')
self.xml.get_widget('gpg_save_password_checkbutton').set_sensitive(False) self.xml.get_widget('gpg_save_password_checkbutton').set_sensitive(False)
@ -1312,10 +1305,9 @@ class Account_modification_window:
#default is checked #default is checked
self.xml.get_widget('sync_with_global_status_checkbutton').set_active(1) self.xml.get_widget('sync_with_global_status_checkbutton').set_active(1)
self.xml.signal_autoconnect(self) self.xml.signal_autoconnect(self)
if infos: if account:
self.modify = True self.modify = True
self.account = infos['accname'] self.init_account()
self.init_account(infos)
self.xml.get_widget('new_account_checkbutton').set_sensitive(False) self.xml.get_widget('new_account_checkbutton').set_sensitive(False)
self.xml.get_widget('save_button').grab_focus() self.xml.get_widget('save_button').grab_focus()
self.window.show_all() self.window.show_all()
@ -1348,7 +1340,7 @@ class Accounts_window:
"""When new button is clicked : open an account information window""" """When new button is clicked : open an account information window"""
if not self.plugin.windows.has_key('account_modification_window'): if not self.plugin.windows.has_key('account_modification_window'):
self.plugin.windows['account_modification'] = \ self.plugin.windows['account_modification'] = \
Account_modification_window(self.plugin, {}) Account_modification_window(self.plugin, '')
else: else:
self.plugin.windows['account_modification'].window.present() self.plugin.windows['account_modification'].window.present()
@ -1367,7 +1359,8 @@ class Accounts_window:
del self.plugin.queues[account] del self.plugin.queues[account]
del self.plugin.roster.groups[account] del self.plugin.roster.groups[account]
del self.plugin.roster.contacts[account] del self.plugin.roster.contacts[account]
#FIXME: missing things: to_be_deleted for ex del self.plugin.roster.to_be_removed[account]
del self.plugin.roster.newlt_added[account]
self.plugin.roster.draw_roster() self.plugin.roster.draw_roster()
self.init_accounts() self.init_accounts()
@ -1378,13 +1371,8 @@ class Accounts_window:
sel = self.accounts_treeview.get_selection() sel = self.accounts_treeview.get_selection()
(model, iter) = sel.get_selected() (model, iter) = sel.get_selected()
account = model.get_value(iter, 0) account = model.get_value(iter, 0)
#FIXME:
infos = self.plugin.accounts[account]
infos['accname'] = account
infos['jid'] = self.plugin.accounts[account]['name'] + \
'@' + self.plugin.accounts[account]['hostname']
self.plugin.windows['account_modification'] = \ self.plugin.windows['account_modification'] = \
Account_modification_window(self.plugin, infos) # may it messes with this one Account_modification_window(self.plugin, account) # may it messes with this one
else: else:
self.plugin.windows['account_modification'].window.present() self.plugin.windows['account_modification'].window.present()

View File

@ -531,13 +531,8 @@ class Roster_window:
def on_edit_account(self, widget, account): def on_edit_account(self, widget, account):
if not self.plugin.windows.has_key('account_modification_window'): if not self.plugin.windows.has_key('account_modification_window'):
#FIXME:
infos = self.plugin.accounts[account]
infos['accname'] = account
infos['jid'] = self.plugin.accounts[account]["name"] + \
'@' + self.plugin.accounts[account]["hostname"]
self.plugin.windows['account_modification'] = \ self.plugin.windows['account_modification'] = \
config.Account_modification_window(self.plugin, infos) config.Account_modification_window(self.plugin, account)
def mk_menu_account(self, event, iter): def mk_menu_account(self, event, iter):
"""Make account's popup menu""" """Make account's popup menu"""
@ -1116,7 +1111,7 @@ class Roster_window:
iconset = gajim.config.get('iconset') iconset = gajim.config.get('iconset')
if not iconset: if not iconset:
iconset = 'sun' iconset = 'sun'
self.path = 'plugins/gtkgui/iconsets/' + iconset + '/' self.path = '../data/iconsets/' + iconset + '/'
self.pixbufs = {} self.pixbufs = {}
for state in ('connecting', 'online', 'chat', 'away', 'xa', 'dnd', \ for state in ('connecting', 'online', 'chat', 'away', 'xa', 'dnd', \
'invisible', 'offline', 'error', 'requested', 'message', \ 'invisible', 'offline', 'error', 'requested', 'message', \
@ -1427,4 +1422,4 @@ class Roster_window:
self.draw_roster() self.draw_roster()
if len(gajim.connections) == 0: # if no account if len(gajim.connections) == 0: # if no account
self.plugin.windows['account_modification'] = \ self.plugin.windows['account_modification'] = \
config.Account_modification_window(self.plugin, {}) config.Account_modification_window(self.plugin)