Re: Gtk2::SimpleList




On Sunday, May 30, 2004, at 08:38 PM, Daniel Kasak wrote:

Right. I'm just getting to the point where I want to use TreeViews with editable data.
How do I know which row has been edited?
I can call a sub when a row_changed signal is fired, but the sub only received 2 things: the simplelist that triggered the signal, and a Gtk2::Gdk::Event::Button ( whatever that is ). Am I supposed to do something with these to figure out which row has changed?

no, it's a little more involved than that.

the row doesn't get edited; a cell gets edited. to enable cell editing, you tell the cell renderer to allow editing. the cell renderer fires a virtual function (not a signal) to start an editing operation, and that's all that the base class does. CellRendererText creates a new editable and lets the user change the value in the editable, and fires a signal ("edited") when the editing operation is complete (e.g., the editable is destroyed). this signal gets the path to the edited row, the new text, and the model; you already know which column you're in, because of which cell renderer is being used.

note that this process does *not* automatically apply the new value! SimpleList attaches an "edited" handler to all "text" columns' cell renderers, and that handler applies the new data to the model (see text_cell_edited() in SimpleList.pm).

SimpleList's editable cell support is designed for cases in which you set up the list when you create a dialog, let the user edit it, and then pull all the data out when the user closes the dialog; thus, what you're wanting do to requires more magic^Wdirect usage of the TreeView.

if you want to trigger something after the value has been set, or if you want validate that data and possibly inhibit applying, then you to do fancy stuff with those signals (in which case simplelist may be getting in your way). if you want to do validation *while* the user edits, you need a custom cell renderer in which you can do your own editing. (it is rather easy to get SimpleList to use custom renderers, by creating new column types.)


Remember -- SimpleList is designed for Simple applications. You appear to be leaving SimpleLand at full speed. Are you sure you still want to use SimpleList or just use TreeView and ListStore directly?


--
I bring the rock, and provided it is fiscally responsible, I will bring the funk as well. And that's fo-shizzle.
        -- Saturday Night Live




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