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



 --- Kristian Rietveld <kris gtk org> ha scritto: > 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).


I haven't already test your advice .. but I have some
doubts about the possibility it has to work. As I said
in my PS I tried to use a counter, that is very
similar to the boolean parameter. But if the first
really selected row is really row 0 the signal isn't
emitted.

Do you think your implementation will have a different
beaviour?


Thank you very very much!!!!
Rosa



______________________________________________________________________
Yahoo! Mail: 6MB di spazio gratuito, 30MB per i tuoi allegati, l'antivirus, il filtro Anti-spam
http://it.yahoo.com/mail_it/foot/?http://it.mail.yahoo.com/



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