set avatar filechooser defaults to My Pictures in the OS that understand user needs [aka Windows]
This commit is contained in:
parent
1c992be553
commit
396c66f8f8
|
@ -38,6 +38,8 @@ from xmpp_stringprep import nodeprep, resourceprep, nameprep
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import winsound # windows-only built-in module for playing wav
|
import winsound # windows-only built-in module for playing wav
|
||||||
|
import win32api
|
||||||
|
import win32con
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -533,3 +535,46 @@ def decode_string(string):
|
||||||
break
|
break
|
||||||
|
|
||||||
return string
|
return string
|
||||||
|
|
||||||
|
def get_windows_reg_env(varname, default=''):
|
||||||
|
'''asks for paths commonly used but not exposed as ENVs
|
||||||
|
in Windows 2003 those are:
|
||||||
|
'AppData' = %USERPROFILE%\Application Data (also an ENV)
|
||||||
|
'Desktop' = %USERPROFILE%\Desktop
|
||||||
|
'Favorites' = %USERPROFILE%\Favorites
|
||||||
|
'NetHood' = %USERPROFILE%\NetHood
|
||||||
|
'Personal' = D:\My Documents (PATH TO MY DOCUMENTS)
|
||||||
|
'PrintHood' = %USERPROFILE%\PrintHood
|
||||||
|
'Programs' = %USERPROFILE%\Start Menu\Programs
|
||||||
|
'Recent' = %USERPROFILE%\Recent
|
||||||
|
'SendTo' = %USERPROFILE%\SendTo
|
||||||
|
'Start Menu' = %USERPROFILE%\Start Menu
|
||||||
|
'Startup' = %USERPROFILE%\Start Menu\Programs\Startup
|
||||||
|
'Templates' = %USERPROFILE%\Templates
|
||||||
|
'My Pictures' = D:\My Documents\My Pictures
|
||||||
|
'Local Settings' = %USERPROFILE%\Local Settings
|
||||||
|
'Local AppData' = %USERPROFILE%\Local Settings\Application Data
|
||||||
|
'Cache' = %USERPROFILE%\Local Settings\Temporary Internet Files
|
||||||
|
'Cookies' = %USERPROFILE%\Cookies
|
||||||
|
'History' = %USERPROFILE%\Local Settings\History
|
||||||
|
'''
|
||||||
|
|
||||||
|
if os.name != 'nt':
|
||||||
|
return ''
|
||||||
|
|
||||||
|
val = default
|
||||||
|
try:
|
||||||
|
rkey = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER,
|
||||||
|
r'Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders')
|
||||||
|
try:
|
||||||
|
val = str(win32api.RegQueryValueEx(rkey, varname)[0])
|
||||||
|
val = win32api.ExpandEnvironmentStrings(v) # expand using environ
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
finally:
|
||||||
|
win32api.RegCloseKey(rkey)
|
||||||
|
return val
|
||||||
|
|
||||||
|
def get_my_pictures_path():
|
||||||
|
'''windows-only atm. [Unix lives in the past]'''
|
||||||
|
return get_windows_reg_env('My Pictures')
|
||||||
|
|
|
@ -1,18 +1,14 @@
|
||||||
## filetransfers_window.py
|
## filetransfers_window.py
|
||||||
##
|
##
|
||||||
## Contributors for this file:
|
|
||||||
## - Yann Le Boulanger <asterix@lagaule.org>
|
|
||||||
## - Nikos Kouremenos <kourem@gmail.com>
|
|
||||||
## - Dimitur Kirov <dkirov@gmail.com>
|
|
||||||
##
|
##
|
||||||
## Copyright (C) 2003-2004 Yann Le Boulanger <asterix@lagaule.org>
|
## Copyright (C) 2003-2006 Yann Le Boulanger <asterix@lagaule.org>
|
||||||
## Vincent Hanquez <tab@snarc.org>
|
## Copyright (C) 2005-2006 Yann Le Boulanger <asterix@lagaule.org>
|
||||||
## Copyright (C) 2005 Yann Le Boulanger <asterix@lagaule.org>
|
## Copyright (C) 2005-2006 Nikos Kouremenos <kourem@gmail.com>
|
||||||
## Vincent Hanquez <tab@snarc.org>
|
## Copyright (C) 2005
|
||||||
## 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>
|
## Norman Rasmussen <norman@rasmussen.co.za>
|
||||||
|
## Copyright (C) 2004-2005 Vincent Hanquez <tab@snarc.org>
|
||||||
##
|
##
|
||||||
## 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
|
||||||
|
|
|
@ -194,7 +194,7 @@ class VcardWindow:
|
||||||
gtk.STOCK_OPEN, gtk.RESPONSE_OK))
|
gtk.STOCK_OPEN, gtk.RESPONSE_OK))
|
||||||
try:
|
try:
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
path = os.environ['USERPROFILE']
|
path = helpers.get_my_pictures_path()
|
||||||
else:
|
else:
|
||||||
path = os.environ['HOME']
|
path = os.environ['HOME']
|
||||||
except:
|
except:
|
||||||
|
|
Loading…
Reference in New Issue