filechooserdialog is no more blocking (no call to run() func). see #777
This commit is contained in:
parent
eb8cc5b7ea
commit
cf819d3835
|
@ -616,7 +616,7 @@ class HigDialog(gtk.MessageDialog):
|
||||||
else:
|
else:
|
||||||
b.connect('clicked', possible_responses[response])
|
b.connect('clicked', possible_responses[response])
|
||||||
break
|
break
|
||||||
|
|
||||||
def just_destroy(self, widget):
|
def just_destroy(self, widget):
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
|
@ -638,25 +638,43 @@ class HigDialog(gtk.MessageDialog):
|
||||||
self.destroy()
|
self.destroy()
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
class FileChooserDialog(gtk.FileChooserDialog):
|
class FileChooserDialog(gtk.FileChooserDialog):
|
||||||
'''Non-blocking FileChooser Dialog around gtk.FileChooserDialog'''
|
'''Non-blocking FileChooser Dialog around gtk.FileChooserDialog'''
|
||||||
def __init__(self, title_text, action, buttons, default_response,
|
def __init__(self, title_text, action, buttons, default_response,
|
||||||
select_multiple, current_folder, on_response_ok = None,
|
select_multiple, current_folder = None, on_response_ok = None,
|
||||||
on_response_cancel = None):
|
on_response_cancel = None):
|
||||||
|
|
||||||
gtk.FileChooserDialog.__init__(self, title=title_text,
|
gtk.FileChooserDialog.__init__(self, title = title_text,
|
||||||
action=action, buttons=buttons)
|
action = action, buttons = buttons)
|
||||||
|
|
||||||
self.set_default_response(default_response)
|
self.set_default_response(default_response)
|
||||||
self.set_select_multiple(select_multiple)
|
self.set_select_multiple(select_multiple)
|
||||||
if current_folder and os.path.isdir(current_folder):
|
if current_folder and os.path.isdir(current_folder):
|
||||||
self.set_current_folder(current_folder)
|
self.set_current_folder(current_folder)
|
||||||
else:
|
else:
|
||||||
self.set_current_folder(helpers.get_documents_path())
|
self.set_current_folder(helpers.get_documents_path())
|
||||||
|
|
||||||
|
buttons = self.action_area.get_children()
|
||||||
|
possible_responses = {gtk.STOCK_OK: on_response_ok,
|
||||||
|
gtk.STOCK_CANCEL: on_response_cancel}
|
||||||
|
for b in buttons:
|
||||||
|
for response in possible_responses:
|
||||||
|
if b.get_label() == response:
|
||||||
|
if not possible_responses[response]:
|
||||||
|
b.connect('clicked', self.just_destroy)
|
||||||
|
elif isinstance(possible_responses[response], tuple):
|
||||||
|
if len(possible_responses[response]) == 1:
|
||||||
|
b.connect('clicked', possible_responses[response][0])
|
||||||
|
else:
|
||||||
|
b.connect('clicked', *possible_responses[response])
|
||||||
|
else:
|
||||||
|
b.connect('clicked', possible_responses[response])
|
||||||
|
break
|
||||||
|
|
||||||
self.show_all()
|
self.show_all()
|
||||||
|
|
||||||
|
def just_destroy(self, widget):
|
||||||
|
self.destroy()
|
||||||
|
|
||||||
class ConfirmationDialog(HigDialog):
|
class ConfirmationDialog(HigDialog):
|
||||||
'''HIG compliant confirmation dialog.'''
|
'''HIG compliant confirmation dialog.'''
|
||||||
|
@ -666,7 +684,7 @@ class ConfirmationDialog(HigDialog):
|
||||||
gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, pritext, sectext,
|
gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, pritext, sectext,
|
||||||
on_response_ok, on_response_cancel)
|
on_response_ok, on_response_cancel)
|
||||||
self.popup()
|
self.popup()
|
||||||
|
|
||||||
class NonModalConfirmationDialog(HigDialog):
|
class NonModalConfirmationDialog(HigDialog):
|
||||||
'''HIG compliant non modal confirmation dialog.'''
|
'''HIG compliant non modal confirmation dialog.'''
|
||||||
def __init__(self, pritext, sectext='', on_response_ok = None,
|
def __init__(self, pritext, sectext='', on_response_ok = None,
|
||||||
|
|
|
@ -244,34 +244,28 @@ _('Connection with peer cannot be established.'))
|
||||||
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):
|
||||||
dialog = dialogs.FileChooserDialog(_('Choose File to Send...'),
|
def on_ok(widget):
|
||||||
|
file_dir = None
|
||||||
|
files_path_list = self.dialog.get_filenames()
|
||||||
|
files_path_list = gtkgui_helpers.decode_filechooser_file_paths(
|
||||||
|
files_path_list)
|
||||||
|
for file_path in files_path_list:
|
||||||
|
if self.send_file(account, contact, file_path) and file_dir is None:
|
||||||
|
file_dir = os.path.dirname(file_path)
|
||||||
|
if file_dir:
|
||||||
|
gajim.config.set('last_send_dir', file_dir)
|
||||||
|
self.dialog.destroy()
|
||||||
|
|
||||||
|
self.dialog = dialogs.FileChooserDialog(_('Choose File to Send...'),
|
||||||
gtk.FILE_CHOOSER_ACTION_OPEN, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL),
|
gtk.FILE_CHOOSER_ACTION_OPEN, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL),
|
||||||
gtk.RESPONSE_OK,
|
gtk.RESPONSE_OK,
|
||||||
True, # select multiple true as we can select many files to send
|
True, # select multiple true as we can select many files to send
|
||||||
gajim.config.get('last_send_dir'),
|
gajim.config.get('last_send_dir'),
|
||||||
)
|
)
|
||||||
|
|
||||||
btn = dialog.add_button(_('_Send'), gtk.RESPONSE_OK)
|
|
||||||
btn.set_use_stock(True) # FIXME: add send icon to this button (JUMP_TO)
|
|
||||||
|
|
||||||
file_props = {}
|
btn = self.dialog.add_button(_('_Send'), gtk.RESPONSE_OK)
|
||||||
while True:
|
btn.set_use_stock(True) # FIXME: add send icon to this button (JUMP_TO)
|
||||||
response = dialog.run()
|
btn.connect('clicked', on_ok)
|
||||||
if response == gtk.RESPONSE_OK:
|
|
||||||
file_dir = None
|
|
||||||
files_path_list = dialog.get_filenames()
|
|
||||||
files_path_list = gtkgui_helpers.decode_filechooser_file_paths(
|
|
||||||
files_path_list)
|
|
||||||
for file_path in files_path_list:
|
|
||||||
if self.send_file(account, contact, file_path) and file_dir is None:
|
|
||||||
file_dir = os.path.dirname(file_path)
|
|
||||||
if file_dir:
|
|
||||||
gajim.config.set('last_send_dir', file_dir)
|
|
||||||
dialog.destroy()
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
dialog.destroy()
|
|
||||||
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 '''
|
||||||
|
|
Loading…
Reference in New Issue