New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show transfered file in folder as default action of notification (single click) #1039
Conversation
I'm not fully happy with the behavior on success. The file manager should open with the file selected, but this is another issue. Behavior when the transfer is unsuccessful is yet untested
Using org.freedesktop.FileManager1.ShowItems the folder containing a file can be opened with the file selected. This can be used for the file transfer successful notification for example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! - and sorry for the late review
if we want to use this behavior when "Open Folder is clicked
Yes. This is better.
For the label, I think GNOME already has a wording for this action but I couldn't find it. Otherwise I'd suggest "Show in folder".
Given this is a GNOME Shell extension, I don't think we need the previous method as fallback.
if dbus is really the only way to achieve this (that's what I found, should work for nautilus and dolphin)
Yep, there are no wrapper exposed in GNOME libraries AFAIK
https://github.com/search?q=org.freedesktop.FileManager1&type=code
how tests can be added
I wouldn't say it's necessary here. But if you like checkout installed-tests/suites/components/
. I guess you could listen on the bus and wait for what's of interested.
@andyholmes wdyt? any better idea for testing this?
how I can check the transfer-failed notification works
Perhaps send a large file and disconnect network midway. Why is it relevant?
@@ -733,6 +740,24 @@ var Device = GObject.registerClass({ | |||
Gio.AppInfo.launch_default_for_uri_async(uri, null, null, null); | |||
} | |||
|
|||
openPathSelectFile(action, parameter) { | |||
const path = parameter.unpack(); | |||
const uri = path.includes('://') ? path : `file://${path}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use https://gjs-docs.gnome.org/gio20/gio.file instead
You can do something like
const file = Gio.File.new_for_path(path);
file.get_uri()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sonnyp Looking at this again, I wonder if that's really necessary. By the time it gets here, the uri has already been through Gio.File
:
gnome-shell-extension-gsconnect/src/service/plugins/share.js
Lines 179 to 189 in 4208acc
buttons = [ | |
{ | |
label: _('Open Folder'), | |
action: 'openPath', | |
parameter: new GLib.Variant('s', file.get_parent().get_uri()), | |
}, | |
{ | |
label: _('Open File'), | |
action: 'openPath', | |
parameter: new GLib.Variant('s', file.get_uri()), | |
}, |
The URI coercion here is (as I read it) just a safety valve, in case someone adds a call to openPath()
(or openPathSelectFile()
) with a bare pathname. But in normal/expected usage, the parameter is the result of a file.get_uri()
already. Round-tripping through Gio.File
a second time may be overkill?
-1, | ||
null, | ||
null | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like there should be an error to catch here
https://www.andyholmes.ca/articles/dbus-in-gjs.html#direct-calls
Logging the error is enough.
@@ -733,6 +740,24 @@ var Device = GObject.registerClass({ | |||
Gio.AppInfo.launch_default_for_uri_async(uri, null, null, null); | |||
} | |||
|
|||
openPathSelectFile(action, parameter) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider renaming to showPathInFolder
I don't think there are many UI tests in the suite yet, those are kind of hard to do in a CI at the moment. Probably this one would just have to be tested locally. |
Jumping in way late on this, but I may pick it up if @HaMF doesn't plan to continue.
The Nautilus wording (seen in both the Recent list and Search results) is "Open Item Location". Which I suppose may not technically be a folder, so I have to give them that. (It may be at the root of a removable drive, for example.) However, when outside the file manager itself, the wording is usually different. Common are:
|
@ferdnyc Thanks for the research regarding the wording. Feel free to take it and finish it, I won't get around to it in the next days. If you haven't done so until next week when I'm back I'll look into it. @sonnyp thanks for the review and the valuable pointers. Sorry must have missed the notification. I'll check in detail if ferdnyc does not pick it up |
This adresses issue #1009, but probably needs some work. See issue discussion for details
closes #1009