- Many things

This commit is contained in:
noisymime 2008-04-25 14:35:16 +00:00
parent 5f03884d51
commit 52847ef532
10 changed files with 182 additions and 74 deletions

View File

@ -151,9 +151,9 @@ class InputQueue(gobject.GObject):
self.queue_north = 0
if not self.accelerating:
#self.timeline.disconnect(self.flush_id)
self.emit("queue-flushed")
self.emit("queue-flushed")
self.accelerating = False
def is_in_queue(self):
if self.accelerating: return True

View File

@ -50,11 +50,13 @@ class MenuItem (clutter.Label):
self.onStage = False
def add_image_from_path(self, path, x, y):
def add_image_from_path(self, path, x, y, width = None, height = None):
tempTexture = clutter.Texture()
pixbuf = gtk.gdk.pixbuf_new_from_file(path)
tempTexture.set_pixbuf(pixbuf)
if not width is None: tempTexture.set_width(width)
if not height is None: tempTexture.set_height(height)
self.add_image_from_texture(tempTexture)

View File

@ -0,0 +1,36 @@
The following functions are required for a backend:
- get_artists
- get_albums_by_artistID ( id )
- get_songs_by_albumID ( id )
- get_songs_by_artistID ( id )
The following properties can be set on song objects (Those marked with * are compulsory):
- songID*
- filename*
- directory*
- name*
- track
- artistID
- albumID
- genreID
- year
- length
- numplays
- rating
- lastplay
- date_entered
- date_modified
- format
- size
- description
- comment
- disc_count
- disc_number
- track_count
- start_time
- stop_time
- eq_preset
- retrieve_volume
- sample_rate
- bitrate
- bpm

View File

@ -141,7 +141,7 @@ class Backend(gobject.GObject):
#Else add the entries in
for record in results:
tempSong = song(self.music_player)
tempSong.import_from_mythObject(record)
self.import_song_from_mythObject(record, tempSong)
tempSong.directory = self.directories[str(tempSong.directory_id)]
songs.append(tempSong)
#self.artistImageRow.add_object(tempArtist)
@ -176,11 +176,47 @@ class Backend(gobject.GObject):
#Else add the entries in
for record in results:
tempSong = song(self.music_player)
tempSong.import_from_mythObject(record)
self.import_song_from_mythObject(record, tempSong)
tempSong.directory = self.directories[str(tempSong.directory_id)]
songs.append(tempSong)
#self.artistImageRow.add_object(tempArtist)
self.emit("query-complete")
self.cache_songs_by_artistID[str(id)] = songs
return songs
def import_song_from_mythObject(self, mythObject, song):
try:
song.songID = mythObject[0]
song.filename = mythObject[1]
song.name = mythObject[2]
song.track = mythObject[3]
song.artistID = mythObject[4]
song.albumID = mythObject[5]
song.genreID = mythObject[6]
song.year = mythObject[7]
song.length = mythObject[8]
song.numplays = mythObject[9]
song.rating = mythObject[10]
song.lastplay = mythObject[11]
song.date_entered = mythObject[12]
song.date_modified = mythObject[13]
song.format = mythObject[14]
song.mythdigest = mythObject[15]
song.size = mythObject[16]
song.description = mythObject[17]
song.comment = mythObject[18]
song.disc_count = mythObject[19]
song.disc_number = mythObject[20]
song.track_count = mythObject[21]
song.start_time = mythObject[22]
song.stop_time = mythObject[23]
song.eq_preset = mythObject[24]
song.retrieve_volume = mythObject[25]
song.sample_rate = mythObject[26]
song.bitrate = mythObject[27]
song.bpm = mythObject[28]
song.directory_id = mythObject[29]
except IndexError, e:
print "Music_Player: Found difference in DB structure for songs. Attempting to continue."

View File

