Simple CTree-gtk-program, with error
- From: Thomas Langås <tlan-gtk initio no>
- To: gtk-app-devel-list gnome org
- Subject: Simple CTree-gtk-program, with error
- Date: Tue, 6 Nov 2001 16:04:26 +0100
Hi!
I'm trying to write a simple gtk-program which uses the CTree-widget, but
I get an odd error. After I've added the column-titles, and the
"test"-content for the five fields I'm adding, the first column-title
disapears. This is only happen if I'm adding fields dynamically. Program
below demonstrates the behaviour, help is apreciated:
-------[START]-------
#include <gtk/gtk.h>
#include <glib.h>
int main(int argc, char *argv[])
{
GtkWidget *main_window, *scroll_window, *ctree;
static gchar **titles, **fields;
gint i;
gtk_init(&argc, &argv);
//Main window
main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width(GTK_CONTAINER(main_window), 5);
gtk_widget_set_usize(main_window, 400, 300);
//Main signals
gtk_signal_connect(GTK_OBJECT(main_window), "delete_event", GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
//Scroll window
scroll_window = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_window), GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_container_add(GTK_CONTAINER(main_window), scroll_window);
gtk_widget_show(scroll_window);
//Column tree...
titles = (gchar **) g_malloc0(5);
titles[0] = g_strdup("Project");
titles[1] = g_strdup("Description");
titles[2] = g_strdup("Session");
titles[3] = g_strdup("Today");
titles[4] = g_strdup("Week");
ctree = gtk_ctree_new_with_titles(5, 0, titles);
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroll_window), ctree);
gtk_widget_show(ctree);
fields = (gchar **) g_malloc0(5);
//Create some fun in the ctree
for (i = 0; i<5; i++) {
fields[0] = g_strdup_printf("Prosjekt %d", i);
fields[1] = g_strdup_printf("blablaba");
fields[2] = g_strdup_printf("00:00");
fields[3] = g_strdup_printf("00:00");
fields[4] = g_strdup_printf("00:00");
gtk_ctree_insert_node(GTK_CTREE(ctree), NULL, NULL, fields, 2, NULL, NULL, NULL, NULL, 0, 0);
g_free(fields[0]);
g_free(fields[1]);
g_free(fields[2]);
g_free(fields[3]);
g_free(fields[4]);
}
//Show main window, and start loop
gtk_widget_show(main_window);
gtk_main();
return 0;
}
---------[STOP]---------
--
Thomas Langås http://www.initio.no/
Tlf: 73561645 Mobil: 95731546
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]