remove many call to dialog.run() function. Some are still here, but they happend only when the user do an action (close a chat window, change status, ...). So UI is not blocked when we receive a groupchat invitation or an error message.

This commit is contained in:
Yann Leboulanger 2006-04-02 16:11:21 +00:00
parent e63de7d933
commit 31e54bc2ed
11 changed files with 312 additions and 251 deletions

View file

@ -26,7 +26,6 @@ import gtkgui_helpers
import message_control import message_control
import dialogs import dialogs
import history_window import history_window
import locale
from common import gajim from common import gajim
from common import helpers from common import helpers
@ -161,7 +160,7 @@ class ChatControlBase(MessageControl):
'set your $LANG as appropriate. Eg. for French do export ' 'set your $LANG as appropriate. Eg. for French do export '
'LANG=fr_FR or export LANG=fr_FR.UTF-8 in ~/.bash_profile or to ' 'LANG=fr_FR or export LANG=fr_FR.UTF-8 in ~/.bash_profile or to '
'make it global in /etc/profile.\n\nHighlighting misspelled ' 'make it global in /etc/profile.\n\nHighlighting misspelled '
'words feature will not be used')).get_response() 'words feature will not be used'))
gajim.config.set('use_speller', False) gajim.config.set('use_speller', False)
self.style_event_id = 0 self.style_event_id = 0
@ -171,7 +170,6 @@ class ChatControlBase(MessageControl):
if gajim.connections[self.account].connected < 2: # we are not connected if gajim.connections[self.account].connected < 2: # we are not connected
dialog = dialogs.ErrorDialog(_('A connection is not available'), dialog = dialogs.ErrorDialog(_('A connection is not available'),
_('Your message can not be sent until you are connected.')) _('Your message can not be sent until you are connected.'))
dialog.get_response()
return return
message_buffer = self.msg_textview.get_buffer() message_buffer = self.msg_textview.get_buffer()
start_iter = message_buffer.get_start_iter() start_iter = message_buffer.get_start_iter()
@ -373,7 +371,6 @@ class ChatControlBase(MessageControl):
if gajim.connections[self.account].connected < 2: # we are not connected if gajim.connections[self.account].connected < 2: # we are not connected
dialog = dialogs.ErrorDialog(_('A connection is not available'), dialog = dialogs.ErrorDialog(_('A connection is not available'),
_('Your message can not be sent until you are connected.')) _('Your message can not be sent until you are connected.'))
dialog.get_response()
send_message = False send_message = False
if send_message: if send_message:
@ -1571,8 +1568,8 @@ class ChatControl(ChatControlBase):
def _on_toggle_gpg_menuitem_activate(self, widget): def _on_toggle_gpg_menuitem_activate(self, widget):
# update the button # update the button
# this is reverse logic, as we are on 'activate' (before change happens) # this is reverse logic, as we are on 'activate' (before change happens)
is_active = self.xml.get_widget('gpg_togglebutton').get_active() tb = self.xml.get_widget('gpg_togglebutton')
tb.set_active(not is_active) tb.set_active(not tb.get_active())
def got_connected(self): def got_connected(self):
ChatControlBase.got_connected(self) ChatControlBase.got_connected(self)

View file

@ -1118,22 +1118,20 @@ class AccountModificationWindow:
if gajim.connections[self.account].connected != 0: if gajim.connections[self.account].connected != 0:
dialogs.ErrorDialog( dialogs.ErrorDialog(
_('You are currently connected to the server'), _('You are currently connected to the server'),
_('To change the account name, you must be disconnected.')).\ _('To change the account name, you must be disconnected.'))
get_response()
return return
if len(gajim.awaiting_events[self.account]): if len(gajim.awaiting_events[self.account]):
dialogs.ErrorDialog(_('Unread events'), dialogs.ErrorDialog(_('Unread events'),
_('To change the account name, you must read all pending ' _('To change the account name, you must read all pending '
'events.')).\ 'events.'))
get_response()
return return
if (name == ''): if (name == ''):
dialogs.ErrorDialog(_('Invalid account name'), dialogs.ErrorDialog(_('Invalid account name'),
_('Account name cannot be empty.')).get_response() _('Account name cannot be empty.'))
return return
if name.find(' ') != -1: if name.find(' ') != -1:
dialogs.ErrorDialog(_('Invalid account name'), dialogs.ErrorDialog(_('Invalid account name'),
_('Account name cannot contain spaces.')).get_response() _('Account name cannot contain spaces.'))
return return
jid = self.xml.get_widget('jid_entry').get_text().decode('utf-8') jid = self.xml.get_widget('jid_entry').get_text().decode('utf-8')
@ -1142,14 +1140,14 @@ class AccountModificationWindow:
jid = helpers.parse_jid(jid) jid = helpers.parse_jid(jid)
except helpers.InvalidFormat, s: except helpers.InvalidFormat, s:
pritext = _('Invalid Jabber ID') pritext = _('Invalid Jabber ID')
dialogs.ErrorDialog(pritext, str(s)).get_response() dialogs.ErrorDialog(pritext, str(s))
return return
n, hn = jid.split('@', 1) n, hn = jid.split('@', 1)
if not n: if not n:
pritext = _('Invalid Jabber ID') pritext = _('Invalid Jabber ID')
sectext = _('A Jabber ID must be in the form "user@servername".') sectext = _('A Jabber ID must be in the form "user@servername".')
dialogs.ErrorDialog(pritext, sectext).get_response() dialogs.ErrorDialog(pritext, sectext)
return return
resource = self.xml.get_widget('resource_entry').get_text().decode('utf-8') resource = self.xml.get_widget('resource_entry').get_text().decode('utf-8')
@ -1157,7 +1155,7 @@ class AccountModificationWindow:
resource = helpers.parse_resource(resource) resource = helpers.parse_resource(resource)
except helpers.InvalidFormat, s: except helpers.InvalidFormat, s:
pritext = _('Invalid Jabber ID') pritext = _('Invalid Jabber ID')
dialogs.ErrorDialog(pritext, (s)).get_response() dialogs.ErrorDialog(pritext, (s))
return return
config['savepass'] = self.xml.get_widget( config['savepass'] = self.xml.get_widget(
@ -1205,7 +1203,7 @@ class AccountModificationWindow:
custom_port = int(custom_port) custom_port = int(custom_port)
except: except:
dialogs.ErrorDialog(_('Invalid entry'), dialogs.ErrorDialog(_('Invalid entry'),
_('Custom port must be a port number.')).get_response() _('Custom port must be a port number.'))
return return
config['custom_port'] = custom_port config['custom_port'] = custom_port
config['custom_host'] = self.xml.get_widget( config['custom_host'] = self.xml.get_widget(
@ -1289,15 +1287,6 @@ class AccountModificationWindow:
config['use_ft_proxies']: config['use_ft_proxies']:
gajim.connections[self.account].discover_ft_proxies() gajim.connections[self.account].discover_ft_proxies()
if relogin_needed:
dialog = dialogs.YesNoDialog(_('Relogin now?'),
_('If you want all the changes to apply instantly, '
'you must relogin.'))
if dialog.get_response() == gtk.RESPONSE_YES:
do_relogin = True
else:
do_relogin = False
for opt in config: for opt in config:
gajim.config.set_per('accounts', name, opt, config[opt]) gajim.config.set_per('accounts', name, opt, config[opt])
if config['savepass']: if config['savepass']:
@ -1312,13 +1301,19 @@ class AccountModificationWindow:
gajim.interface.save_config() gajim.interface.save_config()
self.window.destroy() self.window.destroy()
if relogin_needed and do_relogin: if relogin_needed:
show_before = gajim.SHOW_LIST[gajim.connections[name].connected] def relog(widget):
status_before = gajim.connections[name].status self.dialog.destroy()
gajim.interface.roster.send_status(name, 'offline', show_before = gajim.SHOW_LIST[gajim.connections[self.account].\
_('Be right back.')) connected]
gobject.timeout_add(500, gajim.interface.roster.send_status, name, status_before = gajim.connections[self.account].status
show_before, status_before) gajim.interface.roster.send_status(self.account, 'offline',
_('Be right back.'))
gobject.timeout_add(500, gajim.interface.roster.send_status,
self.account, show_before, status_before)
self.dialog = dialogs.YesNoDialog(_('Relogin now?'),
_('If you want all the changes to apply instantly, '
'you must relogin.'), on_response_yes = relog)
def on_change_password_button_clicked(self, widget): def on_change_password_button_clicked(self, widget):
try: try:
@ -1336,7 +1331,7 @@ class AccountModificationWindow:
def on_edit_details_button_clicked(self, widget): def on_edit_details_button_clicked(self, widget):
if not gajim.interface.instances.has_key(self.account): if not gajim.interface.instances.has_key(self.account):
dialogs.ErrorDialog(_('No such account available'), dialogs.ErrorDialog(_('No such account available'),
_('You must create your account before editing your personal information.')).get_response() _('You must create your account before editing your personal information.'))
return return
jid = self.xml.get_widget('jid_entry').get_text().decode('utf-8') jid = self.xml.get_widget('jid_entry').get_text().decode('utf-8')
@ -1344,8 +1339,7 @@ class AccountModificationWindow:
if not gajim.connections.has_key(self.account) or \ if not gajim.connections.has_key(self.account) or \
gajim.connections[self.account].connected < 2: gajim.connections[self.account].connected < 2:
dialogs.ErrorDialog(_('You are not connected to the server'), dialogs.ErrorDialog(_('You are not connected to the server'),
_('Without a connection, you can not edit your personal information.') _('Without a connection, you can not edit your personal information.'))
).get_response()
return return
# in infos the key jid is OUR jid so we save the vcardwindow instance there # in infos the key jid is OUR jid so we save the vcardwindow instance there
@ -1376,7 +1370,7 @@ _('Without a connection, you can not edit your personal information.')
secret_keys = [] secret_keys = []
if not secret_keys: if not secret_keys:
dialogs.ErrorDialog(_('Failed to get secret keys'), dialogs.ErrorDialog(_('Failed to get secret keys'),
_('There was a problem retrieving your OpenPGP secret keys.')).get_response() _('There was a problem retrieving your OpenPGP secret keys.'))
return return
secret_keys['None'] = 'None' secret_keys['None'] = 'None'
instance = dialogs.ChooseGPGKeyDialog(_('OpenPGP Key Selection'), instance = dialogs.ChooseGPGKeyDialog(_('OpenPGP Key Selection'),
@ -1656,8 +1650,7 @@ class AccountsWindow:
account = model.get_value(iter, 0).decode('utf-8') account = model.get_value(iter, 0).decode('utf-8')
if len(gajim.awaiting_events[account]): if len(gajim.awaiting_events[account]):
dialogs.ErrorDialog(_('Unread events'), dialogs.ErrorDialog(_('Unread events'),
_('Read all pending events before removing this account.')).\ _('Read all pending events before removing this account.'))
get_response()
return return
if gajim.interface.instances[account].has_key('remove_account'): if gajim.interface.instances[account].has_key('remove_account'):
gajim.interface.instances[account]['remove_account'].window.present() gajim.interface.instances[account]['remove_account'].window.present()
@ -2112,31 +2105,33 @@ class RemoveAccountWindow:
self.window.show_all() self.window.show_all()
def on_remove_button_clicked(self, widget): def on_remove_button_clicked(self, widget):
if gajim.connections[self.account].connected: def remove(widget):
dialog = dialogs.ConfirmationDialog( self.dialog.destroy()
_('Account "%s" is connected to the server' % self.account), if gajim.connections[self.account].connected and \
_('If you remove it, the connection will be lost.')) not self.remove_and_unregister_radiobutton.get_active():
if dialog.get_response() != gtk.RESPONSE_OK: # change status to offline only if we will not remove this JID from
return # server
# change status to offline only if we will not remove this JID from server
if not self.remove_and_unregister_radiobutton.get_active():
gajim.connections[self.account].change_status('offline', 'offline') gajim.connections[self.account].change_status('offline', 'offline')
if self.remove_and_unregister_radiobutton.get_active():
if self.remove_and_unregister_radiobutton.get_active(): if not gajim.connections[self.account].password:
if not gajim.connections[self.account].password: passphrase = ''
passphrase = '' w = dialogs.PassphraseDialog(
w = dialogs.PassphraseDialog( _('Password Required'),
_('Password Required'), _('Enter your password for account %s') % self.account,
_('Enter your password for account %s') % self.account, _('Save password'))
_('Save password')) passphrase, save = w.run()
passphrase, save = w.run() if passphrase == -1:
if passphrase == -1: # We don't remove account cause we canceled pw window
# We don't remove account cause we canceled pw window return
return gajim.connections[self.account].password = passphrase
gajim.connections[self.account].password = passphrase gajim.connections[self.account].unregister_account(self._on_remove_success)
gajim.connections[self.account].unregister_account(self._on_remove_success) else:
else: self._on_remove_success(True)
self._on_remove_success(True) if gajim.connections[self.account].connected:
self.dialog = dialogs.ConfirmationDialog(
_('Account "%s" is connected to the server' % self.account),
_('If you remove it, the connection will be lost.'),
on_response_ok = remove)
def _on_remove_success(self, res): def _on_remove_success(self, res):
# action of unregistration has failed, we don't remove the account # action of unregistration has failed, we don't remove the account
@ -2298,7 +2293,7 @@ class ManageBookmarksWindow:
if self.server_entry.get_text().decode('utf-8') == '' or self.room_entry.get_text().decode('utf-8') == '': if self.server_entry.get_text().decode('utf-8') == '' or self.room_entry.get_text().decode('utf-8') == '':
dialogs.ErrorDialog(_('This bookmark has invalid data'), dialogs.ErrorDialog(_('This bookmark has invalid data'),
_('Please be sure to fill out server and room fields or remove this bookmark.')).get_response() _('Please be sure to fill out server and room fields or remove this bookmark.'))
return False return False
return True return True
@ -2536,7 +2531,7 @@ class AccountCreationWizardWindow:
if not username: if not username:
pritext = _('Invalid username') pritext = _('Invalid username')
sectext = _('You must provide a username to configure this account.') sectext = _('You must provide a username to configure this account.')
dialogs.ErrorDialog(pritext, sectext).get_response() dialogs.ErrorDialog(pritext, sectext)
return return
server = widgets['server_comboboxentry'].child.get_text() server = widgets['server_comboboxentry'].child.get_text()
savepass = widgets['save_password_checkbutton'].get_active() savepass = widgets['save_password_checkbutton'].get_active()
@ -2545,12 +2540,12 @@ class AccountCreationWizardWindow:
if not self.modify: if not self.modify:
if password == '': if password == '':
dialogs.ErrorDialog(_('Invalid password'), dialogs.ErrorDialog(_('Invalid password'),
_('You must enter a password for the new account.')).get_response() _('You must enter a password for the new account.'))
return return
if widgets['pass2_entry'].get_text() != password: if widgets['pass2_entry'].get_text() != password:
dialogs.ErrorDialog(_('Passwords do not match'), dialogs.ErrorDialog(_('Passwords do not match'),
_('The passwords typed in both fields must be identical.')).get_response() _('The passwords typed in both fields must be identical.'))
return return
jid = username + '@' + server jid = username + '@' + server
@ -2559,7 +2554,7 @@ class AccountCreationWizardWindow:
jid = helpers.parse_jid(jid) jid = helpers.parse_jid(jid)
except helpers.InvalidFormat, s: except helpers.InvalidFormat, s:
pritext = _('Invalid Jabber ID') pritext = _('Invalid Jabber ID')
dialogs.ErrorDialog(pritext, str(s)).get_response() dialogs.ErrorDialog(pritext, str(s))
return return
already_in_jids = [] already_in_jids = []
@ -2571,7 +2566,7 @@ class AccountCreationWizardWindow:
if jid in already_in_jids: if jid in already_in_jids:
pritext = _('Duplicate Jabber ID') pritext = _('Duplicate Jabber ID')
sectext = _('This account is already configured in Gajim.') sectext = _('This account is already configured in Gajim.')
dialogs.ErrorDialog(pritext, sectext).get_response() dialogs.ErrorDialog(pritext, sectext)
return return
self.account = server self.account = server
@ -2694,7 +2689,7 @@ _('You can set advanced account options by pressing Advanced button, or later by
def save_account(self, login, server, savepass, password): def save_account(self, login, server, savepass, password):
if self.account in gajim.connections: if self.account in gajim.connections:
dialogs.ErrorDialog(_('Account name is in use'), dialogs.ErrorDialog(_('Account name is in use'),
_('You already have an account using this name.')).get_response() _('You already have an account using this name.'))
return return
con = connection.Connection(self.account) con = connection.Connection(self.account)
con.password = password con.password = password

View file

@ -450,13 +450,13 @@ _('Please fill in the data of the contact you want to add in account %s') %accou
jid = helpers.parse_jid(jid) jid = helpers.parse_jid(jid)
except helpers.InvalidFormat, s: except helpers.InvalidFormat, s:
pritext = _('Invalid User ID') pritext = _('Invalid User ID')
ErrorDialog(pritext, str(s)).get_response() ErrorDialog(pritext, str(s))
return return
# No resource in jid # No resource in jid
if jid.find('/') >= 0: if jid.find('/') >= 0:
pritext = _('Invalid User ID') pritext = _('Invalid User ID')
ErrorDialog(pritext, _('The user ID must not contain a resource.')).get_response() ErrorDialog(pritext, _('The user ID must not contain a resource.'))
return return
# Check if jid is already in roster # Check if jid is already in roster
@ -464,7 +464,7 @@ _('Please fill in the data of the contact you want to add in account %s') %accou
c = gajim.contacts.get_first_contact_from_jid(self.account, jid) c = gajim.contacts.get_first_contact_from_jid(self.account, jid)
if _('Not in Roster') not in c.groups and c.sub in ('both', 'to'): if _('Not in Roster') not in c.groups and c.sub in ('both', 'to'):
ErrorDialog(_('Contact already in roster'), ErrorDialog(_('Contact already in roster'),
_('This contact is already listed in your roster.')).get_response() _('This contact is already listed in your roster.'))
return return
message_buffer = self.xml.get_widget('message_textview').get_buffer() message_buffer = self.xml.get_widget('message_textview').get_buffer()
@ -589,14 +589,45 @@ class Dialog(gtk.Dialog):
return index < len(buttons) and buttons[index] or None return index < len(buttons) and buttons[index] or None
class HigDialog(gtk.MessageDialog): class HigDialog(gtk.MessageDialog):
def __init__(self, parent, type, buttons, pritext, sectext): def __init__(self, parent, type, buttons, pritext, sectext,
on_response_ok = None, on_response_cancel = None, on_response_yes = None,
on_response_no = None):
gtk.MessageDialog.__init__(self, parent, gtk.MessageDialog.__init__(self, parent,
gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_MODAL, gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_MODAL,
type, buttons, message_format = pritext) type, buttons, message_format = pritext)
self.format_secondary_text(sectext) self.format_secondary_text(sectext)
buttons = self.action_area.get_children()
possible_response = {gtk.STOCK_OK: on_response_ok,
gtk.STOCK_CANCEL: on_response_cancel, gtk.STOCK_YES: on_response_yes,
gtk.STOCK_NO: on_response_no}
for b in buttons:
for response in possible_response:
if b.get_label() == response:
if not possible_response[response]:
b.connect('clicked', self.just_destroy)
elif isinstance(possible_response[response], tuple):
if len(possible_response[response]) == 1:
b.connect('clicked', possible_response[response][0])
else:
b.connect('clicked', *possible_response[response])
else:
b.connect('clicked', possible_response[response])
break
def just_destroy(self, widget):
self.destroy()
def popup(self):
# Give focus to top vbox
vb = self.get_children()[0].get_children()[0]
vb.set_flags(gtk.CAN_FOCUS)
vb.grab_focus()
self.show_all()
def get_response(self): def get_response(self):
'''Be carefull: this function uses dialog.run() function so GUI is not updated'''
# Give focus to top vbox # Give focus to top vbox
vb = self.get_children()[0].get_children()[0] vb = self.get_children()[0].get_children()[0]
vb.set_flags(gtk.CAN_FOCUS) vb.set_flags(gtk.CAN_FOCUS)
@ -608,45 +639,49 @@ class HigDialog(gtk.MessageDialog):
class ConfirmationDialog(HigDialog): class ConfirmationDialog(HigDialog):
'''HIG compliant confirmation dialog.''' '''HIG compliant confirmation dialog.'''
def __init__(self, pritext, sectext=''): def __init__(self, pritext, sectext='', on_response_ok = None,
on_response_cancel = None):
HigDialog.__init__(self, None, HigDialog.__init__(self, None,
gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, pritext, sectext) gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, pritext, sectext,
on_response_ok, on_response_cancel)
self.popup()
class WarningDialog(HigDialog): class WarningDialog(HigDialog):
def __init__(self, pritext, sectext=''): def __init__(self, pritext, sectext=''):
'''HIG compliant warning dialog.''' '''HIG compliant warning dialog.'''
HigDialog.__init__( self, None, HigDialog.__init__( self, None,
gtk.MESSAGE_WARNING, gtk.BUTTONS_OK, pritext, sectext) gtk.MESSAGE_WARNING, gtk.BUTTONS_OK, pritext, sectext)
self.popup()
class InformationDialog(HigDialog): class InformationDialog(HigDialog):
def __init__(self, pritext, sectext=''): def __init__(self, pritext, sectext=''):
'''HIG compliant info dialog.''' '''HIG compliant info dialog.'''
HigDialog.__init__( self, None, HigDialog.__init__( self, None,
gtk.MESSAGE_INFO, gtk.BUTTONS_OK, pritext, sectext) gtk.MESSAGE_INFO, gtk.BUTTONS_OK, pritext, sectext)
ok_button = self.action_area.get_children()[0] self.popup()
ok_button.connect('clicked', self.on_ok_button_clicked)
self.show_all()
def on_ok_button_clicked(self, widget):
self.destroy()
class ErrorDialog(HigDialog): class ErrorDialog(HigDialog):
def __init__(self, pritext, sectext=''): def __init__(self, pritext, sectext=''):
'''HIG compliant error dialog.''' '''HIG compliant error dialog.'''
HigDialog.__init__( self, None, HigDialog.__init__( self, None,
gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, pritext, sectext) gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, pritext, sectext)
self.popup()
class YesNoDialog(HigDialog): class YesNoDialog(HigDialog):
def __init__(self, pritext, sectext=''): def __init__(self, pritext, sectext='', on_response_yes = None,
on_response_no = None):
'''HIG compliant YesNo dialog.''' '''HIG compliant YesNo dialog.'''
HigDialog.__init__( self, None, HigDialog.__init__( self, None,
gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, pritext, sectext) gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, pritext, sectext,
on_response_yes = on_response_yes, on_response_no = on_response_no)
class ConfirmationDialogCheck(ConfirmationDialog): class ConfirmationDialogCheck(ConfirmationDialog):
'''HIG compliant confirmation dialog with checkbutton.''' '''HIG compliant confirmation dialog with checkbutton.'''
def __init__(self, pritext, sectext='', checktext = ''): def __init__(self, pritext, sectext='', checktext = '',
HigDialog.__init__(self, None, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, on_response_ok = None, on_response_cancel = None):
pritext, sectext) HigDialog.__init__(self, None, gtk.MESSAGE_QUESTION,
gtk.BUTTONS_OK_CANCEL, pritext, sectext, on_response_ok,
on_response_cancel)
self.set_default_response(gtk.RESPONSE_OK) self.set_default_response(gtk.RESPONSE_OK)
@ -775,7 +810,7 @@ class JoinGroupchatWindow:
nick = gajim.nicks[self.account] nick = gajim.nicks[self.account]
if gajim.connections[account].connected < 2: if gajim.connections[account].connected < 2:
ErrorDialog(_('You are not connected to the server'), ErrorDialog(_('You are not connected to the server'),
_('You can not join a group chat unless you are connected.')).get_response() _('You can not join a group chat unless you are connected.'))
raise RuntimeError, 'You must be connected to join a groupchat' raise RuntimeError, 'You must be connected to join a groupchat'
self._empty_required_widgets = [] self._empty_required_widgets = []
@ -911,8 +946,7 @@ class NewMessageDialog:
if gajim.connections[self.account].connected <= 1: if gajim.connections[self.account].connected <= 1:
#if offline or connecting #if offline or connecting
ErrorDialog(_('Connection not available'), ErrorDialog(_('Connection not available'),
_('Please make sure you are connected with "%s".' % self.account) _('Please make sure you are connected with "%s".' % self.account))
).get_response()
return return
gajim.interface.roster.new_chat_from_jid(self.account, jid) gajim.interface.roster.new_chat_from_jid(self.account, jid)
@ -922,7 +956,7 @@ class ChangePasswordDialog:
# 'account' can be None if we are about to create our first one # 'account' can be None if we are about to create our first one
if not account or gajim.connections[account].connected < 2: if not account or gajim.connections[account].connected < 2:
ErrorDialog(_('You are not connected to the server'), ErrorDialog(_('You are not connected to the server'),
_('Without a connection, you can not change your password.')).get_response() _('Without a connection, you can not change your password.'))
raise RuntimeError, 'You are not connected to the server' raise RuntimeError, 'You are not connected to the server'
self.account = account self.account = account
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'change_password_dialog', APP) self.xml = gtk.glade.XML(GTKGUI_GLADE, 'change_password_dialog', APP)
@ -941,12 +975,12 @@ _('Without a connection, you can not change your password.')).get_response()
password1 = self.password1_entry.get_text().decode('utf-8') password1 = self.password1_entry.get_text().decode('utf-8')
if not password1: if not password1:
ErrorDialog(_('Invalid password'), ErrorDialog(_('Invalid password'),
_('You must enter a password.')).get_response() _('You must enter a password.'))
continue continue
password2 = self.password2_entry.get_text().decode('utf-8') password2 = self.password2_entry.get_text().decode('utf-8')
if password1 != password2: if password1 != password2:
ErrorDialog(_('Passwords do not match'), ErrorDialog(_('Passwords do not match'),
_('The passwords typed in both fields must be identical.')).get_response() _('The passwords typed in both fields must be identical.'))
continue continue
message = password1 message = password1
else: else:
@ -1164,7 +1198,7 @@ class SingleMessageWindow:
gtkspell.Spell(self.message_textview) gtkspell.Spell(self.message_textview)
except gobject.GError, msg: except gobject.GError, msg:
#FIXME: add a ui for this use spell.set_language() #FIXME: add a ui for this use spell.set_language()
ErrorDialog(unicode(msg), _('If that is not your language for which you want to highlight misspelled words, then please set your $LANG as appropriate. Eg. for French do export LANG=fr_FR or export LANG=fr_FR.UTF-8 in ~/.bash_profile or to make it global in /etc/profile.\n\nHighlighting misspelled words feature will not be used')).get_response() ErrorDialog(unicode(msg), _('If that is not your language for which you want to highlight misspelled words, then please set your $LANG as appropriate. Eg. for French do export LANG=fr_FR or export LANG=fr_FR.UTF-8 in ~/.bash_profile or to make it global in /etc/profile.\n\nHighlighting misspelled words feature will not be used'))
gajim.config.set('use_speller', False) gajim.config.set('use_speller', False)
self.send_button.set_no_show_all(True) self.send_button.set_no_show_all(True)
@ -1288,8 +1322,7 @@ class SingleMessageWindow:
if gajim.connections[self.account].connected <= 1: if gajim.connections[self.account].connected <= 1:
# if offline or connecting # if offline or connecting
ErrorDialog(_('Connection not available'), ErrorDialog(_('Connection not available'),
_('Please make sure you are connected with "%s".' % self.account) _('Please make sure you are connected with "%s".' % self.account))
).get_response()
return return
to_whom_jid = self.to_entry.get_text().decode('utf-8') to_whom_jid = self.to_entry.get_text().decode('utf-8')
subject = self.subject_entry.get_text().decode('utf-8') subject = self.subject_entry.get_text().decode('utf-8')
@ -1408,8 +1441,7 @@ class XMLConsoleWindow:
if gajim.connections[self.account].connected <= 1: if gajim.connections[self.account].connected <= 1:
#if offline or connecting #if offline or connecting
ErrorDialog(_('Connection not available'), ErrorDialog(_('Connection not available'),
_('Please make sure you are connected with "%s".' % self.account) _('Please make sure you are connected with "%s".' % self.account))
).get_response()
return return
begin_iter, end_iter = self.input_tv_buffer.get_bounds() begin_iter, end_iter = self.input_tv_buffer.get_bounds()
stanza = self.input_tv_buffer.get_text(begin_iter, end_iter).decode('utf-8') stanza = self.input_tv_buffer.get_text(begin_iter, end_iter).decode('utf-8')
@ -1439,9 +1471,11 @@ class XMLConsoleWindow:
class InvitationReceivedDialog: class InvitationReceivedDialog:
def __init__(self, account, room_jid, contact_jid, password = None, comment = None): def __init__(self, account, room_jid, contact_jid, password = None, comment = None):
self.room_jid = room_jid
self.account = account
xml = gtk.glade.XML(GTKGUI_GLADE, 'invitation_received_dialog', APP) xml = gtk.glade.XML(GTKGUI_GLADE, 'invitation_received_dialog', APP)
dialog = xml.get_widget('invitation_received_dialog') self.dialog = xml.get_widget('invitation_received_dialog')
#FIXME: use nickname instead of contact_jid #FIXME: use nickname instead of contact_jid
pritext = _('%(contact_jid)s has invited you to %(room_jid)s room') % { pritext = _('%(contact_jid)s has invited you to %(room_jid)s room') % {
@ -1454,12 +1488,20 @@ class InvitationReceivedDialog:
label_text += '\n\n%s' % sectext label_text += '\n\n%s' % sectext
xml.get_widget('label').set_markup(label_text) xml.get_widget('label').set_markup(label_text)
response = dialog.run() xml.get_widget('deny_button').connect('clicked',
dialog.destroy() self.on_deny_button_clicked)
if response == gtk.RESPONSE_YES: xml.get_widget('accept_button').connect('clicked',
room, server = gajim.get_room_name_and_server_from_room_jid(room_jid) self.on_accept_button_clicked)
JoinGroupchatWindow(account, server = server, room = room) self.dialog.show_all()
def on_deny_button_clicked(self, widget):
self.dialog.destroy()
def on_accept_button_clicked(self, widget):
self.dialog.destroy()
room, server = gajim.get_room_name_and_server_from_room_jid(self.room_jid)
JoinGroupchatWindow(self.account, server = server, room = room)
class ProgressDialog: class ProgressDialog:
def __init__(self, title_text, during_text, messages_queue): def __init__(self, title_text, during_text, messages_queue):

View file

@ -417,7 +417,7 @@ class ServiceDiscoveryWindow:
# Check connection # Check connection
if gajim.connections[account].connected < 2: if gajim.connections[account].connected < 2:
dialogs.ErrorDialog(_('You are not connected to the server'), dialogs.ErrorDialog(_('You are not connected to the server'),
_('Without a connection, you can not browse available services')).get_response() _('Without a connection, you can not browse available services'))
raise RuntimeError, 'You must be connected to browse services' raise RuntimeError, 'You must be connected to browse services'
# Get a ServicesCache object. # Get a ServicesCache object.
@ -635,12 +635,12 @@ _('Without a connection, you can not browse available services')).get_response()
# We can't travel anywhere else. # We can't travel anywhere else.
self.destroy() self.destroy()
dialogs.ErrorDialog(_('The service could not be found'), dialogs.ErrorDialog(_('The service could not be found'),
_('There is no service at the address you entered, or it is not responding. Check the address and try again.')).get_response() _('There is no service at the address you entered, or it is not responding. Check the address and try again.'))
return return
klass = self.cache.get_browser(identities, features) klass = self.cache.get_browser(identities, features)
if not klass: if not klass:
dialogs.ErrorDialog(_('The service is not browsable'), dialogs.ErrorDialog(_('The service is not browsable'),
_('This type of service does not contain any items to browse.')).get_response() _('This type of service does not contain any items to browse.'))
return return
elif klass is None: elif klass is None:
klass = AgentBrowser klass = AgentBrowser
@ -922,7 +922,7 @@ class AgentBrowser:
# We can't travel anywhere else. # We can't travel anywhere else.
self.window.destroy() self.window.destroy()
dialogs.ErrorDialog(_('The service is not browsable'), dialogs.ErrorDialog(_('The service is not browsable'),
_('This service does not contain any items to browse.')).get_response() _('This service does not contain any items to browse.'))
return return
# We got a list of items # We got a list of items
for item in items: for item in items:

View file

@ -159,6 +159,16 @@ class FileTransfersWindow:
''' show a dialog saying that file (file_props) has been transferred''' ''' show a dialog saying that file (file_props) has been transferred'''
self.window.present() self.window.present()
self.window.window.focus() self.window.window.focus()
def on_open(widget, file_props):
self.dialog.destroy()
if not file_props.has_key('file-name'):
return
(path, file) = os.path.split(file_props['file-name'])
if os.path.exists(path) and os.path.isdir(path):
helpers.launch_file_manager(path)
self.tree.get_selection().unselect_all()
if file_props['type'] == 'r': if file_props['type'] == 'r':
# file path is used below in 'Save in' # file path is used below in 'Save in'
(file_path, file_name) = os.path.split(file_props['file-name']) (file_path, file_name) = os.path.split(file_props['file-name'])
@ -190,22 +200,18 @@ class FileTransfersWindow:
if file_props['type'] == 'r': if file_props['type'] == 'r':
sectext += '\n\t' +_('Saved in: %s') % \ sectext += '\n\t' +_('Saved in: %s') % \
gtkgui_helpers.escape_for_pango_markup(file_path) gtkgui_helpers.escape_for_pango_markup(file_path)
dialog = dialogs.HigDialog(None, gtk.MESSAGE_INFO, gtk.BUTTONS_NONE, self.dialog = dialogs.HigDialog(None, gtk.MESSAGE_INFO, gtk.BUTTONS_NONE,
_('File transfer completed'), sectext) _('File transfer completed'), sectext)
if file_props['type'] == 'r': if file_props['type'] == 'r':
dialog.add_buttons(_('_Open Containing Folder'), gtk.RESPONSE_ACCEPT) button = gtk.Button(_('_Open Containing Folder'))
dialog.add_buttons(gtk.STOCK_OK, gtk.RESPONSE_OK) button.connect('clicked', on_open, file_props)
dialog.show_all() self.dialog.action_area.pack_start(button)
response = dialog.run() ok_button = self.dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
dialog.destroy() def on_ok(widget):
if response == gtk.RESPONSE_ACCEPT: self.dialog.destroy()
if not file_props.has_key('file-name'): ok_button.connect('clicked', on_ok)
return self.dialog.show_all()
(path, file) = os.path.split(file_props['file-name'])
if os.path.exists(path) and os.path.isdir(path):
helpers.launch_file_manager(path)
self.tree.get_selection().unselect_all()
def show_request_error(self, file_props): def show_request_error(self, file_props):
''' show error dialog to the recipient saying that transfer ''' show error dialog to the recipient saying that transfer
has been canceled''' has been canceled'''
@ -213,7 +219,7 @@ class FileTransfersWindow:
self.window.window.focus() self.window.window.focus()
dialogs.InformationDialog(_('File transfer canceled'), _('Connection with peer cannot be established.')) dialogs.InformationDialog(_('File transfer canceled'), _('Connection with peer cannot be established.'))
self.tree.get_selection().unselect_all() self.tree.get_selection().unselect_all()
def show_send_error(self, file_props): def show_send_error(self, file_props):
''' show error dialog to the sender saying that transfer ''' show error dialog to the sender saying that transfer
has been canceled''' has been canceled'''
@ -222,7 +228,7 @@ class FileTransfersWindow:
dialogs.InformationDialog(_('File transfer canceled'), dialogs.InformationDialog(_('File transfer canceled'),
_('Connection with peer cannot be established.')) _('Connection with peer cannot be established.'))
self.tree.get_selection().unselect_all() self.tree.get_selection().unselect_all()
def show_stopped(self, jid, file_props): def show_stopped(self, jid, file_props):
self.window.present() self.window.present()
self.window.window.focus() self.window.window.focus()
@ -235,9 +241,9 @@ _('Connection with peer cannot be established.'))
sectext += '\n\t' + _('Sender: %s') % \ sectext += '\n\t' + _('Sender: %s') % \
gtkgui_helpers.escape_for_pango_markup(jid) gtkgui_helpers.escape_for_pango_markup(jid)
dialogs.ErrorDialog(_('File transfer stopped by the contact of the other side'), \ dialogs.ErrorDialog(_('File transfer stopped by the contact of the other side'), \
sectext).get_response() sectext)
self.tree.get_selection().unselect_all() self.tree.get_selection().unselect_all()
def show_file_send_request(self, account, contact): def show_file_send_request(self, account, contact):
last_send_dir = gajim.config.get('last_send_dir') last_send_dir = gajim.config.get('last_send_dir')
dialog = gtk.FileChooserDialog(title=_('Choose File to Send...'), dialog = gtk.FileChooserDialog(title=_('Choose File to Send...'),
@ -269,15 +275,15 @@ _('Connection with peer cannot be established.'))
else: else:
dialog.destroy() dialog.destroy()
break break
def send_file(self, account, contact, file_path): def send_file(self, account, contact, file_path):
''' start the real transfer(upload) of the file ''' ''' start the real transfer(upload) of the file '''
if gtkgui_helpers.file_is_locked(file_path): if gtkgui_helpers.file_is_locked(file_path):
pritext = _('Gajim cannot access this file') pritext = _('Gajim cannot access this file')
sextext = _('This file is being used by another process.') sextext = _('This file is being used by another process.')
dialogs.ErrorDialog(pritext, sextext).get_response() dialogs.ErrorDialog(pritext, sextext)
return return
if isinstance(contact, str): if isinstance(contact, str):
if contact.find('/') == -1: if contact.find('/') == -1:
return return
@ -292,7 +298,7 @@ _('Connection with peer cannot be established.'))
self.add_transfer(account, contact, file_props) self.add_transfer(account, contact, file_props)
gajim.connections[account].send_file_request(file_props) gajim.connections[account].send_file_request(file_props)
return True return True
def confirm_overwrite_cb(self, dialog, file_props): def confirm_overwrite_cb(self, dialog, file_props):
file_path = dialog.get_filename() file_path = dialog.get_filename()
file_path = gtkgui_helpers.decode_filechooser_file_paths((file_path,))[0] file_path = gtkgui_helpers.decode_filechooser_file_paths((file_path,))[0]
@ -316,7 +322,6 @@ _('Connection with peer cannot be established.'))
file requested by a contact''' file requested by a contact'''
if file_props is None or not file_props.has_key('name'): if file_props is None or not file_props.has_key('name'):
return return
last_save_dir = gajim.config.get('last_save_dir')
sec_text = '\t' + _('File: %s') % file_props['name'] sec_text = '\t' + _('File: %s') % file_props['name']
if file_props.has_key('size'): if file_props.has_key('size'):
sec_text += '\n\t' + _('Size: %s') % \ sec_text += '\n\t' + _('Size: %s') % \
@ -326,8 +331,8 @@ _('Connection with peer cannot be established.'))
if file_props.has_key('desc'): if file_props.has_key('desc'):
sec_text += '\n\t' + _('Description: %s') % file_props['desc'] sec_text += '\n\t' + _('Description: %s') % file_props['desc']
prim_text = _('%s wants to send you a file:') % contact.jid prim_text = _('%s wants to send you a file:') % contact.jid
dialog = dialogs.ConfirmationDialog(prim_text, sec_text) def on_response_ok(widet, account, contact, file_props):
if dialog.get_response() == gtk.RESPONSE_OK: self.dialog.destroy()
dialog = gtk.FileChooserDialog(title=_('Save File as...'), dialog = gtk.FileChooserDialog(title=_('Save File as...'),
action=gtk.FILE_CHOOSER_ACTION_SAVE, action=gtk.FILE_CHOOSER_ACTION_SAVE,
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
@ -340,6 +345,7 @@ _('Connection with peer cannot be established.'))
dialog.connect('confirm-overwrite', self.confirm_overwrite_cb, dialog.connect('confirm-overwrite', self.confirm_overwrite_cb,
file_props) file_props)
gtk28 = True gtk28 = True
last_save_dir = gajim.config.get('last_save_dir')
if last_save_dir and os.path.isdir(last_save_dir): if last_save_dir and os.path.isdir(last_save_dir):
dialog.set_current_folder(last_save_dir) dialog.set_current_folder(last_save_dir)
else: else:
@ -366,9 +372,16 @@ _('Connection with peer cannot be established.'))
gajim.connections[account].send_file_rejection(file_props) gajim.connections[account].send_file_rejection(file_props)
dialog.destroy() dialog.destroy()
break break
else:
def on_response_cancel(widget, account, file_props):
self.dialog.destroy()
gajim.connections[account].send_file_rejection(file_props) gajim.connections[account].send_file_rejection(file_props)
self.dialog = dialogs.ConfirmationDialog(prim_text, sec_text,
on_response_ok = (on_response_ok, account, contact, file_props),
on_response_cancel = (on_response_cancel, account, file_props))
self.dialog.run()
def set_images(self): def set_images(self):
''' create pixbufs for status images in transfer rows''' ''' create pixbufs for status images in transfer rows'''
self.images = {} self.images = {}
@ -533,11 +546,11 @@ _('Connection with peer cannot be established.'))
stat = os.stat(file_path) stat = os.stat(file_path)
else: else:
dialogs.ErrorDialog(_('Invalid File'), _('File: ') + file_path).get_response() dialogs.ErrorDialog(_('Invalid File'), _('File: ') + file_path)
return None return None
if stat[6] == 0: if stat[6] == 0:
dialogs.ErrorDialog(_('Invalid File'), dialogs.ErrorDialog(_('Invalid File'),
_('It is not possible to send empty files')).get_response() _('It is not possible to send empty files'))
return None return None
file_props['elapsed-time'] = 0 file_props['elapsed-time'] = 0
file_props['size'] = unicode(stat[6]) file_props['size'] = unicode(stat[6])

View file

@ -192,11 +192,11 @@ class Interface:
def handle_event_warning(self, unused, data): def handle_event_warning(self, unused, data):
#('WARNING', account, (title_text, section_text)) #('WARNING', account, (title_text, section_text))
dialogs.WarningDialog(data[0], data[1]).get_response() dialogs.WarningDialog(data[0], data[1])
def handle_event_error(self, unused, data): def handle_event_error(self, unused, data):
#('ERROR', account, (title_text, section_text)) #('ERROR', account, (title_text, section_text))
dialogs.ErrorDialog(data[0], data[1]).get_response() dialogs.ErrorDialog(data[0], data[1])
def handle_event_information(self, unused, data): def handle_event_information(self, unused, data):
#('INFORMATION', account, (title_text, section_text)) #('INFORMATION', account, (title_text, section_text))
@ -214,13 +214,14 @@ class Interface:
def handle_event_http_auth(self, account, data): def handle_event_http_auth(self, account, data):
#('HTTP_AUTH', account, (method, url, transaction_id, iq_obj)) #('HTTP_AUTH', account, (method, url, transaction_id, iq_obj))
dialog = dialogs.ConfirmationDialog(_('HTTP (%s) Authorization for %s (id: %s)') \ def response(widget, account, iq_obj, answer):
% (data[0], data[1], data[2]), _('Do you accept this request?')) self.dialog.destroy()
if dialog.get_response() == gtk.RESPONSE_OK: gajim.connections[account].build_http_auth_answer(iq_obj, answer)
answer = 'yes'
else: self.dialog = dialogs.YesNoDialog(_('HTTP (%s) Authorization for %s (id: %s)') \
answer = 'no' % (data[0], data[1], data[2]), _('Do you accept this request?'),
gajim.connections[account].build_http_auth_answer(data[3], answer) on_response_yes = (response, account, data[3], 'yes'),
on_response_no = (response, account, data[3], 'no'))
def handle_event_error_answer(self, account, array): def handle_event_error_answer(self, account, array):
#('ERROR_ANSWER', account, (id, jid_from. errmsg, errcode)) #('ERROR_ANSWER', account, (id, jid_from. errmsg, errcode))
@ -518,6 +519,8 @@ class Interface:
# Handle chat states # Handle chat states
contact = gajim.contacts.get_contact(account, jid, resource) contact = gajim.contacts.get_contact(account, jid, resource)
if isinstance(contact, list):
contact = contact[0]
if contact: if contact:
contact.composing_jep = composing_jep contact.composing_jep = composing_jep
if chat_control and chat_control.type_id == message_control.TYPE_CHAT: if chat_control and chat_control.type_id == message_control.TYPE_CHAT:
@ -716,7 +719,7 @@ class Interface:
array[2]) array[2])
else: else:
dialogs.ErrorDialog(_('Contact with "%s" cannot be established'\ dialogs.ErrorDialog(_('Contact with "%s" cannot be established'\
% array[0]), _('Check your connection or try again later.')).get_response() % array[0]), _('Check your connection or try again later.'))
def handle_event_agent_info_items(self, account, array): def handle_event_agent_info_items(self, account, array):
#('AGENT_INFO_ITEMS', account, (agent, node, items)) #('AGENT_INFO_ITEMS', account, (agent, node, items))
@ -943,7 +946,7 @@ class Interface:
keyID = gajim.config.get_per('accounts', account, 'keyid') keyID = gajim.config.get_per('accounts', account, 'keyid')
self.roster.forget_gpg_passphrase(keyID) self.roster.forget_gpg_passphrase(keyID)
dialogs.WarningDialog(_('Your passphrase is incorrect'), dialogs.WarningDialog(_('Your passphrase is incorrect'),
_('You are currently connected without your OpenPGP key.')).get_response() _('You are currently connected without your OpenPGP key.'))
def handle_event_roster_info(self, account, array): def handle_event_roster_info(self, account, array):
#('ROSTER_INFO', account, (jid, name, sub, ask, groups)) #('ROSTER_INFO', account, (jid, name, sub, ask, groups))
@ -1560,7 +1563,7 @@ class Interface:
# it is good to notify the user # it is good to notify the user
# in case he or she cannot see the output of the console # in case he or she cannot see the output of the console
dialogs.ErrorDialog(_('Could not save your settings and preferences'), dialogs.ErrorDialog(_('Could not save your settings and preferences'),
err_str).get_response() err_str)
sys.exit() sys.exit()
def handle_event(self, account, jid, typ): def handle_event(self, account, jid, typ):

