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

Use org.freedesktop.portal.OpenURI for Providing the AppChooser #1162

Closed
wants to merge 6 commits into from

Conversation

Marukesu
Copy link
Contributor

supersedes #1029

Make use of the OpenURI portal for showing an AppChooser and for opening the file on the File Manager.

This one can be used on host too.

makes the "Open In…" menu works on Flatpak.
Copy link
Collaborator

@jeremypw jeremypw left a comment

Choose a reason for hiding this comment

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

A few comments but otherwise this works as expected and the code looks good.

src/FolderManager/FileItem.vala Outdated Show resolved Hide resolved
src/FolderManager/Item.vala Outdated Show resolved Hide resolved
src/FolderManager/Item.vala Outdated Show resolved Hide resolved
@Marukesu
Copy link
Contributor Author

Added a new property on FolderManager.File to query write access, this should work with both read-write and read-only files and directories.

Jeremy Wootten added 2 commits May 4, 2022 19:27
# Conflicts fixed in:
#	data/io.elementary.code.appdata.xml.in
Copy link
Collaborator

@jeremypw jeremypw left a comment

Choose a reason for hiding this comment

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

Sorry for overlloking this for so long.

Is there a reason for the context menu for folder items to differ from that for file items (compared to master running natively)? The former has an ellipsis and launches straight into the AppChooser whereas the latter has a submenu offering an immediate option to open in the FileManager as well as an "Other applications" option (which offers the File Manager).

Otherwise this is looking good. Will changing to the OS7 platform require any changes?

@Marukesu
Copy link
Contributor Author

Marukesu commented May 5, 2022

Is there a reason for the context menu for folder items to differ from that for file items (compared to master running natively)? The former has an ellipsis and launches straight into the AppChooser whereas the latter has a submenu offering an immediate option to open in the FileManager as well as an "Other applications" option (which offers the File Manager).

Since we don't have access to the AppInfo inside the sandbox, the submenu in FolderItem had only one option (AppChooser), so i removed it, while, FileItem ended with three (New Window, File Manager, AppChooser).

In master, the file manager entry is created manually by querying the default AppInfo for inode/directory, the portal has the OpenURI.open_directory() method to replace this case, so i used it. Also, i can't see the File Manager in the AppChooser for FileItem here.

Will changing to the OS7 platform require any changes?

You say the flatpak runtime? since we are using Gtk3 here, no changes should be needed. For Gtk4, we need to adapt the MainWindow.export() code to use Gdk.Surface instead of Gdk.Window.

@jeremypw
Copy link
Collaborator

jeremypw commented May 5, 2022

I still do not really see why a fileitem and a folderitem should have a different "Open in..." submenu. Can we not offer a "Open in FIleManager" item for folder items as well as file items?

It could make sense to offer a "New Window" option for folders as well as files but that is outside the scope of this PR.

@Marukesu
Copy link
Contributor Author

Marukesu commented May 5, 2022

I still do not really see why a fileitem and a folderitem should have a different "Open in..." submenu. Can we not offer a "Open in FIleManager" item for folder items as well as file items?

we can, but it's less useful for folders, since the AppChooser will show the FileManager anyway. that not the case for files.

It could make sense to offer a "New Window" option for folders as well as files but that is outside the scope of this PR.

Well, projects folders aren't unique per-window, so any new window will already have all the folders anyway.

@jeremypw
Copy link
Collaborator

jeremypw commented May 6, 2022

we can, but it's less useful for folders, since the AppChooser will show the FileManager anyway. that not the case for files.

I see. I guess it can be left to the UX team to decide whether the context menu needs redesign - it it is not blocking for this PR anyway.

Well, projects folders aren't unique per-window, so any new window will already have all the folders anyway.

Yes, we would have to implement different projects per window for that to be useful.

jeremypw
jeremypw previously approved these changes May 6, 2022
@tintou
Copy link
Member

tintou commented May 6, 2022

Sorry for taking so long for reviewing it, but it doesn't seems to be the solution we want here as the portal is already implemented elsewhere.

@tintou
Copy link
Member

tintou commented May 6, 2022

Implementing the OpenURI portal inside Code is not the way to go, a portal implementation has to be out of the container

@tintou
Copy link
Member

tintou commented May 6, 2022

The only way to trigger a portal for opening a file would be:

GLib.AppInfo.launch_default_for_uri (file.file.get_uri (), null);

@tintou
Copy link
Member

tintou commented May 6, 2022

@danrabbit We should make a blog post about how app developers should replace the in-app "Open In…" menus with something that works in containers

@Marukesu
Copy link
Contributor Author

Marukesu commented May 6, 2022

Sorry, but I think you misunderstood the PR, we aren't implementing the OpenURI portal here, but using it directly.

Neither Glib or GTK expose the OpenURI.open_file method with the ASK flag that is used do show the app chooser. They also don't expose the OpenURI.open_directory method that we are using here to open the file manager.

@danirabbit
Copy link
Member

@tintou yeah the problem is there isn't a replacement portal yet 😅 elementary/portals#38

@jeremypw
Copy link
Collaborator

@danrabbit So should this PR be blocked pending a wrapper for the OpenUri portal appearing in Gtk or Granite, which it can then use?

@danirabbit
Copy link
Member

@jeremypw it seems like generally the OpenURI Portal probably isn't the appropriate portal to use here long-term anyways so this is more of a work around to preserve some functionality inside the sandbox. The proper long-term solution would be to create a sharing portal that's actually designed for this. Since we're not shipping Code in a Flatpak currently, I'm not sure this specific workaround is a huge priority? We could probably wait for a new portal?

@jeremypw
Copy link
Collaborator

The only "Open in ..." functionality I use is "Open in Terminal".

@jeremypw
Copy link
Collaborator

jeremypw commented Aug 2, 2023

Since we're not shipping Code in a Flatpak currently, I'm not sure this specific workaround is a huge priority? We could probably wait for a new portal?

In view of this I think this can be closed and the matter reviewed when we come to FlatPak Code (not soon afaik)

@jeremypw jeremypw closed this Aug 2, 2023
@Marukesu Marukesu mentioned this pull request Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants