fix launch routine

svn: r6230
This commit is contained in:
Don Allingham 2006-03-30 03:24:04 +00:00
parent 88686265a3
commit 052943f96c
3 changed files with 40 additions and 11 deletions

View File

@ -8,7 +8,8 @@
* src/plugins/DetAncestralReport.py: remove use of deprecated functions * src/plugins/DetAncestralReport.py: remove use of deprecated functions
2006-03-29 Don Allingham <don@gramps-project.org> 2006-03-29 Don Allingham <don@gramps-project.org>
* src/DisplayTabs.py: fix import * src/Utils.py: provide launch function for spawning processes
* src/DisplayTabs.py: fix import, move launch function
* src/Editors/_EditPerson.py: Fix imports of EditMediaRef, remove * src/Editors/_EditPerson.py: Fix imports of EditMediaRef, remove
specific edit image from top image window. specific edit image from top image window.
* src/glade/gramps.glade: remove unused dialogs, replaced by * src/glade/gramps.glade: remove unused dialogs, replaced by

View File

@ -2004,9 +2004,5 @@ class BackRefModel(gtk.ListStore):
yield True yield True
yield False yield False
def launch(prog,path):
print prog, path
os.spawnvpe(os.P_NOWAIT, prog, [ prog, path], os.environ)
def make_launcher(prog, path): def make_launcher(prog, path):
return lambda x: launch(prog, path) return lambda x: Utils.launch(prog, path)

View File

@ -592,11 +592,7 @@ def view_photo(photo):
prog = data[0] prog = data[0]
except: except:
return return
launch(prog,photo.get_path())
args = prog.split()
args.append(photo.get_path())
os.spawnvpe(os.P_NOWAIT, args[0], args, os.environ)
def find_file( filename): def find_file( filename):
# try the filename we got # try the filename we got
@ -1294,3 +1290,39 @@ class ProgressMeter:
Close the progress meter Close the progress meter
""" """
self.ptop.destroy() self.ptop.destroy()
def launch(prog_str,path):
subval = {
'%i' : None,
'%F' : (True,path),
'%f' : (True,path),
'%u' : (True,path),
'%U' : (True,path),
'%n' : (True,path),
'%N' : (True,path),
'"%c"' : (False,'"%s"' % path),
}
prog_data = prog_str.split()
prog = prog_data[0]
prog_list = []
need_path = True
if len(prog_data) > 1:
for item in prog_data:
value = subval.get(item,item)
if not value:
continue
if type(value) == tuple:
if value[0]:
need_path = False
prog_list.append(value[1])
elif value[0] != '%':
prog_list.append(value)
else:
prog_list = [prog_data[0]]
if need_path:
prog_list.append(path)
os.spawnvpe(os.P_NOWAIT, prog, prog_list, os.environ)