Re: Problem related to treeview



sumit kumar escribió:
 Hi all,
i have problem related to treeview.
I am showing list of member in window using treeview. Now I want to select
one out of this list and after selecting that member a window should be
created with that member name.How i can do that?
what API i should use to connect callback to the liststore enries?? I
storing member names using liststore.....

regards,
sumit
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

You can connect a callback funtion to the signal "row-activated" of a treeview (emited when you double click a row).
For example,

/* Creates a model */
GtkTreeModel * function create_model ();

/* Creates the treeview */
GtkWidget * function create_treeview ();

void row_activated_callback (GtkTreeView <http://developer.gnome.org/doc/API/2.0/gtk/GtkTreeView.html> *tree_view, GtkTreePath <http://developer.gnome.org/doc/API/2.0/gtk/GtkTreeModel.html#GtkTreePath> *path, GtkTreeViewColumn <http://developer.gnome.org/doc/API/2.0/gtk/GtkTreeViewColumn.html> *column, gpointer <http://developer.gnome.org/doc/API/2.0/glib/glib-Basic-Types.html#gpointer> user_data)
{
   GtkTreeIter iter;
   GtkTreeModel *model = gtk_tree_view_get_model (tree_view);
   GtkWidget *window;
   GtkWidget *label;
   gchar *membername;

   gtk_tree_model_get_iter (model, path, &iter);
   gtk_tree_model_get (model, &iter, MEMBER_NAME_COLUMN, &membername, -1);
label = gtk_label_new (membername);
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_container_add (GTK_CONTAINER (window), label);

   gtk_widget_show_all (window);
}

/* Assign a model to the treeview, connects the "row-activated" */
void bla ()
{
   GtkTreeModel *model = create_model ();
   GtkTreeView *treeview = create_treeview ();

   gtk_tree_view_set_model (treeview, model);
g_signal_connect (G_OBJECT (treeview), "row-activated", (GCallback) row_activated_callback, NULL);

   [...]
}




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