View file

@ -164,7 +164,7 @@ class GajimThemesWindow:
if self.current_theme == gajim.config.get('roster_theme'): if self.current_theme == gajim.config.get('roster_theme'):
dialogs.ErrorDialog( dialogs.ErrorDialog(
_('You cannot delete your current theme'), _('You cannot delete your current theme'),
_('Please first choose another for your current theme.')).get_response() _('Please first choose another for your current theme.'))
return return
self.theme_options_vbox.set_sensitive(False) self.theme_options_vbox.set_sensitive(False)
gajim.config.del_per('themes', self.current_theme) gajim.config.del_per('themes', self.current_theme)

View file

@ -84,7 +84,7 @@ class PrivateChatControl(ChatControl):
_('Sending private message failed'), _('Sending private message failed'),
#in second %s code replaces with nickname #in second %s code replaces with nickname
_('You are no longer in room "%s" or "%s" has left.') % \ _('You are no longer in room "%s" or "%s" has left.') % \
(room, nick)).get_response() (room, nick))
return return
ChatControl.send_message(self, message) ChatControl.send_message(self, message)
@ -1171,8 +1171,7 @@ class GroupchatControl(ChatControlBase):
if bookmark['jid'] == bm['jid']: if bookmark['jid'] == bm['jid']:
dialogs.ErrorDialog( dialogs.ErrorDialog(
_('Bookmark already set'), _('Bookmark already set'),
_('Room "%s" is already in your bookmarks.') % bm['jid']).\ _('Room "%s" is already in your bookmarks.') % bm['jid'])
get_response()
return return
gajim.connections[self.account].bookmarks.append(bm) gajim.connections[self.account].bookmarks.append(bm)

