remove account allows unregistering too (xml code is missing atm)

This commit is contained in:
Nikos Kouremenos 2005-04-19 22:29:38 +00:00
parent b68da6b69b
commit c5aa9f0e81
3 changed files with 278 additions and 10 deletions

View File

@ -764,6 +764,9 @@ class Connection:
iq.setID(id)
self.connection.send(iq)
def unregister_account(self, account_name)
pass #FIXME: WRITE THE CODE
def process(self, timeout):
if not self.connection:
return

View File

@ -1343,7 +1343,7 @@ class Accounts_window:
def init_accounts(self):
'''initialize listStore with existing accounts'''
self.modify_button.set_sensitive(False)
self.delete_button.set_sensitive(False)
self.remove_button.set_sensitive(False)
model = self.accounts_treeview.get_model()
model.clear()
for account in gajim.connections:
@ -1354,7 +1354,7 @@ class Accounts_window:
def on_accounts_treeview_cursor_changed(self, widget):
'''Activate delete and modify buttons when a row is selected'''
self.modify_button.set_sensitive(True)
self.delete_button.set_sensitive(True)
self.remove_button.set_sensitive(True)
def on_new_button_clicked(self, widget):
'''When new button is clicked : open an account information window'''
@ -1365,17 +1365,23 @@ class Accounts_window:
Account_modification_window(self.plugin, '')
def on_delete_button_clicked(self, widget):
'''When delete button is clicked :
def on_remove_button_clicked(self, widget):
'''When remove 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()
if not iter: return
dialog = self.xml.get_widget('remove_account_dialog')
remove_and_unregister_radiobutton = self.xml.get_widget(\
'remove_and_unregister_radiobutton')
account = model.get_value(iter, 0)
dialog = dialogs.Confirmation_dialog(_('Are you sure you want to remove account (%s) ?') % account)
dialog.set_title(_('Removing (%s) account') % account)
if dialog.get_response() == gtk.RESPONSE_YES:
if gajim.connections[account].connected:
if gajim.connections[account].connected: #FIXME: WHAT? user doesn't know this does he?
gajim.connections[account].change_status('offline', 'offline')
unregister = False
if remove_and_unregister_radiobutton.get_active():
unregister = True
del gajim.connections[account]
gajim.config.del_per('accounts', account)
del self.plugin.windows[account]
@ -1386,6 +1392,8 @@ class Accounts_window:
del self.plugin.roster.newlt_added[account]
self.plugin.roster.draw_roster()
self.init_accounts()
if unregister:
pass #FIXME: call Connection.remove_account(account)
def on_modify_button_clicked(self, widget):
'''When modify button is clicked:
@ -1414,7 +1422,7 @@ class Accounts_window:
self.window = self.xml.get_widget('accounts_window')
self.accounts_treeview = self.xml.get_widget('accounts_treeview')
self.modify_button = self.xml.get_widget('modify_button')
self.delete_button = self.xml.get_widget('delete_button')
self.remove_button = self.xml.get_widget('remove_button')
model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, \
gobject.TYPE_BOOLEAN)
self.accounts_treeview.set_model(model)

View File

@ -470,13 +470,13 @@
</child>
<child>
<widget class="GtkButton" id="delete_button">
<widget class="GtkButton" id="remove_button">
<property name="visible">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 18:20:46 GMT"/>
<signal name="clicked" handler="on_remove_button_clicked" last_modification_time="Tue, 19 Apr 2005 22:15:48 GMT"/>
</widget>
</child>
@ -2828,7 +2828,7 @@
<widget class="GtkWindow" id="preferences_window">
<property name="border_width">4</property>
<property name="width_request">465</property>
<property name="width_request">470</property>
<property name="height_request">410</property>
<property name="title" translatable="yes">Preferences</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
@ -10551,4 +10551,261 @@ send a chat message to</property>
</child>
</widget>
<widget class="GtkDialog" id="remove_account_dialog">
<property name="border_width">4</property>
<property name="width_request">400</property>
<property name="height_request">130</property>
<property name="visible">True</property>
<property name="title" translatable="yes"></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="focus_on_map">True</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox10">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">5</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area9">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="cancelbutton3">
<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="okbutton3">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-5</property>
<child>
<widget class="GtkAlignment" id="alignment60">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="hbox2952">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image499">
<property name="visible">True</property>
<property name="stock">gtk-delete</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label243">
<property name="visible">True</property>
<property name="label">Remove</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</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="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox2951">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">5</property>
<child>
<widget class="GtkImage" id="image498">
<property name="visible">True</property>
<property name="stock">gtk-dialog-question</property>
<property name="icon_size">6</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame30">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="label_yalign">0.5</property>
<property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
<child>
<widget class="GtkAlignment" id="alignment59">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">1</property>
<property name="yscale">1</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">12</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkVBox" id="vbox69">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">5</property>
<child>
<widget class="GtkRadioButton" id="remove_only_radiobutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Remove account only from Gajim</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="remove_and_unregister_radiobutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Remove account from Gajim and from server</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<property name="group">remove_only_radiobutton</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label242">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;What do you want to do?&lt;/b&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</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="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>