You are not logged in.

#1 2010-07-24 12:53:32

stqn
Member
Registered: 2010-03-19
Posts: 1,191
Website

[SOLVED] GtkFileChooserDialog isn't destroyed

Hello,

Edit: rewrite of my original post since the problem is not exactly what I thought it was. I thought execution stopped at gtk_dialog_run(), but it's not the case. I was using printf("pouet") to check program execution, and it wasn't being printed... Using printf("pouet\n") works better! :-}

I'm porting a program that uses SDL and needs file requesters. I want to use GTK file requesters, but when I follow the documentation to open one, it opens fine but it is not destroyed when a button is pressed or a file is double-clicked.

    gtk_init(0, NULL);

    GtkWidget *pFileSelection = gtk_file_chooser_dialog_new(
        "Open...",
        NULL,
        GTK_FILE_CHOOSER_ACTION_OPEN,
        GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
        GTK_STOCK_OPEN, GTK_RESPONSE_OK,
        NULL
    );
    gtk_dialog_run(GTK_DIALOG(pFileSelection));
    gtk_widget_destroy(pFileSelection); // <- this doesn't close the requester

Does someone know what I'm missing?

Last edited by stqn (2010-07-24 14:49:12)

Offline

#2 2010-07-24 14:46:33

stqn
Member
Registered: 2010-03-19
Posts: 1,191
Website

Re: [SOLVED] GtkFileChooserDialog isn't destroyed

Ok, found out how to make it disappear: since I'm not using the gtk_main() main loop in my program, I have to "simulate" it after "destroying" the dialog:

    gtk_init(0, NULL);

    GtkWidget *pFileSelection = gtk_file_chooser_dialog_new(
        "Open...",
        NULL,
        GTK_FILE_CHOOSER_ACTION_OPEN,
        GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
        GTK_STOCK_OPEN, GTK_RESPONSE_OK,
        NULL
    );
    gtk_dialog_run(GTK_DIALOG(pFileSelection));
    gtk_widget_destroy(pFileSelection);

    // This makes the destroy actually happen:
    while (gtk_events_pending ())
        gtk_main_iteration ();

Offline

Board footer

Powered by FluxBB