View file

@ -53,7 +53,7 @@ class HistoryManager:
def __init__(self): def __init__(self):
if not os.path.exists(LOG_DB_PATH): if not os.path.exists(LOG_DB_PATH):
dialogs.ErrorDialog(_('Cannot find history logs database'), dialogs.ErrorDialog(_('Cannot find history logs database'),
'%s does not exist.' % LOG_DB_PATH).get_response() '%s does not exist.' % LOG_DB_PATH)
sys.exit() sys.exit()
xml = gtk.glade.XML('history_manager.glade', xml = gtk.glade.XML('history_manager.glade',
@ -412,76 +412,78 @@ class HistoryManager:
paths_len = len(list_of_paths) paths_len = len(list_of_paths)
if paths_len == 0: # nothing is selected if paths_len == 0: # nothing is selected
return return
def on_ok(widget, liststore, list_of_paths):
# delete all rows from db that match jid_id
list_of_rowrefs = []
for path in list_of_paths: # make them treerowrefs (it's needed)
list_of_rowrefs.append(gtk.TreeRowReference(liststore, path))
for rowref in list_of_rowrefs:
path = rowref.get_path()
if path is None:
continue
jid_id = liststore[path][1]
del liststore[path] # remove from UI
# remove from db
self.cur.execute('''
DELETE FROM logs
WHERE jid_id = ?
''', (jid_id,))
# now delete "jid, jid_id" row from jids table
self.cur.execute('''
DELETE FROM jids
WHERE jid_id = ?
''', (jid_id,))
self.con.commit()
self.AT_LEAST_ONE_DELETION_DONE = True
pri_text = i18n.ngettext( pri_text = i18n.ngettext(
'Do you really want to delete logs of the selected contact?', 'Do you really want to delete logs of the selected contact?',
'Do you really want to delete logs of the selected contacts?', 'Do you really want to delete logs of the selected contacts?',
paths_len) paths_len)
dialog = dialogs.ConfirmationDialog(pri_text, self.dialog = dialogs.ConfirmationDialog(pri_text,
_('This is an irreversible operation.')) _('This is an irreversible operation.'), on_response_ok = (on_ok,
if dialog.get_response() != gtk.RESPONSE_OK: liststore, list_of_paths))
return
# delete all rows from db that match jid_id
list_of_rowrefs = []
for path in list_of_paths: # make them treerowrefs (it's needed)
list_of_rowrefs.append(gtk.TreeRowReference(liststore, path))
for rowref in list_of_rowrefs:
path = rowref.get_path()
if path is None:
continue
jid_id = liststore[path][1]
del liststore[path] # remove from UI
# remove from db
self.cur.execute('''
DELETE FROM logs
WHERE jid_id = ?
''', (jid_id,))
# now delete "jid, jid_id" row from jids table
self.cur.execute('''
DELETE FROM jids
WHERE jid_id = ?
''', (jid_id,))
self.con.commit()
self.AT_LEAST_ONE_DELETION_DONE = True
def _delete_logs(self, liststore, list_of_paths): def _delete_logs(self, liststore, list_of_paths):
paths_len = len(list_of_paths) paths_len = len(list_of_paths)
if paths_len == 0: # nothing is selected if paths_len == 0: # nothing is selected
return return
def on_ok(widget, liststore, list_of_paths):
self.dialog.destroy()
# delete rows from db that match log_line_id
list_of_rowrefs = []
for path in list_of_paths: # make them treerowrefs (it's needed)
list_of_rowrefs.append(gtk.TreeRowReference(liststore, path))
for rowref in list_of_rowrefs:
path = rowref.get_path()
if path is None:
continue
log_line_id = liststore[path][0]
del liststore[path] # remove from UI
# remove from db
self.cur.execute('''
DELETE FROM logs
WHERE log_line_id = ?
''', (log_line_id,))
self.con.commit()
self.AT_LEAST_ONE_DELETION_DONE = True
pri_text = i18n.ngettext( pri_text = i18n.ngettext(
'Do you really want to delete the selected message?', 'Do you really want to delete the selected message?',
'Do you really want to delete the selected messages?', paths_len) 'Do you really want to delete the selected messages?', paths_len)
dialog = dialogs.ConfirmationDialog(pri_text, self.dialog = dialogs.ConfirmationDialog(pri_text,
_('This is an irreversible operation.')) _('This is an irreversible operation.'), on_response_ok = (on_ok,
if dialog.get_response() != gtk.RESPONSE_OK: liststore, list_of_paths))
return
# delete rows from db that match log_line_id
list_of_rowrefs = []
for path in list_of_paths: # make them treerowrefs (it's needed)
list_of_rowrefs.append(gtk.TreeRowReference(liststore, path))
for rowref in list_of_rowrefs:
path = rowref.get_path()
if path is None:
continue
log_line_id = liststore[path][0]
del liststore[path] # remove from UI
# remove from db
self.cur.execute('''
DELETE FROM logs
WHERE log_line_id = ?
''', (log_line_id,))
self.con.commit()
self.AT_LEAST_ONE_DELETION_DONE = True
def on_search_db_button_clicked(self, widget): def on_search_db_button_clicked(self, widget):
text = self.search_entry.get_text() text = self.search_entry.get_text()

View file

@ -513,13 +513,12 @@ class RosterWindow:
win = gajim.interface.msg_win_mgr.get_window(room_jid, account) win = gajim.interface.msg_win_mgr.get_window(room_jid, account)
win.window.present() win.window.present()
win.set_active_tab(room_jid, account) win.set_active_tab(room_jid, account)
dialogs.ErrorDialog(_('You are already in room %s') % room_jid dialogs.ErrorDialog(_('You are already in room %s') % room_jid)
).get_response()
return return
invisible_show = gajim.SHOW_LIST.index('invisible') invisible_show = gajim.SHOW_LIST.index('invisible')
if gajim.connections[account].connected == invisible_show: if gajim.connections[account].connected == invisible_show:
dialogs.ErrorDialog(_('You cannot join a room while you are invisible') dialogs.ErrorDialog(_('You cannot join a room while you are invisible')
).get_response() )
return return
room, server = room_jid.split('@') room, server = room_jid.split('@')
if not gajim.interface.msg_win_mgr.has_window(room_jid, account): if not gajim.interface.msg_win_mgr.has_window(room_jid, account):
@ -1065,8 +1064,8 @@ class RosterWindow:
gajim.contacts.remove_contact(account, contact) gajim.contacts.remove_contact(account, contact)
return return
window = dialogs.ConfirmationDialog(_('Transport "%s" will be removed') % contact.jid, _('You will no longer be able to send and receive messages to contacts from this transport.')) def remove(widget, contact, account):
if window.get_response() == gtk.RESPONSE_OK: self.dialog.destroy()
gajim.connections[account].unsubscribe_agent(contact.jid + '/' \ gajim.connections[account].unsubscribe_agent(contact.jid + '/' \
+ contact.resource) + contact.resource)
# remove transport from treeview # remove transport from treeview
@ -1086,6 +1085,8 @@ class RosterWindow:
gajim.contacts.remove_jid(account, contact.jid) gajim.contacts.remove_jid(account, contact.jid)
gajim.contacts.remove_contact(account, contact) gajim.contacts.remove_contact(account, contact)
self.dialog = dialogs.ConfirmationDialog(_('Transport "%s" will be removed') % contact.jid, _('You will no longer be able to send and receive messages to contacts from this transport.'), on_response_ok = (remove, contact, account))
def on_rename(self, widget, iter, path): def on_rename(self, widget, iter, path):
# this function is called either by F2 or by Rename menuitem # this function is called either by F2 or by Rename menuitem
# to display that menuitem we show a menu, that does focus-out # to display that menuitem we show a menu, that does focus-out
@ -1732,22 +1733,15 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
def on_req_usub(self, widget, contact, account): def on_req_usub(self, widget, contact, account):
'''Remove a contact''' '''Remove a contact'''
check_string = _('I want this contact to know my status after removal') def on_ok(widget, contact, account):
if contact.sub == 'to': self.dialog.destroy()
check_string = ''
window = dialogs.ConfirmationDialogCheck(
_('Contact "%s" will be removed from your roster') % (
contact.get_shown_name()),
_('By removing this contact you also by default remove authorization resulting in him or her always seeing you as offline.'), check_string)
# maybe use 2 optionboxes from which the contact can select? (better)
if window.get_response() == gtk.RESPONSE_OK:
remove_auth = True remove_auth = True
if window.is_checked(): if contact.sub != 'to' and self.dialog.is_checked():
remove_auth = False remove_auth = False
gajim.connections[account].unsubscribe(contact.jid, remove_auth) gajim.connections[account].unsubscribe(contact.jid, remove_auth)
for u in gajim.contacts.get_contact(account, contact.jid): for c in gajim.contacts.get_contact(account, contact.jid):
self.remove_contact(u, account) self.remove_contact(c, account)
gajim.contacts.remove_jid(account, u.jid) gajim.contacts.remove_jid(account, c.jid)
if not remove_auth and contact.sub == 'both': if not remove_auth and contact.sub == 'both':
contact.name = '' contact.name = ''
contact.groups = [] contact.groups = []
@ -1761,6 +1755,18 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
keyID = contact.keyID) keyID = contact.keyID)
gajim.contacts.add_contact(account, c) gajim.contacts.add_contact(account, c)
self.add_contact_to_roster(contact.jid, account) self.add_contact_to_roster(contact.jid, account)
pritext = _('Contact "%s" will be removed from your roster') % \
contact.get_shown_name()
if contact.sub == 'to':
self.dialog = dialogs.ConfirmationDialog(pritext,
_('By removing this contact you also remove authorization resulting in him or her always seeing you as offline.'),
on_response_ok = (on_ok, contact, account))
else:
self.dialog = dialogs.ConfirmationDialogCheck(pritext,
_('By removing this contact you also by default remove authorization resulting in him or her always seeing you as offline.'),
_('I want this contact to know my status after removal'),
on_response_ok = (on_ok, contact, account))
# maybe use 2 optionboxes from which the contact can select? (better)
def forget_gpg_passphrase(self, keyid): def forget_gpg_passphrase(self, keyid):
if self.gpg_passphrase.has_key(keyid): if self.gpg_passphrase.has_key(keyid):
@ -1878,17 +1884,23 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
return False return False
def change_status(self, widget, account, status): def change_status(self, widget, account, status):
if status == 'invisible': def change(widget, account, status):
if self.connected_rooms(account): if self.dialog:
dialog = dialogs.ConfirmationDialog( self.dialog.destroy()
_('You are participating in one or more group chats'), message = self.get_status_message(status)
_('Changing your status to invisible will result in disconnection from those group chats. Are you sure you want to go invisible?')) if message is None:
if dialog.get_response() != gtk.RESPONSE_OK: # user pressed Cancel to change status message dialog
return return
message = self.get_status_message(status) self.send_status(account, status, message)
if message is None: # user pressed Cancel to change status message dialog
return self.dialog = None
self.send_status(account, status, message) if status == 'invisible' and self.connected_rooms(account):
self.dialog = dialogs.ConfirmationDialog(
_('You are participating in one or more group chats'),
_('Changing your status to invisible will result in disconnection from those group chats. Are you sure you want to go invisible?'),
on_response_ok = (change, account, status))
else:
change(None, account, status)
def on_status_combobox_changed(self, widget): def on_status_combobox_changed(self, widget):
'''When we change our status via the combobox''' '''When we change our status via the combobox'''
@ -1902,8 +1914,7 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
accounts = gajim.connections.keys() accounts = gajim.connections.keys()
if len(accounts) == 0: if len(accounts) == 0:
dialogs.ErrorDialog(_('No account available'), dialogs.ErrorDialog(_('No account available'),
_('You must create an account before you can chat with other contacts.') _('You must create an account before you can chat with other contacts.'))
).get_response()
self.update_status_combobox() self.update_status_combobox()
return return
status = model[active][2].decode('utf-8') status = model[active][2].decode('utf-8')
@ -2177,7 +2188,7 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
invisible_show = gajim.SHOW_LIST.index('invisible') invisible_show = gajim.SHOW_LIST.index('invisible')
if gajim.connections[account].connected == invisible_show: if gajim.connections[account].connected == invisible_show:
dialogs.ErrorDialog(_('You cannot join a room while you are invisible') dialogs.ErrorDialog(_('You cannot join a room while you are invisible')
).get_response() )
return return
if gajim.interface.instances[account].has_key('join_gc'): if gajim.interface.instances[account].has_key('join_gc'):
gajim.interface.instances[account]['join_gc'].window.present() gajim.interface.instances[account]['join_gc'].window.present()

