From 75fe94b45a0e9933f2ad6dd5a70725659bbb8999 Mon Sep 17 00:00:00 2001 From: Brian Matherly Date: Sat, 22 Jul 2006 05:52:16 +0000 Subject: [PATCH] * src/plugins/GraphViz.py: launch image viewer in Windows. * src/Mime/_WinMime.py: handle rundll32.exe applications. * src/Utils.py: search path in Windows when looking for applications. svn: r7055 --- ChangeLog | 5 +++++ src/Mime/_WinMime.py | 5 ++++- src/Utils.py | 14 ++++++++++---- src/plugins/GraphViz.py | 27 ++++++++------------------- 4 files changed, 27 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index e0563049e..94da8b9c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-07-21 Brian Matherly + * src/plugins/GraphViz.py: launch image viewer in Windows. + * src/Mime/_WinMime.py: handle rundll32.exe applications. + * src/Utils.py: search path in Windows when looking for applications. + 2006-07-21 Don Allingham * src/DataViews/_RelationView.py: provide number for children/siblings * src/GrampsWidgets.py: fix spacing on link box diff --git a/src/Mime/_WinMime.py b/src/Mime/_WinMime.py index 26bf9e226..b70dd8932 100644 --- a/src/Mime/_WinMime.py +++ b/src/Mime/_WinMime.py @@ -70,9 +70,12 @@ def get_application(type): # Find a friendly name for the application if command.startswith('"'): app = command.split('"')[1] + elif command.startswith('rundll32.exe'): + # Get the description of the DLL instead of the application + app = command.split()[1].split(',')[0] else: app = command.split()[0] - + hcu = ConnectRegistry(None,HKEY_CURRENT_USER) subkey = OpenKey(hcu, "Software\Microsoft\Windows\ShellNoRoam\MUICache") desc = None diff --git a/src/Utils.py b/src/Utils.py index 9faa5d6cc..9f8130883 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -461,10 +461,16 @@ def search_for(name): name = name.split('"')[1] else: name = name.split()[0] - for i in os.environ['PATH'].split(':'): - fname = os.path.join(i,name) - if os.access(fname,os.X_OK) and not os.path.isdir(fname): - return 1 + if os.sys.platform == "win32": + for i in os.environ['PATH'].split(';'): + fname = os.path.join(i,name) + if os.access(fname,os.X_OK) and not os.path.isdir(fname): + return 1 + else: + for i in os.environ['PATH'].split(':'): + fname = os.path.join(i,name) + if os.access(fname,os.X_OK) and not os.path.isdir(fname): + return 1 return 0 #------------------------------------------------------------------------- diff --git a/src/plugins/GraphViz.py b/src/plugins/GraphViz.py index ec2c51377..4ab5104eb 100644 --- a/src/plugins/GraphViz.py +++ b/src/plugins/GraphViz.py @@ -64,6 +64,8 @@ import const from BaseDoc import PAPER_LANDSCAPE from QuestionDialog import ErrorDialog import Errors +import Utils +import Mime #------------------------------------------------------------------------ # @@ -124,11 +126,11 @@ class _options: ) if os.sys.platform == "win32": - _dot_found = os.system("dot -V 2>nul") == 0 + _dot_found = Utils.search_for("dot.exe") else: - _dot_found = os.system("dot -V 2>/dev/null") == 0 + _dot_found = Utils.search_for("dot") -if os.system("which epstopdf >/dev/null 2>&1") == 0: +if Utils.search_for("epstopdf") == 1: _options.formats += (("pdf", "PDF", _("PDF"), "application/pdf"),) _pdf_pipe = 'epstopdf -f -o=%s' @@ -1025,11 +1027,7 @@ class FormatComboBox(gtk.ComboBox): def get_printable(self): _apptype = _options.formats[self.get_active()][3] print_label = None - try: - import Utils - import Mime - mprog = Mime.get_application(_apptype) if Utils.search_for(mprog[0]): @@ -1087,12 +1085,10 @@ class GraphicsFormatComboBox(gtk.ComboBox): _apptype = _options.formats[self.get_active()][3] print_label = None try: - import Utils - import Mime mprog = Mime.get_application(_apptype) if Utils.search_for(mprog[0]): print_label = _("Open in %(program_name)s") % { 'program_name': - mprog[1]} + mprog[1] } else: print_label = None except: @@ -1174,12 +1170,8 @@ class GraphVizGraphics(Report): break if _apptype: try: - import Utils - import Mime - app = Mime.get_application(_apptype) - os.environ["FILE"] = self.user_output - os.system ('%s "$FILE" &' % app[0]) + Utils.launch(app[0],self.user_output) except: pass @@ -1191,11 +1183,8 @@ class GraphVizGraphics(Report): break if _apptype: try: - import Utils - import Mime app = Mime.get_application(_apptype) - os.environ["FILE"] = self.user_output - os.system ('%s "$FILE" &' % app[0]) + Utils.launch(app[0],self.user_output) except: pass