#include <gtk/gtk.h>

int main(int argc, char **argv) {

  GtkWidget *dialog;
  gchar *filename;

  gtk_init(&argc, &argv);
  dialog = gtk_file_chooser_dialog_new("Download directory",
				       NULL,
				       GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
				       GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
				       GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
				       NULL);
  if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
    filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
    g_print("%s\n", filename);
    g_free(filename);
    gtk_widget_destroy(dialog);
  }
  else {
    gtk_widget_destroy(dialog);  
  }
}
