#!/usr/bin/ruby
# encoding: utf-8

class TileHelpers
	def TileHelpers.place_back(panel, layers)
		text = Gtk::Label.new
		text.width_request = 250
		text.wrap = true
		text.set_markup("<span color='white'>Klicken Sie hier, um abzubrechen und zum Startbildschirm zurückzukehren.</span>")
		back = Gtk::EventBox.new.add Gtk::Image.new("cancel.png")
		panel.put(back, 852, 332)
		panel.put(text, 630, 338)
		back.signal_connect('button-release-event') { |x, y|
			if y.button == 1 
				layers.each { |k,v|v.hide_all }
				layers["start"].show_all
			end
		}
		return back
	end
	
	def TileHelpers.create_label(text, width)
		label = Gtk::Label.new
		label.width_request = width
		label.wrap = true
		label.set_markup("<span color='white'>" + text + "</span>")
		return label
	end
	
	def TileHelpers.success_dialog(message, title="Nachricht")
		dialog = Gtk::Dialog.new(title,
                             $main_application_window,
                             Gtk::Dialog::MODAL,
                             [ Gtk::Stock::OK, Gtk::Dialog::RESPONSE_NONE ] )
		dialog.has_separator = false
		label = Gtk::Label.new(message)
		label.wrap = true
		image = Gtk::Image.new(Gtk::Stock::DIALOG_INFO, Gtk::IconSize::DIALOG)
		hbox = Gtk::HBox.new(false, 5)
		hbox.border_width = 10
		hbox.pack_start_defaults(image);
		hbox.pack_start_defaults(label);
			     
		dialog.vbox.add(hbox)
		dialog.show_all
		dialog.run do |response|
			# finito
		end
		dialog.destroy
	end
	
	def TileHelpers.open_pdf(pdfname)
		system("evince '" + pdfname + "' & ")
	end
end
