-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsettings.py
More file actions
96 lines (76 loc) · 2.29 KB
/
settings.py
File metadata and controls
96 lines (76 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#Define all global variables and identify the default download folder.
from os import getcwd, name, popen
downloadIsRunning = False
retrievingFiles = False
retrievedFiles = []
loadingData = False
treeview = None
contentview = None
files = []
folders = []
directory = {}
folderIcon = None
imageIcon = None
videoIcon = None
pdfIcon = None
wordIcon = None
excelIcon = None
gappsIcon = None
writerIcon = None
spreadsheetIcon = None
audioIcon = None
documentIcon = None
shortcutIcon = None
compressedIcon = None
rootID = ''
owner = ''
fileDownloading = ""
fileDownloadingSize = ""
copyInProgress = ""
itemCopying = ""
moveInProgress = ""
itemMoving = ""
error = ""
callback_error = False #to handle the possible file operation error
drive = None
widget = None
currentDir = getcwd()
#GET DOWNLOAD FOLDER#
#absolutely no idea of how this works for the Windows part. Copy-pasted from somewhere.
if name == 'nt':
#import ctypes
from ctypes import windll, wintypes, Structure, POINTER, c_wchar_p, byref, WinError
from uuid import UUID
# ctypes GUID copied from MSDN sample code
class GUID(Structure):
_fields_ = [
("Data1", wintypes.DWORD),
("Data2", wintypes.WORD),
("Data3", wintypes.WORD),
("Data4", wintypes.BYTE * 8)
]
def __init__(self, uuidstr):
uuid = UUID(uuidstr)
Structure.__init__(self)
self.Data1, self.Data2, self.Data3, \
self.Data4[0], self.Data4[1], rest = uuid.fields
for i in range(2, 8):
self.Data4[i] = rest>>(8-i-1)*8 & 0xff
SHGetKnownFolderPath = windll.shell32.SHGetKnownFolderPath
SHGetKnownFolderPath.argtypes = [
POINTER(GUID), wintypes.DWORD,
wintypes.HANDLE, POINTER(c_wchar_p)
]
def _get_known_folder_path(uuidstr):
pathptr = c_wchar_p()
guid = GUID(uuidstr)
if SHGetKnownFolderPath(byref(guid), 0, 0, byref(pathptr)):
raise WinError()
return pathptr.value
FOLDERID_Download = '{374DE290-123F-4565-9164-39C4925E467B}'
def get_download_folder():
return _get_known_folder_path(FOLDERID_Download)
else:
def get_download_folder():
return popen("xdg-user-dir DOWNLOAD").read().split('\n')[0]
downloadFolder = get_download_folder()