eclipse.platform.swt icon indicating copy to clipboard operation
eclipse.platform.swt copied to clipboard

Save FileDialog on Linux does not update the file endings when you select possible file types

Open Mailaender opened this issue 3 years ago • 10 comments

This is a long-standing inconvenience.

image

I don't really know where to start to look into this.

Mailaender avatar May 25 '22 13:05 Mailaender

I looked into a few examples. On Windows it appears that the default tools that have "Save as" abilities such as Paint/Snipping Tool do this extension change when the filter changes. In Fedora 36 I tested LibreOffice writer, and it handle this differently, with the extension being completely hidden, and simply chosen from the drop down, with only a file name being specified by the user.

Changing the extension is something that we could implement using:

void
gtk_file_chooser_set_current_name (
  GtkFileChooser* chooser,
  const gchar* name
)

However, I'm not sure how Windows/Cocoa SWT behaves currently. If someone else can comment on that we can begin discussing this further.

joel-majano avatar May 25 '22 20:05 joel-majano

On Windows (and Mac) it will always match the file ending to the combo box selection

image

which is why I thought this is a bug

Mailaender avatar May 27 '22 09:05 Mailaender

I found that this has been brought up before https://bugs.eclipse.org/bugs/show_bug.cgi?id=578096. GTK isn't providing a signal that we can use when a filter is changed so instead I tried hooking notify::filter to a callback but it never gets called. This is something that might work in FileChooserDialog, but we currently use GtkFileChooserNative. From the GTK docs on GtkFileChooserNative, "No operations that change the dialog work while the dialog is visible. Set all the properties that are required before showing the dialog".

I created an issue in the GNOME gtk repository (https://gitlab.gnome.org/GNOME/gtk/-/issues/4626) earlier this year in January but it has gotten no attention.

joel-majano avatar May 30 '22 19:05 joel-majano

I was able to modify the snippet that was included in this issue https://gitlab.gnome.org/GNOME/gtk/-/issues/1820 to modify the file name when a filter is changed using the notify signal.

However, this only works with GtkFileChooserDialog and not GtkFileChooserNative which we currently use to allow Eclipse to support flatpak. I see no notify signal emitted from the native file chooser.

joel-majano avatar May 30 '22 22:05 joel-majano

I thought this was a good beginners task, but it doesn't look like it. Could there maybe be a parallel FileDialog and NativeFileDialog for when Flatpak matters vs. when a non-broken extension switcher matters more?

Mailaender avatar May 31 '22 17:05 Mailaender

@akurtakov Is this a feature (autoextending file extension) that would be worth it to have, but that would require two code paths for flatpak vs non flatpak?

joel-majano avatar May 31 '22 17:05 joel-majano

@joel-majano Is the issue present with Gtk 4.x too? The feature is nice but right now we can't afford maintaining 2 codepaths, esp if issue is not there with Gtk4.

akurtakov avatar Jun 01 '22 06:06 akurtakov

@akurtakov Yes the issue is still present. I tested with the snippet #171 provided and in GTK4.6.3 changing the filter does not change the extension.

joel-majano avatar Jun 01 '22 16:06 joel-majano

I have just tested under KDE on Fedora on GTK 4 to see nice surprise :

https://github.com/user-attachments/assets/5e3c22ea-2e83-4bc9-8e44-386d6d7d5789

Unfortunately it doesn't work with Gtk dialog.

akurtakov avatar Aug 25 '25 13:08 akurtakov

Base on https://gitlab.gnome.org/GNOME/gtk/-/issues/5367 the feature is totally "optional" . It's worth investigating what other gtk apps are doing as mentioned in it and try to replicate it.

akurtakov avatar Aug 25 '25 14:08 akurtakov