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

Support for TreeModel/ListStore? #59

Open
piegamesde opened this issue Aug 25, 2020 · 5 comments
Open

Support for TreeModel/ListStore? #59

piegamesde opened this issue Aug 25, 2020 · 5 comments

Comments

@piegamesde
Copy link

I'd like to use a gtk::IconView but I somehow can't set the model. I tried inputting a dummy ListStore, Option::None and others but I always get a recursion limit reached error. Is this even supported or is it a bug in the macro?

@zzeroo
Copy link

zzeroo commented Aug 31, 2020

@piegamesde Did you notice the Tutorial? Please read the #getting-started paragraph at least.

... Whenever this happens, it tells you to add an attribute to your crate, that looks like #![recursion_limit = "some number"] ...

@piegamesde
Copy link
Author

I read the tutorial, but several weeks before actually trying it out myself. The error message makes more sense now:

error[E0277]: the trait bound `std::option::Option<gtk::auto::list_store::ListStore>: vgtk::properties::PropertyValueCompare<'_, std::option::Option<gtk::auto::tree_model::TreeModel>>` is not satisfied
  --> src/main.rs:28:9
   |
28 | /         gtk! {
29 | |             <Application::new_unwrap(Some("com.example.{{project-name}}"), ApplicationFlags::empty())>
30 | |                 <Window border_width=20 on destroy=|_| Message::Exit>
31 | |                     <IconView
...  |
34 | |             </Application>
35 | |         }
   | |_________^ the trait `vgtk::properties::PropertyValueCompare<'_, std::option::Option<gtk::auto::tree_model::TreeModel>>` is not implemented for `std::option::Option<gtk::auto::list_store::ListStore>`
   |
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `std::option::Option<gtk::auto::list_store::ListStore>: vgtk::properties::PropertyValueCompare<'_, std::option::Option<gtk::auto::tree_model::TreeModel>>` is not satisfied
  --> src/main.rs:32:13
   |
32 |                         model={Some(ListStore::new(&[]))} />
   |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `vgtk::properties::PropertyValueCompare<'_, std::option::Option<gtk::auto::tree_model::TreeModel>>` is not implemented for `std::option::Option<gtk::auto::list_store::ListStore>`
   |
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

@zzeroo
Copy link

zzeroo commented Sep 1, 2020

@piegamesde Could you create a very minimal example which shows what you are trying. A gist or a git repo would helpful. I know the gtk liststore/ treestores and I'm willing to help you here if I could.

@piegamesde
Copy link
Author

I sadly don't have the original code for my bug report anymore, but cloning the cargo-template-vgtk and changing the view function like below should give similar results:

    fn view(&self) -> VNode<Model> {
        gtk! {
            <Application::new_unwrap(Some("com.example.{{project-name}}"), ApplicationFlags::empty())>
                <Window border_width=20 on destroy=|_| Message::Exit>
                    <IconView
                        model={Some(ListStore::new(&[]))} />
                </Window>
            </Application>
        }
    }

In the end I want the icon view's content to be somehow synchronized with the internal state of the widget: when I add elements to it this should be reflected in the GUI, when I reorder them within the widget, this should trigger an update to the model

@nt8r
Copy link
Contributor

nt8r commented Mar 1, 2021

It looks like there's a functional workaround for this, using a TreeStore--the GTK docs suggest this works for an IconView.

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

3 participants