* src/GrampsDisplay.py: open url in standard way
	* src/gramps.py: add comment on use of import gnome
	* README:
	* INSTALL:
	Remove need for gconf, add need for xdg utilities



svn: r9788
This commit is contained in:
Benny Malengier
2008-01-13 00:48:03 +00:00
parent 3dbb428759
commit a6fe002719
5 changed files with 74 additions and 47 deletions

View File

@ -42,36 +42,55 @@ def help(target, webpage='', section=''):
link + '#' + section
url(link)
def url(target):
def url(link):
"""
Open the specified URL in a browser. Attempt using the GNOME system if
available, if not, try to find a browser.
Open the specified URL in a browser.
"""
try:
import gnome
gnome.url_show(target)
except:
run_browser(target)
if not run_file(link):
run_browser(link)
def run_file(file):
"""
Open a file or url with the default application. This should work
on GNOME, KDE, XFCE, ... as we use a freedesktop application
"""
import os
search = os.environ['PATH'].split(':')
xdgopen = 'xdg-open'
for path in search:
prog = os.path.join(path, xdgopen)
if os.path.isfile(prog):
os.spawnvpe(os.P_NOWAIT, prog, [prog, file], os.environ)
return True
return False
def run_browser(url):
"""
Attempt of find a browswer, and launch with the browser with the
specified URL
Use run_file first!
"""
import os
search = os.environ['PATH'].split(':')
for browser in ['firefox','konqueror','epiphany','galeon','mozilla']:
for path in search:
prog = os.path.join(path,browser)
if os.path.isfile(prog):
os.spawnvpe(os.P_NOWAIT, prog, [prog, url], os.environ)
return
# If we did not find a browser in the path, try this
try:
os.startfile(url)
except:
pass
import webbrowser
webbrowser.open_new_tab(url)
except ImportError:
import os
search = os.environ['PATH'].split(':')
for browser in ['firefox', 'konqueror', 'epiphany',
'galeon', 'mozilla']:
for path in search:
prog = os.path.join(path,browser)
if os.path.isfile(prog):
os.spawnvpe(os.P_NOWAIT, prog, [prog, url], os.environ)
return
# If we did not find a browser in the path, try this
try:
os.startfile(url)
except:
pass