Re: Conversion GtkCTree in GTK 1.2 to GtkTreeView in GTK 2
- From: Arno <dark-arno ifrance com>
- To: "Shahms E. King" <shahms shahms com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Conversion GtkCTree in GTK 1.2 to GtkTreeView in GTK 2
- Date: Thu, 11 Jul 2002 23:54:51 +0200
Shahms E. King wrote:
So if I understand good, it's imppossible to have a dot line. I can't
modify the animation with the triangle :(
Yes, from what I remember it's not possible to modify this without a lot
of work and it was, indeed, a design decision.
Here's how it should look (or something similar):
renderer = gtk_cell_renderer_pixbuf_new ();
column = gtk_tree_view_column_new ()
gtk_tree_view_column_set_title (column, "Author");
gtk_tree_view_column_add_attribute (column, renderer, "pixbuf",
PIXBUF_COLUM);
/* the pixbuf_expander_{open|closed} aren't necessary unless you want
them to be different */
gtk_tree_view_column_pack_start (column, renderer, FALSE);
renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_column_add_attribute (column, renderer, "text",
AUTHOR_COLUMN);
gtk_tree_view_column_pack_start (column, renderer, TRUE);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
that should do what you want, I'm not certain about the TRUE/FALSE in
there, in theory they control the amount of space allocated to the
CellRenderer, but I haven't actually seen it make a difference.
Thank you for this answer but I have a problem with my short test. When
I launch my program, I have the messages :
(tree:518): Gtk-CRITICAL **: file gtktreeviewcolumn.c: line 1271
(gtk_tree_view_column_add_attribute): assertion `info != NULL' failed
(tree:518): Gtk-CRITICAL **: file gtktreeviewcolumn.c: line 1271
(gtk_tree_view_column_add_attribute): assertion `info != NULL' failed
(tree:518): Gtk-WARNING **:
gtktreestore.c:949:gtk_tree_store_set_valist(): Invalid column number 2
added to iter (remember to end your list of columns with a -1)
And I have a white window :(. I join you my source if you could see it.
Thank you
Arno
#include <gtk/gtk.h>
enum
{
PROTOCOL_COLUMN,
DATA_COLUMN,
ICONE_COLUMN,
};
GtkWidget*
create_mainwin (void)
{
GtkWidget *mainwin;
GtkTreeStore *store;
GtkWidget *tree;
GtkTreeViewColumn *column;
GtkCellRenderer *renderer;
GtkTreeIter iter;
GdkPixbuf *pixbuf;
/* mainwin */
mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (mainwin), "Tree GTK 2.0");
gtk_object_set_data (GTK_OBJECT (mainwin), "mainwin", mainwin);
gtk_widget_set_usize (mainwin, 500, 250);
gtk_signal_connect (GTK_OBJECT (mainwin), "delete_event",
GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
gtk_signal_connect (GTK_OBJECT (mainwin), "destroy",
GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
store = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
g_object_unref (G_OBJECT (store));
/* Create the first colum with the pixmap and the text */
column = gtk_tree_view_column_new ();
renderer = gtk_cell_renderer_pixbuf_new ();
gtk_tree_view_column_set_title (column, "Protocol");
gtk_tree_view_column_add_attribute (column, renderer,
"pixbuf", ICONE_COLUMN);
gtk_tree_view_column_pack_start (column, renderer, FALSE);
renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_column_add_attribute (column, renderer,
"text", PROTOCOL_COLUMN);
gtk_tree_view_column_pack_start (column, renderer, TRUE);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
/* Second column... */
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes ("Data send",
renderer,
"text", DATA_COLUMN,
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
/* Insert data */
pixbuf = gdk_pixbuf_new_from_file("pc.xpm", NULL);
gtk_tree_store_append (store, &iter, NULL);
gtk_tree_store_set (store, &iter,
PROTOCOL_COLUMN, "Frame 1",
ICONE_COLUMN, pixbuf,
-1);
/* Apperance */
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (tree));
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree), FALSE);
gtk_widget_show (tree);
gtk_container_add (GTK_CONTAINER (mainwin), tree);
return mainwin;
}
int
main (int argc, char *argv[])
{
GtkWidget *mainwin;
gtk_set_locale ();
gtk_init (&argc, &argv);
mainwin = create_mainwin ();
gtk_widget_show (mainwin);
gtk_main ();
return 0;
}
______________________________________________________________________________
ifrance.com, l'email gratuit le plus complet de l'Internet !
vos emails depuis un navigateur, en POP3, sur Minitel, sur le WAP...
http://www.ifrance.com/_reloc/email.emailif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]