]> Pileus Git - ~andy/gtk/commitdiff
docs: Improve GtkTreeModel iteration pattern
authorDavid King <amigadave@amigadave.com>
Thu, 22 Nov 2012 17:38:41 +0000 (17:38 +0000)
committerDavid King <amigadave@amigadave.com>
Thu, 22 Nov 2012 21:36:46 +0000 (21:36 +0000)
Iterating over the model in this way means that use of continue is less
error-prone, as the increment is part of the loop construct.

https://bugzilla.gnome.org/show_bug.cgi?id=548793

gtk/gtktreemodel.c

index a2abeaddcc538b9915e6f0eaa7058458bb515fa4..31d8843509121af396e3b33d9e2efe8dfa6efbce 100644 (file)
  * /&ast; Fill the list store with data &ast;/
  * populate_model (list_store);
  *
- * /&ast; Get the first iter in the list &ast;/
- * valid = gtk_tree_model_get_iter_first (list_store, &amp;iter);
- *
- * while (valid)
+ * /&ast; Get the first iter in the list, check it is valid and walk
+ *  &ast; through the list, reading each row. &ast;/
+ * for (valid = gtk_tree_model_get_iter_first (list_store, &amp;iter);
+ *      valid;
+ *      valid = gtk_tree_model_iter_next (list_store, &amp;iter))
  *  {
- *    /&ast; Walk through the list, reading each row &ast;/
  *    gchar *str_data;
  *    gint   int_data;
  *
  *    g_free (str_data);
  *
  *    row_count++;
- *    valid = gtk_tree_model_iter_next (list_store, &amp;iter);
  *  }
  * </programlisting>
  * </example>