Add a warning in case of theme not found, and now unsetting 'theme',

setting it to 'default' or a number of spaces has the same effect
This commit is contained in:
mathieui 2011-11-07 19:56:59 +01:00
parent 153137e5d2
commit 7e78353621
2 changed files with 9 additions and 6 deletions

View file

@ -1172,7 +1172,9 @@ class Core(object):
self.xmpp.plugin['xep_0030'].get_items(jid=server, block=False, callback=list_tab.on_muc_list_item_received) self.xmpp.plugin['xep_0030'].get_items(jid=server, block=False, callback=list_tab.on_muc_list_item_received)
def command_theme(self, arg): def command_theme(self, arg):
theming.reload_theme() warning = theming.reload_theme()
if warning:
self.information(warning, 'Warning')
self.refresh_window() self.refresh_window()
def command_win(self, arg): def command_win(self, arg):

View file

@ -240,16 +240,17 @@ def reload_theme():
os.makedirs(themes_dir) os.makedirs(themes_dir)
except OSError: except OSError:
pass pass
theme_name = config.get('theme', '') theme_name = config.get('theme', 'default')
if not theme_name: global theme
if theme_name == 'default' or not theme_name.strip():
theme = Theme()
return return
try: try:
file_path = os.path.join(themes_dir, theme_name)+'.py' file_path = os.path.join(themes_dir, theme_name)+'.py'
log.debug('Theme file to load: %s' %(file_path,)) log.debug('Theme file to load: %s' %(file_path,))
new_theme = imp.load_source('theme', os.path.join(themes_dir, theme_name)+'.py') new_theme = imp.load_source('theme', os.path.join(themes_dir, theme_name)+'.py')
except: # TODO warning: theme not found except:
return return 'Theme not found'
global theme
theme = new_theme.theme theme = new_theme.theme
if __name__ == '__main__': if __name__ == '__main__':