[gtk+] docs: Improve GtkTreeModel iteration pattern
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] docs: Improve GtkTreeModel iteration pattern
- Date: Thu, 22 Nov 2012 21:37:29 +0000 (UTC)
commit c627b221264ff93f5bb4e172fb875a57ec7e5959
Author: David King <amigadave amigadave com>
Date: Thu Nov 22 17:38:41 2012 +0000
docs: Improve GtkTreeModel iteration pattern
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 | 11 +++++------
1 files changed, 5 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtktreemodel.c b/gtk/gtktreemodel.c
index a2abead..31d8843 100644
--- a/gtk/gtktreemodel.c
+++ b/gtk/gtktreemodel.c
@@ -168,12 +168,12 @@
* /* Fill the list store with data */
* populate_model (list_store);
*
- * /* Get the first iter in the list */
- * valid = gtk_tree_model_get_iter_first (list_store, &iter);
- *
- * while (valid)
+ * /* Get the first iter in the list, check it is valid and walk
+ * * through the list, reading each row. */
+ * for (valid = gtk_tree_model_get_iter_first (list_store, &iter);
+ * valid;
+ * valid = gtk_tree_model_iter_next (list_store, &iter))
* {
- * /* Walk through the list, reading each row */
* gchar *str_data;
* gint int_data;
*
@@ -190,7 +190,6 @@
* g_free (str_data);
*
* row_count++;
- * valid = gtk_tree_model_iter_next (list_store, &iter);
* }
* </programlisting>
* </example>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]