Re: add a checkbutton to a treeview?
- From: Ottavio Campana <ottavio campana vi it>
- To: Sven Neumann <sven gimp org>
- Cc: gtk-list gnome org
- Subject: Re: add a checkbutton to a treeview?
- Date: Tue, 14 Jan 2003 18:33:16 +0100
On Tue, Jan 14, 2003 at 10:51:56AM +0100, Sven Neumann wrote:
> > I'm trying to add some rows to a treeview. There's only one column, but
> > I don't want to add some text, but a checkbutton.
> >
> > Is it possible? How can ? I do it?
>
> see http://developer.gnome.org/doc/API/2.0/gtk/GtkCellRendererToggle.html
good, I've done it. The checkbutton is in the treeview, I see it but I
cannot click on it. I mean, it doesn't toggle. Here is a bit of code,
can you please tell me what I'm missing in order to let it behave like a
normal checkbutton?
swap->store = gtk_tree_store_new (N_COLUMNS,
G_TYPE_BOOLEAN,
G_TYPE_STRING);
swap->treeview = (GtkTreeView*) gtk_tree_view_new_with_model ((GtkTreeModel*) swap->store);
gtk_container_add (GTK_CONTAINER(swap), (GtkWidget*) swap->treeview);
gtk_widget_show ((GtkWidget*) swap->treeview);
renderer1 = (GtkCellRendererToggle*) gtk_cell_renderer_toggle_new ();
column1 = gtk_tree_view_column_new_with_attributes ("Usare",
renderer1,
"active", USE_COLUMN,
NULL);
gtk_tree_view_column_pack_start (column1, GTK_CELL_RENDERER (renderer1), 0);
gtk_tree_view_insert_column(swap->treeview, column1, 1);
gtk_widget_show((GtkWidget*) column1);
renderer2 = (GtkCellRenderer*) gtk_cell_renderer_text_new ();
column2 = gtk_tree_view_column_new_with_attributes ("Partizione di swap",
renderer2,
"text", NAME_COLUMN,
NULL);
gtk_tree_view_column_pack_start (column2, GTK_CELL_RENDERER (renderer2), 0);
gtk_tree_view_insert_column(swap->treeview, column2, 1);
gtk_widget_show((GtkWidget*) column2);
...
gtk_tree_store_append (swap->store, &(swap->iter), NULL);
gtk_tree_store_set (swap->store, &(swap->iter), USE_COLUMN, NULL,
NAME_COLUMN, "ciao",
-1);
By the way, I've got a pair of questions. In the doc page I read :
"Object properties can be set globally (with g_object_set())" . What
does it mean? Do I need it to let the button toggle? In the last line of
the code I posted I pass a NULL in the column where should be the
checkbutton. Is it correct?
Thank you.
--
Non c'è più forza nella normalità, c'è solo monotonia.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]