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

[GTK4] Migrate DirectoryDialog from GtkFileChooser to GtkFileDialog #1421

Closed

Conversation

ptziegler
Copy link
Contributor

The FileChooser has been marked as deprecated with GTK 4.10 with the FileDialog being its replacement. Using this new API poses a challenge, as it requires the usage of the AsyncReadyCallback mechanism in order to respond to the closure of the dialog.

Once the dialog has been opened via gtk_file_dialog_select_folder(), it is necessary to call gtk_file_dialog_select_folder_finish() from within the callback method. This method also returns the selected folder, which has to be cached until after the dialog has been closed.

Following native methods have been added to GTK4:

  • gtk_file_dialog_new
  • gtk_file_dialog_select_folder
  • gtk_file_dialog_select_folder_finish
  • gtk_file_dialog_set_initial_folder

@ptziegler
Copy link
Contributor Author

Contributes to #652

For comparison, the "current" GTK3-based directory dialog:
gtk3

And the "new" GTK4-based directory dialog:
gtk4

@akurtakov
Copy link
Member

Looks promising.Please ping me in 2 weeks if I haven't reviewed it yet as we are in a freeze now.

Copy link
Contributor

github-actions bot commented Aug 26, 2024

Test Results

   486 files  ±0     486 suites  ±0   7m 38s ⏱️ -17s
 4 158 tests ±0   4 150 ✅ ±0   8 💤 ±0  0 ❌ ±0 
16 386 runs  ±0  16 294 ✅ ±0  92 💤 ±0  0 ❌ ±0 

Results for commit d4e0a6b. ± Comparison against base commit d908f99.

♻️ This comment has been updated with latest results.

@ptziegler ptziegler force-pushed the gtk4-file-dialog branch 3 times, most recently from 03cea78 to e3d777a Compare August 27, 2024 19:34
@ptziegler ptziegler mentioned this pull request Aug 27, 2024
3 tasks
@akurtakov akurtakov force-pushed the gtk4-file-dialog branch 4 times, most recently from 92f1acf to f8a2840 Compare September 13, 2024 12:19
The FileChooser has been marked as deprecated with GTK 4.10 with the
FileDialog being its replacement. Using this new API poses a challenge,
as it requires the usage of the AsyncReadyCallback mechanism in order to
respond to the closure of the dialog.

Once the dialog has been opened via gtk_file_dialog_select_folder(), it
is necessary to call gtk_file_dialog_select_folder_finish() from within
the callback method. This method also returns the selected folder, which
has to be cached until after the dialog has been closed.

Following native methods have been added to GTK4:
- gtk_file_dialog_new
- gtk_file_dialog_select_folder
- gtk_file_dialog_select_folder_finish
- gtk_file_dialog_set_initial_folder
Copy link
Member

@akurtakov akurtakov left a comment

Choose a reason for hiding this comment

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

After a local change as commented it is all fine.

/**
* @param self cast=(GtkFileDialog *)
* @param result cast=(GAsyncResult *)
* @param error cast=(GError *)
Copy link
Member

@akurtakov akurtakov Sep 16, 2024

Choose a reason for hiding this comment

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

Should be '(GError **)'. What you have here fails with

gtk4.c:737:103: error: passing argument 3 of ‘gtk_file_dialog_select_folder_finish’ from incompatible pointer type [-Wincompatible-pointer-types]
  737 |         rc = (jlong)gtk_file_dialog_select_folder_finish((GtkFileDialog *)arg0, (GAsyncResult *)arg1, (GError *)lparg2);
      |                                                                                                       ^~~~~~~~~~~~~~~~
      |                                                                                                       |
      |                                                                                                       GError * {aka struct _GError *}
In file included from /usr/include/gtk-4.0/gtk/gtk.h:134,
                 from gtk4.h:23,
                 from gtk4_structs.h:18,
                 from gtk4.c:19:
/usr/include/gtk-4.0/gtk/gtkfiledialog.h:118:77: note: expected ‘GError **’ {aka ‘struct _GError **’} but argument is of type ‘GError *’ {aka ‘struct _GError *’}
  118 |                                                       GError              **error);
      |                                                       ~~~~~~~~~~~~~~~~~~~~~~^~~~~


import org.eclipse.swt.*;
Copy link
Member

Choose a reason for hiding this comment

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

Remove this unused import.

@akurtakov
Copy link
Member

Fixed version is in #1473 in order to get this one in while I am at it.

@akurtakov akurtakov closed this Sep 17, 2024
@ptziegler
Copy link
Contributor Author

My apologies for the belated response. The past few days have been a little hectic...

@ptziegler ptziegler deleted the gtk4-file-dialog branch September 18, 2024 04:28
@akurtakov
Copy link
Member

My apologies for the belated response. The past few days have been a little hectic...

NP, Thanks again for the patch and keep'em coming! I would love to see the GTK 4 port shape better and better.

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.

2 participants