Re: GtkTreeIter validity.




 For those who care, I found a solution ( might be dirty, but easy. :)

  some_func()
  {
     gboolean valid;
 
     valid = gtk_tree_store_get_iter_first(iter);
      while(valid)
      {
         if(some_crtieria == TRUE)
           {
             gtk_list_store_remove(model, iter); 
               valid = ( iter.stamp != 0 ? TRUE : FALSE);  <====== this did it.
               continue;
            }
         
         valid = gtk_tree_model_iter_next(..., iter);
      }
  }


--- Harring Figueiredo <harringf yahoo com> wrote:

 Is there a way to check for an gtkTreeIter validity ?


  Here is what I am trying to do:

I would like to remove some rows from my GtkTreeStore.

  Using this code causes some rows to still stay on the GtkTreeView.
  some_func()
  {
     gtk_tree_store_for_each(model, foreach_callback, NULL);
  }


 gboolean  foreach_callback( *model, *iter, *path, gpoiter)
 {
    if(some criteria on the row == TRUE)
       gtk_list_store_remove(model, iter); 
 
     return FALSE; /* keep going */
 }
  
 The reason for this is that the gtk_list_store_remove causes the iter to
change, thus causing the gtk_tree_store_for_each to advance some rows without
being processed.

 I modified the code to do my own walking of the ListStore as follows:

 some_func()
 {
    gboolean valid;

    valid = gtk_tree_store_get_iter_first(iter);
     while(valid)
     {
        if(some_crtieria == TRUE)
            gtk_list_store_remove(model, iter); 
     
        valid = valid = gtk_tree_model_iter_next(..., iter);
     }
 }

 The problem still continues to exist since store_remove changes the iter for
the store.

 I noticed that in the new docs (2.1), gtk_list_store_remove(model, iter)
returns gboolean indicating if the iter is valid or not, but in 2.0.6, it
returns void.

  Any help on this dilema is appreciated.

  Thanks,

Harring

__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com



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