GtkTreeView: GTK_SELECTION_SINGLE not working?
- From: Carlos Pereira <jose carlos pereira ist utl pt>
- To: gtk-app-devel-list gnome org
- Subject: GtkTreeView: GTK_SELECTION_SINGLE not working?
- Date: Tue, 25 Mar 2008 16:53:22 +0000
Hi,
For some strange reason GtkTreeview is not working in
GTK_SELECTION_SINGLE mode, here (Fedora 8, Gtk 2.10, I believe).
GTK_SELECTION_NONE, GTK_SELECTION_BROWSE,
GTK_SELECTION_MULTIPLE work as expected, but GTK_SELECTION_SINGLE always
behaves as GTK_SELECTION_BROWSE... so one row is always selected...
I am including a simple 40-line working example below, that shows this.
What am I missing?
Carlos
---------------------- working treeview example---------------
#include <gtk/gtk.h>
int main (int argc, char **argv)
{
GtkWidget *window;
GtkWidget *treeview;
GtkTreeSelection *selection;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
GtkListStore *store;
GtkTreeIter iter;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 280, 150);
treeview = gtk_tree_view_new ();
gtk_container_add (GTK_CONTAINER (window), treeview);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes ("Fruit", renderer,
"text", 0, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
column = gtk_tree_view_column_new_with_attributes ("Color", renderer,
"text", 1, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, 0, "Apples", 1, "Red", -1);
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, 0, "Bananas", 1, "Yellow", -1);
gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), GTK_TREE_MODEL (store));
g_object_unref (store);
gtk_widget_show_all (window);
gtk_main ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]