#include <gtk/gtk.h>

static void
signal_h (GtkFileChooser *chooser, gpointer data)
{
  const char *signal_name = data;
  char *filename;

  filename = gtk_file_chooser_get_filename(chooser);
  g_print("%s, filename %s\n", signal_name, filename);
  g_free(filename);
}

int
main (int argc, char **argv)
{
  GtkWidget *window;
  GtkWidget *button;

  gtk_init(&argc, &argv);

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

  button = gtk_file_chooser_button_new("foo", GTK_FILE_CHOOSER_ACTION_OPEN);
  gtk_file_chooser_button_set_width_chars(GTK_FILE_CHOOSER_BUTTON(button), 32);

  g_signal_connect(button, "file-set", G_CALLBACK(signal_h), "file-set");
  g_signal_connect(button, "selection-changed", G_CALLBACK(signal_h), "selection-changed");

  gtk_container_add(GTK_CONTAINER(window), button);

  gtk_widget_show_all(window);

  gtk_main();

  return 0;
}
