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

Example Of FileDialog ! #117

Closed
SudoDios opened this issue Jul 26, 2024 · 6 comments
Closed

Example Of FileDialog ! #117

SudoDios opened this issue Jul 26, 2024 · 6 comments

Comments

@SudoDios
Copy link

Can you write example of FileDialog with openMultiple ?
(how to get file from ListModel of GObjects ?)

val files = openMultipleFinish(result) //this is ListModel of GObject
@jwharm
Copy link
Owner

jwharm commented Jul 26, 2024

FileDialog.openMultipleFinish doesn't specify the item type of the ListModel, so it defaults to plain GObjects. I'll log an issue in Gtk to add the missing annotation.

You can work around it in the meantime:

ListModel list = dialog.openMultipleFinish(result);
List<File> files = new ArrayList<>();
for (int i = 0; i < list.getNItems(); i++)
    files.add(new File.FileImpl(list.getItem(i).handle()));

@SudoDios
Copy link
Author

thanks bro.
Okay

@jwharm
Copy link
Owner

jwharm commented Jul 26, 2024

Correction; it's not a missing annotation. ListModels just always return plain GObjects. I'll try to find a better solution than the workaround above though.

@SudoDios
Copy link
Author

Yes that's right.

ListModels just always return plain GObjects.

@jwharm
Copy link
Owner

jwharm commented Jul 29, 2024

In the next release it will be possible to do var file = (File) listmodel.getItem(i).

@SudoDios
Copy link
Author

How great 👍

jwharm added a commit that referenced this issue Aug 1, 2024
…verify that the returned constructor is compatible with the documented type
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

No branches or pull requests

2 participants