- Sanitising the menu image loading code

This commit is contained in:
noisymime 2008-06-09 12:07:31 +00:00
parent a8360950be
commit e72f4798f4
9 changed files with 53 additions and 277 deletions

View File

@ -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

View File

@ -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)

View File

@ -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):

View File

@ -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')

View File

@ -22,21 +22,23 @@
<item_gap>0</item_gap>
<num_visible_elements>4</num_visible_elements>
<!-- The following properties all relate to the image / textures that accompany each menu item -->
<menu_item_texture>
<use_image_reflections>0</use_image_reflections>
<image_y_rotation>0</image_y_rotation>
<image_transition>
<name>ring</name>
<options>None</options>
</image_transition>
<!-- The following properties all relate to the image / textures that accompany each menu item -->
<image_frame id="menu_item_texture">
<dimensions type="relativeToStage">
<width>40%</width>
<height>relative</height>
</dimensions>
<position type="relativeToStage">
<x>5%</x>
<x>8%</x>
<y>20%</y>
</position>
</menu_item_texture>
<use_reflections>False</use_reflections>
</image_frame>
<image_transition>
<name>ring</name>
<options>None</options>
</image_transition>
<!-- These are the opacity and scale values for the 3 possible steps in the menu
Make all the values the same if you do not want these effects -->

View File

@ -22,24 +22,23 @@
<item_gap>0</item_gap>
<num_visible_elements>6</num_visible_elements>
<!-- The following properties all relate to the image / textures that accompany each menu item -->
<menu_item_texture>
<use_image_reflections>True</use_image_reflections>
<image_y_rotation>45</image_y_rotation>
<image_transition>
<name>fade</name>
<options>None</options>
</image_transition>
<position type="relativeToStage">
<x>5%</x>
<y>30%</y>
</position>
<!-- The following properties all relate to the image / textures that accompany each menu item -->
<image_frame id="menu_item_texture">
<dimensions type="relativeToStage">
<width>30%</width>
<height>30%</height>
<width>40%</width>
<height>relative</height>
</dimensions>
</menu_item_texture>
<position type="relativeToStage">
<x>8%</x>
<y>20%</y>
</position>
<use_reflections>True</use_reflections>
</image_frame>
<image_transition>
<name>ring</name>
<options>None</options>
</image_transition>
<!-- These are the opacity and scale values for the 3 possible steps in the menu
Make all the values the same if you do not want these effects -->

View File

@ -1,112 +0,0 @@
<gloss-theme>
<texture id="music_menu_image">
<image>music/music.png</image>
<dimensions type="relativeToSelf">
<width>100%</width>
<height>relative</height>
</dimensions>
<position type="relativeToParent">
<x>0</x>
<y>0</y>
</position>
</texture>
<label_list id="music_albums">
<font id="main">
<face>Tahoma</face>
<size id="default">30</size>
<size id="1024x768">38</size>
<size id="800x600">30</size>
<size id="1920x1080">25</size>
</font>
<dimensions type="relativeToStage">
<width>40%</width>
<height>40%</height>
</dimensions>
<position type="relativeToStage">
<x>40%</x>
<y>50%</y>
</position>
<!-- This determines the height of each item based on a percentage of the font size.
Eg: 1.00 means that each item will be the same height as the font,
1.50 means that the item will be 1.x times the height as the font etc
-->
<item_height_percent>1.00</item_height_percent>
<!-- These are the opacity and scale values for the 3 possible steps in the menu
Make all the values the same if you do not want these effects -->
<opacity_step0>255</opacity_step0>
<opacity_step1>135</opacity_step1>
<opacity_step2>135</opacity_step2>
<scale_step0>0.9</scale_step0>
<scale_step1>0.8</scale_step1>
<scale_step2>0.8</scale_step2>
<transition_fps>30</transition_fps>
<transition_frames>10</transition_frames>
</label_list>
<label_list id="music_songs">
<font id="main">
<face>Tahoma</face>
<size id="default">30</size>
<size id="1024x768">38</size>
<size id="800x600">30</size>
<size id="1920x1080">25</size>
</font>
<dimensions type="relativeToStage">
<width>40%</width>
<height>40%</height>
</dimensions>
<position type="relativeToStage">
<x>70%</x>
<y>50%</y>
</position>
<!-- This determines the height of each item based on a percentage of the font size.
Eg: 1.00 means that each item will be the same height as the font,
1.50 means that the item will be 1.x times the height as the font etc
-->
<item_height_percent>1.00</item_height_percent>
<!-- These are the opacity and scale values for the 3 possible steps in the menu
Make all the values the same if you do not want these effects -->
<opacity_step0>255</opacity_step0>
<opacity_step1>135</opacity_step1>
<opacity_step2>135</opacity_step2>
<scale_step0>0.9</scale_step0>
<scale_step1>0.8</scale_step1>
<scale_step2>0.8</scale_step2>
<transition_fps>30</transition_fps>
<transition_frames>10</transition_frames>
</label_list>
<texture id="music_default_artist_image">
<image>music/default_cover.png</image>
</texture>
<texture id="music_default_album_image">
<image>music/default_cover.png</image>
</texture>
<image_frame id="music_main_image">
<image>None</image>
<use_reflections>True</use_reflections>
<dimensions type="relativeToStage">
<width>25%</width>
<height>25%</height>
</dimensions>
<position type="relativeToStage">
<x>10%</x>
<y>40%</y>
</position>
</image_frame>
</gloss-theme>

View File

@ -1,95 +0,0 @@
<gloss-theme>
<label_list id="music_play_screen_songs">
<font id="main">
<face>Tahoma</face>
<size id="default">30</size>
<size id="1024x768">38</size>
<size id="800x600">30</size>
<size id="1920x1080">25</size>
</font>
<dimensions type="relativeToStage">
<width>40%</width>
<height>40%</height>
</dimensions>
<position type="relativeToStage">
<x>50%</x>
<y>25%</y>
</position>
<!-- This determines the height of each item based on a percentage of the font size.
Eg: 1.00 means that each item will be the same height as the font,
1.50 means that the item will be 1.x times the height as the font etc
-->
<item_height_percent>1.00</item_height_percent>
<!-- These are the opacity and scale values for the 3 possible steps in the menu
Make all the values the same if you do not want these effects -->
<opacity_step0>255</opacity_step0>
<opacity_step1>135</opacity_step1>
<opacity_step2>135</opacity_step2>
<scale_step0>1</scale_step0>
<scale_step1>1</scale_step1>
<scale_step2>1</scale_step2>
<transition_fps>30</transition_fps>
<transition_frames>10</transition_frames>
<texture id="inactive_background">
<image>music/songlist_off.png</image>
<dimensions type="relativeToParent">
<width>100%</width>
<height>100%</height>
</dimensions>
<position type="blah">
<x>0</x>
<y>0</y>
</position>
</texture>
<texture id="image_up">
<image>up.png</image>
<dimensions type="relativeToStage">
<width>3%</width>
<height>3%</height>
</dimensions>
<position type="relativeToSelf">
<x>0</x>
<y>0</y>
</position>
</texture>
<texture id="image_down">
<image>down.png</image>
<dimensions type="relativeToStage">
<width>3%</width>
<height>3%</height>
</dimensions>
<position type="blah">
<x>0</x>
<y>0</y>
</position>
</texture>
<inactive_background>music/songlist_off.png</inactive_background>
</label_list>
<image_frame id="music_playing_image">
<image>None</image>
<use_reflections>True</use_reflections>
<dimensions type="relativeToStage">
<width>30%</width>
<height>30%</height>
</dimensions>
<position type="relativeToStage">
<x>10%</x>
<y>35%</y>
</position>
</image_frame>
</gloss-theme>

View File

@ -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