GtkTreeView -> moving the cursor when a row is deleted



Hello,

I am now converting my app from using a GtkCList to a GtkTreeView.
Wow, much more powerful, but much more complicated.  I guess there's
no free lunch.

Anyway, I have got my TreeView doing almost everything I want it to do
with one exception.  At some point, I delete a row from the ListStore
behind the TreeView.

Everything works fine with that except when the row being deleted is
the row that the cursor is on.  If that happens, the cursor appears to
go away.  What is actually happening is that the cursor goes to the
first item in the list but does not highlight it.  If I use the down
arrow key, the second item is highlighted.

First question: is there an easy way to tell the TreeView that if the
item the cursor is on is deleted, then move the cursor to the item
before (or after)?

If there is not, I have hacked something up that _almost_ does what I
want.  I hooked a callback to the row-deleted signal of the ListStore,
and my callback gets successfully called before the row is deleted
from the ListStore, which is all fine and good.  I can also
successfully move the cursor to the next item with:

  gtk_tree_view_get_cursor(tree_view, &path, NULL);
  /* how to determine if path is the row being deleted? */
  gtk_tree_path_next(path);
  gtk_tree_view_set_cursor(tree_view, path, NULL, FALSE);

in my row_deleted callback, but I really only want to do this when the
row being deleted is the row in path after the call to
gtk_tree_view_get_cursor().  But how do I determine this?

Or am I going about this all wrong?

Thanx,
b.

-- 
Brian J. Murrell

Attachment: pgpg4nRNykx76.pgp
Description: PGP signature



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