View file

@ -229,8 +229,7 @@ class VcardWindow:
scaled_pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, scaled_pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf,
'notification') 'notification')
except gobject.GError, msg: # unknown format except gobject.GError, msg: # unknown format
dialogs.ErrorDialog(_('Could not load image'), dialogs.ErrorDialog(_('Could not load image'), msg)
msg).get_response()
continue continue
else: else:
path_to_file = os.path.join(gajim.TMP, 'avatar_scaled.png') path_to_file = os.path.join(gajim.TMP, 'avatar_scaled.png')
@ -481,7 +480,7 @@ class VcardWindow:
if gajim.connections[self.account].connected < 2: if gajim.connections[self.account].connected < 2:
dialogs.ErrorDialog(_('You are not connected to the server'), dialogs.ErrorDialog(_('You are not connected to the server'),
_('Without a connection you can not publish your contact ' _('Without a connection you can not publish your contact '
'information.')).get_response() 'information.'))
return return
vcard = self.make_vcard() vcard = self.make_vcard()
nick = '' nick = ''
@ -509,7 +508,7 @@ class VcardWindow:
gajim.connections[self.account].request_vcard(self.jid) gajim.connections[self.account].request_vcard(self.jid)
else: else:
dialogs.ErrorDialog(_('You are not connected to the server'), dialogs.ErrorDialog(_('You are not connected to the server'),
_('Without a connection, you can not get your contact information.')).get_response() _('Without a connection, you can not get your contact information.'))
def change_to_vcard(self): def change_to_vcard(self):
self.xml.get_widget('information_notebook').remove_page(0) self.xml.get_widget('information_notebook').remove_page(0)