Thread: [Java-gnome-developer] Problems with TreeView
Brought to you by:
afcowie
From: Tiago C. <cog...@li...> - 2003-11-17 10:15:23
|
Apparently something got broken from 0.8 to 0.8.1 in what regards to the TreeView component. Considering the following defenitions: DataBlockInt dataIndex = new DataBlockInt(); DataBlockString dataName = new DataBlockString(); DataBlockBoolean dataExtract = new DataBlockBoolean(); ListStore list = new ListStore(new DataBlock[]{dataIndex, dataExtract, dataName}); While this still does not work properly (without showing a warning): // To get wheter or not the item is selected TreeIter i = list.getIter(String.valueOf(index)); return list.getValue(i, dataExtract); Now this does not work too: // Now to get the name of the item TreeIter iter = list.getIter(String.valueOf(index)); return list.getValue(iter, dataName); This used to work before, now i feel obligated to have a java copy of the names in a List as i already do for the boolean field (extract or not), getting these fields from the treeview generates the following error: (java-gnome:29591): GLib-GObject-WARNING **: gvalue.c:86: cannot initialize GValue with type `gchararray', the value has already been initialized as `gchararray' I am going to try to find out through the diffs what broke this and maybe we can get the bolean value to work too. Tiago Cogumbreiro |
From: Keywan N. T. <li...@pr...> - 2006-07-08 22:18:05
|
Hi, I have a application with groupchat window. I save the roster of the user, who are in the groupchat, in a TreeView. I use a ListStore with two columns (Pixbuf and String). I read the tutorial and create my ListStore/TreeView nearly exact as shown in the tutorial. Now I want to modify the rows in the TreeView. I wonder how I could get a specified row. I want to retrieve a row by searching for a String (Give me the row with the username "foo"). I looked into the JavaDocs, searched the examples and even the GTK Tutorial, but I didn't understand the C code. Did anyone have a code example? Did I missed a tutorial or method in the API? Should I use a TreeIter instead of a ListStore, even though I just want a simple list? Regards, Keywan -- Keywan Najafi Tonekaboni http://www.prometoys.net people@world:/# apt-get --purge remove dominion After unpacking world will be freed. You are about to do something potentially beneficial To continue type in the phrase 'Yes, do as We say!' |
From: Andrew C. <an...@op...> - 2006-07-09 11:19:28
|
On Sun, 2006-07-09 at 00:17 +0200, Keywan Najafi Tonekaboni wrote: > Hi, > > I have a application with groupchat window. I save the roster of the > user, who are in the groupchat, in a TreeView. I use a ListStore with > two columns (Pixbuf and String). > > I read the tutorial and create my ListStore/TreeView nearly exact as > shown in the tutorial. > > Now I want to modify the rows in the TreeView. I wonder how I could get > a specified row. You need to hunt down the row you want to modify, which means getting a TreeIter that points at it. How do you do that? Assuming you do not have a TreeRowReference kicking around that points at it, then what you need to do is iterate through the ListStore to find your row. TreeIter pointer = model.getFirstIter(); Then, as you loop through, you just call getValue() on a particular column and see if its the one you want, and if not, pointer = model.getNextIter(); An example of this is line 601 of http://research.operationaldynamics.com/source/darcsweb/?r=objective;a=headblob;f=/src/accounts/ui/TransactionListView.java#l595 Incidentally, this is half the reason one usually stores a DataColumnObject in the ListStore with a reference to the domain object we're modelling - easier to just test the result of getValue() == obj. If you're reacting to a selection event, you can get a TreePath from the Event and from there a TreeIter. If you're reacting to an activate, you can get a TreeIter right off of the Event... and from there quickly lift the domain object you're modelling and then carry on with business logic from there. AfC London -- Andrew Frederick Cowie Technology strategy, managing change, establishing procedures, and executing successful upgrades to mission critical business infrastructure. http://www.operationaldynamics.com/ Sydney New York Toronto London |
From: Keywan N. T. <li...@pr...> - 2006-07-10 07:16:39
|
Hi, Am Sonntag, den 09.07.2006, 12:19 +0100 schrieb Andrew Cowie: > Assuming you do not have a TreeRowReference kicking around that points > at it, then what you need to do is iterate through the ListStore to find > your row. Thanks. It works know. This was exactly what I need. > Incidentally, this is half the reason one usually stores a > DataColumnObject in the ListStore with a reference to the domain object > we're modelling - easier to just test the result of getValue() == obj. > When I understand you correctly I guess I have did this. > If you're reacting to a selection event, you can get a TreePath from the > Event and from there a TreeIter. If you're reacting to an activate, you > can get a TreeIter right off of the Event... and from there quickly lift > the domain object you're modelling and then carry on with business logic > from there. Unfortunately not. To react on a selection is covered by the tutorial[1]. Maybe I manage to improve it with your example at the and of the week. Do you think this would be a helpful part in the tutorial? Thanks a lot, Keywan [1] http://java-gnome.sourceforge.net/cgi-bin/bin/view/Main/TreeViewTutorial -- Keywan Najafi Tonekaboni http://www.prometoys.net people@world:/# apt-get --purge remove dominion After unpacking world will be freed. You are about to do something potentially beneficial To continue type in the phrase 'Yes, do as We say!' |
From: Tiago C. <cog...@li...> - 2003-11-17 10:18:08
|
On Seg, 2003-11-17 at 09:14, Tiago Cogumbreiro wrote: > Apparently something got broken from 0.8 to 0.8.1 in what regards to the > TreeView component. > Considering the following defenitions: > DataBlockInt dataIndex = new DataBlockInt(); > DataBlockString dataName = new DataBlockString(); > DataBlockBoolean dataExtract = new DataBlockBoolean(); > ListStore list = new ListStore(new DataBlock[]{dataIndex, dataExtract, > dataName}); > > While this still does not work properly (without showing a warning): > // To get wheter or not the item is selected > TreeIter i = list.getIter(String.valueOf(index)); > return list.getValue(i, dataExtract); > > Now this does not work too: > // Now to get the name of the item > TreeIter iter = list.getIter(String.valueOf(index)); > return list.getValue(iter, dataName); > > This used to work before, now i feel obligated to have a java copy of > the names in a List as i already do for the boolean field (extract or > not), getting these fields from the treeview generates the following > error: > > (java-gnome:29591): GLib-GObject-WARNING **: gvalue.c:86: cannot > initialize GValue with type `gchararray', the value has already been > initialized as `gchararray' > > I am going to try to find out through the diffs what broke this and > maybe we can get the bolean value to work too. > > Tiago Cogumbreiro As you might've guessed the problems are with ListStore and not with TreeView, sry ;) |