fix typo; also saner defaults [only first time] for last_save_dir and last_send_dir

This commit is contained in:
Nikos Kouremenos 2006-03-15 02:09:57 +00:00
parent 396c66f8f8
commit 036265081b
3 changed files with 26 additions and 28 deletions

View File

@ -1,17 +1,10 @@
## common/helpers.py ## common/helpers.py
## ##
## Contributors for this file: ## Copyright (C) 2003-2006 Yann Le Boulanger <asterix@lagaule.org>
## - Yann Le Boulanger <asterix@lagaule.org> ## Copyright (C) 2005-2006 Nikos Kouremenos <kourem@gmail.com>
## - Nikos Kouremenos <kourem@gmail.com> ## Copyright (C) 2005
##
## Copyright (C) 2003-2004 Yann Le Boulanger <asterix@lagaule.org>
## Vincent Hanquez <tab@snarc.org>
## Copyright (C) 2005 Yann Le Boulanger <asterix@lagaule.org>
## Vincent Hanquez <tab@snarc.org>
## Nikos Kouremenos <nkour@jabber.org>
## Dimitur Kirov <dkirov@gmail.com> ## Dimitur Kirov <dkirov@gmail.com>
## Travis Shirk <travis@pobox.com> ## Travis Shirk <travis@pobox.com>
## Norman Rasmussen <norman@rasmussen.co.za>
## ##
## This program is free software; you can redistribute it and/or modify ## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published ## it under the terms of the GNU General Public License as published
@ -538,7 +531,7 @@ def decode_string(string):
def get_windows_reg_env(varname, default=''): def get_windows_reg_env(varname, default=''):
'''asks for paths commonly used but not exposed as ENVs '''asks for paths commonly used but not exposed as ENVs
in Windows 2003 those are: in english Windows 2003 those are:
'AppData' = %USERPROFILE%\Application Data (also an ENV) 'AppData' = %USERPROFILE%\Application Data (also an ENV)
'Desktop' = %USERPROFILE%\Desktop 'Desktop' = %USERPROFILE%\Desktop
'Favorites' = %USERPROFILE%\Favorites 'Favorites' = %USERPROFILE%\Favorites
@ -568,7 +561,7 @@ def get_windows_reg_env(varname, default=''):
r'Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders') r'Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders')
try: try:
val = str(win32api.RegQueryValueEx(rkey, varname)[0]) val = str(win32api.RegQueryValueEx(rkey, varname)[0])
val = win32api.ExpandEnvironmentStrings(v) # expand using environ val = win32api.ExpandEnvironmentStrings(val) # expand using environ
except: except:
pass pass
finally: finally:
@ -578,3 +571,17 @@ r'Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders')
def get_my_pictures_path(): def get_my_pictures_path():
'''windows-only atm. [Unix lives in the past]''' '''windows-only atm. [Unix lives in the past]'''
return get_windows_reg_env('My Pictures') return get_windows_reg_env('My Pictures')
def get_desktop_path():
if os.name == 'nt':
path = get_windows_reg_env('Desktop')
else:
path = os.path.join(os.path.expanduser('~'), 'Desktop')
return path
def get_documents_path():
if os.name == 'nt':
path = get_windows_reg_env('Personal')
else:
path = os.path.expanduser('~')
return path

View File

@ -1,8 +1,6 @@
## filetransfers_window.py ## filetransfers_window.py
## ##
##
## Copyright (C) 2003-2006 Yann Le Boulanger <asterix@lagaule.org> ## Copyright (C) 2003-2006 Yann Le Boulanger <asterix@lagaule.org>
## Copyright (C) 2005-2006 Yann Le Boulanger <asterix@lagaule.org>
## Copyright (C) 2005-2006 Nikos Kouremenos <kourem@gmail.com> ## Copyright (C) 2005-2006 Nikos Kouremenos <kourem@gmail.com>
## Copyright (C) 2005 ## Copyright (C) 2005
## Dimitur Kirov <dkirov@gmail.com> ## Dimitur Kirov <dkirov@gmail.com>
@ -253,7 +251,7 @@ _('Connection with peer cannot be established.'))
if last_send_dir and os.path.isdir(last_send_dir): if last_send_dir and os.path.isdir(last_send_dir):
dialog.set_current_folder(last_send_dir) dialog.set_current_folder(last_send_dir)
else: else:
dialog.set_current_folder(gajim.HOME_DIR) dialog.set_current_folder(helpers.get_documents_path())
file_props = {} file_props = {}
while True: while True:
response = dialog.run() response = dialog.run()
@ -343,10 +341,13 @@ _('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
print 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)
print 'set last save', last_save_dir
else: else:
dialog.set_current_folder(gajim.HOME_DIR) dialog.set_current_folder(helpers.get_desktop_path())
print 'set desktop', helpers.get_desktop_path()
while True: while True:
response = dialog.run() response = dialog.run()
if response == gtk.RESPONSE_OK: if response == gtk.RESPONSE_OK:

View File

@ -1,17 +1,7 @@
## vcard.py (has VcardWindow class) ## vcard.py (has VcardWindow class)
## ##
## Contributors for this file: ## Copyright (C) 2003-2006 Yann Le Boulanger <asterix@lagaule.org>
## - Yann Le Boulanger <asterix@lagaule.org> ## Copyright (C) 2005-2006 Nikos Kouremenos <kourem@gmail.com>
## - Nikos Kouremenos <kourem@gmail.com>
##
## Copyright (C) 2003-2004 Yann Le Boulanger <asterix@lagaule.org>
## Vincent Hanquez <tab@snarc.org>
## Copyright (C) 2005 Yann Le Boulanger <asterix@lagaule.org>
## Vincent Hanquez <tab@snarc.org>
## Nikos Kouremenos <nkour@jabber.org>
## Dimitur Kirov <dkirov@gmail.com>
## Travis Shirk <travis@pobox.com>
## Norman Rasmussen <norman@rasmussen.co.za>
## ##
## This program is free software; you can redistribute it and/or modify ## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published ## it under the terms of the GNU General Public License as published