From e72f4798f42ceb3e2696c423f746b3c5f1194c94 Mon Sep 17 00:00:00 2001 From: noisymime Date: Mon, 9 Jun 2008 12:07:31 +0000 Subject: [PATCH] - Sanitising the menu image loading code --- gloss.py | 4 +- interfaces/ListMenu/ListMenu.py | 32 +++----- interfaces/MenuItem.py | 24 +++--- myth/MythMySQL.py | 6 +- themes/Pear/main.xml | 24 +++--- themes/default/main.xml | 31 ++++---- themes/default/music.xml | 112 --------------------------- themes/default/music_play_screen.xml | 95 ----------------------- utils/themeMgr.py | 2 +- 9 files changed, 53 insertions(+), 277 deletions(-) delete mode 100644 themes/default/music.xml delete mode 100644 themes/default/music_play_screen.xml diff --git a/gloss.py b/gloss.py index 8e7a0e6..04fe166 100644 --- a/gloss.py +++ b/gloss.py @@ -55,7 +55,9 @@ class MainApp: #Create a master mySQL connection self.dbMgr = mythDB() if not self.dbMgr.connected: + self.connected = False return + self.connected = True #Do an initial lookup for GUI size width = int(self.dbMgr.get_setting("GuiWidth")) @@ -139,7 +141,7 @@ def main (args): app = MainApp(args) #app.loadGloss() - app.run() + if app.connected: app.run() return 0 diff --git a/interfaces/ListMenu/ListMenu.py b/interfaces/ListMenu/ListMenu.py index 399e971..e787a9a 100644 --- a/interfaces/ListMenu/ListMenu.py +++ b/interfaces/ListMenu/ListMenu.py @@ -4,7 +4,8 @@ import gtk import pango import time import math -from ui_elements.ReflectionTexture import Texture_Reflection +from ui_elements.image_frame import ImageFrame +#from ui_elements.ReflectionTexture import Texture_Reflection from interfaces.MenuItem import MenuItem from utils.InputQueue import InputQueue @@ -66,30 +67,15 @@ class Interface(clutter.Group): menu.opacityStep2 = int(themeMgr.find_child_value(element, "opacity_step2")) #setup the menu_image properties - menu.useReflection = "True" == (themeMgr.find_child_value(element, "menu_item_texture.use_image_reflections")) - menu.menu_image_rotation = int(themeMgr.find_child_value(element, "menu_item_texture.image_y_rotation")) - menu_image_node = themeMgr.get_subnode(element, "menu_item_texture") - if not menu_image_node is None: - #Set the position - (x, y) = themeMgr.get_position(menu_image_node, self.stage) - menu.menu_image_x = int(x) - menu.menu_image_y = int(y) - - """ - #Set the size - (width, height) = self.get_dimensions(menu_image_node, self.stage) - if width is None: - print "no size change" - menu.menu_image_width = None - menu.menu_image_height = None - else: - menu.menu_image_width = int(width) - menu.menu_image_height = int(height) - """ + tmp_frame = themeMgr.get_imageFrame("menu_item_texture") + self.menu_image_size = int(tmp_frame.img_size) + self.use_reflection = tmp_frame.use_reflection + self.menu_image_x = tmp_frame.get_x() + self.menu_image_y = tmp_frame.get_y() #Setup the menu image transition - image_transition = themeMgr.find_child_value(element, "menu_item_texture.image_transition.name") - transition_options = themeMgr.find_child_value(element, "menu_item_texture.image_transition.options") + image_transition = themeMgr.find_child_value(element, "image_transition.name") + transition_options = themeMgr.find_child_value(element, "image_transition.options") transition_path = "transitions/menu_items/" + str(image_transition) try: menu.menu_item_transition = __import__(transition_path).Transition(self.glossMgr) diff --git a/interfaces/MenuItem.py b/interfaces/MenuItem.py index f215e27..46c08ee 100644 --- a/interfaces/MenuItem.py +++ b/interfaces/MenuItem.py @@ -2,7 +2,7 @@ import clutter import pango import gtk import pygtk -from ui_elements.ReflectionTexture import Texture_Reflection +from ui_elements.image_frame import ImageFrame class MenuItem (clutter.Label): zoomLevel = 0.5 @@ -50,7 +50,7 @@ class MenuItem (clutter.Label): self.onStage = False - def add_image_from_path(self, path, x, y, width = None, height = None): + 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) @@ -66,26 +66,20 @@ class MenuItem (clutter.Label): if texture is None: print "NO TEXTURE!" if self.main_texture is None: self.main_texture = texture - """ - Removing as this is currently already handled in individual module files - #Set the image to the size in the theme - if not self.menu.menu_image_height is None: - texture.set_height(self.menu.menu_image_height) - if not self.menu.menu_image_width is None: - texture.set_width(self.menu.menu_image_width) - """ + + pixbuf = texture.get_pixbuf() + size = self.menu.menu_image_size + reflection = self.menu.use_reflection + texture = ImageFrame(pixbuf, size, reflection) #Rotate appropriately + """ rotation = self.menu.menu_image_rotation x_rotation = (texture.get_width()) texture.set_rotation(clutter.Y_AXIS, rotation, x_rotation, 0, 0) + """ self.itemTexturesGroup.add(texture) - #If reflection is turned on in the theme, add a reflection texture - if self.menu.useReflection: - self.reflectionTexture = Texture_Reflection(texture) - self.itemTexturesGroup.add(self.reflectionTexture) - self.itemTexturesGroup.show_all() def set_data(self, data): diff --git a/myth/MythMySQL.py b/myth/MythMySQL.py index 61e8be9..4935ab8 100644 --- a/myth/MythMySQL.py +++ b/myth/MythMySQL.py @@ -19,7 +19,7 @@ class mythDB(): print "Error %d: %s" % (e.args[0], e.args[1]) clutter.main_quit() self.connected = False - return None + return self.cursor = self.db.cursor() @@ -37,9 +37,9 @@ class mythDB(): if not os.path.exists(conf_file): conf_file = "/etc/mythtv/mysql.txt" if not os.path.exists(conf_file): - print "ERROR: No config file found at ~/.mythtv/mysql.txt!" + print "ERROR: No config file found at ~/.mythtv/mysql.txt or /etc/mythtv/mysql.txt!" print "No connection to MythTV Database can be made. Quitting" - clutter.main_quit() + #clutter.main_quit() return False f=open(conf_file, 'r') diff --git a/themes/Pear/main.xml b/themes/Pear/main.xml index 9c82134..39768c3 100644 --- a/themes/Pear/main.xml +++ b/themes/Pear/main.xml @@ -22,21 +22,23 @@ 0 4 - - - 0 - 0 - - ring - None - - + + + + 40% + relative + - 5% + 8% 20% - + False + + + ring + None + diff --git a/themes/default/main.xml b/themes/default/main.xml index 226a3d5..7a93ea6 100644 --- a/themes/default/main.xml +++ b/themes/default/main.xml @@ -22,24 +22,23 @@ 0 6 - - - True - 45 - - fade - None - - - - 5% - 30% - + + - 30% - 30% + 40% + relative - + + 8% + 20% + + + True + + + ring + None + diff --git a/themes/default/music.xml b/themes/default/music.xml deleted file mode 100644 index fe60d27..0000000 --- a/themes/default/music.xml +++ /dev/null @@ -1,112 +0,0 @@ - - - music/music.png - - 100% - relative - - - 0 - 0 - - - - - - Tahoma - 30 - 38 - 30 - 25 - - - - 40% - 40% - - - 40% - 50% - - - - 1.00 - - - 255 - 135 - 135 - 0.9 - 0.8 - 0.8 - - 30 - 10 - - - - - - - Tahoma - 30 - 38 - 30 - 25 - - - - 40% - 40% - - - 70% - 50% - - - - 1.00 - - - 255 - 135 - 135 - 0.9 - 0.8 - 0.8 - - 30 - 10 - - - - - music/default_cover.png - - - music/default_cover.png - - - - None - True - - - - 25% - 25% - - - 10% - 40% - - - diff --git a/themes/default/music_play_screen.xml b/themes/default/music_play_screen.xml deleted file mode 100644 index 7d56cf1..0000000 --- a/themes/default/music_play_screen.xml +++ /dev/null @@ -1,95 +0,0 @@ - - - - - Tahoma - 30 - 38 - 30 - 25 - - - - 40% - 40% - - - 50% - 25% - - - - 1.00 - - - 255 - 135 - 135 - 1 - 1 - 1 - - 30 - 10 - - - music/songlist_off.png - - 100% - 100% - - - 0 - 0 - - - - - up.png - - 3% - 3% - - - 0 - 0 - - - - - down.png - - 3% - 3% - - - 0 - 0 - - - music/songlist_off.png - - - - - - - None - True - - - - 30% - 30% - - - 10% - 35% - - - - diff --git a/utils/themeMgr.py b/utils/themeMgr.py index 125022f..770c5ae 100644 --- a/utils/themeMgr.py +++ b/utils/themeMgr.py @@ -358,7 +358,7 @@ class ThemeMgr: (width, height) = self.get_dimensions(element, self.stage) if (not width is None) and (not height is None): - if width > height: + if (width > height) or (height == "relative"): size = width else: size = height