Re: How to retrieve the data of the selected row in TreeView containing GtkListStore



On Sunday 23 November 2003 03:04, chenjun1 egr msu edu wrote:

Hi,

I'm trying to retrieve the data of the selected row in TreeView containing
GtkListStore.But not succeded. Is it possible to finish this
functionality? Is there something wrong with my code? or will you just
give a example having that functionality.
(snip)

      if(gtk_tree_selection_get_selected (selection, &model, &iter))
      {
              char *str;
              gtk_tree_model_get_value(model, &iter,
                             0, &str);
              g_print ("%s\n", str);
              g_free (str);
      }

You need to use a GValue with gtk_tree_model_get_value(). Most likely you're 
looking for something along the lines of:

if (gtk_tree_selection_get_selected(sel,&model,&iter))
{
   gchar *str;

   gtk_tree_model_get(model, &iter, 0, &str, -1);

   if (str)
  {
     ......
  }
}

Cheers
-Tim

PS: There's a GtkTreeView/C tutorial at http://scentric.net/tutorial/  - you 
might find some of the code examples useful 






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]