From 185883c0abb0a761614e42810968ffe8a8623b53 Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Wed, 29 Aug 2012 10:03:17 +0000 Subject: [PATCH] Avoid show of errordialog if osmgpsmap is not present. No need to check GTK, GTK3 is required for GUI svn: r20281 --- src/plugins/view/geography.gpr.py | 39 +++++++++++++++++----------- src/plugins/view/htmlrenderer.gpr.py | 7 +---- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/plugins/view/geography.gpr.py b/src/plugins/view/geography.gpr.py index c130eb30b..7522b020f 100644 --- a/src/plugins/view/geography.gpr.py +++ b/src/plugins/view/geography.gpr.py @@ -29,28 +29,37 @@ MODULE_VERSION="4.0" -try : - NEWGTK = False - from gi.repository import Gtk - if Gtk.get_major_version() >= 3: - OSMGPSMAP = False - NEWGTK = True - if NEWGTK: +from gi import Repository + +#------------------------------------------------------------------------- +# +# set up logging +# +#------------------------------------------------------------------------- +import logging +_LOG = logging.getLogger("Geography") + +OSMGPSMAP = False + +# Attempting to import OsmGpsMap gives an error dialog if OsmGpsMap is not +# available so test first and log just a warning to the console instead. +repository = Repository.get_default() +if repository.enumerate_versions("OsmGpsMap"): + try : # current osmgpsmap support GTK3 from gi.repository import OsmGpsMap as osmgpsmap - print "OsmGpsMap version : ", osmgpsmap._version OSMGPSMAP = True if osmgpsmap._version < '1.0': OSMGPSMAP = False - import logging - logging.warning( _("WARNING: osmgpsmap module not loaded. " + _LOG.warning( _("WARNING: osmgpsmap module not loaded. " "osmgpsmap must be >= 1.0. yours is %s") % osmgpsmap._version) -except: - OSMGPSMAP = False - import logging - logging.warning(_("WARNING: osmgpsmap module not loaded. " - "Geography functionality will not be available.")) + else: + _LOG.info("OsmGpsMap loaded, version : " + osmgpsmap._version) + except: + OSMGPSMAP = False + _LOG.warning(_("WARNING: osmgpsmap module not loaded. " + "Geography functionality will not be available.")) if OSMGPSMAP: # Load the view only if osmgpsmap library is present. diff --git a/src/plugins/view/htmlrenderer.gpr.py b/src/plugins/view/htmlrenderer.gpr.py index acfb728f9..c24310324 100644 --- a/src/plugins/view/htmlrenderer.gpr.py +++ b/src/plugins/view/htmlrenderer.gpr.py @@ -54,15 +54,10 @@ TOOLKIT = NOWEB repository = Repository.get_default() if repository.enumerate_versions("WebKit"): try: - print "import Webkit" from gi.repository import WebKit TOOLKIT = WEBKIT except: - ##try: - ## import gtkmozembed - ## TOOLKIT = MOZILLA - ##except: - pass + pass else: _LOG.warning("Webkit is not installed");