Show an error dialog if a file can not be opened with the default application.

svn: r11792
This commit is contained in:
Brian Matherly 2009-02-01 21:21:54 +00:00
parent ea96136bf9
commit 662dbc94f6

View File

@ -45,11 +45,10 @@ import gtk
# Gramps modules # Gramps modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import Mime
from BasicUtils import name_displayer from BasicUtils import name_displayer
import gen.lib import gen.lib
import Errors import Errors
from QuestionDialog import WarningDialog from QuestionDialog import WarningDialog, ErrorDialog
from const import TEMP_DIR, USER_HOME from const import TEMP_DIR, USER_HOME
import shutil import shutil
@ -1124,9 +1123,16 @@ def open_file_with_default_application( file_path ):
""" """
norm_path = os.path.normpath( file_path ) norm_path = os.path.normpath( file_path )
if not os.path.exists(norm_path):
ErrorDialog(_("Error Opening File"), _("File does not exist"))
return
if os.sys.platform == 'win32': if os.sys.platform == 'win32':
norm_path = norm_path.encode(os.sys.getfilesystemencoding()) norm_path = norm_path.encode(os.sys.getfilesystemencoding())
os.startfile(norm_path) try:
os.startfile(norm_path)
except WindowsError, msg:
ErrorDialog(_("Error Opening File"), str(msg))
else: else:
search = os.environ['PATH'].split(':') search = os.environ['PATH'].split(':')
for lpath in search: for lpath in search: