Combo Box



I'm new to GTK and am trying to create a Combo Widget in a window.
I'm not sure if the problem is with how I create the Combo, or how I
create the list of strings that I want to put in the combo.  (Proboably
both:P).  Here is what I have so far.


#define WEEKS 17
GtkWidget *table1;
GtkWidget *combo;
GList *list
GString *string;
int i;

combo = gtk_combo_new ();
list = g_list_alloc();

for(i = 0; i < WEEKS; i++)
{
	string = g_string_new("Week ");
	string = g_string_append_c(string, i+49);	
	list = g_list_append(list, string);
}

gtk_combo_set_popdown_strings(GTK_COMBO(combo), list);
gtk_table_attach_defaults(GTK_TABLE(table1), combo, 2, 3, 2, 3);
gtk_widget_show(combo);
g_list_free(list);


What I want to happen is to put:  Week 1, Week 2, Week 3, etc... in the combo
Box, but when I run it, I get the following errors:

Gtk-CRITICAL **:file gtklabel.c line 187 (gtk_label_new):assertion 'str != NULL' failed.

Gtk-CRITICAL **:file tkmisc.c: line 160 (gtk_misc_set_alignment): assertion 'misc != NULL' failed.

Gtk-CRITICAL **:file gtkcontainer.c: line 687 (gtk_container_add):assersion 'widget != NULL' failed.

Gtk-CRITICAL **:file gtkwidget.c: line 1345 (gtk_widget_show): assertions 'widget != NULL' failed.


Can someone give me a quick example on how to do this?


Thanks.




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