mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
When choosing a program for Open With manually, default to /usr/bin on linux
This commit is contained in:
parent
b5d622335f
commit
76e89a8d38
@ -746,7 +746,7 @@ def choose_osx_app(window, name, title, default_dir='/Applications'):
|
|||||||
return app
|
return app
|
||||||
|
|
||||||
def choose_files(window, name, title,
|
def choose_files(window, name, title,
|
||||||
filters=[], all_files=True, select_only_single_file=False):
|
filters=[], all_files=True, select_only_single_file=False, default_dir=u'~'):
|
||||||
'''
|
'''
|
||||||
Ask user to choose a bunch of files.
|
Ask user to choose a bunch of files.
|
||||||
:param name: Unique dialog name used to store the opened directory
|
:param name: Unique dialog name used to store the opened directory
|
||||||
@ -759,7 +759,7 @@ def choose_files(window, name, title,
|
|||||||
:param select_only_single_file: If True only one file can be selected
|
:param select_only_single_file: If True only one file can be selected
|
||||||
'''
|
'''
|
||||||
mode = QFileDialog.ExistingFile if select_only_single_file else QFileDialog.ExistingFiles
|
mode = QFileDialog.ExistingFile if select_only_single_file else QFileDialog.ExistingFiles
|
||||||
fd = FileDialog(title=title, name=name, filters=filters,
|
fd = FileDialog(title=title, name=name, filters=filters, default_dir=default_dir,
|
||||||
parent=window, add_all_files_filter=all_files, mode=mode,
|
parent=window, add_all_files_filter=all_files, mode=mode,
|
||||||
)
|
)
|
||||||
fd.setParent(None)
|
fd.setParent(None)
|
||||||
|
@ -192,7 +192,9 @@ else:
|
|||||||
ans.setToolTip(comment + _('Command line:') + '\n' + (' '.join(entry['Exec'])))
|
ans.setToolTip(comment + _('Command line:') + '\n' + (' '.join(entry['Exec'])))
|
||||||
|
|
||||||
def choose_manually(filetype, parent):
|
def choose_manually(filetype, parent):
|
||||||
ans = choose_files(parent, 'choose-open-with-program-manually', _('Choose a program to open %s files') % filetype.upper(), select_only_single_file=True)
|
dd = '/usr/bin' if os.path.isdir('/usr/bin') else '~'
|
||||||
|
ans = choose_files(parent, 'choose-open-with-program-manually', _('Choose a program to open %s files') % filetype.upper(),
|
||||||
|
select_only_single_file=True, default_dir=dd)
|
||||||
if ans:
|
if ans:
|
||||||
ans = ans[0]
|
ans = ans[0]
|
||||||
if not os.access(ans, os.X_OK):
|
if not os.access(ans, os.X_OK):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user