<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Re-hallo,<br>
Ok, the case is now solved.<br>
<br>
I made the model too complicated. <br>
I need only to create gtk.ListStore() and that's it. There is no need
to go via model_sort.<br>
<br>
<strike> model_sort = gtk.TreeModelSort(model) </strike><br>
<strike> self.set_model(model_sort) <br>
</strike><br>
This works really well:<br>
<br>
model = gtk.ListStore(gobject.TYPE_STRING, # Filename<br>
gtk.gdk.Pixbuf, # Icon image<br>
gobject.TYPE_FLOAT, # File date<br>
gobject.TYPE_INT) # File size<br>
<br>
self.set_tooltip_column(COL_THUMB_FILENAME)<br>
self.set_text_column(COL_THUMB_FILENAME)<br>
self.set_pixbuf_column(COL_THUMB_PIXBUF)<br>
<br>
self.set_model(model)<br>
<br>
# Make iconview sortable<br>
<br>
# Compare function is not actually needed. The default
(internal cmp) function is good enough.<br>
# model.set_sort_func(COL_THUMB_FILENAME,
self.default_sort_compare_func)<br>
# model.set_sort_func(COL_THUMB_FILESIZE,
self.default_sort_compare_func)<br>
# model.set_sort_func(COL_THUMB_FILEDATE,
self.default_sort_compare_func)<br>
<br>
# Set default sort order<br>
model.set_sort_column_id(COL_THUMB_FILESIZE, gtk.SORT_ASCENDING)<br>
----<br>
Here is a fully functional test code:
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<a href="http://www.futuredesktop.com/tmp/Test6-good.tar.gz">http://www.futuredesktop.com/tmp/Test6-good.tar.gz</a><br>
It rocks!<br>
<br>
Thanks,<br>
Osmo (Moma) Antero M<br>
Grønland, Norway<br>
<br>
<br>
Osmo Maatta wrote:
<blockquote cite="mid:4B854AA7.7080905@gmail.com" type="cite">Hello,<br>
<br>
I have a small application that shows thumbnail-images in a
gtk.IconView widget. <br>
The thumbnails are sortable on filename, file size and date. The
sorting seems to work fine.<br>
<br>
But the program crashes when I try to reload the thumbnails.<br>
<br>
Here is a picture of the application. <br>
<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="http://bildr.no/view/595635">http://bildr.no/view/595635</a><br>
When I press the [Reload thumbnails] button 2'nd time, the program
crashes with "Segmentation fault". <br>
No other error messages appear.<br>
<br>
The crash happens at self.clear_display() function. It simply finds the
model/ListStore and clears it.<br>
<br>
model_sort = self.get_model()<br>
model = model_sort.get_model()<br>
model.clear()<br>
<br>
Can you help me to spot the error.<br>
<br>
The first version was un-sortable and it worked very well. But I really
want to make it sortable.<br>
Here is a test-code:
<meta http-equiv="content-type" content="text/html; ">
<a moz-do-not-send="true"
href="http://www.futuredesktop.com/tmp/Test6.zip">http://www.futuredesktop.com/tmp/Test6.zip</a><br>
My system is Ubuntu Linux 9.10, 64bit.<br>
-----<br>
Most kindly<br>
Moma Antero<br>
</blockquote>
<br>
</body>
</html>