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 631548 - Gtk.TreeStore.append() is counter-intuitive
Gtk.TreeStore.append() is counter-intuitive
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: introspection
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
: 631764 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2010-10-06 18:30 UTC by Vincent Untz
Modified: 2010-10-11 14:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Make row optional in Gtk.TreeStore/ListStore.append override (2.34 KB, patch)
2010-10-07 07:43 UTC, Vincent Untz
committed Details | Review

Description Vincent Untz 2010-10-06 18:30:07 UTC
Here's the C API:

void                gtk_tree_store_append               (GtkTreeStore *tree_store,
                                                         GtkTreeIter *iter,
                                                         GtkTreeIter *parent);

It will append an iter to tree_store and set it in the iter variable. It does nothing else.

Now, GtkTreeStore.append() works another way (it's overridden):

model.append(parent, row)

where row is a tuple containing the values for each column.

A few things are wrong here:

 + it forces me to make sure that the row tuple will always have the values for the columns in the right order. Usually, I have no real interest in the order of my columns and I use variables like COLUMN_NAME = 0, COLUMN_ICON = 1, etc.

 + the C and the python API don't work the same way, and the user will assume they will since they have the same name. I think the python API provided here is useful, but it should come with another name.
Comment 1 johnp 2010-10-06 20:07:28 UTC
I thought I modelled this after the Python API:

http://library.gnome.org/devel/pygtk/stable/class-gtktreestore.html#method-gtktreestore--append
Comment 2 Vincent Untz 2010-10-07 07:41:19 UTC
The main difference is that you can skip row in pygtk, which gives you an API that looks like the C API. Should be trivial to do too, actually.
Comment 3 Vincent Untz 2010-10-07 07:43:29 UTC
Created attachment 171881 [details] [review]
Make row optional in Gtk.TreeStore/ListStore.append override
Comment 4 johnp 2010-10-07 15:56:00 UTC
Comment on attachment 171881 [details] [review]
Make row optional in Gtk.TreeStore/ListStore.append override

We might also want to add a the ability to do this:

model.append(None,{COLUMN_ICON: icon, COLUMN_NAME: name})

Not important if you don't but can you add a TODO: Accept a dictionary for row where the keys represent the column number and the values represent what to set the column to
Comment 5 johnp 2010-10-11 13:36:29 UTC
*** Bug 631764 has been marked as a duplicate of this bug. ***
Comment 6 Vincent Untz 2010-10-11 14:09:30 UTC
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.