#include <gtk/gtk.h>

gboolean
test_filename_is_set(gpointer data)
{
	char *filename;

	filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(data));

        if (!filename) {
                g_print("Huh? no filename set\n");
                return TRUE;
        }

        g_print("filename = %s\n", filename);

        gtk_main_quit();

	return FALSE;
}

gboolean
create_filechooser(gpointer data)
{
        GtkWidget *filechooser;
        char *filename;

        filechooser = gtk_file_chooser_dialog_new(NULL, NULL, GTK_FILE_CHOOSER_ACTION_OPEN, NULL, NULL);
        gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(filechooser),  "/etc/resolv.conf");

	g_print("filename set\n");

	g_idle_add(test_filename_is_set, filechooser);

	return FALSE;
}

int main(int argc, char **argv)
{
	gtk_init(&argc, &argv);

	g_idle_add(create_filechooser, NULL);

	gtk_main();

	return 0;
}

