summaryrefslogtreecommitdiff
path: root/src/theme.py
diff options
context:
space:
mode:
authorlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-08-22 14:57:47 +0000
committerlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-08-22 14:57:47 +0000
commitaab22c794397a29d3a865c073702879a1e5a4645 (patch)
treedf515dbaf722b71dbf764eb1a48c1c61cbe94f69 /src/theme.py
parent3ed25bdfce85e774b6992d32a112b69154d55f3e (diff)
downloadpoezio-aab22c794397a29d3a865c073702879a1e5a4645.tar.gz
poezio-aab22c794397a29d3a865c073702879a1e5a4645.tar.bz2
poezio-aab22c794397a29d3a865c073702879a1e5a4645.tar.xz
poezio-aab22c794397a29d3a865c073702879a1e5a4645.zip
Themes working
Diffstat (limited to 'src/theme.py')
-rw-r--r--src/theme.py30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/theme.py b/src/theme.py
index 1748e4a3..58a51717 100644
--- a/src/theme.py
+++ b/src/theme.py
@@ -22,8 +22,10 @@ used when drawing the interface (mainly colors)
"""
import curses
-import inspect
+import shutil
+import glob
import imp
+import os
from config import config
## Define the default colors
@@ -64,7 +66,7 @@ COLOR_OWN_NICK = 72
# Status color
COLOR_STATUS_XA = 40
-COLOR_STATUS_NONE = 0
+COLOR_STATUS_NONE = 72
COLOR_STATUS_DND = 50
COLOR_STATUS_AWAY = 70
COLOR_STATUS_CHAT = 30
@@ -75,6 +77,9 @@ COLOR_TOPIC_BAR = 15
COLOR_PRIVATE_ROOM_BAR = 33
COLOR_SCROLLABLE_NUMBER = 16
+# Chars
+STATUS_CHAR = ' '
+
def init_colors():
"""
Initilization of all the available ncurses colors
@@ -100,14 +105,25 @@ def init_colors():
reload_theme()
def reload_theme():
- current_module = __import__(inspect.getmodulename(__file__))
- path = config.get('theme_file', '../default.theme')
+ themes_dir = config.get('themes_dir',
+ os.path.join(os.environ.get('XDG_DATA_HOME') or os.path.join(os.environ.get('HOME'), '.local', 'share'), 'poezio', 'themes'))
+ try:
+ os.makedirs(themes_dir)
+ # if the directory didn't exist, copy the default themes
+ themes = glob.glob('../data/themes/*')
+ for filename in themes:
+ shutil.copy2(filename, themes_dir)
+ except OSError:
+ pass
+ theme_name = config.get('theme_file', '')
+ if not theme_name:
+ return
try:
- theme = imp.load_source('theme', path)
- except:
+ theme = imp.load_source('theme', os.path.join(themes_dir, theme_name))
+ except: # TODO warning: theme not found
return
for var in dir(theme):
- if var.startswith('COLOR_'):
+ if var.startswith('COLOR_') or var.startswith('STATUS_'):
globals()[var] = getattr(theme, var)
if __name__ == '__main__':