Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.9, 0.9.1, and 0.9.1.1

gtklib: fix NativeFolderSelectDialog freezing gtk

refs #636

Changeset 1c5869a11840

Parent 14aba8c5b16a

by Adrian Buehlmann

Changes to one file · Browse files at 1c5869a11840 Showing diff from parent 14aba8c5b16a Diff from another changeset...

 
305
306
307
308
309
 
 
 
 
310
311
312
313
314
315
316
317
318
319
320
321
322
323
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
324
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
325
326
327
328
329
330
331
332
333
334
335
336
337
 
 
338
339
340
 
305
306
307
 
 
308
309
310
311
312
 
 
 
 
 
 
 
 
 
 
 
 
 
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
 
 
 
 
 
 
 
 
 
 
 
 
352
353
354
355
356
@@ -305,36 +305,52 @@
  return self.runCompatible()     def runWindows(self): - from win32com.shell import shell, shellcon - import win32gui, pywintypes + + def rundlg(q): + from win32com.shell import shell, shellcon + import win32gui, pywintypes   - def BrowseCallbackProc(hwnd, msg, lp, data): - if msg == shellcon.BFFM_INITIALIZED: - win32gui.SendMessage(hwnd, shellcon.BFFM_SETSELECTION, 1, data) - elif msg == shellcon.BFFM_SELCHANGED: - # Set the status text of the - # For this message, 'lp' is the address of the PIDL. - pidl = shell.AddressAsPIDL(lp) - try: - path = shell.SHGetPathFromIDList(pidl) - win32gui.SendMessage(hwnd, shellcon.BFFM_SETSTATUSTEXT, 0, path) - except shell.error: - # No path for this PIDL - pass + def BrowseCallbackProc(hwnd, msg, lp, data): + if msg == shellcon.BFFM_INITIALIZED: + win32gui.SendMessage( + hwnd, shellcon.BFFM_SETSELECTION, 1, data) + elif msg == shellcon.BFFM_SELCHANGED: + # Set the status text of the + # For this message, 'lp' is the address of the PIDL. + pidl = shell.AddressAsPIDL(lp) + try: + path = shell.SHGetPathFromIDList(pidl) + win32gui.SendMessage( + hwnd, shellcon.BFFM_SETSTATUSTEXT, 0, path) + except shell.error: + # No path for this PIDL + pass   + fname = None + try: + flags = shellcon.BIF_EDITBOX | 0x40 #shellcon.BIF_NEWDIALOGSTYLE + pidl, _, _ = shell.SHBrowseForFolder( + 0, + None, + hglib.fromutf(self.title), + flags, + BrowseCallbackProc, # callback function + self.initial) # 'data' param for the callback + if pidl: + fname = hglib.toutf(shell.SHGetPathFromIDList(pidl)) + except (pywintypes.error, pywintypes.com_error): + pass + q.put(fname) + + q = Queue.Queue() + thread = thread2.Thread(target=rundlg, args=(q,)) + thread.start() + while thread.isAlive(): + # let gtk process events while we wait for rundlg finishing + gtk.main_iteration(block=True)   fname = None - try: - flags = shellcon.BIF_EDITBOX | 0x40 #shellcon.BIF_NEWDIALOGSTYLE - pidl, _, _ = shell.SHBrowseForFolder(0, - None, - hglib.fromutf(self.title), - flags, - BrowseCallbackProc, # callback function - self.initial) # 'data' param for the callback - if pidl: - fname = hglib.toutf(shell.SHGetPathFromIDList(pidl)) - except (pywintypes.error, pywintypes.com_error): - pass + if q.qsize(): + fname = q.get(0)   return fname     def runCompatible(self):