last_send_dir for sending and not last_save_dir for sending! also os.path.isdir() is enough and no need for exists() and last but not least set $HOME if last_*_dir is None (else we show the place from we run Gajim!

This commit is contained in:
Nikos Kouremenos 2005-08-23 13:04:07 +00:00
parent 9b483b62ee
commit bc80ff4ae5
1 changed files with 11 additions and 6 deletions

View File

@ -44,6 +44,7 @@ class FileTransfersWindow:
self.plugin = plugin self.plugin = plugin
self.height_diff = 0 self.height_diff = 0
self.last_save_dir = None self.last_save_dir = None
self.last_send_dir = None
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'file_transfers_window', APP) self.xml = gtk.glade.XML(GTKGUI_GLADE, 'file_transfers_window', APP)
self.window = self.xml.get_widget('file_transfers_window') self.window = self.xml.get_widget('file_transfers_window')
self.tree = self.xml.get_widget('transfers_list') self.tree = self.xml.get_widget('transfers_list')
@ -202,16 +203,18 @@ _('Connection with peer cannot be established.'))
butt = dialog.add_button(_('Send'), gtk.RESPONSE_OK) butt = dialog.add_button(_('Send'), gtk.RESPONSE_OK)
butt.set_use_stock(True) butt.set_use_stock(True)
dialog.set_default_response(gtk.RESPONSE_OK) dialog.set_default_response(gtk.RESPONSE_OK)
if self.last_save_dir and os.path.exists(self.last_save_dir) \ if self.last_send_dir and os.path.isdir(self.last_send_dir):
and os.path.isdir(self.last_save_dir): dialog.set_current_folder(self.last_send_dir)
dialog.set_current_folder(self.last_save_dir) else:
home_dir = os.path.expanduser('~')
dialog.set_current_folder(home_dir)
file_props = {} file_props = {}
response = dialog.run() response = dialog.run()
if response == gtk.RESPONSE_OK: if response == gtk.RESPONSE_OK:
file_path = unicode(dialog.get_filename(), 'utf-8') file_path = unicode(dialog.get_filename(), 'utf-8')
(file_dir, file_name) = os.path.split(file_path) (file_dir, file_name) = os.path.split(file_path)
if file_dir: if file_dir:
self.last_save_dir = file_dir self.last_send_dir = file_dir
dialog.destroy() dialog.destroy()
self.send_file(account, contact, file_path) self.send_file(account, contact, file_path)
else: else:
@ -250,9 +253,11 @@ _('Connection with peer cannot be established.'))
gtk.STOCK_SAVE, gtk.RESPONSE_OK)) gtk.STOCK_SAVE, gtk.RESPONSE_OK))
dialog.set_current_name(file_props['name']) dialog.set_current_name(file_props['name'])
dialog.set_default_response(gtk.RESPONSE_OK) dialog.set_default_response(gtk.RESPONSE_OK)
if self.last_save_dir and os.path.exists(self.last_save_dir) \ if self.last_save_dir and os.path.isdir(self.last_save_dir):
and os.path.isdir(self.last_save_dir):
dialog.set_current_folder(self.last_save_dir) dialog.set_current_folder(self.last_save_dir)
else:
home_dir = os.path.expanduser('~')
dialog.set_current_folder(home_dir)
while True: while True:
response = dialog.run() response = dialog.run()
if response == gtk.RESPONSE_OK: if response == gtk.RESPONSE_OK: