gtk-rs / gtk3-rs

Rust bindings for GTK 3
https://gtk-rs.org
MIT License
508 stars 90 forks source link

Add binding for Gtk.FileFilterInfo #757

Closed kelnos closed 2 years ago

kelnos commented 2 years ago

This enables the .add_custom() and .filter() functions on gtk::FileFilter.

I'm not 100% sure about my implementations of FromGlibPtr*, but I've at least tested both a "regular" filter and an "add custom" filter, and they both seem to work (and not crash).

kelnos commented 2 years ago

Hmm, looks like there are clippy failures for code unrelated to my change.

sdroege commented 2 years ago

Hmm, looks like there are clippy failures for code unrelated to my change.

Yes, don't worry about those :) They were introduced by the Rust beta being automatically updated.

sdroege commented 2 years ago

clippy failures should be gone if you rebase

kelnos commented 2 years ago

The little test I wrote is ending up causing

thread 'file_filter_info::test::custom_filter' panicked at 'GTK may only be used from the main thread.', gtk/src/auto/file_filter.rs:24:9

Is there a way to make the tests run on the main thread? Alternatively I can just delete the test; mainly wrote it as a quick check that I wasn't doing anything weird with memory.

sdroege commented 2 years ago

Is there a way to make the tests run on the main thread? Alternatively I can just delete the test; mainly wrote it as a quick check that I wasn't doing anything weird with memory.

Check for the usage of crate::TEST_THREAD_WORKER in the gtk3 crate :)

kelnos commented 2 years ago

Thanks for the feedback and merge! Just wanted to say I really appreciated the process here, and your patience in helping me as I was learning how this should work! Would it be ok if I pushed a PR to backport this to the 0.15 branch as well?

sdroege commented 2 years ago

Would it be ok if I pushed a PR to backport this to the 0.15 branch as well?

Yes but please check at the same time if there are other things worth backporting too :) Thanks!

kelnos commented 2 years ago

Yes but please check at the same time if there are other things worth backporting too :) Thanks!

Yep, was planning to take care of adding everything i need to to master, and then doing a single backport PR for everything to 0.15.