Request to autoconnect removable-media for gnome-text-editor

Gnome-text-editor should be able to edit files located in removable media, thus we added to the last snap version the removable-media plug. I request to allow the autoconnection of that plug. The package is maintained by the desktop team at Canonical.

This a clear case and the user should expect this. +1 for auto-connect to removable-media for gnome-text-editor snap

Hi, gnome-text-editor should be able to use portals, but as I see it is not. But, I can fix it. Should I share a PR?

EDIT: This is how we can achieve it

But, the icon is missing too.

Mmmā€¦ good point. So it isnā€™t using portals by defaultā€¦

Iā€™ll try with GTK_USE_PORTAL=1

Anyway, I presume that it is still required to have the removable-media plug for the case when the editor tries to open a file passed by command lineā€¦

Mmmā€¦ it doesnā€™t workā€¦ I tried to open the .bash-history file using the portal, and it allows me to select it, but canā€™t load it because I donā€™t have permissions.

I remember GTK discussing removing GTK_USE_PORTAL in favour of GDK_DEBUG=portals. Relevant discussion https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4829, which looks like itā€™s been in for long enough that Iā€™ll just assume itā€™s in the latest releases.

Up until recently Iā€™d been under the impression the GTK4 libs in the Core22 Gnome extension were fairly fixed, but apparently they have been rolling since the extensions release. I think in effect, portals probably worked for GTK4 apps when the extension was released, but might not be now, since the GTK upgrades?

@jamesh does GDK_DEBUG=PORTALS need appending alongside the older GTK3 logic here? https://github.com/snapcore/snapcraft/blob/4b1cff546cde4ddd933e92ae928ba140a78cef2b/snapcraft/extensions/gnome.py#L149

The odd thing is that the gnome-text-editor code does have some extra checks for ā€œGTK_USE_PORTALā€ā€¦

imagen

Ok, setting both GTK_USE_PORTAL and GDK_DEBUG=ā€œportalsā€ seems to workā€¦

gnome-text-editor version 45 will fix this issue. Before this release, Gtk.FileChooserNative was used, which for some reason was not able to use portals in snaps, but were able to use it in flatpaks. Gtk.FileDialog fixes it. I have two such snaps clapper, metadata-cleaner facing the same issue. This is a related forum post.

EDIT: gnome-text-editor version 45 have not implemented Gtk.FileDialog yet. Sorry about that

https://gitlab.gnome.org/GNOME/gnome-text-editor/-/blob/main/src/editor-window-actions.c#L349

I created an extra patch that adds GDK_DEBUG=portals

But Iā€™m not sure if itā€™s a good ideaā€¦ What do you think?

Shit, I made one too!

This is a bit of a pain. That might be worth doing in the short term, but it is clearly not something they want us doing. Slightly longer term, we probably want:

  1. Follow up on this thread in GLib MR !3037, and make glib_get_sandbox_type a real exported API of libgio.
  2. In GTK, replace gdk_running_in_sandbox body with glib_get_sandbox_type() != G_SANDBOX_TYPE_UNKNOWN or whatever the public API ends up being called.

It looks like glibā€™s use of GTK_USE_PORTAL was also changed in GLib MR !3602, but it correctly detects snap confinement already so the portal calls there function correctly.

Hi @SergioCostas , I see that the issue has been solved using portals. Do you still need auto-connect to removable-media interface (e.g. for cases where desktop portals are not available)? In case itā€™s not needed anymore I can go ahead and remove this request from our queue. Thanks.

Opsā€¦ yes, you can remove this. It seems to work fine. If there are people with problems where portals arenā€™t available, Iā€™ll open this again. Sorry.

1 Like

@SergioCostas what about old Ubuntus?

Like here mentioned, that it didnā€™t work in Jammy. Itā€™s not that much old.

Mmmā€¦ You are right, doing ā€œdouble clickā€ in nautilus to open a file with gnome-text-editor from a removable media could be a problemā€¦ So yes, it seems that autoconnect is needed here too.

Yeahā€¦ that should not work but it works when opening the dialog from within the text-editor right?

Yes. With portals enabled, you can open files from a removable media from within GTE, but canā€™t pass a URI that points to a file in a removable media. for the later, the ā€œremovable-mediaā€ plug must be connected.

1 Like