diff --git a/SplashScr.py b/SplashScr.py index 70db3a2..a8a29f9 100644 --- a/SplashScr.py +++ b/SplashScr.py @@ -114,6 +114,7 @@ class SplashScr(clutter.Group): def set_msg(self, msg): self.message.set_text(msg) + """ (x1, y1, x2, y2) = self.message.get_coords() if x2 > self.box.get_width(): new_width = int(x2 * 1.10) @@ -121,6 +122,7 @@ class SplashScr(clutter.Group): new_x = int( (self.stage.get_width() - new_width) / 2 ) self.centre_group.set_x(new_x) + """ def set_details(self, detail): self.detail.set_text(detail) diff --git a/interfaces/MenuItem.py b/interfaces/MenuItem.py index e93afe3..465db69 100644 --- a/interfaces/MenuItem.py +++ b/interfaces/MenuItem.py @@ -46,9 +46,9 @@ class MenuItem (clutter.Label): def add_image_from_path(self, path, x, y, width=None, height=None): - tempTexture = clutter.Texture() + tempTexture = cluttergtk.Texture() pixbuf = gtk.gdk.pixbuf_new_from_file(path) - tempTexture.set_pixbuf(pixbuf) + tempTexture.set_from_pixbuf(pixbuf) if not width is None: tempTexture.set_width(width) if not height is None: tempTexture.set_height(height) @@ -61,10 +61,10 @@ class MenuItem (clutter.Label): if texture is None: print "NO TEXTURE!" - pixbuf = texture.get_pixbuf() + #pixbuf = texture.get_pixbuf() size = self.menu.menu_image_size reflection = self.menu.use_reflection - texture = ImageFrame(pixbuf, size, reflection) + #texture = ImageFrame(pixbuf, size, reflection) #Rotate appropriately """ diff --git a/modules/dvd_player/dvd_player.py b/modules/dvd_player/dvd_player.py index b5f742e..68b0555 100644 --- a/modules/dvd_player/dvd_player.py +++ b/modules/dvd_player/dvd_player.py @@ -1,5 +1,5 @@ import clutter -from clutter import cluttergst +import cluttergst from multimedia.VideoController import VideoController class Module: diff --git a/modules/music_player/music_player.py b/modules/music_player/music_player.py index 23337c9..5f6f9c9 100644 --- a/modules/music_player/music_player.py +++ b/modules/music_player/music_player.py @@ -44,6 +44,7 @@ class Module: print "Music DB Version error: Expected version %s, found version %s" % (self.required_schema_version, dbSchema) print "Music Player will not be available" self.version_check = False + self.setup_ui() return self.artistImageRow = MusicObjectRow(self.glossMgr, self.stage.get_width(), 200, self.num_columns, self) diff --git a/modules/myth_tv_player/myth_tv_player.py b/modules/myth_tv_player/myth_tv_player.py index e5cc2e8..a978524 100644 --- a/modules/myth_tv_player/myth_tv_player.py +++ b/modules/myth_tv_player/myth_tv_player.py @@ -5,7 +5,7 @@ import os import clutter import gobject -from clutter import cluttergst +import cluttergst from modules.myth_tv_player.MythBackendConn import MythBackendConnection from modules.myth_tv_player.tv_db_controller import tv_db_controller from SplashScr import SplashScr diff --git a/modules/slideshow/slideshow.py b/modules/slideshow/slideshow.py deleted file mode 100644 index cd386c8..0000000 --- a/modules/slideshow/slideshow.py +++ /dev/null @@ -1,490 +0,0 @@ -import clutter -from clutter import cluttergst -from ui_elements.image_preview import image_previewer -import time -import os.path -import pygtk -import gtk -import random -#import thread - -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? - imageDuration = 7 # In seconds - effect_FPS = 50 - - max_percent_of_stage = 0.75 # The maximum percentage of the stage size that images can be - - def __init__(self, glossMgr, dbMgr): - self.glossMgr = glossMgr - self.setup_ui() - self.currentSong = None - self.paused = False - self.textures = [] - self.music = [] - self.overlay = clutter.Rectangle() - self.backdrop = None - - #Load the base image directory. This is pulled from the myth db's settings table - self.baseDir = dbMgr.get_setting('GalleryDir') - - def setup_ui(self): - self.menu_image = self.glossMgr.themeMgr.get_texture("slideshow_menu_image", None, None) - - #Need to get/set the size of the preview images - element = self.glossMgr.themeMgr.search_docs("preview_image", "main").childNodes - (self.preview_width, self.preview_height) = self.glossMgr.themeMgr.get_dimensions(element, self.glossMgr.stage) - - - def action(self): - return self.generateMenu() - - def on_key_press_event (self, stage, event): - #print event.hardware_keycode - if event.keyval == clutter.keysyms.p: - if self.paused: - self.unpause() - else: - self.pause() - if event.keyval == clutter.keysyms.q: - clutter.main_quit() - if event.keyval == clutter.keysyms.Escape: - return True - - def loadDir(self, dirPath, recurse): - if not os.path.isdir(dirPath): - print "ERROR: Invalid path" - return None - - new_file_list = os.listdir(dirPath) - - #If recursive sub-dirs is on, loop through any directories - if recurse: - for fs_object in new_file_list: - path = dirPath + "/" + fs_object - if os.path.isdir(path): - self.loadDir(path, True) - - new_image_list = filter(self.filterImageFile, new_file_list) - new_sound_list = filter(self.filterSoundFile, new_file_list) - - #Load pictures into textures array - for pic in new_image_list: - imgName = dirPath + "/" + pic - self.textures.append(imgName) - - - #Load sound into music array - i = len(self.music) - for sound in new_sound_list: - self.music.append(cluttergst.Audio()) - sndName = dirPath + "/" + sound - self.music[i].set_filename(sndName) - i = i+1 - - #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 - elif fileName[0] == ".": - return False - else: - return True - - #This makes sure we only take in sound files - def filterSoundFile(self, fileName): - extension = fileName[-3:] #Get 3 letter extension - if extension in self.sound_file_types: - 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] == "."): - continue - 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): - - self.stage = self.glossMgr.get_stage() - self.currentTexture = clutter.Texture() - - #Set the maximum sizes of the images - self.max_height = int(self.stage.get_height() * self.max_percent_of_stage) - self.max_width = int(self.stage.get_width() * self.max_percent_of_stage) - - #Check for an empty baseDir, this means there are no slideshows or no db connection. We simply tell the menuMgr to go back a menu level when this occurs - if self.baseDir is None: - MenuMgr.go_up_x_levels(1) - return - #self.MenuMgr.get_selector_bar().set_spinner(True) - #self.stage.queue_redraw() - - #Clear out music and texture lists - self.textures = [] - self.music = [] - #Then load them back up - slideName = self.baseDir + "/" + self.menu.get_current_item().get_data() #self.glossMgr.get_current_menu().get_current_item().get_data() - self.loadDir(slideName, True) - - #Check if there actually are any images, quit if there aren't - if len(self.textures) == 0: - glossMgr.display_msg("Slideshow", "Directory is empty") - if glossMgr.currentMenu.get_opacity() > 0: - self.timeline_stop = clutter.Timeline(10,30) - alpha = clutter.Alpha(self.timeline_stop, clutter.ramp_inc_func) - self.stop_behaviour = clutter.BehaviourOpacity(opacity_start=0, opacity_end=255, alpha=alpha) - self.stop_behaviour.apply(glossMgr.currentMenu) - glossMgr.currentMenu.show() - self.timeline_stop.start() - glossMgr.currentPlugin = None - return - - if self.backdrop == None: - #Create a rectangle that serves as the backdrop for the slideshow - self.backdrop = clutter.Rectangle() - self.backdrop.set_color(clutter.color_parse('Black')) - self.backdrop.set_width(self.stage.get_width()) - self.backdrop.set_height(self.stage.get_height()) - self.stage.add(self.backdrop) - #Fade the backdrop in - #self.image_texture_group.set_opacity(255) - self.backdrop.set_opacity(0) - self.backdrop.show() - timeline_backdrop = clutter.Timeline(10,30) - alpha = clutter.Alpha(timeline_backdrop, clutter.ramp_inc_func) - self.backdrop_behaviour = clutter.BehaviourOpacity(opacity_start=0, opacity_end=255, alpha=alpha) - self.menu_behaviour = clutter.BehaviourOpacity(opacity_start=255, opacity_end=0, alpha=alpha) - self.backdrop_behaviour.apply(self.backdrop) - #self.menu_behaviour.apply(self.menu.getItemGroup()) - timeline_backdrop.start() - - - #print "No of children: " + str(self.image_texture_group.get_n_children()) - #Get a random texture - self.currentFilename = "" - self.currentTexture = self.get_rand_texture() - - (x_pos, y_pos) = self.get_random_coords(self.currentTexture) - self.currentTexture.set_position(x_pos, y_pos) - - self.stage.add(self.currentTexture) - #Make sure its visible - self.currentTexture.set_opacity(255) - - #Get a random song (if there's songs available) - if not len(self.music) == 0: - self.rand1 = random.randint(0, len(self.music)-1) - self.currentSong = self.music[self.rand1] - self.playNextSong(None) - - #Housekeeping - self.nextSong = None - - #Begin the show - self.currentTexture.show() - self.nextImage(self.currentTexture) - - def end(self): - pass - - - def nextImage(self, currentTexture): - #Setup stuff for KEN BURNS EFFECT!! - self.timeline_main = clutter.Timeline((self.effect_FPS * self.imageDuration), self.effect_FPS) - self.timeline_main.connect('completed', self.image_timeline_end_event) - self.alpha = clutter.Alpha(self.timeline_main, clutter.ramp_inc_func) - - #Decide on the next texture to use - self.nextTexture = self.get_rand_texture() - - - #Make sure its not visible initially (Prevents a nasty flicker the first time a photo is shown) - self.nextTexture.set_opacity(0) - - #Zooming stuff - rand_zoom = random.uniform(1,1.3) # Zoom somewhere between 1 and 1.3 times - self.behaviour1 = clutter.BehaviourScale(x_scale_start=1, y_scale_start=1, x_scale_end=rand_zoom, y_scale_end=rand_zoom, alpha=self.alpha) - #self.behaviour1.set_property("scale-gravity", clutter.GRAVITY_CENTER) #As at Clutter r1807 you cannot set the gravity on the line above. - - #panning stuff - x_pos = self.currentTexture.get_x() + random.randint(-100, 100) - y_pos = self.currentTexture.get_y() + random.randint(-100, 100) - self.alpha = clutter.Alpha(self.timeline_main, clutter.ramp_inc_func) - - knots = (\ - (self.currentTexture.get_x(), self.currentTexture.get_y()),\ - (x_pos, y_pos)\ - ) - self.behaviour2 = clutter.BehaviourPath(self.alpha, knots) - - - #Start and run the Ken Burns effect - self.behaviour1.apply(self.currentTexture) - self.behaviour2.apply(self.currentTexture) - self.timeline_main.start() - - #Just gets a random texture - def get_rand_texture(self): - self.nextTexture = None - while (self.nextTexture == None): - self.rand1 = random.randint(0, len(self.textures)-1 ) - self.newFilename = self.textures[self.rand1] - #Make sure we don't show the same photo twice - if (self.newFilename == self.currentFilename) and (len(self.textures) > 1): - self.nextTexture = None - else: - self.nextTexture = clutter.Texture() - pixbuf = gtk.gdk.pixbuf_new_from_file(self.newFilename) - self.currentFilename = self.newFilename - - #Do a check on the size of the image - if (pixbuf.get_width() > self.max_width) or (pixbuf.get_height() > self.max_height): - #Resize as necesary - xy_ratio = float(pixbuf.get_width()) / pixbuf.get_height() - if pixbuf.get_width() > pixbuf.get_height(): - width = self.max_width - height = int(width / xy_ratio) - else: - height = self.max_height - width = int(xy_ratio * height) - - pixbuf = pixbuf.scale_simple(width, height, gtk.gdk.INTERP_BILINEAR) - - self.nextTexture.set_pixbuf(pixbuf) - - return self.nextTexture - - def image_timeline_end_event(self, data): - #Add the timeline for the dissolve at the end - self.timeline_dissolve = clutter.Timeline(30,30) - self.timeline_dissolve.connect('completed', self.dissolve_timeline_end_event) - self.alpha_dissolve = clutter.Alpha(self.timeline_dissolve, clutter.ramp_inc_func) - - #Setup the dissolve to the next image - self.behaviour3 = clutter.BehaviourOpacity(opacity_start=255, opacity_end=0, alpha=self.alpha_dissolve) - self.behaviour4 = clutter.BehaviourOpacity(opacity_start=0, opacity_end=255, alpha=self.alpha_dissolve) - - self.behaviour3.apply(self.currentTexture) - self.behaviour4.apply(self.nextTexture) - - #Pick a random spot for the next image - #x_pos = random.randint(0, abs(self.stage.get_width() - self.nextTexture.get_width()) ) #Somewhere between 0 and (stage_width-image_width) - #y_pos = random.randint(0, abs(self.stage.get_height() - self.nextTexture.get_height()) ) - #Messy stuff because of damned gravity messup in 0.5 - (x_pos, y_pos) = self.get_random_coords(self.nextTexture) - #print "pic pos: " + str(x_pos) + ":" + str(y_pos) - - - self.oldTexture = self.currentTexture - self.currentTexture = self.nextTexture - self.currentTexture.set_anchor_point_from_gravity(clutter.GRAVITY_CENTER) - self.currentFilename = self.newFilename - self.stage.add(self.currentTexture) - self.nextTexture.set_position(x_pos, y_pos) - self.nextTexture.show() - self.timeline_dissolve.start() - self.nextImage(self.currentTexture) - - def get_random_coords(self, texture): - x_pos = random.randint(texture.get_width()/2, (self.stage.get_width() - texture.get_width()/2) ) #Somewhere between 0 and (stage_width-image_width) - y_pos = random.randint(texture.get_height()/2, (self.stage.get_height() - texture.get_height()/2) ) - - return (x_pos, y_pos) - - def dissolve_timeline_end_event(self, data): - self.stage.remove(self.oldTexture) - - #Begins playing a new song - def playNextSong(self, data): - self.nextSong = None - #Check first that there actually is music - if len(self.music) == 0: - return None - - #Decide on the next song to play - while self.nextSong == None: - self.rand1 = random.randint(0, len(self.music)-1) - self.nextSong = self.music[self.rand1] - #Make sure we don't play the same song twice - if (self.nextSong == self.currentSong) and (len(self.music) > 1): - self.nextSong = None - - self.currentSong = self.nextSong - self.currentSong.set_playing(True) - self.currentSong.connect('eos', self.playNextSong) - - def pause(self): - self.paused = True - - #Use the overlay to go over show - self.overlay.set_color(clutter.color_parse('Black')) - self.overlay.set_width(self.stage.get_width()) - self.overlay.set_height(self.stage.get_height()) - self.overlay.set_opacity(0) - self.overlay.show() - #self.overlay.raise_top() - #self.image_texture_group.lower(self.overlay) - self.stage.add(self.overlay) - #Fade the backdrop in - timeline_overlay = clutter.Timeline(10,30) - alpha = clutter.Alpha(timeline_overlay, clutter.ramp_inc_func) - overlay_behaviour = clutter.BehaviourOpacity(alpha, 0, 100) - overlay_behaviour2 = clutter.BehaviourOpacity(alpha, 255, 100) #Used on the backdrop - overlay_behaviour3 = clutter.BehaviourOpacity(alpha, 255, 0) #Used on the current texture - overlay_behaviour.apply(self.overlay) - overlay_behaviour2.apply(self.backdrop) - overlay_behaviour3.apply(self.currentTexture) - timeline_overlay.start() - - #Pause the main slideshow - self.timeline_main.pause() - - #Pause any music - if not self.currentSong == None: - if self.currentSong.get_playing(): - self.currentSong.set_playing(False) - - def unpause(self): - self.paused = False - - #Fade the backdrop in - timeline_overlay = clutter.Timeline(10,30) - alpha = clutter.Alpha(timeline_overlay, clutter.ramp_inc_func) - overlay_behaviour = clutter.BehaviourOpacity(alpha, 100, 0) - overlay_behaviour2 = clutter.BehaviourOpacity(alpha, 100, 255) #Used on the backdrop - overlay_behaviour3 = clutter.BehaviourOpacity(alpha, 0, 255) #Used on the current texture - overlay_behaviour.apply(self.overlay) - overlay_behaviour2.apply(self.backdrop) - overlay_behaviour3.apply(self.currentTexture) - timeline_overlay.start() - - #Resume the main slideshow - self.timeline_main.start() - - #Resume any music - if not self.currentSong == None: - self.currentSong.set_playing(True) - - def stop(self): - #Stop any running timelines - self.timeline_main.stop() - - #Fade everything out - timeline_stop = clutter.Timeline(10,30) - alpha = clutter.Alpha(timeline_stop, clutter.ramp_inc_func) - self.stop_behaviour = clutter.BehaviourOpacity(opacity_start=255, opacity_end=0, alpha=alpha) - self.menu_behaviour = clutter.BehaviourOpacity(opacity_start=0, opacity_end=255, alpha=alpha) - self.stop_behaviour.apply(self.currentTexture) - self.stop_behaviour.apply(self.backdrop) - self.stop_behaviour.apply(self.overlay) - #self.menu_behaviour.apply(self.menu.getItemGroup()) - timeline_stop.connect('completed', self.destroySlideshow) - timeline_stop.start() - - #Stop any music - if not self.currentSong == None: - if self.currentSong.get_playing(): - self.currentSong.set_playing(False) - self.currentSong.set_position(0) - - - def destroySlideshow(self, data): - self.stage.remove(self.currentTexture) - #self.stage.remove(self.nextTexture) - self.backdrop.hide() - #self.stage.remove(self.overlay) - - self.currentTexture = None - self.nextTexture = None - self.currentSong = None - self.nexttSong = None - - #The following generates a menu with an option for each of the slideshows in the base menu - def generateMenu(self): - tempMenu = self.glossMgr.create_menu() #Menu(self.glossMgr) - - self.menu = tempMenu - - #print self.baseDir - #This occurs when there are not slideshows or we could not connect to the db to establish baseDir - if self.baseDir is None: - tempItem = tempMenu.addItem("No slideshows available") - tempItem.setAction(self) - return - - try: - file_list = os.listdir(self.baseDir) - except os.error, (errno, errstr): - self.glossMgr.display_msg("File Error", "Could not load Slideshow directory") - return - - for directoryEntry in file_list: - subdir = self.baseDir + "/" + directoryEntry - if os.path.isdir(subdir): - - tempItem = tempMenu.addItem(directoryEntry) - - #Start experimental schtuff (MESSY!!!) - img_list = os.listdir(subdir) - img_list_temp = [] - for img in img_list: - if img[0] == ".": continue - img = subdir + "/" + img - img_list_temp.append(img) - img_list = img_list_temp - img_list.extend(self.os_listdir_recursive(subdir, showHidden = False)) - #Attempt to get the thumbnail images - #print img_list - - 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): - img_previewer.set_max_img_dimensions(self.preview_width, self.preview_height) - - preview_count = 0 - for img in img_list: - #imgPath = subdir + "/" + img #os.listdir(subdir)[0] - imgPath = img - #print imgPath - - #Only add a max of 15 images to the previewer - if preview_count < 10: - img_previewer.add_texture(imgPath) - preview_count += 1 - - #new_file_list = os.listdir(dirPath) - if tempMenu.usePreviewEffects: - tempItem.menu_item.itemTexturesGroup = img_previewer - img_previewer.set_position(tempItem.menu.menu_image_x, tempItem.menu.menu_image_y) - else: - if not len(img_list) == 0: - tempItem.add_image_from_path(imgPath, 0, 0, self.preview_width, self.preview_height) - - tempItem.setAction(self) - - tempMenu.selectFirst() - return tempMenu - diff --git a/modules/tests/tests.py b/modules/tests/tests.py index 9c1a3c5..bd27012 100644 --- a/modules/tests/tests.py +++ b/modules/tests/tests.py @@ -1,5 +1,5 @@ import clutter -from clutter import cluttergst +import cluttergst from ui_elements.image_preview import image_previewer import time import os.path diff --git a/modules/video_player/video_player.py b/modules/video_player/video_player.py index 2e99cd9..b2c2853 100644 --- a/modules/video_player/video_player.py +++ b/modules/video_player/video_player.py @@ -4,7 +4,7 @@ import gobject import pango import clutter import os -from clutter import cluttergst +import cluttergst from multimedia.VideoController import VideoController from modules.video_player.elements.cover_viewer import coverViewer from modules.video_player.elements.video_details import video_details diff --git a/multimedia/AudioController.py b/multimedia/AudioController.py index 6fe20f2..6d475b9 100644 --- a/multimedia/AudioController.py +++ b/multimedia/AudioController.py @@ -1,4 +1,11 @@ -import sys, clutter, clutter.cluttergst, gst, pygst, gtk, pygtk, gobject +import sys +import clutter +import cluttergst +import gst +import pygst +import gtk +import pygtk +import gobject import threading import os from multimedia.MediaController import MediaController @@ -10,7 +17,7 @@ class AudioController(MediaController): self.isPlaying = False # Primary audio object - self.audio = clutter.cluttergst.Audio() + self.audio = cluttergst.Audio() self.audio.connect("eos", self.stream_complete) self.media_element = self.audio diff --git a/multimedia/VideoController.py b/multimedia/VideoController.py index 766f77a..bc2f407 100644 --- a/multimedia/VideoController.py +++ b/multimedia/VideoController.py @@ -1,4 +1,10 @@ -import sys, clutter, clutter.cluttergst, gst, pygst, gtk, pygtk, gobject +import sys, clutter +import cluttergst +import gst +import pygst +import gtk +import pygtk +import gobject import threading import os from multimedia.MediaController import MediaController @@ -11,9 +17,9 @@ class VideoController(MediaController): self.blackdrop = None # Primary video texture & sink definition - self.video_texture = clutter.cluttergst.VideoTexture() + self.video_texture = cluttergst.VideoTexture() self.media_element = self.video_texture - self.video_sink = clutter.cluttergst.VideoSink(self.video_texture) + self.video_sink = cluttergst.VideoSink(self.video_texture) self.video_texture.connect('size-change', self.set_fullscreen) self.video_texture.set_position(0,0) diff --git a/myth/MythMySQL.py b/myth/MythMySQL.py index e6b0d6a..43c8041 100644 --- a/myth/MythMySQL.py +++ b/myth/MythMySQL.py @@ -58,12 +58,16 @@ class mythDB(): return True + #Runs arbitary sql. Returns an empty array if there's a problem def run_sql(self, sql): if not self.connected: print "Unable to perform lookup, could not establish connection to SQL server" return None - self.cursor.execute(sql) + try: + self.cursor.execute(sql) + except: + return [] # get the resultset as a tuple result = self.cursor.fetchall() return result diff --git a/ui_elements/ReflectionTexture.py b/ui_elements/ReflectionTexture.py index 404116b..cb548be 100644 --- a/ui_elements/ReflectionTexture.py +++ b/ui_elements/ReflectionTexture.py @@ -1,7 +1,7 @@ import cairo import clutter import gtk -from clutter.cluttercairo import CairoTexture +from cluttercairo import CairoTexture class Texture_Reflection (CairoTexture): diff --git a/ui_elements/Spinner.py b/ui_elements/Spinner.py index 8c8d02a..fe91c61 100644 --- a/ui_elements/Spinner.py +++ b/ui_elements/Spinner.py @@ -1,15 +1,16 @@ +import cluttergtk import clutter import gtk -class Spinner (clutter.Texture): +class Spinner (cluttergtk.Texture): def __init__(self, glossMgr): - clutter.Texture.__init__ (self) + cluttergtk.Texture.__init__ (self) #Theme me please theme = glossMgr.themeMgr.currentTheme pixbuf = gtk.gdk.pixbuf_new_from_file("themes/%s/spinner.svg" % theme) - self.set_pixbuf(pixbuf) + self.set_from_pixbuf(pixbuf) def start(self): self.timeline = clutter.Timeline(40,20) diff --git a/ui_elements/gloss_texture.py b/ui_elements/gloss_texture.py new file mode 100644 index 0000000..51258b7 --- /dev/null +++ b/ui_elements/gloss_texture.py @@ -0,0 +1,22 @@ +import pygtk +import gtk +import clutter +import cluttergtk + +######################################################## + +######################################################## +class GlossTexture(cluttergtk.Texture): + pixbuf = None + + def __init__(self): + cluttergtk.Texture.__init__(self) + print "loading" + + def set_from_pixbuf(self, pixbuf): + self.pixbuf = pixbuf + cluttergtk.Texture.set_from_pixbuf(self, pixbuf) + + def get_pixbuf(self): + return self.pixbuf + \ No newline at end of file diff --git a/ui_elements/image_frame.py b/ui_elements/image_frame.py index f3715a0..4d1feab 100644 --- a/ui_elements/image_frame.py +++ b/ui_elements/image_frame.py @@ -1,6 +1,7 @@ import pygtk import gtk import pango +import cluttergtk import clutter import os from ui_elements.ReflectionTexture import Texture_Reflection @@ -20,11 +21,11 @@ class ImageFrame(clutter.Group): self.orig_pixbuf = pixbuf - self.main_pic = clutter.Texture() + self.main_pic = cluttergtk.Texture() self.reflection = None #self.reflection = Texture_Reflection(self.main_pic) - self.set_pixbuf(pixbuf) + self.set_from_pixbuf(pixbuf) self.add(self.main_pic) def resize_pixbuf(self, pixbuf): @@ -66,7 +67,7 @@ class ImageFrame(clutter.Group): return pixbuf - def set_pixbuf(self, pixbuf): + def set_from_pixbuf(self, pixbuf): self.orig_pixbuf = pixbuf if pixbuf is None: self.main_pic.hide() @@ -74,7 +75,7 @@ class ImageFrame(clutter.Group): return else: self.pixbuf = self.resize_pixbuf(pixbuf) - self.main_pic.set_pixbuf(self.pixbuf) + self.main_pic.set_from_pixbuf(self.pixbuf) self.main_pic.set_position(self.x, self.y) self.main_pic.show() diff --git a/ui_elements/rounded_rectangle.py b/ui_elements/rounded_rectangle.py index 8dd99ea..da0311f 100644 --- a/ui_elements/rounded_rectangle.py +++ b/ui_elements/rounded_rectangle.py @@ -1,7 +1,7 @@ import cairo import clutter import gtk -from clutter.cluttercairo import CairoTexture +from cluttercairo import CairoTexture """ This element is a Clutter Group that displays as a rectangle of arbitary size diff --git a/utils/themeMgr.py b/utils/themeMgr.py index 00a4748..392221a 100644 --- a/utils/themeMgr.py +++ b/utils/themeMgr.py @@ -1,11 +1,14 @@ import os +#import cluttergtk import clutter import pygtk import gtk from ui_elements.image_frame import ImageFrame from ui_elements.rounded_rectangle import RoundedRectangle +from ui_elements.gloss_texture import GlossTexture from xml.dom import minidom + class ThemeMgr: theme_dir = "themes/" @@ -179,8 +182,11 @@ class ThemeMgr: (width, height) = self.get_dimensions(element, parent) if (not height is None) and (not height == "default"): if height == "relative": - xy_ratio = float(actor.get_height()) / float(actor.get_width()) - height = int(width * xy_ratio) + if actor.get_width() == 0: + height = 0 + else: + xy_ratio = float(actor.get_height()) / float(actor.get_width()) + height = int(width * xy_ratio) actor.set_height(height) if (not width is None) and (not width == "default"): actor.set_width(width) @@ -304,7 +310,7 @@ class ThemeMgr: def get_texture(self, name, parent=None, texture=None, element=None): texture_src = None if texture is None: - texture = clutter.Texture() + texture = GlossTexture() if parent is None: parent = self.stage @@ -323,7 +329,7 @@ class ThemeMgr: elif not src is None: src = self.theme_dir + self.currentTheme + "/" + src pixbuf = gtk.gdk.pixbuf_new_from_file(src) - texture.set_pixbuf(pixbuf) + texture.set_from_pixbuf(pixbuf) elif not rect is None: colour_element = self.search_docs("texture", name).getElementsByTagName("texture") colour_element = self.find_element(colour_element, "id", "rect_colour")