@ -11,41 +11,36 @@ class song:
self.music_player = music_player
self.base_dir = music_player.base_dir
def import_from_mythObject(self, mythObject):
try:
self.songID = mythObject[0]
self.filename = mythObject[1]
self.name = mythObject[2]
self.track = mythObject[3]
self.artistID = mythObject[4]
self.albumID = mythObject[5]
self.genreID = mythObject[6]
self.year = mythObject[7]
self.length = mythObject[8]
self.numplays = mythObject[9]
self.rating = mythObject[10]
self.lastplay = mythObject[11]
self.date_entered = mythObject[12]
self.date_modified = mythObject[13]
self.format = mythObject[14]
self.mythdigest = mythObject[15]
self.size = mythObject[16]
self.description = mythObject[17]
self.comment = mythObject[18]
self.disc_count = mythObject[19]
self.disc_number = mythObject[20]
self.track_count = mythObject[21]
self.start_time = mythObject[22]
self.stop_time = mythObject[23]
self.eq_preset = mythObject[24]
self.retrieve_volume = mythObject[25]
self.sample_rate = mythObject[26]
self.bitrate = mythObject[27]
self.bpm = mythObject[28]
self.directory_id = mythObject[29]
except IndexError, e:
print "Music_Player: Found difference in DB structure for songs. Attempting to continue."
self.songID = None
self.filename = None
self.directory = None
self.name = None
self.track = None
self.artistID = None
self.albumID = None
self.genreID = None
self.year = None
self.length = None
self.numplays = None
self.rating = None
self.lastplay = None
self.date_entered = None
self.date_modified = None
self.format = None
self.mythdigest = None
self.size = None
self.description = None
self.comment = None
self.disc_count = None
self.disc_number = None
self.track_count = None
self.start_time = None
self.stop_time = None
self.eq_preset = None
self.retrieve_volume = None
self.sample_rate = None
self.bitrate = None
self.bpm = None
def get_image(self):
return self.get_image_from_ID3()

View File

@ -12,7 +12,7 @@ from ui_elements.image_clone import ImageClone
from ui_elements.label_list import LabelList
class Module:
CONTEXT_HEADINGS, CONTEXT_ROW, CONTEXT_LIST1, CONTEXT_LIST2, CONTEXT_PLAYING = range(5)
CONTEXT_HEADINGS, CONTEXT_ROW, CONTEXT_ALBUM_LIST, CONTEXT_SONG_LIST, CONTEXT_PLAYING = range(5)
title = "Music"
num_columns = 6
@ -43,11 +43,9 @@ class Module:
print "Music Base Dir: " + self.base_dir
self.is_playing = False
#self.load_albums()
self.artists = self.backend.get_artists()
self.timeout_id = 0
self.queue_id = 0
#thread.start_new_thread(self.load_artists, ())
def setup_ui(self):
@ -98,7 +96,7 @@ class Module:
elif (event.keyval == clutter.keysyms.Down):
self.list1.select_first_elegant()
self.current_context = self.CONTEXT_LIST1
self.current_context = self.CONTEXT_ALBUM_LIST
elif (event.keyval == clutter.keysyms.Return):
artist = self.artistImageRow.get_current_object()
@ -107,7 +105,7 @@ class Module:
self.playlist.add_songs(songs)
self.playlist.play()
elif self.current_context == self.CONTEXT_LIST1:
elif self.current_context == self.CONTEXT_ALBUM_LIST:
if (event.keyval == clutter.keysyms.Up):
self.artistImageRow.external_timeline = self.list1.timeline
@ -130,9 +128,11 @@ class Module:
tmpItem = self.list2.add_item(song.name)
self.list2.display()
"""
#Simple delay
def start_delay(self, queue, function, args):
self.timeout_id = gobject.timeout_add((self.delay * 1000), function, args)
"""
#Loads albums into List1
def load_albums(self, queue):
@ -249,7 +249,7 @@ class Module:
def unpause(self):
pass
"""
def load_songs(self):
#Generate some SQL to retrieve videos that were in the final_file_list
#Load the videos into the cover viewer
@ -285,3 +285,4 @@ class Module:
self.tmpImage = clutter.Texture()
self.tmpImage.set_pixbuf(pixbuf)
"""

View File

