[gtk-server] Re: Automatic numerical sorting in ListStores

  • From: Peter van Eerten <administrator@xxxxxxxxxxxxxx>
  • To: gtk-server@xxxxxxxxxxxxx
  • Date: Tue, 02 Sep 2008 17:14:43 +0200

Hi Erik,

Yes, you have to keep in mind that every function you use must be carefully defined in advance. By default, the GTK-server defines 'gtk_list_store_set' as follows:

FUNCTION_NAME = gtk_list_store_set, NONE, NONE, 5, WIDGET, WIDGET, INT, STRING, INT


Now, if you want to set an INTEGER value in your list, first redefine this function as follows:

gtk_server_redefine (gtk_list_store_set NONE NONE 5 WIDGET WIDGET INT INT INT)


Now set the value into your list, for example:

gtk_list_store_set(List_Store, List_Iter, 0, 23, -1)


So this will set value '23' into column 0. It also will be shown as: 23. If you want to set a string again, redefine the function again.

Hope this helps,
Peter

Quoting Erik Winkels <euqirea@xxxxxxxxx>:

Hi Peter,

First of all, thanks for your reply.

Secondly, thanks for writing gtk-server.  It's a really good tool to use
GTK from.  (I'm using it with CLISP.)

Date: Mon, 01 Sep 2008 15:21:47 +0200
From: Peter van Eerten <administrator@xxxxxxxxxxxxxx>
Subject: [gtk-server] Re: Glade & comboboxes

[...]
Please let me know if this works for you,

I eventually went with just creating the whole GUI from code since I wasn't
able to add a combobox created from code in the Glade created UI.

I have got another question now which I haven't been able to solve with
Googling or checking the examples on gtk-server.org:

I've made a list-store with three columns.  The first column contains a name,
the second and the third some kind of numerical id.  I've turned on sorting
for each column with gtk_tree_view_column_set_sort_column_id.

If I create the list-store like this:

    gtk_list_store_new 3 G_TYPE_STRING G_TYPE_STRING G_TYPE_STRING

Everything works alright except the second and third columns are sorted as
strings while they ought to be sorted numerically, so I thought creating the
list-store like this would solve it:

    gtk_list_store_new 3 G_TYPE_STRING G_TYPE_LONG G_TYPE_LONG

But it doesn't (I also tried G_TYPE_INT and G_TYPE_FLOAT).  Worse yet,
the second and third columns don't even display the correct values anymore.
(Actually they now display what look like widget ids).

Have you got any idea how to turn on numerical sorting for specific columns?


Regards,
Erik



--
http://www.gtk-server.org


Other related posts: