a connection can be active or not. If not active, we cannot login.

This commit is contained in:
Yann Leboulanger 2004-09-28 21:31:26 +00:00
parent 00da2fee2c
commit 7f64d59c11
2 changed files with 27 additions and 6 deletions

View File

@ -462,7 +462,11 @@ class GajimCore:
#TODO: tell the changes to other plugins #TODO: tell the changes to other plugins
#('STATUS', account, (status, msg)) #('STATUS', account, (status, msg))
elif ev[0] == 'STATUS': elif ev[0] == 'STATUS':
if (ev[2][0] != 'offline') and (self.connected[ev[1]] == 0): activ = 1
if self.cfgParser.tab[ev[1]].has_key('active'):
activ = self.cfgParser.tab[ev[1]]['active']
if (ev[2][0] != 'offline') and (self.connected[ev[1]] == 0) and \
activ:
con = self.connect(ev[1]) con = self.connect(ev[1])
if self.connected[ev[1]]: if self.connected[ev[1]]:
statuss = ['offline', 'online', 'away', 'xa', 'dnd', \ statuss = ['offline', 'online', 'away', 'xa', 'dnd', \

View File

@ -533,9 +533,12 @@ class accounts_Window:
model = self.treeview.get_model() model = self.treeview.get_model()
model.clear() model.clear()
for account in self.plugin.accounts: for account in self.plugin.accounts:
activ = 1
if self.plugin.accounts[account].has_key("active"):
activ = self.plugin.accounts[account]["active"]
iter = model.append() iter = model.append()
model.set(iter, 0, account, 1, \ model.set(iter, 0, account, 1, \
self.plugin.accounts[account]["hostname"]) self.plugin.accounts[account]["hostname"], 2, activ)
def on_row_activated(self, widget): def on_row_activated(self, widget):
"""Activate delete and modify buttons when a row is selected""" """Activate delete and modify buttons when a row is selected"""
@ -595,21 +598,35 @@ class accounts_Window:
self.plugin.windows['accountPreference'] = \ self.plugin.windows['accountPreference'] = \
accountPreference_Window(self.plugin, infos) accountPreference_Window(self.plugin, infos)
def on_toggled(self, cell, path, model=None):
iter = model.get_iter(path)
model.set_value(iter, 2, not cell.get_active())
account = model.get_value(iter, 0)
if cell.get_active():
self.plugin.accounts[account]["active"] = 0
else:
self.plugin.accounts[account]["active"] = 1
def __init__(self, plugin): def __init__(self, plugin):
self.plugin = plugin self.plugin = plugin
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'Accounts', APP) self.xml = gtk.glade.XML(GTKGUI_GLADE, 'Accounts', APP)
self.window = self.xml.get_widget("Accounts") self.window = self.xml.get_widget("Accounts")
self.treeview = self.xml.get_widget("treeview") self.treeview = self.xml.get_widget("treeview")
model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, \
gobject.TYPE_BOOLEAN)
self.treeview.set_model(model) self.treeview.set_model(model)
#columns #columns
renderer = gtk.CellRendererText() renderer = gtk.CellRendererText()
renderer.set_data('column', 0) self.treeview.insert_column_with_attributes(-1, _('Name'), renderer, \
self.treeview.insert_column_with_attributes(-1, _('Name'), renderer, text=0) text=0)
renderer = gtk.CellRendererText() renderer = gtk.CellRendererText()
renderer.set_data('column', 1)
self.treeview.insert_column_with_attributes(-1, _('Server'), \ self.treeview.insert_column_with_attributes(-1, _('Server'), \
renderer, text=1) renderer, text=1)
renderer = gtk.CellRendererToggle()
renderer.set_property('activatable', True)
renderer.connect('toggled', self.on_toggled, model)
self.treeview.insert_column_with_attributes(-1, _('Active'), \
renderer, active=2)
self.xml.signal_connect('gtk_widget_destroy', self.delete_event) self.xml.signal_connect('gtk_widget_destroy', self.delete_event)
self.xml.signal_connect('on_row_activated', self.on_row_activated) self.xml.signal_connect('on_row_activated', self.on_row_activated)
self.xml.signal_connect('on_new_clicked', self.on_new_clicked) self.xml.signal_connect('on_new_clicked', self.on_new_clicked)