#include <gtk/gtk.h>

int
main (int argc, char **argv)
{
  GtkWidget *fdiag;
  gchar *selected_file;

  gtk_init (&argc, &argv);

  fdiag = gtk_file_chooser_dialog_new ("Choose a folder...",
                                       NULL,
                                       GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
                                       GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                       GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
                                       NULL);

  gtk_dialog_set_default_response (GTK_DIALOG (fdiag),
                                   GTK_RESPONSE_ACCEPT);

  gtk_dialog_run (GTK_DIALOG (fdiag));

  selected_file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fdiag));

  if (selected_file)
    {
      printf ("Selected: %s\n", selected_file);

      g_free (selected_file);
    }
  else
    printf ("No folder selected\n");

  gtk_widget_destroy (fdiag);

  return 0;
}

/*
 * Local Variables:
 * compile-command: "gcc -Wall -g -o opendir opendir.c `pkg-config gtk+-2.0 --cflags --libs`"
 * End:
 */
