[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Associating with an entry in a GtkListStore



On Thu, 2004-01-29 at 20:25, Chris Seaton wrote:
> I'm using a GtkListStore with a GtkTreeView to show a simple list of 
> items. Each item has a text name and binary data. The list just needs to 
> show the name - the binary data is stored elsewhere in memory and is 
> used when the user selects commands from a menu (I'm making things 
> simplier than they are here, but the principle is the same).
> 
> The problem is: how do I associate the entry in the list store with my 
> binary data? There is no user field for the list store items like with 
> the signal handler functions, and there could be more than one item with 
> exactly the same name but different binary data so I can't use a hash 
> table or something.
> 
> I would use the index of the item (from the itterator), but I'm not sure 
> to do that, and anyway the indicies would change when the list is sorted 
> by clicking on column headers.

Just by chance I've been trying to do this as well.  I wanted to store a
G_OBJECT in the GtkListStore, and display some info contained within the
object in the GtkTreeView.

I ended up writing a test program that uses the solution Harring
Figueiredo suggested in a previous email.  I've packaged the code up and
put it on the web if you want to take a look:

  http://www.employees.org/~kmsharp/software/example.tar.gz

Note that this is proof of concept code, and as such has no comments and
probably isn't the optimal solution, but it does illustrate the point.

Keith.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]