[rhythmbox] context: use the user's default browser directly instead of gtk.show_uri()



commit b5c505ed55db1174a7bd6867af0b61b5416d5aa3
Author: Jonathan Matthew <jonathan d14n org>
Date:   Fri Dec 10 21:49:22 2010 +1000

    context: use the user's default browser directly instead of gtk.show_uri()
    
    gtk.show_uri() downloads the URI content to figure out which app to use,
    which is slow and unnecessary in this case.  We already know we want to use
    a web browser, so the only issue is which one to use.

 plugins/context/context/ContextView.py |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/plugins/context/context/ContextView.py b/plugins/context/context/ContextView.py
index 46e951b..ab65927 100644
--- a/plugins/context/context/ContextView.py
+++ b/plugins/context/context/ContextView.py
@@ -25,7 +25,7 @@
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA.
 
 import rb, rhythmdb
-import gtk, gobject
+import gtk, gobject, gio
 import pango
 import webkit
 import os
@@ -207,7 +207,12 @@ class ContextView (gobject.GObject):
         # open HTTP URIs externally.  this isn't a web browser.
         if request.get_uri().startswith('http'):
             print "opening uri %s" % request.get_uri()
-            gtk.show_uri(self.shell.props.window.get_screen(), request.get_uri(), gtk.gdk.CURRENT_TIME)
+            appinfo = gio.app_info_get_default_for_uri_scheme("http")
+            try:
+                appinfo.launch_uris((request.get_uri(),))
+            except Exception, e:
+                print "failed: %s" % str(e)
+
             return 1        # WEBKIT_NAVIGATION_RESPONSE_IGNORE
         else:
             return 0        # WEBKIT_NAVIGATION_RESPONSE_ACCEPT



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