Using Gio::ListStore with custom content type and Gtk::ListView (Gtkmm 4)

Jackson Campolattaro via gtkmm-list <[email protected]> Sun, 20 Feb 2022 18:36:06 +0100
Newsgroups gmane.comp.gnome.gtkmm
Message-ID <CAK-p+x8mriffoXMRE+F9ghwTNLB372MH2wSDsV2bA45Ex5DJCQ@mail.gmail.com>
--===============0397575712112155373==
Content-Type: multipart/alternative; boundary="0000000000009d7f4605d8768d45"

--0000000000009d7f4605d8768d45
Content-Type: text/plain; charset="UTF-8"

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

--0000000000009d7f4605d8768d45
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<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`, but ins=
ide my `on_bind(list_item)` handler `list_item-&gt;get_item()` returns a nu=
ll RefPtr. I also get the same &quot;Failed to wrap&quot; error seen [here]=
(<a href=3D"https://stackoverflow.com/questions/3233727/what-has-to-be-glib=
inited-in-order-to-use-glibwrap">https://stackoverflow.com/questions/323372=
7/what-has-to-be-glibinited-in-order-to-use-glibwrap</a>), but adding `Glib=
::init()` at the start of my program didn&#39;t help. <br></div><div><br></=
div><div>I haven&#39;t been able to get the ListStore working with any type=
s, including the example custom `Glib::Object` shown [here](<a href=3D"http=
s://github.com/GNOME/glibmm/blob/master/examples/properties/properties_exam=
ple.cc">https://github.com/GNOME/glibmm/blob/master/examples/properties/pro=
perties_example.cc</a>) and provided Object types like `Gtk::Box`. `Gtk::St=
ringList` works fine, so I suspect the problem lies in how I&#39;m using th=
e ListStore.</div><div><br></div><div>Has anyone produced a known-working e=
xample of a `Gtk::ListView` which displays custom objects?</div><div><br></=
div><div>Kind regards,</div><div><br></div><div>Jackson Campolattaro<br></d=
iv><div><br>-- <br><div dir=3D"ltr" class=3D"gmail_signature" data-smartmai=
l=3D"gmail_signature"><div dir=3D"ltr"><div><div dir=3D"ltr"><font size=3D"=
2">Jackson Campolattaro</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>

--0000000000009d7f4605d8768d45--

--===============0397575712112155373==
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

--===============0397575712112155373==--