diff --git a/GlossMgr.py b/GlossMgr.py index ca5836a..c158746 100644 --- a/GlossMgr.py +++ b/GlossMgr.py @@ -23,7 +23,7 @@ __version__= '0.1' class GlossMgr: theme_dir = "themes/" - def __init__ (self, stage): + def __init__ (self, stage, dbMgr, theme=None): self.stage = stage self.menus = [] 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.ui_overide = None self.uiMsg = Message(self) + self.dbMgr = dbMgr - self.themeMgr = ThemeMgr(self) + self.themeMgr = ThemeMgr(self, theme) #Set the menu interface element = self.themeMgr.search_docs("menu", "main").childNodes diff --git a/gloss.py b/gloss.py index 963a040..a8d9fa1 100644 --- a/gloss.py +++ b/gloss.py @@ -85,18 +85,25 @@ class MainApp: #clutter.threads_add_timeout(500, self.loadGloss()) def loadGloss(self): - #Create the Gloss Manager - self.glossMgr = GlossMgr(self.stage) - - + theme = None #loop through the args - for arg in self.args: + for i in range(0, len(self.args)): + arg = self.args[i] if arg == "--debug": print "Using debug mode" self.glossMgr.debug = True elif arg == "--tests": self.show_tests = True 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 self.splashScreen.set_msg("Creating menus") diff --git a/interfaces/ListMenu2/ListMenu2.py b/interfaces/ListMenu2/ListMenu2.py index 068e6fc..de4479d 100644 --- a/interfaces/ListMenu2/ListMenu2.py +++ b/interfaces/ListMenu2/ListMenu2.py @@ -41,6 +41,10 @@ class Interface(clutter.Group): def setup(self, themeMgr): 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 tmp_frame = themeMgr.get_imageFrame("menu_item_texture") self.menu_image_size = int(tmp_frame.img_size) @@ -191,4 +195,7 @@ class MenuListItem (ListItem): def get_item_textures(self): return self.menu_item.itemTexturesGroup + + def get_text(self): + return self.menu_item.get_text() \ No newline at end of file diff --git a/myth/MythMySQL.py b/myth/MythMySQL.py index 4935ab8..e6b0d6a 100644 --- a/myth/MythMySQL.py +++ b/myth/MythMySQL.py @@ -95,7 +95,12 @@ class mythDB(): print "Error: Could not establish connection to SQL server. Unable to obtain setting '" + setting_name + "'" 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) #Gets the backend server details, which, in theory, can be different from the SQL server details and/or default port diff --git a/themes/Gloxygen/main.xml b/themes/Gloxygen/main.xml index 3d4b6a8..3f6099b 100644 --- a/themes/Gloxygen/main.xml +++ b/themes/Gloxygen/main.xml @@ -1,6 +1,6 @@ - - ListMenu + + ListMenu2 Tahoma @@ -9,7 +9,7 @@ 30 25 - + 180 180 @@ -25,8 +25,57 @@ 30% - 0 - 4 + + + Tahoma + 30 + 38 + 30 + 25 + + + + 40% + 40% + + + 60% + 30% + + + + 1.00 + + + 255 + 135 + 50 + 1 + 0.5 + 0.4 + + 150 + 30 + + + active_bar.png + + 1.20 + + 40% + default + + + -20 + -1% + + + + @@ -46,15 +95,6 @@ None - - 255 - 135 - 50 - 1 - 0.5 - 0.4 - slide diff --git a/ui_elements/message.py b/ui_elements/message.py index f94bd62..6091853 100644 --- a/ui_elements/message.py +++ b/ui_elements/message.py @@ -69,7 +69,7 @@ class Message(): self.detail.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() self.box.set_height(box_height) box_y = int( (self.stage.get_height() - box_height) /2 ) @@ -112,7 +112,8 @@ class Message(): if len(self.msgQueue) > 0: (title, text) = self.msgQueue.pop() self.display_msg(title, text) + else: + self.glossMgr.ui_overide = None def on_key_press_event (self, stage, event): - self.hide_msg() - self.glossMgr.ui_overide = None \ No newline at end of file + self.hide_msg() \ No newline at end of file diff --git a/utils/themeMgr.py b/utils/themeMgr.py index a6e18ff..2e16ccd 100644 --- a/utils/themeMgr.py +++ b/utils/themeMgr.py @@ -10,16 +10,25 @@ class ThemeMgr: defaultTheme = "default" currentTheme = "default" - currentTheme = "Pear" - #currentTheme = "Mich" - #currentTheme = "Gloxygen" + currentTheme = "Gloxygen" - def __init__(self, glossMgr): + def __init__(self, glossMgr, theme=None): self.stage = glossMgr.stage self.glossMgr = glossMgr self.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 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