mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Linux: Fix kdialog based file dialogs not supporting multiple file name filter groups
This commit is contained in:
parent
b57708dd67
commit
c3cdafb59f
@ -152,16 +152,12 @@ def kdialog_choose_dir(window, name, title, default_dir='~', no_save_dir=False):
|
|||||||
|
|
||||||
|
|
||||||
def kdialog_filters(filters, all_files=True):
|
def kdialog_filters(filters, all_files=True):
|
||||||
# Currently kdialog has no way to specify multiple filters
|
ans = []
|
||||||
if all_files or not filters:
|
for name, exts in filters:
|
||||||
return '*'
|
ans.append('{} ({})'.format(name, ' '.join('*.' + x for x in exts)))
|
||||||
if len(filters) == 1:
|
if all_files:
|
||||||
text, exts = filters[0]
|
ans.append(_('All files') + ' (*)')
|
||||||
return '{} ({})'.format(text, ' '.join('*.' + x for x in exts))
|
return '\n'.join(ans)
|
||||||
ans = set()
|
|
||||||
for text, exts in filters:
|
|
||||||
ans |= set(exts)
|
|
||||||
return ' '.join('*.' + x for x in ans)
|
|
||||||
|
|
||||||
|
|
||||||
def kdialog_choose_files(
|
def kdialog_choose_files(
|
||||||
@ -344,9 +340,9 @@ def check_for_linux_native_dialogs():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print(repr(kdialog_choose_dir(None, 'testkddcd', 'Testing choose dir...')))
|
# print(repr(kdialog_choose_dir(None, 'testkddcd', 'Testing choose dir...')))
|
||||||
# print(repr(kdialog_choose_files(None, 'testkddcf', 'Testing choose files...', select_only_single_file=True, filters=[
|
print(repr(kdialog_choose_files(None, 'testkddcf', 'Testing choose files...', select_only_single_file=True, filters=[
|
||||||
# ('moo', 'epub png'.split()), ('boo', 'docx'.split())], all_files=False)))
|
('moo', 'epub png'.split()), ('boo', 'docx'.split())], all_files=True)))
|
||||||
# print(repr(kdialog_choose_images(None, 'testkddci', 'Testing choose images...')))
|
# print(repr(kdialog_choose_images(None, 'testkddci', 'Testing choose images...')))
|
||||||
# print(repr(kdialog_choose_save_file(None, 'testkddcs', 'Testing choose save file...', initial_filename='moo.x')))
|
# print(repr(kdialog_choose_save_file(None, 'testkddcs', 'Testing choose save file...', initial_filename='moo.x')))
|
||||||
# print(repr(zenity_choose_dir(None, 'testzcd', 'Testing choose dir...')))
|
# print(repr(zenity_choose_dir(None, 'testzcd', 'Testing choose dir...')))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user