Merge lp:~jmiguelbenitez/pantheon-photos/fix-1368626 into lp:~pantheon-photos/pantheon-photos/trunk

Proposed by José M. Benítez
Status: Merged
Approved by: Corentin Noël
Approved revision: 2870
Merged at revision: 2872
Proposed branch: lp:~jmiguelbenitez/pantheon-photos/fix-1368626
Merge into: lp:~pantheon-photos/pantheon-photos/trunk
Diff against target: 50 lines (+5/-20)
2 files modified
src/AppWindow.vala (+4/-11)
src/util/system.vala (+1/-9)
To merge this branch: bzr merge lp:~jmiguelbenitez/pantheon-photos/fix-1368626
Reviewer Review Type Date Requested Status
Corentin Noël Approve
Review via email: mp+281376@code.launchpad.net

Commit message

Added launch context when launching file manager to highlight the selected file

Description of the change

Item is highlighted in file manager when "Show in File Manager" option is used from the context menu.

Also, Nautilus was explicitly looked up. That has been removed to use the default file manager instead.

Please note that the fix does not work when an item is shown in the same directory than a previously open file manager instance is currently displaying. But this seems to be a Files thing (this behavior can be easily reproduced launching instances from the command line).

I guess I should file a bug against Files to see what people there say about it, but, as long as Photos is concerned, this fix should be as good as it gets ;)

To post a comment you must log in.
Revision history for this message
Corentin Noël (tintou) wrote :

Really nice fix.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/AppWindow.vala'
2--- src/AppWindow.vala 2015-09-05 18:50:53 +0000
3+++ src/AppWindow.vala 2015-12-27 12:20:41 +0000
4@@ -754,17 +754,10 @@
5 }
6
7 public void show_file_uri (File file) throws Error {
8- string tmp;
9-
10- // if file manager is nautilus then pass the full path to file; otherwise pass
11- // the enclosing directory
12- if (get_nautilus_install_location () != null) {
13- tmp = file.get_uri ().replace ("'", "\\\'");
14- show_file_in_nautilus (tmp);
15- } else {
16- tmp = file.get_parent ().get_uri ().replace ("'", "\\\'");
17- show_uri (tmp);
18- }
19+ AppInfo app_info = AppInfo.get_default_for_type ("inode/directory", true);
20+ var file_list = new List<File> ();
21+ file_list.append (file);
22+ app_info.launch (file_list, get_window ().get_screen ().get_display ().get_app_launch_context ());
23 }
24
25 public void show_uri (string url) throws Error {
26
27=== modified file 'src/util/system.vala'
28--- src/util/system.vala 2014-08-24 00:41:11 +0000
29+++ src/util/system.vala 2015-12-27 12:20:41 +0000
30@@ -23,18 +23,10 @@
31 return exec_dir1.has_prefix (prefix_dir) ? prefix_dir : null;
32 }
33
34-string get_nautilus_install_location () {
35- return Environment.find_program_in_path ("nautilus");
36-}
37-
38 void sys_show_uri (Gdk.Screen screen, string uri) throws Error {
39 Gtk.show_uri (screen, uri, Gdk.CURRENT_TIME);
40 }
41
42-void show_file_in_nautilus (string filename) throws Error {
43- GLib.Process.spawn_command_line_async (get_nautilus_install_location () + " " + filename);
44-}
45-
46 int posix_wexitstatus (int status) {
47 return (((status) & 0xff00) >> 8);
48-}
49\ No newline at end of file
50+}

Subscribers

People subscribed via source and target branches