void SludgeFloorMaker::on_filechooserbutton_realize(GtkFileChooser *theChooser)
{	
	setFileChooserFilters(theChooser, TRUE, TRUE);

	if (currentFolder[0] != 0)
	{
		gtk_file_chooser_set_current_folder(theChooser, currentFolder);
	}
}
void SludgeZBufferMaker::postNew()
{
	GtkWidget *dialog;

	dialog = gtk_file_chooser_dialog_new("Load file to zBuffer",
				      NULL,
				      GTK_FILE_CHOOSER_ACTION_OPEN,
				      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
				      GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
				      NULL);

	setFileChooserFilters(GTK_FILE_CHOOSER (dialog), FALSE, TRUE);

	if (currentFolder[0] != 0)
	{
		gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER (dialog), currentFolder);
	}

	if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
	{
		char *filename;
		filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog));
		flipBackslashes(&filename);

		if (!loadZBufferFromTGA(filename, &backdrop))
		{
			errorBox("Error", "Loading TGA file failed.");
		} else {
			setFolderFromFilename(filename);
			setFilename(filename);
			int i, lastSlash;
			for (i = 0; filename[i] != 0; i++)
			{
				if (filename[i] == '/')
				lastSlash = i;
			}		
			currentShortname[i-lastSlash-4] = 'z';
			currentShortname[i-lastSlash-3] = 'b';
			currentShortname[i-lastSlash-2] = 'u';
			currentFilename[0] = 0;
			gtk_window_set_title(GTK_WINDOW(theWindow), getWindowTitle());
			setFileChanged();
			postOpen();
		}

		g_free(filename);
	}
	gtk_widget_destroy(dialog);

	setupButtons();
}