Commit 938cc404 authored by Jonathan Blandford's avatar Jonathan Blandford Committed by Jonathan Blandford

new FAQ.


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
parent 5c02002e
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.
......
......@@ -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?
......
......@@ -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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment