[gnoduino] Try harder to launch a web browser for viewing reference



commit ecbfc949395f5a78a370c5ed757044888c4617e5
Author: Claude Paroz <claude 2xlibre net>
Date:   Sat Sep 17 19:39:18 2011 +0200

    Try harder to launch a web browser for viewing reference

 src/misc.py |   13 +++++++++++++
 src/ui.py   |    3 +--
 2 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/src/misc.py b/src/misc.py
index dddeca0..2c4fb0b 100644
--- a/src/misc.py
+++ b/src/misc.py
@@ -260,6 +260,19 @@ def createPopup(title, parent, msg):
 	dialog.destroy()
 	return response
 
+
+def launch_in_browser(page):
+	# The difficulty here is that the default open method for local files may not be
+	# a browser (even with python webbrowser module). That's why we try first to read
+	# the gconf key
+	try:
+		import gconf
+		client = gconf.client_get_default()
+		prog = client.get_string("/desktop/gnome/url-handlers/http/command")
+		subprocess.call(prog % page, shell=True)
+	except:
+		gtk.show_uri(None, "file:///"+page, int(time.time()))
+
 #float = config.getfloat('Section1', 'float')
 #int = config.getint('Section1', 'int')
 #print float + int
diff --git a/src/ui.py b/src/ui.py
index 38781a5..9115930 100644
--- a/src/ui.py
+++ b/src/ui.py
@@ -26,7 +26,6 @@ import select
 import shutil
 import signal
 import urlparse
-import time
 
 import locale
 import gettext
@@ -282,7 +281,7 @@ def menuUpload(widget, data=None):
 	upload(widget, ser, data)
 
 def menuReference(widget, data=None):
-	gtk.show_uri(None, "file:///"+os.path.join(misc.getArduinoFile("reference"), "index.html"), int(time.time()))
+	misc.launch_in_browser(os.path.join(misc.getArduinoFile("reference"), "index.html"))
 
 def about(widget, data=None):
 	about = gui.get_object("about")



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]