From 662dbc94f60df3ead65003125e1429c1a9458e2d Mon Sep 17 00:00:00 2001 From: Brian Matherly Date: Sun, 1 Feb 2009 21:21:54 +0000 Subject: [PATCH] Show an error dialog if a file can not be opened with the default application. svn: r11792 --- src/Utils.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Utils.py b/src/Utils.py index 326b1d143..a6416544f 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -45,11 +45,10 @@ import gtk # Gramps modules # #------------------------------------------------------------------------- -import Mime from BasicUtils import name_displayer import gen.lib import Errors -from QuestionDialog import WarningDialog +from QuestionDialog import WarningDialog, ErrorDialog from const import TEMP_DIR, USER_HOME import shutil @@ -1123,10 +1122,17 @@ def open_file_with_default_application( file_path ): @return: nothing """ 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': 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: search = os.environ['PATH'].split(':') for lpath in search: