Merge lp:~turl/specto/better-web-launching into lp:specto

Proposed by Emilio
Status: Needs review
Proposed branch: lp:~turl/specto/better-web-launching
Merge into: lp:specto
Diff against target: 30 lines (+13/-7)
1 file modified
spectlib/util.py (+13/-7)
To merge this branch: bzr merge lp:~turl/specto/better-web-launching
Reviewer Review Type Date Requested Status
Jeff Fortin Tam Needs Fixing
Review via email: mp+16665@code.launchpad.net
To post a comment you must log in.
lp:~turl/specto/better-web-launching updated
147. By Emilio

Cosmetic fix.

148. By Emilio

Remove GConf fallback from return_webpage.

Revision history for this message
Jeff Fortin Tam (kiddo) wrote :

Two things:
- The Pythonic/PEP-8 way is to write "if path:", not "if path is not False:"
- It doesn't work here. My gnome settings for preferred applications were set by chromium to be:

/usr/lib/chromium-browser/chromium-browser %s

review: Needs Fixing

Unmerged revisions

148. By Emilio

Remove GConf fallback from return_webpage.

147. By Emilio

Cosmetic fix.

146. By Emilio

Improve return_webpage to use xdg-open when available.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'spectlib/util.py'
--- spectlib/util.py 2009-12-29 21:45:20 +0000
+++ spectlib/util.py 2010-01-06 19:50:23 +0000
@@ -28,13 +28,19 @@
2828
29def return_webpage(webpage):29def return_webpage(webpage):
30 """ Open the webpage in the default browser. """30 """ Open the webpage in the default browser. """
31 specto_gconf = Specto_gconf("/desktop/gnome/url-handlers/http")31 # Scan the system path looking for a supported launcher
32 default_browser = specto_gconf.get_entry("command")32 path = os.environ.get('PATH',False)
33 # Return the browser executable with the URL33 if path is not False:
34 if "%s" in default_browser: # Most browsers34 path = path.split(':')
35 return (default_browser % webpage)35 possible_launchers = ('xdg-open','gnome-open','kde-open','x-www-browser')
36 else: # TODO: This is a hack for Google Chrome. We should use xdg-open instead, ideally. See bug #284.36 for launcher in possible_launchers:
37 return ("%s %s" % (default_browser, webpage))37 for directory in path:
38 test_file = os.path.join(directory,launcher)
39 if os.path.isfile(test_file):
40 return ("%s %s" % (test_file, webpage))
41
42 # There is no way for us to know the user's preferred browser :(
43 return False
3844
3945
40def show_webpage(webpage):46def show_webpage(webpage):

Subscribers

People subscribed via source and target branches