Ticket #1114 (closed defect: fixed)

Opened 10 years ago

Last modified 9 years ago

Graphics.UI.Gtk.ModelView.entryCompletionSetMatchFunc results in cellLayoutSetAttributeFunc error

Reported by: guest Owned by: somebody
Priority: normal Milestone: 0.9.14
Component: general (Gtk+, Glib) Version: 0.9.12
Keywords: Cc: smithp@…


Attempting to set a match function on an EntryCompletion? results in the following error when a key is pressed in the field:

Test: cellLayoutSetAttributeFunc: attempt to set attributes of CellRenderer? from different model.

See attached file for example.


Test.hs (1.1 kB) - added by guest 10 years ago.

Change History

Changed 10 years ago by guest

Changed 9 years ago by axel

  • status changed from new to closed
  • resolution set to wontfix

From my point of view, this is a bug in Gtk+. I've reported the issue (and a patch) as Bug no 551202. What happens is that the widget internally takes the passed-in model and wraps it in a TreeModelFilter?. The widget simply calls the setter function with this internal widget. Gtk2Hs does a sanity check that the model with which you installed you CellRenderer? and the one that Gtk+ returns is the same, which is good since you couldn't run the Haskell extractor functions in a TreeModelFilter? model of Gtk.

So no real fix for Gtk2Hs, but hopefully it will be fixed in Gtk+.

Changed 9 years ago by axel

  • status changed from closed to reopened
  • resolution wontfix deleted
  • milestone set to 0.9.14

I have changed my mind about this.

Although it is a bug in Gtk+ that it passes an iterator to an internal model to the function set by cellLayoutSetAttributeFunc, implemented a workaround that simply checks if the model in the call back (that is not visible to the user function) is a TreeModelFilter? or a TreeModelSort? and convert the iterator to the encapsulated model until the user model is reached. This is an ugly hack, but I think there are several widgets in Gtk that are unclean with respect to this. In fact, most implementations of the CellLayout? interface seem to be copy and paste jobs. So this hack should fix your problem and hopefully several problems in other widgets.

There are, however, some callbacks that pass a TreeIter? and TreeModel? to the callback function (one example is the 'matchSelected' signal in EntryCompletion?). In this case the user has to create a column and use the 'treeModelGetValue' function that I have just resurrected. I could use the same hacky function to convert the iterator to the user model, but that I would have to implement for each such signal which means that I'll probably miss the odd one.

Changed 9 years ago by axel

  • status changed from reopened to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.