GtkCellEditable or a better way?



Hi!

I'm still struggling with GtkTreeView & co. I'm going to explain my problem
and then perhaps someone may drop a hint...

I need a GtkListStore of six columns:

	1 ... a string   (filter name)
	2 ... a checkbox (should data be plotted)
	3 ... a checkbox (should lines be drawn)
	4 ... a pixbuf   (choose the data color)
	5 ... a pixbuf   (choose the line color)
	6 ... a double   (vertical offset)

These columns should be editable - the user should be able to change them
directly within GtkTreeView.

So far I have tried to create only the first two columns to get at least
the toggle button working. I tried it like this:

plot_lc_data_info_list_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_BOOLEAN);
plot_lc_data_info_list_table = gtk_tree_view_new_with_model (GTK_TREE_MODEL (plot_lc_data_info_list_store));
plot_lc_data_info_list_renderer_text   = gtk_cell_renderer_text_new ();
plot_lc_data_info_list_renderer_toggle = gtk_cell_renderer_toggle_new ();

plot_lc_data_info_list_column_1 = gtk_tree_view_column_new ();
gtk_tree_view_column_set_alignment (plot_lc_data_info_list_column_1, 0.5);
gtk_tree_view_column_set_title (plot_lc_data_info_list_column_1, "Filter");
gtk_tree_view_column_pack_start (plot_lc_data_info_list_column_1, plot_lc_data_info_list_renderer_text, FALSE);
gtk_tree_view_column_add_attribute (plot_lc_data_info_list_column_1, plot_lc_data_info_list_renderer_text, "text", 0);
gtk_tree_view_column_set_resizable (plot_lc_data_info_list_column_1, TRUE);
gtk_tree_view_append_column (GTK_TREE_VIEW (plot_lc_data_info_list_table), plot_lc_data_info_list_column_1);

plot_lc_data_info_list_column_2 = gtk_tree_view_column_new ();
g_object_set_data (G_OBJECT (PHOEBE), "plot_lc_data_info_list_column_2", plot_lc_data_info_list_column_2);
gtk_tree_view_column_set_alignment (plot_lc_data_info_list_column_2, 0.5);
gtk_tree_view_column_set_title (plot_lc_data_info_list_column_2, "Plot experimental?");
gtk_tree_view_column_pack_start (plot_lc_data_info_list_column_2, plot_lc_data_info_list_renderer_toggle, FALSE);
gtk_tree_view_column_add_attribute (plot_lc_data_info_list_column_2, plot_lc_data_info_list_renderer_toggle, "activatable", 1);
gtk_tree_view_column_set_resizable (plot_lc_data_info_list_column_2, TRUE);
gtk_tree_view_append_column (GTK_TREE_VIEW (plot_lc_data_info_list_table), plot_lc_data_info_list_column_2);

gtk_list_store_append (plot_lc_data_info_list_store, &iter);
gtk_list_store_set (plot_lc_data_info_list_store, &iter, 0, "Filter name", -1);
gtk_list_store_set (plot_lc_data_info_list_store, &iter, 1, TRUE, -1);


(I apologize for WAY too long lines above). This works in showing the rows
properly, but I don't have a clue on how to make a checkbox editable.
Help?

Thanks,

Andrej



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