Merge lp:~kamstrup/unity-lens-files/bookmarks-handling into lp:unity-lens-files

Proposed by Mikkel Kamstrup Erlandsen
Status: Merged
Merged at revision: 194
Proposed branch: lp:~kamstrup/unity-lens-files/bookmarks-handling
Merge into: lp:unity-lens-files
Diff against target: 73 lines (+29/-4)
2 files modified
src/daemon.vala (+3/-2)
src/folder.vala (+26/-2)
To merge this branch: bzr merge lp:~kamstrup/unity-lens-files/bookmarks-handling
Reviewer Review Type Date Requested Status
Michal Hruby (community) Approve
Review via email: mp+77508@code.launchpad.net

Description of the change

Open FTP bookmarks in the default handler for inode/directory. This makes FTP bookmarks open in Nautilus. Note this only applies on *bookmarks*. Incidentally this also fixes automounting of remote shares (except in the cases where GIO b0rks it (FTP works well, SSH not so much))

To post a comment you must log in.
Revision history for this message
Michal Hruby (mhr3) wrote :

> if (launcher == null)

I think we should fallback here to opening it via default handler for the uri scheme.

review: Needs Fixing
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

Fallback is handled in:

18 + if (!bookmarks.launch_if_bookmark (uri))
19 + AppInfo.launch_default_for_uri (uri, null);

194. By Mikkel Kamstrup Erlandsen

Let errors from bookmark launching bubble up to the main activation handler

Revision history for this message
Michal Hruby (mhr3) wrote :

Very well then, let's have some error dialogs :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/daemon.vala'
2--- src/daemon.vala 2011-09-29 11:44:16 +0000
3+++ src/daemon.vala 2011-09-29 12:09:23 +0000
4@@ -650,7 +650,7 @@
5 {
6 results_model.append (bookmark.uri, bookmark.icon, category,
7 bookmark.mimetype, bookmark.display_name,
8- bookmark.uri);
9+ bookmark.dnd_uri);
10 }
11 }
12
13@@ -713,7 +713,8 @@
14 {
15 debug (@"Activating: $uri");
16 try {
17- AppInfo.launch_default_for_uri (uri, null);
18+ if (!bookmarks.launch_if_bookmark (uri))
19+ AppInfo.launch_default_for_uri (uri, null);
20 return new Unity.ActivationResponse(Unity.HandledType.HIDE_DASH);
21 } catch (GLib.Error error) {
22 warning ("Failed to launch URI %s", uri);
23
24=== modified file 'src/folder.vala'
25--- src/folder.vala 2011-09-22 08:49:28 +0000
26+++ src/folder.vala 2011-09-29 12:09:23 +0000
27@@ -168,6 +168,29 @@
28
29 return filter_bookmarks (matches);
30 }
31+
32+ public bool launch_if_bookmark (string uri) throws Error
33+ {
34+ if (!uri.has_prefix ("bookmark:"))
35+ return false;
36+
37+ var launcher = AppInfo.get_default_for_type ("inode/directory", true);
38+
39+ uri = uri.offset (9); // Remove "bookmark:" prefix from uri
40+
41+ if (launcher == null)
42+ {
43+ warning ("No default handler for inode/directory. Unable to open bookmark '%s'", uri);
44+ throw new IOError.FAILED ("No default handler for inode/directory. Unable to open bookmark '%s'", uri);
45+ }
46+
47+ var uris = new List<string> ();
48+ uris.append (uri);
49+
50+ launcher.launch_uris (uris, new AppLaunchContext());
51+
52+ return true;
53+ }
54
55 }
56
57@@ -177,13 +200,14 @@
58 public string icon { get; set construct; }
59 public string mimetype { get; set construct; }
60 public string display_name { get; set construct; }
61+ public string dnd_uri { get; set construct; }
62
63 private List<string> index_terms;
64
65 public Bookmark (string uri, string mimetype, string display_name)
66 {
67- Object (uri:uri, icon:Utils.get_icon_for_uri (uri, mimetype),
68- mimetype:mimetype, display_name:display_name);
69+ Object (uri:"bookmark:"+uri, icon:Utils.get_icon_for_uri (uri, mimetype),
70+ mimetype:mimetype, display_name:display_name, dnd_uri:uri);
71
72 index_terms = new List<string> ();
73 index_terms.append (Utils.normalize_string (Path.get_basename (uri)));

Subscribers

People subscribed via source and target branches

to all changes: