Re: GtkTreeView data



Kris Marsh ha scritto lo scorso 14/04/2005 19:23:
Hi,

I'm trying to attach extra information to each row in a list, and then retrieve it later on from a row on a double click (row_activated) event.
Basically, i've tried:

g_object_set_data(G_OBJECT(&iter_child), "my_info", GUINT_TO_POINTER(some_info));


This is quite different, bat it should be esealy adapted to your case:

  cell = gtk_cell_renderer_toggle_new ();
                
  /* both model pointer and widget reference are sent
   * to item-toggled callback function, packed in a
   * ModelAndWidget (custom) structure
   */
  mw = (ModelAndWidget *)g_malloc (sizeof (ModelAndWidget));
  mw->model  = model;
  mw->widget = drGraph;
  g_signal_connect (cell,
                    "toggled",
                    G_CALLBACK (on_tvCurves_item_toggled),
                    mw);

  col  = gtk_tree_view_column_new_with_attributes ("Selection",
                                                   cell,
                                                   "active",
                                                   0,
                                                   "activatable",
                                                   2,
                                                   NULL);
  /* adding columns to TreeView
   */
  gtk_tree_view_append_column (GTK_TREE_VIEW (treev), col);


Information attached to toggles in a treeview are packed into a custom structure and retrievd when they are toggled.

HTH



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