After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 684558 - gtk_tree_model_rows_reordered is skipped by introspection
gtk_tree_model_rows_reordered is skipped by introspection
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
3.3.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2012-09-21 13:44 UTC by Benny Malengier
Modified: 2013-07-22 21:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add gtk_tree_model_rows_reordered_safe introspectable method (3.27 KB, patch)
2012-09-25 00:12 UTC, Simon Feltman
none Details | Review
Added "Since: 3.8" for the new API (3.29 KB, patch)
2012-09-30 00:45 UTC, Simon Feltman
none Details | Review
Add gtk_tree_model_rows_reordered_with_length (3.31 KB, patch)
2012-12-27 22:23 UTC, Simon Feltman
none Details | Review
Add gtk_tree_model_rows_reordered_with_length introspectable method (3.77 KB, patch)
2013-01-31 03:59 UTC, Simon Feltman
committed Details | Review
Add gtk_tree_model_rows_reordered_with_length introspectable method (3.00 KB, patch)
2013-07-22 21:42 UTC, Simon Feltman
committed Details | Review

Description Benny Malengier 2012-09-21 13:44:14 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?
Comment 1 Simon Feltman 2012-09-25 00:12:52 UTC
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.
Comment 2 Simon Feltman 2012-09-30 00:45:37 UTC
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.
Comment 3 Benny Malengier 2012-12-22 09:35:00 UTC
It is unclear to me if this is now part of GTK 3.8 
Can I use rows_reordered again in 3.8?
Comment 4 Simon Feltman 2012-12-22 10:17:23 UTC
(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.
Comment 5 Kristian Rietveld 2012-12-26 10:56:46 UTC
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...
Comment 6 Simon Feltman 2012-12-27 22:23:28 UTC
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.
Comment 7 Simon Feltman 2013-01-31 03:59:21 UTC
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 8 John Ralls 2013-07-15 17:57:40 UTC
Comment on attachment 234886 [details] [review]
Add gtk_tree_model_rows_reordered_with_length introspectable method

Just change the "Since" tag to 3.10.
Comment 9 Simon Feltman 2013-07-22 21:42:12 UTC
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
Comment 10 Simon Feltman 2013-07-22 21:42:18 UTC
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".