GNOME Bugzilla – Bug 684558
gtk_tree_model_rows_reordered is skipped by introspection
Last modified: 2013-07-22 21:42:18 UTC
The treemodel function rows_reordered http://developer.gnome.org/gtk3/stable/GtkTreeModel.html#GtkTreeModel-rows-reordered is not available in python. Is there a workaround? Specific problem: A sorted custom treeview, where user has opened and collapsed some inner nodes. User now clicks column to invert sort direction. Without rows_reordered, one is forced to disconnect the treemodel, and reconnect after the sort. After reconnect, the nodes are however no longer collapsed and opened as before, so user sees a different situation. Suggestion: provide C function that has no variable int array as input? Is there another workaround possible?
Created attachment 225112 [details] [review] Add gtk_tree_model_rows_reordered_safe introspectable method The gtk_tree_model_rows_reordered method specifies (skip) in its annotation. This original method does not take an array length argument, so passing an array lesser than the number of children will crash. To expose this safely through introspection, the new method requires a length argument bound as the size of the array. The new method then uses the "Rename to:" annotation to expose it as "gtk_tree_model_rows_reordered". If there is precedence for another technique or naming convention for this kind of thing, please mention it.
Created attachment 225404 [details] [review] Added "Since: 3.8" for the new API Same patch but additionally adds "Since: 3.8" to the new methods annotation.
It is unclear to me if this is now part of GTK 3.8 Can I use rows_reordered again in 3.8?
(In reply to comment #3) > It is unclear to me if this is now part of GTK 3.8 > Can I use rows_reordered again in 3.8? Not until a gtk+ dev approves and applies the attached patch.
The C API has never included a length argument, because the length must equal the number of nodes in the level for which the signal is to be emitted. Now, in theory, language bindings could do the _iter_n_children() call and check the array length, but this would complicate the language binding and go against the idea of introspection. So, I agree that the additional function is necessary. On the patch: - I personally don't like the _safe suffix and would probably pick something like "_with_length" as suffix. But please check with the introspection people to see if they have guidelines. - It is great that you already included the check with gtk_tree_model_iter_n_children. You could make the check even stronger and demand that the length must equal, instead of greater equal. But leaving greater equal is fine too (the non-with-length version of the code would not complain either if you put in a larger array). - Style nitpick: you need a space after gtk_tree_model_iter_n_children and before the (. I would be fine with a patch like this going in, though please check with the introspection people if they have any function naming or function signature guidelines. I haven't followed GTK+ development for the last 8 months...
Created attachment 232308 [details] [review] Add gtk_tree_model_rows_reordered_with_length Kristian, Thanks for reviewing this. New patch includes the following updates: * Renamed to gtk_tree_model_rows_reordered_with_length I asked in #introspection but didn't get any responses. The _with_length suffix seems much better and matches the rest of glib/gtk at least in regards to constructor naming conventions. Note that this new method will be exposed using the "Rename to" annotation as simply "rows_reordered". The original method is skipped due to its problems and pygobject implicitly fills in the length param for us. * Also fixed style nitpick and length check.
Created attachment 234886 [details] [review] Add gtk_tree_model_rows_reordered_with_length introspectable method Added gtk_tree_model_rows_reordered_with_length to gtk/gtk.symbols
Comment on attachment 234886 [details] [review] Add gtk_tree_model_rows_reordered_with_length introspectable method Just change the "Since" tag to 3.10.
Commited with Since: 3.10 and GDK_AVAILABLE_IN_3_10 The following fix has been pushed: ab13787 Add gtk_tree_model_rows_reordered_with_length introspectable method
Created attachment 249843 [details] [review] Add gtk_tree_model_rows_reordered_with_length introspectable method Add introspection friendly version of gtk_tree_model_rows_reordered with a "_with_length" suffix. This allows language bindings to safely pass an array with length argument. Use the "Rename to:" annotation to expose as "gtk_tree_model_rows_reordered".