Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

FileChooser interface is not implementable #756

Open
kelnos opened this issue Jun 20, 2022 · 6 comments
Open

FileChooser interface is not implementable #756

kelnos opened this issue Jun 20, 2022 · 6 comments

Comments

@kelnos
Copy link
Contributor

kelnos commented Jun 20, 2022

I'm trying to build my own widget and have it implement the GtkFileChooser interface. To my ObjectSubclass impl, I've added:

type Interfaces = (gtk::FileChooser,);

However, I get the following error:

error[E0277]: the trait bound `gtk::FileChooser: IsImplementable<file_chooser_widget::imp::BetterFileChooserWidget>` is not satisfied
   --> widget/src/file_chooser_widget.rs:110:27
    |
110 |         type Interfaces = (gtk::FileChooser,);
    |                           ^^^^^^^^^^^^^^^^^^^ the trait `IsImplementable<file_chooser_widget::imp::BetterFileChooserWidget>` is not implemented for `gtk::FileChooser`
    |
    = note: required because of the requirements on the impl of `InterfaceList<file_chooser_widget::imp::BetterFileChooserWidget>` for `(gtk::FileChooser,)`
note: required by a bound in `gtk::subclass::prelude::ObjectSubclass::Interfaces`
   --> /home/brian/.cargo/registry/src/github.com-1ecc6299db9ec823/glib-0.15.11/src/subclass/types.rs:549:22
    |
549 |     type Interfaces: InterfaceList<Self>;
    |                      ^^^^^^^^^^^^^^^^^^^ required by this bound in `gtk::subclass::prelude::ObjectSubclass::Interfaces`

This seems to be correct; I don't see an IsImplementable implementation for FileChooser. There also isn't a FileChooserImpl trait to implement like I'd expect (though there is FileChooserExt, but my -- perhaps incorrect -- understanding is that is for consumers, not subclassers). Am I missing something here, or is this feature not implemented?

@sdroege
Copy link
Member

sdroege commented Jun 20, 2022

Support for implementing FileChooser is not implemented in the bindings yet. You'd have to implement IsImplementable for that in the bindings and also add a FileChooserImpl, etc., similar to the other interfaces.

@kelnos
Copy link
Contributor Author

kelnos commented Jun 20, 2022

Ah, I see! Ok, I'll take a crack at that. Thanks for the quick reply!

@kelnos kelnos changed the title [HELP] Can't seem to figure out how implement FileChooser in a subclass FileChooser interface is not implementable Jun 20, 2022
@bilelmoussaoui
Copy link
Member

There is an implementation in gtk4-rs, you can look at it for inspiration.

@kelnos
Copy link
Contributor Author

kelnos commented Jun 20, 2022

Hmm, gtk4-rs doesn't seem to have FileChooserImpl either, but it does have impls for interfaces, unlike gtk3-rs, so I'll take a look.

One thing I'm noticing that I don't quite understand is that some of the *Impl and *ImplExt traits use ObjectImpl as a trait bound, and others use ObjectSubclass. What is the reason for using one or the other?

@bilelmoussaoui
Copy link
Member

Hmm, gtk4-rs doesn't seem to have FileChooserImpl either, but it does have impls for interfaces, unlike gtk3-rs, so I'll take a look.

Ah yeah never mind, I was confused for a bit and thought of FontChooser.

One thing I'm noticing that I don't quite understand is that some of the *Impl and *ImplExt traits use ObjectImpl as a trait bound, and others use ObjectSubclass. What is the reason for using one or the other?

Impl is the trait you implement in your application, ImplExt provides a way for you to chain up to the parent implementation

The Impl trait is something the end user will be implementing and it does enforce the requirements while the ImplExt is implemented on the bindings side for each type T that implements the Impl trait, hence it is already indirectly enforcing the requirement that is defined for Impl trait.

@kelnos
Copy link
Contributor Author

kelnos commented Jun 20, 2022

Ok, I think I understand.

But I am now not sure this is doable. It looks like GtkFileChooserIface is defined in gtk/gtkfilechooserprivate.h. So the autogenerated bindings in the gtk-sys crate don't pick it up. Digging through their commit history, it looks like the interface refers to GtkFileSystem, which isn't public, so that's why they moved it into a private header. Bummer.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants