Re: gtk_tree_foreach() and gtk_tree_find_item()



On Fri, 18 Feb 2000, Fritz Jetzek wrote:

> hi there,
> 
> i implemented the above mentioned functions and would like to hand them
> over to discussion; may be they could be part of gtk+ someday.. see
> details + example code at
> http://www.buggerz.com/index.proposals.gtk.html

please post patches like this to this list directly.
a few notes on the patch,
- _first_ update you list pointer, then invoke the callback,
  so you don't access invalid memory if the callback deletes
  the item currently traversed.
- call gtk_tree_forech() soemthing else, that name is already taken
  by gtk_container_foreach(). best bet is probably to model them after
  clist's pre_recursive() and post_recursive() functions.
- make the callback function return TRUE to continue traversal and
  FALSE to abort traversal, then gtk_tree_find_item() can be left to an
  appropriate callback function, and doesn't need to be implemented by
  gtk itself. e.g. use
  typedef gboolean (GtkTraverseFunc) (GtkWidget *widget,
                                      gpointer   data);
- honour the coding style of gtk, specifically:
  * put { braces after newlines
  * use a single line for each statement, so if (foo) return FALSE; becomes:
    if (foo)
      return FALSE;
  * don't use inline assignments, so if ((w = expr())) becomes:
    w = expr ();
    if (w)
    
> 
> best wishes,
> fritz jetzek
> 

---
ciaoTJ





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