Skip to content

Commit

Permalink
[Cocoa] Fix open file dialog file type selector and all files filter
Browse files Browse the repository at this point in the history
  • Loading branch information
r0x0r committed Sep 13, 2024
1 parent d36529d commit a2b8d04
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions webview/platforms/cocoa.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,12 @@ def initWithFilter_(self, file_filter):
self.setTarget_(self)
return self

def setFileDialog_(self, file_dlg):
self.file_dlg = file_dlg

def onChange_(self, sender):
option = sender.indexOfSelectedItem()
self.window().setAllowedFileTypes_(self.filter[option][1])
self.file_dlg.setAllowedFileTypes_(self.filter[option][1])

class WebKitHost(WebKit.WKWebView):
def performDragOperation_(self, sender):
Expand Down Expand Up @@ -857,6 +860,7 @@ def create_dialog(*args):
filter_chooser = BrowserView.FileFilterChooser.alloc().initWithFilter_(
file_filter
)
filter_chooser.setFileDialog_(open_dlg)
open_dlg.setAccessoryView_(filter_chooser)
open_dlg.setAccessoryViewDisclosed_(True)

Expand Down Expand Up @@ -1154,7 +1158,7 @@ def create_file_dialog(dialog_type, directory, allow_multiple, save_filename, fi
for s in file_types:
description, extensions = parse_file_type(s)
file_extensions = [i.lstrip('*.') for i in extensions.split(';') if i != '*.*']
file_filter.append([description, file_extensions or None])
file_filter.append([description, file_extensions or []])

i = BrowserView.instances.get(uid)
return i.create_file_dialog(dialog_type, directory, allow_multiple, save_filename, file_filter)
Expand Down

0 comments on commit a2b8d04

Please sign in to comment.