some changes. introduce accounts window bug

This commit is contained in:
Nikos Kouremenos 2005-03-01 18:00:34 +00:00
parent e06db9ab36
commit fe2abb1dbd
3 changed files with 77 additions and 150 deletions

View File

@ -1050,7 +1050,7 @@ class accountpreferences_window:
jid = self.xml.get_widget('jid_entry').get_text()
if self.plugin.connected[self.account]:
self.plugin.windows[self.account]['infos'][jid] = \
vCard_Window(jid, self.plugin, self.account)
vCard_Window(jid.get_text(), self.plugin, self.account)
self.plugin.send('ASK_VCARD', self.account, jid)
else:
warning_Window(_('You must be connected to get your informations'))
@ -1126,49 +1126,58 @@ class accountpreferences_window:
self.init_account(infos)
self.xml.get_widget('new_account_checkbutton').set_sensitive(False)
class accounts_Window:
class accounts_window:
"""Class for accounts window : lists of accounts"""
def delete_event(self, widget):
def on_accounts_window_delete_event(self, widget, event):
"""close window"""
print 'delete'
del self.plugin.windows['accounts']
def on_close(self, widget):
def on_close_button_clicked(self, widget):
"""When Close button is clicked"""
print 'destroy'
widget.get_toplevel().destroy()
def init_accounts(self):
"""initialize listStore with existing accounts"""
self.xml.get_widget("modify_button").set_sensitive(False)
self.xml.get_widget("delete_button").set_sensitive(False)
self.xml.get_widget('modify_button').set_sensitive(False)
self.xml.get_widget('delete_button').set_sensitive(False)
model = self.accounts_treeview.get_model()
model.clear()
for account in self.plugin.accounts:
activ = 1
if self.plugin.accounts[account].has_key("active"):
activ = self.plugin.accounts[account]["active"]
if self.plugin.accounts[account].has_key('active'):
activ = self.plugin.accounts[account]['active']
iter = model.append()
model.set(iter, 0, account, 1, \
self.plugin.accounts[account]["hostname"], 2, activ)
self.plugin.accounts[account]['hostname'], 2, activ)
def on_row_activated(self, widget):
"""Activate delete and modify buttons when a row is selected"""
self.xml.get_widget("modify_button").set_sensitive(True)
self.xml.get_widget("delete_button").set_sensitive(True)
def on_new_clicked(self, widget):
def on_new_button_clicked(self, widget):
"""When new button is clicked : open an account information window"""
if not self.plugin.windows.has_key('accountPreference'):
self.plugin.windows['accountPreference'] = \
accountpreferences_window(self.plugin)
def on_delete_clicked(self, widget):
def on_delete_button_clicked(self, widget):
"""When delete button is clicked :
Remove an account from the listStore and from the config file"""
sel = self.accounts_treeview.get_selection()
(model, iter) = sel.get_selected()
account = model.get_value(iter, 0)
window = confirm_Window(_("Are you sure you want to remove this account (%s) ?") % account)
if window.wait() == gtk.RESPONSE_OK:
dlg = gtk.MessageDialog(None,
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO,
_("Are you sure you want to remove\nthis account (%s) ?") % account)
response = dlg.run()
dlg.hide()
if response == gtk.RESPONSE_YES:
if self.plugin.connected[account]:
self.plugin.send('STATUS', account, ('offline', 'offline'))
del self.plugin.accounts[account]
@ -1182,7 +1191,7 @@ class accounts_Window:
self.plugin.roster.draw_roster()
self.init_accounts()
def on_modify_clicked(self, widget):
def on_modify_button_clicked(self, widget):
"""When modify button is clicked :
open the account information window for this account"""
if not self.plugin.windows.has_key('accountPreference'):
@ -1226,12 +1235,7 @@ class accounts_Window:
renderer.connect('toggled', self.on_toggled, model)
self.accounts_treeview.insert_column_with_attributes(-1, _('Active'), \
renderer, active=2)
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_new_clicked', self.on_new_clicked)
self.xml.signal_connect('on_delete_clicked', self.on_delete_clicked)
self.xml.signal_connect('on_modify_clicked', self.on_modify_clicked)
self.xml.signal_connect('on_close_clicked', self.on_close)
self.xml.signal_autoconnect(self)
self.init_accounts()
@ -1286,14 +1290,18 @@ class agentRegistration_Window:
self.xml.signal_connect('on_button_ok_clicked', self.on_ok)
class agent_browser_window:
class browseAgent_Window:
"""Class for bowser agent window :
to know the agents on the selected server"""
def on_agent_browser_window_destroy(self, widget):
def delete_event(self, widget):
"""close window"""
del self.plugin.windows[self.account]['browser']
def on_close_button_clicked(self, widget):
def on_cancel(self, widget):
"""When Cancel button is clicked"""
widget.get_toplevel().destroy()
def on_close(self, widget):
"""When Close button is clicked"""
widget.get_toplevel().destroy()
@ -1304,14 +1312,14 @@ class agent_browser_window:
def agents(self, agents):
"""When list of available agent arrive :
Fill the treeview with it"""
model = self.agents_treeview.get_model()
model = self.treeview.get_model()
for agent in agents:
iter = model.append(None, (agent['name'], agent['jid']))
self.agent_infos[agent['jid']] = {'features' : []}
def agent_info(self, agent, identities, features, items):
"""When we recieve informations about an agent"""
model = self.agents_treeview.get_model()
model = self.treeview.get_model()
iter = model.get_iter_root()
expand = 0
while (iter):
@ -1336,24 +1344,23 @@ class agent_browser_window:
model.append(iter, (item['name'], item['jid']))
self.agent_infos[item['jid']] = {'identities': [item]}
if expand:
self.agents_treeview.expand_row((model.get_path(iter)), False)
self.treeview.expand_row((model.get_path(iter)), False)
def on_refresh_button_clicked(self, widget):
def on_refresh(self, widget):
"""When refresh button is clicked :
refresh list : clear and rerequest it"""
self.agents_treeview.get_model().clear()
self.treeview.get_model().clear()
self.browse()
def on_agents_treeview_row_activated(self, widget, path, col=0):
def on_row_activated(self, widget, path, col=0):
"""When a row is activated :
Register or join the selected agent"""
#TODO
pass
def on_join_button_clicked(self, widget):
"""When we want to join a conference :
Ask specific informations about the selected agent and close the window"""
model, iter = self.agents_treeview.get_selection().get_selected()
model, iter = self.treeview.get_selection().get_selected()
if not iter:
return
service = model.get_value(iter, 1)
@ -1368,17 +1375,17 @@ class agent_browser_window:
def on_register_button_clicked(self, widget):
"""When we want to register an agent :
Ask specific informations about the selected agent and close the window"""
model, iter = self.agents_treeview.get_selection().get_selected()
model, iter = self.treeview.get_selection().get_selected()
if not iter :
return
service = model.get_value(iter, 1)
self.plugin.send('REG_AGENT_INFO', self.account, service)
widget.get_toplevel().destroy()
def on_agents_treeview_cursor_changed(self, widget):
def on_cursor_changed(self, widget):
"""When we select a row :
activate buttons if needed"""
model, iter = self.agents_treeview.get_selection().get_selected()
model, iter = self.treeview.get_selection().get_selected()
jid = model.get_value(iter, 1)
self.register_button.set_sensitive(False)
if self.agent_infos[jid].has_key('features'):
@ -1395,29 +1402,35 @@ class agent_browser_window:
if not plugin.connected[account]:
warning_Window(_("You must be connected to view Agents"))
return
xml = gtk.glade.XML(GTKGUI_GLADE, 'agent_browser_window', APP)
self.window = xml.get_widget('agent_browser_window')
self.agents_treeview = xml.get_widget('agents_treeview')
xml = gtk.glade.XML(GTKGUI_GLADE, 'browser', APP)
self.window = xml.get_widget('browser')
self.treeview = xml.get_widget('treeview')
self.plugin = plugin
self.account = account
self.agent_infos = {}
model = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
self.agents_treeview.set_model(model)
self.treeview.set_model(model)
#columns
renderer = gtk.CellRendererText()
renderer.set_data('column', 0)
self.agents_treeview.insert_column_with_attributes(-1, 'Name', \
renderer, text=0)
self.treeview.insert_column_with_attributes(-1, 'Name', renderer, text=0)
renderer = gtk.CellRendererText()
renderer.set_data('column', 1)
self.agents_treeview.insert_column_with_attributes(-1, 'Service', \
self.treeview.insert_column_with_attributes(-1, 'Service', \
renderer, text=1)
self.register_button = xml.get_widget('register_button')
self.register_button.set_sensitive(False)
self.join_button = xml.get_widget('join_button')
self.join_button.set_sensitive(False)
xml.signal_autoconnect(self)
xml.signal_connect('gtk_widget_destroy', self.delete_event)
xml.signal_connect('on_refresh_clicked', self.on_refresh)
xml.signal_connect('on_row_activated', self.on_row_activated)
xml.signal_connect('on_join_button_clicked', self.on_join_button_clicked)
xml.signal_connect('on_register_button_clicked', self.on_register_button_clicked)
xml.signal_connect('on_cursor_changed', self.on_cursor_changed)
xml.signal_connect('on_close_clicked', self.on_close)
self.browse()
class join_gc:

View File

@ -671,7 +671,7 @@
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<signal name="destroy" handler="gtk_widget_destroy" last_modification_time="Wed, 10 Dec 2003 22:31:27 GMT"/>
<signal name="delete_event" handler="on_accounts_window_delete_event" last_modification_time="Tue, 01 Mar 2005 16:41:41 GMT"/>
<child>
<widget class="GtkVBox" id="vbox5">
@ -747,20 +747,7 @@
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_new_clicked" last_modification_time="Thu, 28 Oct 2004 11:35:22 GMT"/>
</widget>
</child>
<child>
<widget class="GtkButton" id="delete_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-delete</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_delete_clicked" last_modification_time="Thu, 28 Oct 2004 13:36:37 GMT"/>
<signal name="clicked" handler="on_new_button_clicked" last_modification_time="Tue, 01 Mar 2005 16:11:26 GMT"/>
</widget>
</child>
@ -771,10 +758,10 @@
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_modify_clicked" last_modification_time="Thu, 28 Oct 2004 13:36:59 GMT"/>
<signal name="clicked" handler="on_modify_button_clicked" last_modification_time="Tue, 01 Mar 2005 16:11:36 GMT"/>
<child>
<widget class="GtkAlignment" id="alignment30">
<widget class="GtkAlignment" id="alignment44">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
@ -786,13 +773,13 @@
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="hbox45">
<widget class="GtkHBox" id="hbox2919">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image172">
<widget class="GtkImage" id="image320">
<property name="visible">True</property>
<property name="stock">gtk-refresh</property>
<property name="icon_size">4</property>
@ -809,7 +796,7 @@
</child>
<child>
<widget class="GtkLabel" id="label167">
<widget class="GtkLabel" id="label201">
<property name="visible">True</property>
<property name="label" translatable="yes">_Modify</property>
<property name="use_underline">True</property>
@ -835,6 +822,19 @@
</widget>
</child>
<child>
<widget class="GtkButton" id="delete_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-delete</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_delete_button_clicked" last_modification_time="Tue, 01 Mar 2005 16:11:50 GMT"/>
</widget>
</child>
<child>
<widget class="GtkButton" id="close_button">
<property name="visible">True</property>
@ -844,7 +844,7 @@
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_close_clicked" last_modification_time="Thu, 28 Oct 2004 11:36:49 GMT"/>
<signal name="clicked" handler="on_close_button_clicked" last_modification_time="Tue, 01 Mar 2005 16:11:58 GMT"/>
</widget>
</child>
</widget>
@ -2548,92 +2548,6 @@ on the server as a vCard</property>
</child>
</widget>
<widget class="GtkDialog" id="Confirm">
<property name="border_width">5</property>
<property name="visible">True</property>
<property name="title" translatable="yes">Sure ?</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="has_separator">True</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="cancelbutton">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-6</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="okbutton">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-5</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">5</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label_confirm">
<property name="visible">True</property>
<property name="label" translatable="yes"></property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">True</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="mnemonic_widget">okbutton</property>
</widget>
<packing>
<property name="padding">10</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
<widget class="GtkWindow" id="subscription_request_window">
<property name="border_width">5</property>
<property name="visible">True</property>

View File

@ -2029,7 +2029,7 @@ class roster_Window:
"""When accounts is seleted :
call the accounts class to modify accounts"""
if not self.plugin.windows.has_key('accounts'):
self.plugin.windows['accounts'] = accounts_Window(self.plugin)
self.plugin.windows['accounts'] = accounts_window(self.plugin)
def close_all(self, dic):
"""close all the windows in the given dictionary"""