Re: Using Gio::ListStore with custom content type and Gtk::ListView (Gtkmm 4)
Jackson Campolattaro via gtkmm-list <[email protected]> Sun, 20 Feb 2022 23:02:36 +0100
| Newsgroups | gmane.comp.gnome.gtkmm |
|---|---|
| Message-ID | <CAK-p+x960=A_Hk2ZwQ2TgSAy6dyLNeFHu5X0iFnnoxNk73gijQ@mail.gmail.com> |
--===============1773536384924038671== Content-Type: multipart/alternative; boundary="000000000000b3515a05d87a4674" --000000000000b3515a05d87a4674 Content-Type: text/plain; charset="UTF-8" Hi again, From an earlier thread I found the columnview demo ( https://gitlab.gnome.org/GNOME/gtkmm/-/blob/master/demos/gtk-demo/example_listview_columnview.cc), which was exactly what I needed! In case anyone runs into the same problem as I did, my mistake was using `std::make_shared` to create new instances, when I should have been using `Glib::make_refptr_for_instance`. Have a good day, Jackson On Sun, Feb 20, 2022 at 6:36 PM Jackson Campolattaro <[email protected]> wrote: > Hello, > > I would like to use `Gtk::ListView` to display a custom type held in a > `Gio::ListStore`, but inside my `on_bind(list_item)` handler > `list_item->get_item()` returns a null RefPtr. I also get the same "Failed > to wrap" error seen [here]( > https://stackoverflow.com/questions/3233727/what-has-to-be-glibinited-in-order-to-use-glibwrap), > but adding `Glib::init()` at the start of my program didn't help. > > I haven't been able to get the ListStore working with any types, including > the example custom `Glib::Object` shown [here]( > https://github.com/GNOME/glibmm/blob/master/examples/properties/properties_example.cc) > and provided Object types like `Gtk::Box`. `Gtk::StringList` works fine, so > I suspect the problem lies in how I'm using the ListStore. > > Has anyone produced a known-working example of a `Gtk::ListView` which > displays custom objects? > > Kind regards, > > Jackson Campolattaro > > -- > Jackson Campolattaro > Masters Student at TU Delft > -- Jackson Campolattaro Masters Student at TU Delft --000000000000b3515a05d87a4674 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div>Hi again,</div><div><br></div><div>From an earlier th= read I found the columnview demo (<a href=3D"https://gitlab.gnome.org/GNOME= /gtkmm/-/blob/master/demos/gtk-demo/example_listview_columnview.cc">https:/= /gitlab.gnome.org/GNOME/gtkmm/-/blob/master/demos/gtk-demo/example_listview= _columnview.cc</a>), which was exactly what I needed! <br></div><div><br></= div><div>In case anyone runs into the same problem as I did, my mistake was= using `std::make_shared` to create new instances, when I should have been = using `Glib::make_refptr_for_instance`.</div><div><br></div><div>Have a goo= d day,</div><div><br></div><div>Jackson<br></div></div><br><div class=3D"gm= ail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Sun, Feb 20, 2022 at 6:= 36 PM Jackson Campolattaro <<a href=3D"mailto:[email protected]">jackcamp@= vt.edu</a>> wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"m= argin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left= :1ex"><div dir=3D"ltr"><div>Hello,</div><div><br></div><div>I would like to= use `Gtk::ListView` to display a custom type held in a `Gio::ListStore`, b= ut inside my `on_bind(list_item)` handler `list_item->get_item()` return= s a null RefPtr. I also get the same "Failed to wrap" error seen = [here](<a href=3D"https://stackoverflow.com/questions/3233727/what-has-to-b= e-glibinited-in-order-to-use-glibwrap" target=3D"_blank">https://stackoverf= low.com/questions/3233727/what-has-to-be-glibinited-in-order-to-use-glibwra= p</a>), but adding `Glib::init()` at the start of my program didn't hel= p. <br></div><div><br></div><div>I haven't been able to get the ListSto= re working with any types, including the example custom `Glib::Object` show= n [here](<a href=3D"https://github.com/GNOME/glibmm/blob/master/examples/pr= operties/properties_example.cc" target=3D"_blank">https://github.com/GNOME/= glibmm/blob/master/examples/properties/properties_example.cc</a>) and provi= ded Object types like `Gtk::Box`. `Gtk::StringList` works fine, so I suspec= t the problem lies in how I'm using the ListStore.</div><div><br></div>= <div>Has anyone produced a known-working example of a `Gtk::ListView` which= displays custom objects?</div><div><br></div><div>Kind regards,</div><div>= <br></div><div>Jackson Campolattaro<br></div><div><br>-- <br><div dir=3D"lt= r"><div dir=3D"ltr"><div><div dir=3D"ltr"><font size=3D"2">Jackson Campolat= taro</font></div><div><font size=3D"2"><font size=3D"1">Masters Student at = TU Delft</font><br></font></div></div></div></div></div></div> </blockquote></div><br clear=3D"all"><br>-- <br><div dir=3D"ltr" class=3D"g= mail_signature"><div dir=3D"ltr"><div><div dir=3D"ltr"><font size=3D"2">Jac= kson Campolattaro</font></div><div><font size=3D"2"><font size=3D"1">Master= s Student at TU Delft</font><br></font></div></div></div></div> --000000000000b3515a05d87a4674-- --===============1773536384924038671== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ gtkmm-list mailing list [email protected] https://mail.gnome.org/mailman/listinfo/gtkmm-list --===============1773536384924038671==--