Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYann Leboulanger <asterix@lagaule.org>2008-08-07 17:25:25 +0400
committerYann Leboulanger <asterix@lagaule.org>2008-08-07 17:25:25 +0400
commit9329bcc4c12e2ecac97b68a64c8d0ec5fcaa0b8f (patch)
treedf9db38a40d9ec2e1cca72a21162f245420ebdbf
parentcb0049a1cb341a99e3e54129535ee6a62c9d770f (diff)
less and less blocking dialogs
-rw-r--r--src/dialogs.py41
-rw-r--r--src/filetransfers_window.py19
-rw-r--r--src/gtkgui_helpers.py81
-rwxr-xr-xsrc/history_manager.py17
-rw-r--r--src/roster_window.py75
5 files changed, 137 insertions, 96 deletions
diff --git a/src/dialogs.py b/src/dialogs.py
index 1397100bf..7c6a26a4c 100644
--- a/src/dialogs.py
+++ b/src/dialogs.py
@@ -632,11 +632,7 @@ class ChangeStatusMessageDialog:
start_iter, finish_iter = self.message_buffer.get_bounds()
status_message_to_save_as_preset = self.message_buffer.get_text(
start_iter, finish_iter)
- dlg = InputDialog(_('Save as Preset Status Message'),
- _('Please type a name for this status message'), is_modal = True)
- response = dlg.get_response()
- if response == gtk.RESPONSE_OK:
- msg_name = dlg.input_entry.get_text()
+ def on_ok(msg_name):
msg_text = status_message_to_save_as_preset.decode('utf-8')
msg_text_1l = helpers.to_one_line(msg_text)
if not msg_name: # msg_name was ''
@@ -644,13 +640,13 @@ class ChangeStatusMessageDialog:
msg_name = msg_name.decode('utf-8')
if msg_name in self.preset_messages_dict:
- def on_ok():
+ def on_ok2():
self.preset_messages_dict[msg_name] = msg_text
gajim.config.set_per('statusmsg', msg_name, 'message',
msg_text_1l)
dlg2 = ConfirmationDialog(_('Overwrite Status Message?'),
_('This name is already used. Do you want to overwrite this '
- 'status message?'), on_response_ok=on_ok)
+ 'status message?'), on_response_ok=on_ok2)
return
self.preset_messages_dict[msg_name] = msg_text
iter_ = self.message_liststore.append((msg_name,))
@@ -658,6 +654,9 @@ class ChangeStatusMessageDialog:
# select in combobox the one we just saved
self.message_combobox.set_active_iter(iter_)
gajim.config.set_per('statusmsg', msg_name, 'message', msg_text_1l)
+ InputDialog(_('Save as Preset Status Message'),
+ _('Please type a name for this status message'), is_modal=False,
+ ok_handler=on_ok)
class AddNewContactWindow:
'''Class for AddNewContactWindow'''
@@ -1435,6 +1434,12 @@ class ConfirmationDialogDubbleCheck(ConfirmationDialog):
class FTOverwriteConfirmationDialog(ConfirmationDialog):
'''HIG compliant confirmation dialog to overwrite or resume a file transfert'''
def __init__(self, pritext, sectext='', propose_resume=True):
+ self.user_response_ok = on_response_ok
+ self.user_response_cancel = on_response_cancel
+ HigDialog.__init__(self, None,
+ gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, pritext, sectext,
+ self.on_response_ok, self.on_response_cancel)
+ self.popup()
HigDialog.__init__(self, None, gtk.MESSAGE_QUESTION, gtk.BUTTONS_CANCEL,
pritext, sectext)
@@ -1455,6 +1460,22 @@ class FTOverwriteConfirmationDialog(ConfirmationDialog):
label.set_use_underline(True)
self.add_action_widget(b, 200)
+ def on_response_ok(self, widget):
+ if self.user_response_ok:
+ if isinstance(self.user_response_ok, tuple):
+ self.user_response_ok[0](*self.user_response_ok[1:])
+ else:
+ self.user_response_ok()
+ self.destroy()
+
+ def on_response_cancel(self, widget):
+ if self.user_response_cancel:
+ if isinstance(self.user_response_cancel, tuple):
+ self.user_response_cancel[0](*self.user_response_ok[1:])
+ else:
+ self.user_response_cancel()
+ self.destroy()
+
class CommonInputDialog:
'''Common Class for Input dialogs'''
def __init__(self, title, label_str, is_modal, ok_handler, cancel_handler):
@@ -3831,11 +3852,11 @@ class ESessionInfoWindow:
sectext = _('''To prevent a man-in-the-middle attack, you should speak to %(jid)s directly (in person or on the phone) and verify that they see the same Short Authentication String (SAS) as you.\n\nThis session's Short Authentication String: <b>%(sas)s</b>''') % {'jid': self.session.jid, 'sas': self.session.sas}
sectext += '\n\n' + _('Did you talk to the remote contact and verify the SAS?')
- dialog = YesNoDialog(pritext, sectext)
-
- if dialog.get_response() == gtk.RESPONSE_YES:
+ def on_yes(checked):
self.session._verified_srs_cb()
self.session.verified_identity = True
self.update_info()
+ YesNoDialog(pritext, sectext, on_response_yes=on_yes)
+
# vim: se ts=3:
diff --git a/src/filetransfers_window.py b/src/filetransfers_window.py
index 1ee6086ad..c5050ac6c 100644
--- a/src/filetransfers_window.py
+++ b/src/filetransfers_window.py
@@ -327,16 +327,21 @@ _('Connection with peer cannot be established.'))
dl_size = stat.st_size
file_size = file_props['size']
dl_finished = dl_size >= file_size
+
+ def on_response(response):
+ if response < 0:
+ return
+ elif response == 100:
+ file_props['offset'] = dl_size
+ dialog2.destroy()
+ self._start_receive(file_path, account, contact, file_props)
+
dialog = dialogs.FTOverwriteConfirmationDialog(
_('This file already exists'), _('What do you want to do?'),
- not dl_finished)
+ propose_resume=not dl_finished, on_response=on_response)
dialog.set_transient_for(dialog2)
dialog.set_destroy_with_parent(True)
- response = dialog.get_response()
- if response < 0:
- return
- elif response == 100:
- file_props['offset'] = dl_size
+ return
else:
dirname = os.path.dirname(file_path)
if not os.access(dirname, os.W_OK) and os.name != 'nt':
@@ -965,4 +970,4 @@ _('Connection with peer cannot be established.'))
self.window.hide()
-# vim: se ts=3: \ No newline at end of file
+# vim: se ts=3:
diff --git a/src/gtkgui_helpers.py b/src/gtkgui_helpers.py
index 5e4fcfe7e..36f0899f3 100644
--- a/src/gtkgui_helpers.py
+++ b/src/gtkgui_helpers.py
@@ -769,38 +769,9 @@ def destroy_widget(widget):
def on_avatar_save_as_menuitem_activate(widget, jid, account,
default_name = ''):
- def on_ok(widget):
- def on_ok2(file_path, pixbuf):
- pixbuf.save(file_path, 'jpeg')
- dialog.destroy()
-
- file_path = dialog.get_filename()
- file_path = decode_filechooser_file_paths((file_path,))[0]
- if os.path.exists(file_path):
- # check if we have write permissions
- if not os.access(file_path, os.W_OK):
- file_name = os.path.basename(file_path)
- dialogs.ErrorDialog(_('Cannot overwrite existing file "%s"' %
- file_name),
- _('A file with this name already exists and you do not have '
- 'permission to overwrite it.'))
- return
- dialog2 = dialogs.FTOverwriteConfirmationDialog(
- _('This file already exists'), _('What do you want to do?'),
- False)
- dialog2.set_transient_for(dialog)
- dialog2.set_destroy_with_parent(True)
- response = dialog2.get_response()
- if response < 0:
- return
- else:
- dirname = os.path.dirname(file_path)
- if not os.access(dirname, os.W_OK):
- dialogs.ErrorDialog(_('Directory "%s" is not writable') % \
- dirname, _('You do not have permission to create files in this'
- ' directory.'))
- return
-
+ def on_continue(response):
+ if response < 0:
+ return
# Get pixbuf
pixbuf = None
is_fake = False
@@ -831,18 +802,46 @@ default_name = ''):
else:
dialog.destroy()
+ def on_ok(widget):
+ def on_ok2(file_path, pixbuf):
+ pixbuf.save(file_path, 'jpeg')
+ dialog.destroy()
+
+ file_path = dialog.get_filename()
+ file_path = decode_filechooser_file_paths((file_path,))[0]
+ if os.path.exists(file_path):
+ # check if we have write permissions
+ if not os.access(file_path, os.W_OK):
+ file_name = os.path.basename(file_path)
+ dialogs.ErrorDialog(_('Cannot overwrite existing file "%s"' %
+ file_name),
+ _('A file with this name already exists and you do not have '
+ 'permission to overwrite it.'))
+ return
+ dialog2 = dialogs.FTOverwriteConfirmationDialog(
+ _('This file already exists'), _('What do you want to do?'),
+ propose_resume=False, on_response=on_continue)
+ dialog2.set_transient_for(dialog)
+ dialog2.set_destroy_with_parent(True)
+ else:
+ dirname = os.path.dirname(file_path)
+ if not os.access(dirname, os.W_OK):
+ dialogs.ErrorDialog(_('Directory "%s" is not writable') % \
+ dirname, _('You do not have permission to create files in this'
+ ' directory.'))
+ return
+
+ on_continue(0)
+
def on_cancel(widget):
dialog.destroy()
- dialog = dialogs.FileChooserDialog(
- title_text = _('Save Image as...'),
- action = gtk.FILE_CHOOSER_ACTION_SAVE,
- buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
- gtk.STOCK_SAVE, gtk.RESPONSE_OK),
- default_response = gtk.RESPONSE_OK,
- current_folder = gajim.config.get('last_save_dir'),
- on_response_ok = on_ok,
- on_response_cancel = on_cancel)
+ dialog = dialogs.FileChooserDialog(title_text=_('Save Image as...'),
+ action=gtk.FILE_CHOOSER_ACTION_SAVE, buttons=(gtk.STOCK_CANCEL,
+ gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE, gtk.RESPONSE_OK),
+ default_response=gtk.RESPONSE_OK,
+ current_folder=gajim.config.get('last_save_dir'), on_response_ok=on_ok,
+ on_response_cancel=on_cancel)
dialog.set_current_name(default_name)
dialog.connect('delete-event', lambda widget, event:
diff --git a/src/history_manager.py b/src/history_manager.py
index f20bab870..126fa968a 100755
--- a/src/history_manager.py
+++ b/src/history_manager.py
@@ -206,16 +206,23 @@ class HistoryManager:
def on_history_manager_window_delete_event(self, widget, event):
if self.AT_LEAST_ONE_DELETION_DONE:
+ def on_yes(clicked):
+ self.cur.execute('VACUUM')
+ self.con.commit()
+ gtk.main_quit()
+
+ def on_no():
+ gtk.main_quit()
+
dialog = dialogs.YesNoDialog(
_('Do you want to clean up the database? '
'(STRONGLY NOT RECOMMENDED IF GAJIM IS RUNNING)'),
_('Normally allocated database size will not be freed, '
'it will just become reusable. If you really want to reduce '
'database filesize, click YES, else click NO.'
- '\n\nIn case you click YES, please wait...'))
- if dialog.get_response() == gtk.RESPONSE_YES:
- self.cur.execute('VACUUM')
- self.con.commit()
+ '\n\nIn case you click YES, please wait...'),
+ on_response_yes=on_yes, on_response_no=on_no)
+ return
gtk.main_quit()
@@ -623,4 +630,4 @@ if __name__ == '__main__':
HistoryManager()
gtk.main()
-# vim: se ts=3: \ No newline at end of file
+# vim: se ts=3:
diff --git a/src/roster_window.py b/src/roster_window.py
index 75e8f6eb0..502ffd1b2 100644
--- a/src/roster_window.py
+++ b/src/roster_window.py
@@ -2210,6 +2210,16 @@ class RosterWindow:
get_msg = True
break
+ def on_continue2(message):
+ self.quit_on_next_offline = 0
+ for acct in accounts:
+ if gajim.connections[acct].connected:
+ self.quit_on_next_offline += 1
+ self.send_status(acct, 'offline', message)
+
+ if not self.quit_on_next_offline:
+ self.quit_gtkgui_interface()
+
def on_continue(message):
if message is None:
# user pressed Cancel to change status message dialog
@@ -2227,7 +2237,8 @@ class RosterWindow:
for ctrl in win.controls():
fjid = ctrl.get_full_jid()
if gajim.last_message_time[ctrl.account].has_key(fjid):
- if time.time() - gajim.last_message_time[ctrl.account][fjid] < 2:
+ if time.time() - gajim.last_message_time[ctrl.account][fjid] \
+ < 2:
recent = True
break
if recent:
@@ -2236,18 +2247,10 @@ class RosterWindow:
if unread or recent:
dialog = dialogs.ConfirmationDialog(_('You have unread messages'),
_('Messages will only be available for reading them later if you'
- ' have history enabled and contact is in your roster.'))
- if dialog.get_response() != gtk.RESPONSE_OK:
- return
-
- self.quit_on_next_offline = 0
- for acct in accounts:
- if gajim.connections[acct].connected:
- self.quit_on_next_offline += 1
- self.send_status(acct, 'offline', message)
-
- if not self.quit_on_next_offline:
- self.quit_gtkgui_interface()
+ ' have history enabled and contact is in your roster.'),
+ on_response_ok=(on_continue2, message))
+ return
+ on_continue2(message)
if get_msg:
self.get_status_message('offline', on_continue)
@@ -3217,26 +3220,6 @@ class RosterWindow:
# we can return to this show
self.previous_status_combobox_active = active
connected_accounts = gajim.get_number_of_connected_accounts()
- if status == 'invisible':
- bug_user = False
- for account in accounts:
- if connected_accounts < 1 or gajim.account_is_connected(account):
- if not gajim.config.get_per('accounts', account,
- 'sync_with_global_status'):
- continue
- # We're going to change our status to invisible
- if self.connected_rooms(account):
- bug_user = True
- break
- if bug_user:
- 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?'))
- if dialog.get_response() != gtk.RESPONSE_OK:
- self.update_status_combobox()
- return
def on_continue(message):
if message is None:
@@ -3263,6 +3246,32 @@ class RosterWindow:
self.send_status(account, status, message)
self.update_status_combobox()
+ if status == 'invisible':
+ bug_user = False
+ for account in accounts:
+ if connected_accounts < 1 or gajim.account_is_connected(account):
+ if not gajim.config.get_per('accounts', account,
+ 'sync_with_global_status'):
+ continue
+ # We're going to change our status to invisible
+ if self.connected_rooms(account):
+ bug_user = True
+ break
+ if bug_user:
+ def on_ok():
+ self.get_status_message(status, on_continue)
+
+ def on_cancel():
+ self.update_status_combobox()
+
+ 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_reponse_ok=on_ok,
+ on_response_cancel=on_cancel)
+ return
+
self.get_status_message(status, on_continue)
def on_preferences_menuitem_activate(self, widget):