Re: Gtk2::SimpleList
- From: Daniel Kasak <dkasak nusconsulting com au>
- To: gtk-perl list <gtk-perl-list gnome org>
- Subject: Re: Gtk2::SimpleList
- Date: Mon, 31 May 2004 16:24:43 +1000
muppet wrote:
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?
Thanks for the explanation.
At least I know what I *can't* do ;)
As for where I'm going from here ... ummmmmmm ...
I really don't know which I want out of SimpleList, TreeView and ListStore.
What I'm doing is displaying data from a database table, and ( hopefully
) letting the user update stuff.
It looks like I'll have to leave the SimpleList in place for now, and
have a separate way of adding / editing data.
I'll have a play around with Gtk2::ListStore and see if I can make it work.
However, one part of muppet's post looks promising for me:
(it is rather easy to get SimpleList to use custom renderers, by
creating new column types.)
So does that mean I can do all the validation *and* database
synchronisation in custom cell renderers, and then just drop the
renderers into a SimpleList?
That sounds like the easiest way to go, as long as I'm not missing
something.
I will, however, have a look at TreeView / ListStore stuff. Maybe I
should learn that too?
Dan
--
Daniel Kasak
IT Developer
NUS Consulting Group
Level 5, 77 Pacific Highway
North Sydney, NSW, Australia 2060
T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989
email: dkasak nusconsulting com au
website: http://www.nusconsulting.com.au
Title: CanIt Vote for ID 49173
The following links have been placed here by the
NUS Consulting internal spam filter
and are for use by NUS Consulting staff only.
Please ingore these links.
Spam
Not spam
Forget previous vote
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]