Re: signal SIGSEGV, Segmentation fault for GtkTreeView
- From: "DC A" <adc4444 hotmail com>
- To: yeti physics muni cz
- Cc: gtk-list gnome org
- Subject: Re: signal SIGSEGV, Segmentation fault for GtkTreeView
- Date: Sat, 29 Apr 2006 00:42:43 +0000
Thanks for explaining mvc for me and also for that link. What I've done is:
model = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING,
G_TYPE_INT);
gtk_list_store_append( GTK_LIST_STORE(model), &iter);
gtk_list_store_set (model, &iter, 0, pixbuf, 1, "HHHH", 2, 2, -1);
Then:
GtkTreeViewColumn *aa = gtk_tree_view_column_new();
layout = GTK_CELL_LAYOUT(aa);
renderer = gtk_cell_renderer_pixbuf_new();
gtk_cell_layout_pack_start(layout, renderer, FALSE);
gtk_tree_view_column_add_attribute(aa, renderer, "pixbuf", 0);
text_rend = gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start(layout, text_rend, FALSE);
gtk_tree_view_column_add_attribute(aa, text_rend, "text", 1);
GtkTreeViewColumn *bb = gtk_tree_view_column_new();
GtkCellRenderer *renderer2 = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start (bb, renderer2, FALSE);
gtk_tree_view_column_add_attribute(bb, renderer2, "text", 2);
gtk_tree_view_append_column(GTK_TREE_VIEW(tree), aa);
gtk_tree_view_append_column(GTK_TREE_VIEW(tree), bb);
That's it. Now I got what i wanted.
--DC
From: "David Necas (Yeti)" <yeti physics muni cz>
To: DC A <adc4444 hotmail com>
CC: gtk-list gnome org
Subject: Re: signal SIGSEGV, Segmentation fault for GtkTreeView
Date: Sat, 29 Apr 2006 02:08:38 +0200
On Fri, Apr 28, 2006 at 11:02:38PM +0000, DC A wrote:
> I want to add pixbuf and a string in a single GtkTreeView cell. My code
for
> adding these to list store:
>
>
> pixbuf = gdk_pixbuf_new_from_file("example.png", &error);
> model = gtk_list_store_new(3, GDK_TYPE_PIXBUF | G_TYPE_STRING,
> G_TYPE_INT);
This creates a list store with 3 columns of following types:
1. an invalid type GDK_TYPE_PIXBUF | G_TYPE_STRING
(GTypes are ugly numbers that definitely cannot be bitwise
or-ed)
2. G_TYPE_INT
3. some random junk that happens to lie on stack after the
first two arguments
Therefore
> After compilation I get segmentation fault.
GtkTreeView is based on the Model-View-Controller pattern
thus
****************************************************************************
*
*
* GtkTreeModel columns and GtkTreeView columns are
*
* two unrelated sets of columns.
*
*
*
****************************************************************************
A tree *model* column holds one value of a specific type [in
each row]. To create a model with a pixbuf, a string, and
an int in each row, do
model = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING,
G_TYPE_INT);
Now you create a view that consists of some columns and use
cell data functions or column attributte mapping to relate
the view columns to the model columns. This relation can be
arbitrary -- even none at all in the extreme case.
If you want to pack more cells (i.e., cell renderers) to one
tree *view* column, do just that (examples can be found in
many places, one recent probably not very didactic is here:
http://mail.gnome.org/archives/gtk-app-devel-list/2006-April/msg00008.html).
Please read the tree view tutorial.
Yeti
--
That's enough.
_________________________________________________________________
Take advantage of powerful junk e-mail filters built on patented Microsoft®
SmartScreen Technology.
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines
Start enjoying all the benefits of MSN® Premium right now and get the
first two months FREE*.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]