GNOME Bugzilla – Bug 780758
flowbox: bind_model passes wrong reference to create_widget_func in bindings
Last modified: 2017-09-27 11:42:52 UTC
Created attachment 349039 [details] gjs-flowbox.js While trying to bind a GListStore to a GtkFlowBox I am getting the following errors: for Gjs (gjs:15347): GLib-GObject-CRITICAL **: g_object_is_floating: assertion 'G_IS_OBJECT (object)' failed (gjs:15347): Gtk-CRITICAL **: gtk_widget_show: assertion 'GTK_IS_WIDGET (widget)' failed (gjs:15347): Gtk-CRITICAL **: gtk_flow_box_insert: assertion 'GTK_IS_WIDGET (widget)' failed (gjs:15347): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed for Python AttributeError: 'int' object has no attribute 'get_label' test.py:21: Warning: g_object_is_floating: assertion 'G_IS_OBJECT (object)' failed model.append (item1) (test.py:15457): Gtk-CRITICAL **: gtk_widget_show: assertion 'GTK_IS_WIDGET (widget)' failed (test.py:15457): Gtk-CRITICAL **: gtk_flow_box_insert: assertion 'GTK_IS_WIDGET (widget)' failed test.py:21: Warning: g_object_unref: assertion 'G_IS_OBJECT (object)' failed model.append (item1) Notice that the $item pointer passed to the GtkFlowBoxCreateWidgetFunc is an int in python (probably an address).
Created attachment 349040 [details] python-flowbox.py
Created attachment 349041 [details] gjs-listbox.js It works just fine with Gtk.ListBox using exactly the same code, just s/FlowBox/ListBox/g
Created attachment 349042 [details] flowbox.vala Curiously it works just fine with Vala.
This issue seems to be due to missing annotations on the callback type. Patch incoming.
Created attachment 360362 [details] [review] flowbox: Fix annotation for GListModel binding callback The GtkFlowBoxCreateWidgetFunc type lacked GObject Introspection annotations for its arguments. This made gtk_flow_box_bind_model() unusable from Python as the callback function would be passed useless values. The annotations that I've added match those of the similar callback type GtkListBoxCreateWidgetFunc.
Review of attachment 360362 [details] [review]: Thanks. It works for me now. I will let a gtk+ maintainer weight on it.
Attachment 360362 [details] pushed as c9df0c3 - flowbox: Fix annotation for GListModel binding callback