Re: popup window



On 11/23/06, sunzysjzri <sunzysjzri gmail com> wrote:
hi, guys
    I write an application which has a button , when you click the button popup a new window, i want to add a 
button in the popup window, which could
close the popup window.
    when i run my application, gtk debuger said that the the "gtk_main_loop != NULL" failed, why ?
this is my button callback function:
 void leftbutton_clicked(GtkWidget *widget, gpointer my_data)
{
     GtkWidget *win;
     GtkButton *btnclose;

    win = gtk_window_new (GTK_WINDOW_POPUP);
     gtk_widget_show (win);

    btncolse = gtk_button_new_with_label ("close");
    gtk_widget_show (button);

    gtk_container_add (GTK_BOX(task_manager), GTK_WIDGET (btnclose));

    g_signal_connect (G_OBJECT (task_manager), "delete_event", G_CALLBACK (gtk_main_quit), NULL);
    g_signal_connect (G_OBJECT (list->close_button), "clicked", gtk_main_quit, NULL);

     gtk_widget_show_all (task_manager);
}

Hello,
if I understand you correctly all you need is just to change the following line:
g_signal_connect (G_OBJECT (list->close_button), "clicked",
gtk_main_quit, NULL);
with this one:
g_signal_connect_swapped (list->close_button, "clicked",
gtk_widget_destroy, win);

Also you may not use gtk_main_quit() callback as your "delete-event"
handler, because it is supposed to terminate all application.

Some notes:
1. You can show all widgets in a container (with the container itself)
in one shot - just use gtk_widget_show_all().
2. You don't need to use G_OBJECT() cast in a first parameter to
signal connection functions.

  Olexiy



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