- Added --theme option to startup
- Brought Gloxygen theme up to spec - Fixed bug in Message queue where focus was returned to GlossMgr too soon
This commit is contained in:
parent
cabfdccb4e
commit
69e390b1cf
|
@ -23,7 +23,7 @@ __version__= '0.1'
|
||||||
class GlossMgr:
|
class GlossMgr:
|
||||||
theme_dir = "themes/"
|
theme_dir = "themes/"
|
||||||
|
|
||||||
def __init__ (self, stage):
|
def __init__ (self, stage, dbMgr, theme=None):
|
||||||
self.stage = stage
|
self.stage = stage
|
||||||
self.menus = []
|
self.menus = []
|
||||||
self.menuHistory = [] #A list that contains menus in the order that they've been viewed
|
self.menuHistory = [] #A list that contains menus in the order that they've been viewed
|
||||||
|
@ -31,8 +31,9 @@ class GlossMgr:
|
||||||
self.debug = False #Debug flag
|
self.debug = False #Debug flag
|
||||||
self.ui_overide = None
|
self.ui_overide = None
|
||||||
self.uiMsg = Message(self)
|
self.uiMsg = Message(self)
|
||||||
|
self.dbMgr = dbMgr
|
||||||
|
|
||||||
self.themeMgr = ThemeMgr(self)
|
self.themeMgr = ThemeMgr(self, theme)
|
||||||
|
|
||||||
#Set the menu interface
|
#Set the menu interface
|
||||||
element = self.themeMgr.search_docs("menu", "main").childNodes
|
element = self.themeMgr.search_docs("menu", "main").childNodes
|
||||||
|
|
17
gloss.py
17
gloss.py
|
@ -85,18 +85,25 @@ class MainApp:
|
||||||
#clutter.threads_add_timeout(500, self.loadGloss())
|
#clutter.threads_add_timeout(500, self.loadGloss())
|
||||||
|
|
||||||
def loadGloss(self):
|
def loadGloss(self):
|
||||||
#Create the Gloss Manager
|
theme = None
|
||||||
self.glossMgr = GlossMgr(self.stage)
|
|
||||||
|
|
||||||
|
|
||||||
#loop through the args
|
#loop through the args
|
||||||
for arg in self.args:
|
for i in range(0, len(self.args)):
|
||||||
|
arg = self.args[i]
|
||||||
if arg == "--debug":
|
if arg == "--debug":
|
||||||
print "Using debug mode"
|
print "Using debug mode"
|
||||||
self.glossMgr.debug = True
|
self.glossMgr.debug = True
|
||||||
elif arg == "--tests":
|
elif arg == "--tests":
|
||||||
self.show_tests = True
|
self.show_tests = True
|
||||||
print "Showing tests"
|
print "Showing tests"
|
||||||
|
elif arg == "--theme":
|
||||||
|
theme = self.args[i+1]
|
||||||
|
print "Using theme %s" % theme
|
||||||
|
|
||||||
|
#Create the Gloss Manager
|
||||||
|
self.glossMgr = GlossMgr(self.stage, self.dbMgr, theme=theme)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#Update splash status msg
|
#Update splash status msg
|
||||||
self.splashScreen.set_msg("Creating menus")
|
self.splashScreen.set_msg("Creating menus")
|
||||||
|
|
|
@ -41,6 +41,10 @@ class Interface(clutter.Group):
|
||||||
def setup(self, themeMgr):
|
def setup(self, themeMgr):
|
||||||
element = themeMgr.search_docs("menu", "main").childNodes
|
element = themeMgr.search_docs("menu", "main").childNodes
|
||||||
|
|
||||||
|
#Sets the stages background colour
|
||||||
|
colour = themeMgr.get_colour(element, "menu", subnode=True)
|
||||||
|
if not colour is None: self.stage.set_color(colour)
|
||||||
|
|
||||||
#setup the menu_image properties
|
#setup the menu_image properties
|
||||||
tmp_frame = themeMgr.get_imageFrame("menu_item_texture")
|
tmp_frame = themeMgr.get_imageFrame("menu_item_texture")
|
||||||
self.menu_image_size = int(tmp_frame.img_size)
|
self.menu_image_size = int(tmp_frame.img_size)
|
||||||
|
@ -191,4 +195,7 @@ class MenuListItem (ListItem):
|
||||||
|
|
||||||
def get_item_textures(self):
|
def get_item_textures(self):
|
||||||
return self.menu_item.itemTexturesGroup
|
return self.menu_item.itemTexturesGroup
|
||||||
|
|
||||||
|
def get_text(self):
|
||||||
|
return self.menu_item.get_text()
|
||||||
|
|
|
@ -95,7 +95,12 @@ class mythDB():
|
||||||
print "Error: Could not establish connection to SQL server. Unable to obtain setting '" + setting_name + "'"
|
print "Error: Could not establish connection to SQL server. Unable to obtain setting '" + setting_name + "'"
|
||||||
return None
|
return None
|
||||||
|
|
||||||
sql = "INSERT INTO settings VALUES('%s', '%s', '%s')" % (setting, value, self.localHost)
|
#First check if the setting already exists and delete it if it does
|
||||||
|
if not self.get_setting(setting) is None:
|
||||||
|
sql = "DELETE FROM settings WHERE value = '%s' AND hostname = '%s'" % (setting, self.localHost)
|
||||||
|
self.cursor.execute(sql)
|
||||||
|
|
||||||
|
sql = "REPLACE INTO settings VALUES('%s', '%s', '%s')" % (setting, value, self.localHost)
|
||||||
self.cursor.execute(sql)
|
self.cursor.execute(sql)
|
||||||
|
|
||||||
#Gets the backend server details, which, in theory, can be different from the SQL server details and/or default port
|
#Gets the backend server details, which, in theory, can be different from the SQL server details and/or default port
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<gloss-theme>
|
<gloss-theme>
|
||||||
<menu id="main">
|
<menu id="main">
|
||||||
<interface>ListMenu</interface>
|
<interface>ListMenu2</interface>
|
||||||
|
|
||||||
<font id="main">
|
<font id="main">
|
||||||
<face>Tahoma</face>
|
<face>Tahoma</face>
|
||||||
|
@ -9,7 +9,7 @@
|
||||||
<size id="800x600">30</size>
|
<size id="800x600">30</size>
|
||||||
<size id="1920x1080">25</size>
|
<size id="1920x1080">25</size>
|
||||||
</font>
|
</font>
|
||||||
|
|
||||||
<colour id="stage">
|
<colour id="stage">
|
||||||
<r>180</r>
|
<r>180</r>
|
||||||
<g>180</g>
|
<g>180</g>
|
||||||
|
@ -25,8 +25,57 @@
|
||||||
<y>30%</y>
|
<y>30%</y>
|
||||||
</position>
|
</position>
|
||||||
|
|
||||||
<item_gap>0</item_gap>
|
<label_list id="main_menu">
|
||||||
<num_visible_elements>4</num_visible_elements>
|
<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>60%</x>
|
||||||
|
<y>30%</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>50</opacity_step2>
|
||||||
|
<scale_step0>1</scale_step0>
|
||||||
|
<scale_step1>0.5</scale_step1>
|
||||||
|
<scale_step2>0.4</scale_step2>
|
||||||
|
|
||||||
|
<transition_fps>150</transition_fps>
|
||||||
|
<transition_frames>30</transition_frames>
|
||||||
|
|
||||||
|
<texture id="selector_bar">
|
||||||
|
<image>active_bar.png</image>
|
||||||
|
<!-- This is a special property of selector bar the sets the height of the bar relative to the menu items its selecting -->
|
||||||
|
<height_percent>1.20</height_percent>
|
||||||
|
<dimensions type="relativeToStage">
|
||||||
|
<width>40%</width>
|
||||||
|
<height>default</height>
|
||||||
|
</dimensions>
|
||||||
|
<position type="relativeToParent">
|
||||||
|
<x>-20</x>
|
||||||
|
<y>-1%</y>
|
||||||
|
</position>
|
||||||
|
</texture>
|
||||||
|
|
||||||
|
</label_list>
|
||||||
|
|
||||||
<!-- The following properties all relate to the image / textures that accompany each menu item -->
|
<!-- The following properties all relate to the image / textures that accompany each menu item -->
|
||||||
<image_frame id="menu_item_texture">
|
<image_frame id="menu_item_texture">
|
||||||
|
@ -46,15 +95,6 @@
|
||||||
<options>None</options>
|
<options>None</options>
|
||||||
</image_transition>
|
</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 -->
|
|
||||||
<opacity_step0>255</opacity_step0>
|
|
||||||
<opacity_step1>135</opacity_step1>
|
|
||||||
<opacity_step2>50</opacity_step2>
|
|
||||||
<scale_step0>1</scale_step0>
|
|
||||||
<scale_step1>0.5</scale_step1>
|
|
||||||
<scale_step2>0.4</scale_step2>
|
|
||||||
|
|
||||||
<!-- Used for transitioning between menus -->
|
<!-- Used for transitioning between menus -->
|
||||||
<menu_transition>
|
<menu_transition>
|
||||||
<name>slide</name>
|
<name>slide</name>
|
||||||
|
|
|
@ -69,7 +69,7 @@ class Message():
|
||||||
self.detail.set_width(width)
|
self.detail.set_width(width)
|
||||||
self.message.set_width(width)
|
self.message.set_width(width)
|
||||||
|
|
||||||
box_height = self.message.get_height() + self.detail.get_height() + (self.message.get_y() - self.box.get_y())
|
box_height = self.message.get_height() + self.detail.get_height() + (self.message.get_y() - self.box.get_y())*2
|
||||||
if box_height > self.stage.get_height(): box_height = self.stage.get_height()
|
if box_height > self.stage.get_height(): box_height = self.stage.get_height()
|
||||||
self.box.set_height(box_height)
|
self.box.set_height(box_height)
|
||||||
box_y = int( (self.stage.get_height() - box_height) /2 )
|
box_y = int( (self.stage.get_height() - box_height) /2 )
|
||||||
|
@ -112,7 +112,8 @@ class Message():
|
||||||
if len(self.msgQueue) > 0:
|
if len(self.msgQueue) > 0:
|
||||||
(title, text) = self.msgQueue.pop()
|
(title, text) = self.msgQueue.pop()
|
||||||
self.display_msg(title, text)
|
self.display_msg(title, text)
|
||||||
|
else:
|
||||||
|
self.glossMgr.ui_overide = None
|
||||||
|
|
||||||
def on_key_press_event (self, stage, event):
|
def on_key_press_event (self, stage, event):
|
||||||
self.hide_msg()
|
self.hide_msg()
|
||||||
self.glossMgr.ui_overide = None
|
|
|
@ -10,16 +10,25 @@ class ThemeMgr:
|
||||||
|
|
||||||
defaultTheme = "default"
|
defaultTheme = "default"
|
||||||
currentTheme = "default"
|
currentTheme = "default"
|
||||||
currentTheme = "Pear"
|
currentTheme = "Gloxygen"
|
||||||
#currentTheme = "Mich"
|
|
||||||
#currentTheme = "Gloxygen"
|
|
||||||
|
|
||||||
def __init__(self, glossMgr):
|
def __init__(self, glossMgr, theme=None):
|
||||||
self.stage = glossMgr.stage
|
self.stage = glossMgr.stage
|
||||||
self.glossMgr = glossMgr
|
self.glossMgr = glossMgr
|
||||||
self.docs = []
|
self.docs = []
|
||||||
self.default_docs = []
|
self.default_docs = []
|
||||||
|
|
||||||
|
#Check the db for a theme setting, if it doesn't exist, we create an entry using the current theme
|
||||||
|
if not theme is None:
|
||||||
|
self.currentTheme = theme
|
||||||
|
glossMgr.dbMgr.set_setting("gloss_theme", self.currentTheme)
|
||||||
|
else:
|
||||||
|
db_theme = glossMgr.dbMgr.get_setting("gloss_theme")
|
||||||
|
if db_theme is None:
|
||||||
|
glossMgr.dbMgr.set_setting("gloss_theme", self.currentTheme)
|
||||||
|
else:
|
||||||
|
self.currentTheme = db_theme
|
||||||
|
|
||||||
current_theme_dir = self.theme_dir + self.currentTheme
|
current_theme_dir = self.theme_dir + self.currentTheme
|
||||||
self.importDocs(current_theme_dir, self.docs)
|
self.importDocs(current_theme_dir, self.docs)
|
||||||
#If the current theme is the default theme, we just use the one list, else create a second one
|
#If the current theme is the default theme, we just use the one list, else create a second one
|
||||||
|
|
Loading…
Reference in New Issue