@ -12,6 +12,7 @@ class Module:
title = "Slideshow"
menu_image = None
MAX_PREVIEW_IMG = 15 #The maximum number of images from each directory that will be used in the preview
image_file_types = ["jpg", "gif", "jpeg", "png", "bmp"]
sound_file_types = ["mp3", "wav", "ogg"] #possibly more supported by default?
@ -89,6 +90,10 @@ class Module:
#This makes sure we only take in image files
def filterImageFile(self, fileName):
#Strip out any directory info
filename_structure = fileName.split("/")
fileName = filename_structure[ len(filename_structure)-1 ]
extension = fileName[-3:] #Get 3 letter extension
if not extension in self.image_file_types:
return False
@ -96,6 +101,20 @@ class Module:
return False
else:
return True
#This filters for image files starting with "."
def filterPreviewImageFile(self, fileName):
#Strip out any directory info
filename_structure = fileName.split("/")
fileName = filename_structure[ len(filename_structure)-1 ]
extension = fileName[-3:] #Get 3 letter extension
if not extension in self.image_file_types:
return False
elif not fileName[0] == ".":
return False
else:
return True
#This makes sure we only take in sound files
def filterSoundFile(self, fileName):
@ -104,6 +123,19 @@ class Module:
return True
else:
return False
#A simple function to add recursive nature to os.listdir
def os_listdir_recursive(self, dirPath, file_list = None, showHidden = True):
if file_list is None: file_list = []
new_file_list = os.listdir(dirPath)
for fs_object in new_file_list:
if not showHidden and fs_object[0] == ".": break
path = dirPath + "/" + fs_object
if os.path.isdir(path):
self.os_listdir_recursive(path, file_list)
else: file_list.append(path)
return file_list
def begin(self, glossMgr):
@ -428,7 +460,16 @@ class Module:
#Start experimental schtuff
img_list = os.listdir(subdir)
img_list = filter(self.filterImageFile, img_list)
img_list = self.os_listdir_recursive(subdir, showHidden = False)
#Attempt to get the thumbnail images
#print img_list
img_list_preview = filter(self.filterPreviewImageFile, img_list)
if len(img_list_preview) == 0:
img_list = img_list_preview
#If not, just use the full images
else:
img_list = filter(self.filterImageFile, img_list)
img_previewer = image_previewer(self.glossMgr.stage)
#Set the max preview img sizes (These come from the slideshow.xml theme file
if (not self.preview_width is None) and (not self.preview_height is None):
@ -436,6 +477,8 @@ class Module:
for img in img_list:
imgPath = subdir + "/" + img #os.listdir(subdir)[0]
imgPath = img
print imgPath
img_previewer.add_texture(imgPath)
#print imgPath
#new_file_list = os.listdir(dirPath)
@ -443,7 +486,8 @@ class Module:
tempItem.itemTexturesGroup = img_previewer
img_previewer.set_position(tempItem.menu.menu_image_x, tempItem.menu.menu_image_y)
else:
tempItem.add_image_from_path(imgPath, 0, 0)
if not len(img_list) == 0:
tempItem.add_image_from_path(imgPath, 0, 0, self.preview_width, self.preview_height)
tempItem.setAction(self)

View File

@ -1,5 +1,6 @@
import clutter
import time
import gobject
class osd:

View File

@ -10,7 +10,7 @@ class ThemeMgr:
defaultTheme = "default"
currentTheme = "default"
currentTheme = "Pear"
currentTheme = "Mich"
#currentTheme = "Mich"
#currentTheme = "Gloxygen"
def __init__(self, glossMgr):

View File

@ -1,9 +1,11 @@
import clutter
import pygtk
import gtk
import gobject
import random
import math
from ReflectionTexture import Texture_Reflection
from ui_elements.image_frame import ImageFrame
class image_previewer(clutter.Group):
tex1 = None
@ -113,7 +115,8 @@ class image_previewer(clutter.Group):
self.show()
self.timeline1.start()
timeline_opacity.start()
self.nextTexture = self.get_rand_tex()
gobject.idle_add(self.get_next_tex)
#self.nextTexture = self.get_rand_tex()
else:
self.timeline1.start()
self.timeline2.start()
@ -149,31 +152,20 @@ class image_previewer(clutter.Group):
def get_rand_tex(self):
rand = random.randint(0, len(self.textures)-1)
texture = clutter.Texture()
pixbuf = gtk.gdk.pixbuf_new_from_file(self.textures[rand])
#Set the image size based on the max bounds
xy_ratio = float(pixbuf.get_width()) / pixbuf.get_height()
if pixbuf.get_width() > pixbuf.get_height():
width = self.max_img_width
height = int(self.max_img_width / xy_ratio)
#Determine the largest size for the image
if self.max_img_height > self.max_img_width:
img_size = self.max_img_height
else:
height = self.max_img_height
width = int(xy_ratio * self.max_img_height)
img_size = self.max_img_width
pixbuf = pixbuf.scale_simple(width, height, gtk.gdk.INTERP_BILINEAR)
texture.set_pixbuf(pixbuf)
reflectionTexture = Texture_Reflection(texture)
pixbuf = gtk.gdk.pixbuf_new_from_file(self.textures[rand])
texture = ImageFrame(pixbuf, img_size, use_reflection = True, quality = ImageFrame.QUALITY_FAST)
return texture
def get_next_tex(self):
self.nextTexture = self.get_rand_tex()
return False
textureGroup = clutter.Group()
textureGroup.add(texture)
textureGroup.add(reflectionTexture)
texture.show()
reflectionTexture.show()
return textureGroup
def next_image(self, data):
texture = self.nextTexture
@ -232,7 +224,8 @@ class image_previewer(clutter.Group):
self.add(texture)
texture.show()
self.nextTexture = self.get_rand_tex()
gobject.idle_add(self.get_next_tex)
#self.nextTexture = self.get_rand_tex()
def get_texture_knots(self, texture):
knots = (\