void SludgeFloorMaker::on_filechooserbutton_file_set(GtkFileChooser *theChooser)
{	
	char *filename;
	gboolean success = 0;

    filename = gtk_file_chooser_get_filename(theChooser);
	if (filename == NULL) return;

	flipBackslashes(&filename);

	if (strlen(filename) > 4) {
		char * extension = filename + strlen(filename) - 4;
		if        (!strcmp(extension, ".png") || !strcmp(extension, ".PNG")) {
			success = loadSpriteFromPNG(filename, &backdrop, 0);
		} else if (!strcmp(extension, ".tga") || !strcmp(extension, ".TGA")) {
			success = loadSpriteFromTGA(filename, &backdrop, 0);
		}
	} else {
		errorBox("Can't load image", "I don't recognise the file type. TGA and PNG are the supported file types.");
	}

	if (success) {
		setFolderFromFilename(filename);
		backdrop.sprites[0].height = -backdrop.sprites[0].height;
		activateZoomButtons(backdrop.sprites[0].width, -backdrop.sprites[0].height);
		showStatusbar(backdrop.sprites[0].width, -backdrop.sprites[0].height);
		on_zoom_fit_clicked();
		reshape();
		render_timer_event(theDrawingarea);
	}

	g_free(filename);
}
void SludgeZBufferMaker::postOpen()
{
	gtk_adjustment_set_upper( theSliderAdjustment, backdrop.total-1 );
	gtk_adjustment_set_upper( theYAdjustment, -backdrop.sprites[0].height*2 ); // *2 to allow obscuring characters exiting to the bottom 
	setBuffer(1);
	setBufferY(backdrop.sprites[buffer()].special);
	char buf[5];
	sprintf(buf, "%i", backdrop.total-1);
	gtk_label_set_text(theNumBuffersLabel, buf);

	activateZoomButtons(backdrop.sprites[0].width, -backdrop.sprites[0].height);
	showStatusbar(backdrop.sprites[0].width, -backdrop.sprites[0].height);
	on_zoom_fit_clicked();

	reshape();
	loadZTextures(&backdrop);
	render_timer_event(theDrawingarea);

	setupButtons();
}