Ejemplo n.º 1
0
    def mouseDoubleClickEvent(self, ev):
        if self.item:
            pos = self.item.dur * ev.pos().x() / self.width()
            print pos
            print self.item.file
            xmms.set_playlist_pos(self.item.playlist_pos)
            xmms.jump_to_time(pos)

        self.drawTime()
Ejemplo n.º 2
0
	def search(self):
		'''This function searches, and plays songs if asked'''
		self.jump.clear()
		string = ""

		# self.base is the first drawn song in jump window
		# self.highlight is the highlighted song
		self.base = 0
		self.highlight = 0

		# if any key pressed
		while True:
			song = self.draw_jump(string)
			print >> log, "song returned %d\n" % song
			self.update()
			# select() rocks, timeout == 1 sec
			key = self.get_key()
			if key:
				print >> log, "key pressed %s\n" % str(key)
				if key == self.keys["esc"]:
					self.jump.clear()
					return
					
				elif key == self.keys["enter"]:
					if song != -1:
						xmms.set_playlist_pos(song)
						self.jump.clear()
						return
					
				elif key == self.keys["backspace"]:
					string = string[:-1]
					self.base = 0
					self.highlight = 0

				elif key == self.keys["down"]:
					if self.highlight < 2:
						self.highlight = self.highlight + 1
					else:
						self.base = min(self.base + 1, self.length - 3)

				elif key == self.keys["up"]:
					if self.highlight > 0:
						self.highlight = self.highlight - 1
					else:
						self.base = max(self.base - 1, 0)
				
				else:
					# try used in case a non letter is passed
					try:
						string = string + chr(key)
						self.base = 0
						self.highlight = 0
					except:
						pass
Ejemplo n.º 3
0
	def pass_keystroke(self,key):
		'''This Accepts a KeyStroke from the WM and returns instruction on
		what the WM should do next, ex: close the jump function'''
		self.jump.clear()
		
		# select() rocks, timeout == 1 sec
		if key == self.keys["esc"]:
			self.win.clear()
			return "search_finished"
		
		if key == self.keys["enter"]:
			if self.song != -1:
				xmms.set_playlist_pos(self.song)
				self.win.clear()
				return "search_finished"
		
		if key == self.keys["up"]:
			if self.highlight != 0:
				self.highlight = max(self.highlight - 1,0)
			else:
				self.base = max(self.base - 1, 0)
		
		if key == self.keys["down"]:
			if self.highlight != 2:
				self.highlight = min(self.highlight + 1,len(self.song_list) - 1)
			else:
				self.base = min(self.base + 1, len(self.song_list) - 3)
			
		if key in self.keys["backspace"]:
			self.highlight = 0
			self.base = 0
			self.string = self.string[:-1]
		else:
			# If key is a tuple, we do not want a crash over here
			try:
				self.string = self.string + chr(key)
				self.highlight = 0
				self.base = 0
			except:
				pass
			
		self.song = self.draw_jump(self.string)