]> Pileus Git - ~andy/gtk/commitdiff
new FAQ.
authorJonathan Blandford <jrb@redhat.com>
Tue, 12 Mar 2002 05:36:12 +0000 (05:36 +0000)
committerJonathan Blandford <jrb@src.gnome.org>
Tue, 12 Mar 2002 05:36:12 +0000 (05:36 +0000)
Tue Mar 12 00:29:31 2002  Jonathan Blandford  <jrb@redhat.com>

* gtk/question_index.sgml: new FAQ.

* gtk/tmpl/gtktreemodel.sgml: clean up example

docs/reference/ChangeLog
docs/reference/gtk/question_index.sgml
docs/reference/gtk/tmpl/gtktreemodel.sgml

index d0117afe7fb2797a0909821483c25595510eee04..45e2739508d746958a41ea8c678c3c78883f59e7 100644 (file)
@@ -1,3 +1,9 @@
+Tue Mar 12 00:29:31 2002  Jonathan Blandford  <jrb@redhat.com>
+
+       * gtk/question_index.sgml: new FAQ.
+
+       * gtk/tmpl/gtktreemodel.sgml: clean up example
+
 2002-03-12  Matthias Clasen  <maclas@gmx.de>
 
        * gdk/tmpl/windows.sgml: Document GdkScreen.
index 871e8e179cd21dda842a1c080689f5f6a5efec2c..599e38aca0ad6bffc32e24174b9498599e7d9fb5 100644 (file)
@@ -483,6 +483,21 @@ See the <link linkend="TreeWidget">tree widget overview</link>.
 </answer>
 </qandaentry>
 
+<qandaentry>
+<question><para>
+What's the #GtkTreeView equivalent of gtk_clist_find_row_from_data()?
+</para></question>
+
+<answer>
+<para>
+As there is no separate data column in the #GtkTreeModel, there's no
+built in function to find the iter from data.  You can write a custom
+searching function to walk the tree and find the data, or use
+gtk_tree_model_foreach().
+</para>
+</answer>
+</qandaentry>
+
 <qandaentry>
 <question><para>
 How do I put an image and some text in the same column?
index bd3072d38cf6e47b73fc1a32623d34b99dc28716..9c60f905f5f68976f83dfa30dff7772b04cf228d 100644 (file)
@@ -150,6 +150,8 @@ enum
 {
   GtkTreeModel *list_store;
   GtkTreeIter iter;
+  gboolean valid;
+  gint row_count = 0;
 
   /* make a new list_store */
   list_store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_INT);
@@ -158,36 +160,28 @@ enum
   populate_model (list_store);
 
   /* Get the first iter in the list */
-  if (gtk_tree_model_get_iter_first (model, &amp;iter))
-    {
-      gint row_count = 0;
+  valid = gtk_tree_model_get_iter_first (model, &amp;iter);
 
-      /* Walk through the list, reading each row */
-      do
-        {
-          gchar *str_data;
-          gint   int_data;
-
-          /* Make sure you terminate calls to gtk_tree_model_get(<!>)
-           * with a '-1' value
-           */
-          gtk_tree_model_get (list_store, &amp;iter, 
-                              STRING_COLUMN, &amp;str_data,
-                              INT_COLUMN, &amp;int_data,
-                              -1);
-
-          /* Do something with the data */
-          g_print ("Row &percent;d: (&percent;s,&percent;d)\n", row_count, str_data, int_data);
-          g_free (str_data);
-
-          row_count ++;
-        }
-      while (gtk_tree_model_iter_next (model, &amp;iter));
-    }
-  else
+  while (valid)
     {
-      /* As gtk_tree_model_get_iter_first(<!>) returned FALSE, the list is empty */
-      g_print ("Model is empty.\n");
+      /* Walk through the list, reading each row */
+      gchar *str_data;
+      gint   int_data;
+
+      /* Make sure you terminate calls to gtk_tree_model_get(<!>)
+       * with a '-1' value
+       */
+      gtk_tree_model_get (list_store, &amp;iter, 
+                          STRING_COLUMN, &amp;str_data,
+                          INT_COLUMN, &amp;int_data,
+                          -1);
+
+      /* Do something with the data */
+      g_print ("Row &percent;d: (&percent;s,&percent;d)\n", row_count, str_data, int_data);
+      g_free (str_data);
+
+      row_count ++;
+      valid = gtk_tree_model_iter_next (model, &amp;iter))
     }
 }
 </programlisting>