Added method for gramps to handle url requests

svn: r15808
This commit is contained in:
Doug Blank 2010-08-23 14:06:41 +00:00
parent ecef5c1d26
commit bdd07988c6
3 changed files with 11 additions and 2 deletions

View File

@ -21,6 +21,7 @@
# $Id$
import const
import config
import locale
import os
@ -73,10 +74,16 @@ def help(webpage='', section=''):
link = link + '#' + section
url(link)
def url(link):
def url(link, uistate=None):
"""
Open the specified URL in a browser.
"""
if uistate and config.get('htmlview.url-handler'):
if 'Web' in uistate.viewmanager.get_categories():
uistate.viewmanager.goto_category('Web')
page = uistate.viewmanager.get_category_page('Web')
page.open(link)
return
if not run_file(link):
run_browser(link)

View File

@ -165,6 +165,7 @@ register('geoview.stylesheet', "")
register('geoview.zoom', 0)
register('htmlview.start-url', "http://gramps-project.org")
register('htmlview.url-handler', False)
register('interface.address-height', 450)
register('interface.address-width', 650)

View File

@ -717,7 +717,8 @@ class StyledTextEditor(gtk.TextView):
else:
return
# If ok, then let's open
display_url(url)
obj = find_parent_with_attr(self, attr="dbstate")
display_url(url, obj.uistate)
def _copy_url_cb(self, menuitem, url, flavor):
"""Copy url to both useful selections."""