Re: GtkTreeView signal before row change



On Wed, Mar 9, 2011 at 12:38 AM, Lance Zhang <zhangp8 hotmail com> wrote:

Hi:

I have a situation where I need to verify data before allowing a row change in a GtkTreeView. Essentially:

1. User requests a row change through a keyboard or a mouse;
2. Check if data in the current row has been edited without be saved, or even is complete
and valid, and prompt the user appropriately;
3. Depending on user request, I may need to veto the row change request (aka cancel)

What's the best practice?

A possible way is use "cursor-changed" signal
1. always remember the current row (possibly by store a GtkTreeIter)
2. in the cursor-changed signal handler, check if on the same row and go back to original row by way of
stored GtkTreeIter if necessary.

Is there a better way? Tell me how you would approach this please.

If you need to store the current row, the safe way is to use
GtkTreeRowReference.

If you want to step in between when a user edits a cell and before it
gets committed
to the model... then you have code already in place where that can be done.

i.e. when you receive the "edited" signal from GtkCellRendererText, the model
does not update by itself, it's up to you to update the underlying
store (or not)
depending on the user input from the GtkCellRenderer.

Cheers,
          -Tristan



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