Le dim 13/06/2004 à 18:31, Ranieri a écrit : > How to qualify the selection of multiples itens in tree_view? GtkTreeSelection *selection = gtk_tree_view_get_selection (tree_view); gtk_tree_selection_set_mode (GTK_SELECTION_MULTIPLE); > How to catch which itens had been selected in the list of tree_view? GtkTreeModel *model; GList *l = gtk_tree_selection_get_selected_rows (selection, &model); For more details consult the doc (http://developer.gnome.org/doc/API/2.0/gtk/GtkTreeSelection.html). > > The source code is below. > > I am thankful who will be able to help me > Very Obliged > > #include <stdio.h> > #include <gtk/gtk.h> > > int main(int argc, char **argv) > { > int i; > > GtkWidget *main_window; > GtkWidget *fixed_mw; > GtkWidget *tree_view; > GtkWidget *scrolled_window; > GtkListStore *model; > GtkTreeIter iter; > GtkCellRenderer *cell; > GtkTreeViewColumn *column; > > gtk_init(&argc, &argv); > > main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); > gtk_window_set_title(GTK_WINDOW(main_window), "MyTitleMyTitleMyTitle"); > gtk_widget_set_usize(main_window, 650, 350); > g_signal_connect(G_OBJECT(main_window), "destroy", > G_CALLBACK(gtk_main_quit), NULL); > > fixed_mw = gtk_fixed_new(); > gtk_container_add(GTK_CONTAINER(main_window), fixed_mw); > > model = gtk_list_store_new(1, G_TYPE_STRING); > > tree_view = gtk_tree_view_new(); > gtk_tree_view_set_model(GTK_TREE_VIEW(tree_view), > GTK_TREE_MODEL(model)); > > scrolled_window = gtk_scrolled_window_new(NULL, NULL); > gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), > GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); > gtk_fixed_put(GTK_FIXED(fixed_mw), scrolled_window, 5, 50); > gtk_widget_set_usize(scrolled_window, 640, 300); > > gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), > GTK_WIDGET(tree_view)); > > for (i=0;i<20;i++) > { > gchar *msg = g_strdup_printf ("Item%d", i+1); > gtk_list_store_append(GTK_LIST_STORE(model), &iter); > gtk_list_store_set (GTK_LIST_STORE(model), &iter, 0, msg, -1); > g_free(msg); > } > > cell = gtk_cell_renderer_text_new(); > column = gtk_tree_view_column_new_with_attributes("Itens", cell, > "text", 0, NULL); > gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), > GTK_TREE_VIEW_COLUMN(column)); > > gtk_widget_show(scrolled_window); > gtk_widget_show(tree_view); > gtk_widget_show(fixed_mw); > gtk_widget_show(main_window); > > gtk_main(); > > return 0; > }
Attachment:
signature.asc
Description: Ceci est une partie de message =?ISO-8859-1?Q?num=E9riquement?= =?ISO-8859-1?Q?_sign=E9e?=