Re: GtkTreeView selection- troubles in managing "changed" signal



On Tue, 2003-10-14 at 10:02, Rosa Mannini wrote:
I can't understand why for the real FIRST time I
select an item different from the first one (row 0 of
the list) the row 0 is selected automatically, and

When the GtkTreeView gets focus for the first time (for example when the
application window is showed up for the first time), it will check if
the cursor has been set. If not, it will set the cursor on row 0 by
default, and this is what's happening here.

The problem is that we can't change that behavior at this time. To get
around it you have two options:

- Set the cursor on row "0" yourself (using gtk_tree_view_set_cursor)
before connecting to the changed signal.
- Keep a boolean value "first_sel_changed", initially set to TRUE, and
make your ::changed signal handler look like this:

void selection_changed (GtkTreeSelection *sel, gpointer data)
{
  if (first_sel_changed)
    {
      first_sel_changed = FALSE;
      return;
    }

  /* else do stuff */
}

So the first changed signal will be ignored. (If you are using a struct
or object to keep your widgets together, it's of course a very good idea
to put this boolean there).



        -Kris


this event creates a lot of problems to me and to my
application. I would like to connect other signals,
but there aren't any that fit to me (or this is what
seems to me), or the others are deprecated (because
GtkTree and GtkList are deprecated widgets now).

Can you give me some advice and help????
Thanks!

Rosa


PS I have already tried to introduce a counter of
selection times (updated only when selected rows
number is not 0) but it doesn't work when I really
select row 0 as the first selected row of the list).




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