I have a scrolledwindow inside a main window. I want to when i click button refresh, content of scrolledwindow will refresh automatic.This is callback to button
vbox = gtk_vbox_new(TRUE, 5);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window), vbox);
gtk_signal_connect(GTK_OBJECT(button_refresh), "clicked", GTK_SIGNAL_FUNC(button_re), NULL);
there is callback function:
void button_re(GtkWidget *window, gpointer data){
connectserver(myFile, numof);//connect to server and get information
if(numof > 0){
for(int i = 0; i< numof; i++){
hbox = gtk_hbox_new(TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
sprintf(buffer, "%s", myFile[i].name);
label = gtk_label_new(buffer);
button_down = gtk_button_new_with_label("Download");
gtk_signal_connect(GTK_OBJECT(button_down), "clicked", GTK_SIGNAL_FUNC(button_download), (gpointer ) i);
gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), button_down, TRUE, FALSE, 0);
}
}else if(numof == 0){
label = gtk_label_new("Have nothing on server");
gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, FALSE, 2);
}
But when i click button, there are nothing happed. What should i do? I'm so sorry because my english is not good. Thanks !
In button_re
you are creating new labels, buttons, etc. These won't show up until you call gtk_widget_show
on them, somehow. Somewhere in the initialization of your program - main()
perhaps - probably you call gtk_widget_show_all
on your main window, which recursively "show"s everything within it. But these new objects won't be shown until you explicitly request that they are.