Fix some omissions in r23001
svn: r23003
This commit is contained in:
@@ -80,13 +80,14 @@ def url(link, uistate=None):
|
|||||||
"""
|
"""
|
||||||
Open the specified URL in a browser.
|
Open the specified URL in a browser.
|
||||||
"""
|
"""
|
||||||
|
from gui.utils import open_file_with_default_application
|
||||||
if uistate and config.get('htmlview.url-handler'):
|
if uistate and config.get('htmlview.url-handler'):
|
||||||
cat_num = uistate.viewmanager.get_category('Web')
|
cat_num = uistate.viewmanager.get_category('Web')
|
||||||
if cat_num is not None:
|
if cat_num is not None:
|
||||||
page = uistate.viewmanager.goto_page(cat_num, None)
|
page = uistate.viewmanager.goto_page(cat_num, None)
|
||||||
page.open(link)
|
page.open(link)
|
||||||
return
|
return
|
||||||
if not open_with_default_application(link):
|
if not open_file_with_default_application(link):
|
||||||
run_browser(link)
|
run_browser(link)
|
||||||
|
|
||||||
def run_browser(url):
|
def run_browser(url):
|
||||||
|
@@ -333,12 +333,15 @@ def display_error_dialog (index, errorstrings):
|
|||||||
Display a message box for errors resulting from xdg-open/open
|
Display a message box for errors resulting from xdg-open/open
|
||||||
"""
|
"""
|
||||||
from QuestionDialog import ErrorDialog
|
from QuestionDialog import ErrorDialog
|
||||||
error = "The external program failed to launch or experienced an error"
|
error = _("The external program failed to launch or experienced an error")
|
||||||
if errorstrings:
|
if errorstrings:
|
||||||
try:
|
if isinstance(errorstrings, dict):
|
||||||
error = errorstrings[resp]
|
try:
|
||||||
except KeyError:
|
error = errorstrings[resp]
|
||||||
pass
|
except KeyError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
error = errorstrings
|
||||||
|
|
||||||
ErrorDialog(_("Error from external program"), error)
|
ErrorDialog(_("Error from external program"), error)
|
||||||
|
|
||||||
@@ -382,7 +385,7 @@ def open_file_with_default_application(uri):
|
|||||||
if (not urlcomp.scheme or urlcomp.scheme == 'file'):
|
if (not urlcomp.scheme or urlcomp.scheme == 'file'):
|
||||||
norm_path = os.path.normpath(urlcomp.path)
|
norm_path = os.path.normpath(urlcomp.path)
|
||||||
if not os.path.exists(norm_path):
|
if not os.path.exists(norm_path):
|
||||||
ErrorDialog(_("Error Opening File"), _("File does not exist"))
|
display_error(0, _("File does not exist"))
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
norm_path = uri
|
norm_path = uri
|
||||||
@@ -391,7 +394,7 @@ def open_file_with_default_application(uri):
|
|||||||
try:
|
try:
|
||||||
os.startfile(norm_path)
|
os.startfile(norm_path)
|
||||||
except WindowsError, msg:
|
except WindowsError, msg:
|
||||||
ErrorDialog(_("Error Opening File"), str(msg))
|
display_error(0, str(msg))
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user