This is an experiment to use GtkFileChooserNative on Windows and macOS to address issues like
https://github.com/geany/geany-osx/issues/14
where the GTK dialogs don't offer the best user experience.
I kept using GtkFileChooser on Linux because it adds extra widgets to the dialog like file encoding and filetype selection and these aren't supported when using native dialogs. To me at least this isn't the most important thing and using native dialogs under Windows and macOS is more important IMO.
This leads to a few ifdefs in the code but I'd say the result isn't too bad (GtkFileChooser is a GtkWidget while GtkFileChooserNative isn't so some things have to differ). Before continuing with the save dialog and project open dialog, my question is whether something like that would be acceptable for Geany - @b4n @eht16 what do you think?
@eht16 Do the native dialogs work correctly on Windows with this patch? It seems to work alright on macOS. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/3861
-- Commit Summary --
* Use GtkFileChooserNative for opening files on Windows and macOS
-- File Changes --
M src/dialogs.c (75)
-- Patch Links --
https://github.com/geany/geany/pull/3861.patch https://github.com/geany/geany/pull/3861.diff
I'm curious though as I only use Linux, it won't change anything for me :D. But I'll give it a try on Windows, this will take a few days though.
Somebody who has Windows 11 and can build Geany with this needs to test as well.
Also I presume the native dialogs are themed by the platform, not by GTK themes, so they may look totally different to the rest of Geany. @techee for Macos and whoever tests on Windows 11 need to try.
Somebody who has Windows 11 and can build Geany with this needs to test as well.
No need to build yourself, a full installer with the changes can be downloaded from the CI builds: https://github.com/geany/geany/actions/runs/8869590862
Windows 10/11 feedback would be great, I can only test on Windows 7 which is unsupported and not representative.
Windows 10/11 feedback would be great
So far so good on a stock Win 10 (22H2) VM with native dark mode active (i.e. `AppsUseLightTheme` == `0`):<sup>1.</sup>
<img width="800" alt="geany-2.1_ci_20240428183001_d3bb7fe-2024-04-29-151630" src="https://github.com/geany/geany/assets/59004801/ef76157a-d5ae-4111-b147-ce6a4ce91945"><br>
Also I presume the native dialogs are themed by the platform, not by GTK themes
The screen capture and Registry values below confirm as much.
At least it's not launching the XP-era file dialogue that caused #3209
--- <sup>1.</sup> ~~~sh-session $ reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" /se #
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize ColorPrevalence REG_DWORD 0x0 EnableTransparency REG_DWORD 0x0 AppsUseLightTheme REG_DWORD 0x0 SystemUsesLightTheme REG_DWORD 0x0 ~~~
No need to build yourself, a full installer with the changes can be
downloaded from the CI builds: https://github.com/geany/geany/actions/runs/8869590862
Nice, I didn't know about that.
The screenshot below comes from Windows 11, Geany on the left, Notepad++ on the right. The only difference I see is the file type selection that Notepad++ offers. I ifdef'ed that out in this patch thinking it wouldn't work but maybe it does - I'll try that.
![Screenshot 2024-04-29 221123](https://github.com/geany/geany/assets/713965/4100df30-5eb4-4fa4-9978-d390220...)
@techee pushed 1 commit.
2bf55c0d6657fa0a80ffd573316c47308d9ba581 Use filters with GtkFileChooserNative
File filters work both on Windows and macOS:
![Screenshot 2024-04-30 001617](https://github.com/geany/geany/assets/713965/a457b3df-a2fe-4bc3-b8e8-de97402...) <img width="833" alt="Screenshot 2024-04-30 at 0 11 00" src="https://github.com/geany/geany/assets/713965/03616e82-594b-4921-be10-ce999eb38167">
@rdipardo @techee thanks for testing, so apart from the inconsistent theming issue it seems to work.
@techee you said in the OP "where the GTK dialogs don't offer the best user experience.". Can you expand on that and why " using native dialogs under Windows and macOS is more important IMO."?
Didn't we have native dialogs a while ago, at least on Windows? So this brings that back, basically?
To me at least this isn't the most important thing and using native dialogs under Windows and macOS is more important IMO.
You hard-coded the native dialogs. As they don't offer all the features of our dialog (renaming a file, for example) you should be able to use that. I can also imagine not everyone likes an "alien" dialog in a GTK application (it's native to Windows but alien Geany).
Since I can't try either of the native dialogs, the reason I (politely) asked what the advantages of the native dialogs are is because as they are hard coded at compile time (AFAICT) users on Windows and Macos are gonna be stuck with them. So its important to know what the advantages are vs the disadvantages.
@techee you said in the OP "where the GTK dialogs don't offer the best user experience.". Can you expand on that and why " using native dialogs under Windows and macOS is more important IMO."?
It's pretty much this: https://github.com/geany/geany-osx/issues/14#issuecomment-1988461271. Basically the GTK keyboard shortcuts don't work on macOS and even if they worked, users don't know this because they are used to normal macOS behavior. Then it's the matter of favorite folders in the sidebar which one can normally define once and then they arte used in all the dialogs - that doesn't work with the GTK dialog. Finally, when using the native dialog, on macOS at least, the operating system automatically grants read/write "protected folder" file access without additional permission popup - this doesn't happen for GTK dialogs because they are "some foreign code" and the system doesn't know it was the user's explicit file selection.
Didn't we have native dialogs a while ago, at least on Windows? So this brings that back, basically?
Yes, but I think the problem wasn't the dialogs themselves (apart from the fact they were some "old" open dialogs), but rather the fact they were implemented using Windows API that nobody understood well. The API of `GtkFileChooserNative` is pretty much like `GtkFileChooser` except it isn't a widget and you cannot put custom widgets inside it.
You hard-coded the native dialogs.
This isn't meant to be the final implementation - as said in the PR description, I asked whether using them would be acceptable in Geany and implemented it only for the open dialog for some testing. I don't want to spend much time on something that nobody likes so here I just wanted some initial feedback. Making this feature optional is surely an option but if it's done that way, I'd lean towards using the native dialogs by default.
As they don't offer all the features of our dialog (renaming a file, for example)
I didn't even know it was possible to rename a file using the Open dialog - how does one do that? I was talking about these options:
<img width="878" alt="Screenshot 2024-04-30 at 15 21 11" src="https://github.com/geany/geany/assets/713965/46cf8725-cf6d-4acf-9cad-51c65eed02b7">
which are a custom widget inserted to the open dialog and which I personally have never used (I just tend to open the file and modify what's needed afterwards in Geany - especially with file encoding one cannot be sure before seeing how the file displays).
I didn't even know it was possible to rename a file using the Open dialog - how does one do that?
OK, I guess you meant the Save as dialog where the Rename button is the added widget, which, indeed, won't be present in the native dialogs.
Yes, but I think the problem wasn't the dialogs themselves (apart from the fact they were some "old" open dialogs), but rather the fact they were implemented using Windows API that nobody understood well.
And #3209 crash.
But one thing positive they did was that they automounted remote servers IIRC, @techee @rdipardo do you have a configuration to check that on windows with the new native filechooser?
Like @kugel, I didn't understand that this was WIP (label added) and would be selectable by the user in the final PR, not compiled in. In that case its less of a problem that there are functionality and theme differences, the user can choose. It will need to be explained properly in the manual why this happens with a section head that I can link to and close the issue when users complain :smiling_imp:
The native file dialog on Windows 7 works very well after some testing. Non-ASCII path and file names seem to work well, too. ![Screenshot_2024-05-01_19-35-32](https://github.com/geany/geany/assets/617017/3aaca2a3-9213-4435-89ab-864a946...)
I don't know how to set up "automounted remote servers", so can't test it. But what the native dialog offers is access to network drives, I tested it with a file on a network drive added via the RDP client (I think this uses SMB under the hood) and this works fine while the GTK dialog does not see those drives.
To me it seems fine to use those dialogs since it seems to work well and if it goes the same for "Save As" and maybe "Open Folder". Making it configurable is a good idea, I don't mind about the default. Most of the infrastructure for the setting we already had (see #3219 and #3791) which could be revived.
To me it seems fine to use those dialogs since it seems to work well and if it goes the same for "Save As" and maybe "Open Folder". Making it configurable is a good idea, I don't mind about the default.
Good to hear. I'll try to prepare the patches (after finishing the boring task of writing documentation for the lsp plugin, sigh).
Maybe one more question - should the open dialog show hidden files by default? This is configurable using the custom widget on GTK but we won't be able to add it so we should decide either to show hidden files or not. On macOS hidden files can be shown using some keyboard shortcut for the dialog so it wouldn't be completely necessary to always show hidden files, I'm not sure if it's possible on Windows too though (on the other hand Windows hidden files aren't so important I think because it's not those beginning with `.` like `.gitignore` that typical developer needs to edit).
If there's an option for it, sure (I didn't understand that was something you would be happy about). And I don't mind the default on non-Linux either, whatever people like best on those platforms. It would be nice to have this available on Linux as well (**but off by default**) for the sandboxing caps -- although I'm not really sure whether "sandboxing" an editor/IDE really makes much sense, but well, it has been mentioned quite a few times.
File filters work both on Windows and macOS
That's nice. And indeed, the [documentation](https://docs.gtk.org/gtk3/class.FileChooserNative.html#win32-details-gtkfile...) lead me to think it wouldn't work with out patterns, but [custom filters](https://docs.gtk.org/gtk3/method.FileFilter.add_custom.html) are actually something else.
Maybe one more question - should the open dialog show hidden files by default? [...] I'm not sure if it's possible on Windows too though (on the other hand Windows hidden files aren't so important I think because it's not those beginning with `.` like `.gitignore` that typical developer needs to edit).
I don't think it's necessary because as you said, hidden files on Windows are usually less relevant and have stronger means than on Linux. The dialog in the current configuration shows files like `.gitignore` and this is good, I think.
@techee pushed 3 commits.
91fb8850281979356cdc38b5ea2b97e1b7132461 Use GtkFileChooserNative depending on user configuration ee8f885acf554c494b00f0f3a80a3c17676838ca Remove usage of windows-native dialogs from ui_utils.c and win32.c/h 4dff3767b9f80719dab3d1a83443be52cd377fa8 Use GtkFileChooserNative in ui_utils.c
@techee pushed 1 commit.
2d8d4f2edacbfc82743a4d020d9c22bc6526b92b Use GTK_RESPONSE_ACCEPT which is also used by GtkFileChooserNative
Alright, I made the suggested changes: 1. I made GtkFileChooserNative configurable, by default enabled on macOS and Windows, disabled on Linux. 2. I went through all GtkFileChooser occurrences in Geany and added the native variant 3. Not sure if intentional or if it's some left-over but `ui_utils.c` still contains native win32 dialogs: https://github.com/geany/geany/blob/11b4a00a3020b1c9ace3d3ae65aa5ec7d5ff84e0... I replaced those with GtkFileChooserNative and eliminated the native code in win32.c. 4. For now I didn't modify plugins which also contain some GtkFileChooser code but I could do the same for them too if desired.
github-comments@lists.geany.org