/* gcc -Wall -o chooser_set_filename chooser_set_filename.c `pkg-config --cflags --libs gtk+-2.0` */

#include <gtk/gtk.h>

static void onClicked(GtkWidget *button, GtkWidget *file)
{
    gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(file), "/etc/passwd");
}

int main(int argc, char **argv)
{
    GtkWidget *win, *vbox, *file, *button;

    gtk_init(&argc, &argv);

    win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(win), "File button test");

    vbox = gtk_vbox_new(FALSE, 10);
    gtk_container_set_border_width(GTK_CONTAINER(vbox), 10);
    gtk_container_add(GTK_CONTAINER(win), vbox);

    file = gtk_file_chooser_button_new(NULL, GTK_FILE_CHOOSER_ACTION_OPEN);
    gtk_container_add(GTK_CONTAINER(vbox), file);

    button = gtk_button_new_with_label("Set filename to '/etc/passwd'");
    g_signal_connect(button, "clicked", G_CALLBACK(onClicked), file);
    gtk_container_add(GTK_CONTAINER(vbox), button);

    gtk_widget_show_all(win);

    gtk_main();

    return 0;
}

