gtk-rs/gtk

gtk::PopoverMenu::popup doesn't work for PopoverMenu

qarmin opened this issue · 4 comments

I tried to use PopoverMenu with same functions like in this video - https://www.youtube.com/watch?v=6hE62eXNKU4
But this code(which seems to work )

let popover_select = gtk::PopoverMenu::new();
popover_select.popup();

this error

error[E0599]: no method named `popup` found for struct `gtk::PopoverMenu` in the current scope
   --> czkawka_gui/src/main.rs:604:40
    |
604 |                         popover_select.popup();
    |                                        ^^^^^ method not found in `gtk::PopoverMenu`
    | 
   ::: /home/rafal/.cargo/registry/src/github.com-1ecc6299db9ec823/glib-0.10.2/src/object.rs:727:9
    |
727 |         pub struct $name($crate::object::ObjectRef, ::std::marker::PhantomData<$ffi_name>);
    |         -----------------------------------------------------------------------------------
    |         |
    |         doesn't satisfy `gtk::PopoverMenu: glib::IsA<gtk::ComboBox>`
    |         doesn't satisfy `gtk::PopoverMenu: glib::IsA<gtk::Menu>`
    |         doesn't satisfy `gtk::PopoverMenu: gtk::ComboBoxExt`
    |         doesn't satisfy `gtk::PopoverMenu: gtk::prelude::GtkMenuExtManual`
    |
    = note: the method `popup` exists but the following trait bounds were not satisfied:
            `gtk::PopoverMenu: glib::IsA<gtk::Menu>`
            which is required by `gtk::PopoverMenu: gtk::prelude::GtkMenuExtManual`
            `gtk::PopoverMenu: glib::IsA<gtk::ComboBox>`
            which is required by `gtk::PopoverMenu: gtk::ComboBoxExt`

Here what I suggest: please open a PR with your code (targetting the pending branch if you're using the github version) so I can take a look. So I can help you and in addition, once done, we can merge it so there will be an example for this case.

Do you enable the v3_22 feature on your gtk dependency in Cargo.toml?

https://gtk-rs.org/docs/gtk/trait.PopoverExt.html#tymethod.popup exists in any case (if you enable that feature), and should be usable. If it isn't, please provide a full testcase like @GuillaumeGomez wrote :)

I completely forgot about enabling gtk v3_24 in my project(I had v3_18).
I had installed on Ubuntu 20.04 gtk 3.24 so I wrongly assumed that everything should works fine.