/*
 * Test case for GtkFileChooserDialog bug where "Home" and "Desktop" entries
 * are not shown in the "Places" sidebar.
 *
 * See bug #363147 on http://bugzilla.gnome.org
 *
 * If compiled with -DTEST2 the FileChooserDialog works as expected,
 * if compiled without, the bug can be seen.
 *
 * Steps to reproduce the bug:
 * 1) click the "Save as" button
 * 2) Click the "Browse for other folders" expander
 * 
 * Christian Becke <christianbecke@web.de>
 */

#include <gtk/gtk.h>

#ifndef TEST2
static gboolean
save_as_clicked (GtkButton *button, gpointer data)
{
	GtkWidget *fc;

	fc = gtk_file_chooser_dialog_new ("Save File",
					GTK_WINDOW (data),
					GTK_FILE_CHOOSER_ACTION_SAVE,
					GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
					NULL);
	gtk_dialog_run (GTK_DIALOG (fc));
	gtk_widget_destroy (GTK_WIDGET (fc));

	return FALSE;
}


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

	gtk_init (&argc, &argv);

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (gtk_main_quit), NULL);
	
	button = gtk_button_new_from_stock (GTK_STOCK_SAVE_AS);
	g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (save_as_clicked), window);
	gtk_container_add (GTK_CONTAINER (window), button);
	gtk_widget_show (button);

	gtk_widget_show (window);

	gtk_main ();

	return 0;
}

#else

int
main (int argc, char *argv[])
{
	GtkWidget *fc;

	gtk_init (&argc, &argv);

	fc = gtk_file_chooser_dialog_new ("Save File",
					NULL,
					GTK_FILE_CHOOSER_ACTION_SAVE,
					GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
					NULL);
	gtk_dialog_run (GTK_DIALOG (fc));
	
	return 0;
}
#endif

