0
votes

I m compiling and running a gtk app and i get that error while running when I try to put a button in an hbox. What does this error mean/how can I fix this. I get this when running it through the terminal, and somehow GTK prints this when I push a button that runs this function:

void ButtonHandler(void) {
    GtkWidget (*Button) = NULL;
    GtkWidget (*Entry) = gtk_entry_new();
    GtkWidget (*Vbox) = gtk_vbox_new(0, 8);
    GtkWidget (*Hbox) = gtk_hbox_new(0, 8);
    FILE (*SelectedWorld);
    gtk_container_add(GTK_CONTAINER(Vbox), Hbox);
    gtk_box_pack_start(GTK_BOX(Vbox), Entry, 1, 1, 0);
    gtk_box_pack_start(GTK_BOX(Hbox),Button, 1, 1, 0);//<---- here is the problem
    printf("Button pushed\n");
}
1

1 Answers

0
votes

Oh, you just forgot to initialize the button with gtk_button_new. The problem is that it cannot put NULL into a vbox or hbox. Here you go:

void ButtonHandler(void) {
    GtkWidget *Button = gtk_button_new_with_label("Button");// <--- add this
    GtkWidget *Entry = gtk_entry_new();
    GtkWidget *Vbox = gtk_vbox_new(0, 8);
    GtkWidget *Hbox = gtk_hbox_new(0, 8);
    FILE *SelectedWorld;

    gtk_container_add(GTK_CONTAINER(Vbox), Hbox);
    gtk_box_pack_start(GTK_BOX(Vbox), Entry, 1, 1, 0);
    gtk_box_pack_start(GTK_BOX(Hbox),Button, 1, 1, 0);
    printf("Button pushed\n");
}