gtk print the selected value from list
hi every one i need a help i am developing an interface using gtk i am completely new to gtk. in my program i have a list with two columns. and a button.list is filled with some value i want that when i select a value from list and press button it value will print on screen.
up till now my list get filled and button is also working but when i select the value it id not stored in variable i guess and is not printed kindly help me here is the code of my event handler
static void show_graph(GtkWidget *widget, gpointer selection)
{
GtkListStore *store;
GtkTreeModel *model;
GtkTreeIter iter;
char * value;
store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (list)));
model = gtk_tree_view_get开发者_C百科_model (GTK_TREE_VIEW (list));
if (gtk_tree_model_get_iter_first(model, &iter) == FALSE)
return;
if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(selection),
&model, &iter)) {
gtk_tree_model_get(model, &iter, AIP, &value, -1);
printf("%s" ,value);
gtk_list_store_remove(store, &iter);
}
}
According to API documentation about gtk_tree_selection_get_selected():
(...) This function will not work if you use selection is GTK_SELECTION_MULTIPLE.
Check what's set in your case using gtk_tree_selection_get_mode()
.
精彩评论