Skip to content
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

Closed
wants to merge 5 commits into from

Conversation

HaMF
Copy link

@HaMF HaMF commented Jan 3, 2021

This adresses issue #1009, but probably needs some work. See issue discussion for details

closes #1009

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
@HaMF HaMF changed the title Implement showing transfered file in folder as default action of notification (single click) Show transfered file in folder as default action of notification (single click) Jan 3, 2021
@sonnyp sonnyp self-requested a review April 9, 2021 23:14
@HaMF HaMF marked this pull request as ready for review April 29, 2021 19:28
Copy link
Member

@sonnyp sonnyp left a 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}`;
Copy link
Member

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()

Copy link
Member

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:

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
);
Copy link
Member

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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider renaming to showPathInFolder

@andyholmes
Copy link
Collaborator

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?

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.

@ferdnyc
Copy link
Member

ferdnyc commented May 22, 2022

Jumping in way late on this, but I may pick it up if @HaMF doesn't plan to continue.

@HaMF

if we want to use this behavior when "Open Folder is clicked

@sonnyp

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".

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:

  • "Show in folder" (Chrome & Firefox download lists)
  • "Open Containing Folder" (Evince, GNOME Builder)
  • No text since there's just a 📁 icon with no tooltip, JFC. (GNOME Web)
  • No idea, it has never found a single photo on my system (which contains plenty of photos). (GNOME Photos)

@HaMF
Copy link
Author

HaMF commented May 23, 2022

@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

@ferdnyc
Copy link
Member

ferdnyc commented Oct 19, 2022

I've submitted #1491 containing both @HaMF's commits from this PR (thanks, @HaMF!), as well as my further changes to address the review input here.

This can probably be closed in favor of #1491. I'll wait a bit, tho, so others have time to look over that PR and decide whether it's the right path.

@sonnyp sonnyp closed this in #1491 Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review A contribution that needs code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Click on "Transfer successful" notification should open file or it's location with file selected
4 participants