Dont depend on win32api for getting HOME dir
This commit is contained in:
parent
f1693fa5a6
commit
33041619ee
|
@ -168,7 +168,6 @@ class GajimApplication(Gtk.Application):
|
|||
if os.name == 'nt':
|
||||
try:
|
||||
import winsound # windows-only built-in module for playing wav
|
||||
import win32api # do NOT remove. we req this module
|
||||
except Exception:
|
||||
pritext = _('Gajim needs pywin32 to run')
|
||||
sectext = _('Please make sure that Pywin32 is installed on your '
|
||||
|
|
|
@ -54,8 +54,6 @@ from common.i18n import ngettext
|
|||
|
||||
try:
|
||||
import winsound # windows-only built-in module for playing wav
|
||||
import win32api
|
||||
import win32con
|
||||
import wave # posix-only fallback wav playback
|
||||
import ossaudiodev as oss
|
||||
except Exception:
|
||||
|
@ -462,52 +460,6 @@ def get_output_of_command(command):
|
|||
|
||||
return output
|
||||
|
||||
def get_windows_reg_env(varname, default=''):
|
||||
r"""
|
||||
Ask for paths commonly used but not exposed as ENVs in english 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(val) # expand using environ
|
||||
except Exception:
|
||||
pass
|
||||
finally:
|
||||
win32api.RegCloseKey(rkey)
|
||||
return val
|
||||
|
||||
def get_documents_path():
|
||||
if os.name == 'nt':
|
||||
path = get_windows_reg_env('Personal')
|
||||
else:
|
||||
path = os.path.expanduser('~')
|
||||
return path
|
||||
|
||||
def sanitize_filename(filename):
|
||||
"""
|
||||
Make sure the filename we will write does contain only acceptable and latin
|
||||
|
|
|
@ -1495,7 +1495,7 @@ class FileChooserDialog(Gtk.FileChooserDialog):
|
|||
if current_folder and os.path.isdir(current_folder):
|
||||
self.set_current_folder(current_folder)
|
||||
else:
|
||||
self.set_current_folder(helpers.get_documents_path())
|
||||
self.set_current_folder(os.path.expanduser('~'))
|
||||
self.response_ok, self.response_cancel = \
|
||||
on_response_ok, on_response_cancel
|
||||
# in gtk+-2.10 clicked signal on some of the buttons in a dialog
|
||||
|
@ -5047,7 +5047,7 @@ class ArchiveChooserDialog(FileChooserDialog):
|
|||
callback(path_to_file)
|
||||
self.destroy()
|
||||
|
||||
path = helpers.get_documents_path()
|
||||
path = os.path.expanduser('~')
|
||||
|
||||
FileChooserDialog.__init__(self,
|
||||
title_text=_('Choose Archive'),
|
||||
|
|
Loading…
Reference in New Issue