forked from AuroraMiddleware/gtk
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
This commit is contained in:
parent
5c02002e2c
commit
938cc404c1
@ -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.
|
||||
|
@ -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, &iter))
|
||||
{
|
||||
gint row_count = 0;
|
||||
valid = gtk_tree_model_get_iter_first (model, &iter);
|
||||
|
||||
while (valid)
|
||||
{
|
||||
/* Walk through the list, reading each row */
|
||||
do
|
||||
{
|
||||
gchar *str_data;
|
||||
gint int_data;
|
||||
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, &iter,
|
||||
STRING_COLUMN, &str_data,
|
||||
INT_COLUMN, &int_data,
|
||||
-1);
|
||||
/* Make sure you terminate calls to gtk_tree_model_get(<!>)
|
||||
* with a '-1' value
|
||||
*/
|
||||
gtk_tree_model_get (list_store, &iter,
|
||||
STRING_COLUMN, &str_data,
|
||||
INT_COLUMN, &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);
|
||||
/* 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, &iter));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* As gtk_tree_model_get_iter_first(<!>) returned FALSE, the list is empty */
|
||||
g_print ("Model is empty.\n");
|
||||
row_count ++;
|
||||
valid = gtk_tree_model_iter_next (model, &iter))
|
||||
}
|
||||
}
|
||||
</programlisting>
|
||||
|
Loading…
Reference in New Issue
Block a user