def start (self):
		if self.preferences.drive.get_media_type () == nautilus_burn.MEDIA_TYPE_CDRW:
			gtk_util.dialog_warn ("CD-RW disk will be erased",
			                      "Please remove your disk if you want to preserve it's contents.",
			                      self.__parent)
		self.__blocked = False
		self.preferences.pool.temporary_dir = self.preferences.temporary_dir
		oper = FetchMusicList(self.__music_list, self.preferences.pool)
		self.__fetching = oper
		self.__queue.append (oper)
		
		oper = RecordMusicList (self.__music_list, self.preferences)
		                        
		oper.recorder.connect ('progress-changed', self.__tick)
		oper.recorder.connect ('action-changed', self.__on_action_changed)
		self.__queue.append (oper)
		self.__recording = oper

		self.__queue.start ()
		self.__source = gobject.timeout_add (200, self.__tick)
		if self.__prog.run () == gtk.RESPONSE_CANCEL and self.__queue.can_stop:
			# Disable the cancel button to make sure user 
			# doesn't click it twice
			self.__prog.set_response_sensitive (gtk.RESPONSE_CANCEL, False)
			self.__queue.stop ()
	def __init__ (self, data_dir):
		gtk.Window.__init__ (self, gtk.WINDOW_TOPLEVEL)
		self.preferences = RecordingPreferences (data_dir)
		self.masterer = AudioMastering (self.preferences)
		self.masterer.listeners.append (self)
		g = gtk.glade.XML (os.path.join (self.preferences.data_dir, "serpentine.glade"),
		                   "main_window_container")
		self.add (g.get_widget ("main_window_container"))
		self.set_title ("Serpentine")
		
		# Add a file button
		g.get_widget ("add").connect ("clicked", self.add_file)
		g.get_widget ("add_mni").connect ("activate", self.add_file)
		
		# record button
		g.get_widget("burn").connect ("clicked", self.burn)
		
		# masterer widget
		box = self.get_child()
		self.masterer.show()
		box.add (self.masterer)
		
		# preferences
		g.get_widget ("preferences_mni").connect ('activate', self.__on_preferences)
		
		# setup remove buttons
		self.remove = MapProxy ({'menu': g.get_widget ("remove_mni"),
		                         'button': g.get_widget ("remove")})

		self.remove['menu'].connect ("activate", self.remove_file)
		self.remove['button'].connect ("clicked", self.remove_file)
		self.remove.set_sensitive (False)
		
		# setup record button
		self.burn = g.get_widget ("burn")
		self.burn.set_sensitive (False)
		
		# setup clear buttons
		self.clear = MapProxy ({'menu': g.get_widget ("clear_mni"),
		                        'button': g.get_widget ("clear")})
		self.clear['button'].connect ("clicked", self.clear_files)
		self.clear['menu'].connect ("activate", self.clear_files)
		self.clear.set_sensitive (False)
		
		# setup quit menu item
		g.get_widget ("quit_mni").connect ('activate', self.quit)
		self.connect("destroy", self.quit)
		
		# About dialog
		g.get_widget ("about_mni").connect ('activate', self.__on_about)
		
		self.__last_path = None
		self.__add_file = gtk.FileChooserDialog (buttons = (gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
		self.__add_file.set_title ('')
		self.__add_file.set_select_multiple (True)
		
		if not self.preferences.drive:
			gtk_util.dialog_warn ("No recording drive found", "No recording drive found on your system, therefore some of Serpentine's functionalities will be disabled.")
			g.get_widget ("preferences_mni").set_sensitive (False)
			self.burn.set_sensitive (False)
	def burn (self, *args):
		if not self.preferences.temporary_dir_is_ok():
			gtk_util.dialog_warn ("Temporary directory location unavailable", "Please check if the temporary exists and has writable permissions.")
			self.__on_preferences ()
			return
		if gtk_util.dialog_ok_cancel ("Do you want to continue?", "You are about to record a media disk. Canceling a writing operation will make your disk unusable.", self) != gtk.RESPONSE_OK:
			return
		r = RecordingMedia (self.masterer.source, self.preferences, self)
		r.start()
	def burn (self, *args):
		# Check if we have space available in our cache dir
		secs = 0
		for music in self.masterer.source:
			if not self.preferences.pool.is_available (music['uri']):
				secs += music['duration']
		# 44100hz * 16bit * 2channels / 8bits = 176400 bytes per sec
		size_needed = secs * 176400L
		s = os.statvfs (self.preferences.temporary_dir)
		size_avail = s[statvfs.F_BAVAIL] * long(s[statvfs.F_BSIZE])
		if (size_avail - size_needed) < 0:
			
			gtk_util.dialog_error ("Not enough space on cache directory",
				"Remove some music tracks or make sure your cache location location has enough free space (about %s)." % (self.__hig_bytes(size_needed - size_avail)), self)
			return
	
		if not self.preferences.temporary_dir_is_ok():
			gtk_util.dialog_warn ("Cache directory location unavailable", "Please check if the cache location exists and has writable permissions.", self)
			self.__on_preferences ()
			return
		if gtk_util.dialog_ok_cancel ("Do you want to continue?", "You are about to record a media disk. Canceling a writing operation will make your disk unusable.", self) != gtk.RESPONSE_OK:
			return
		r = RecordingMedia (self.masterer.source, self.preferences, self)
		r.start()