summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-01-12 20:09:48 +0100
committerFlorent Le Coz <louiz@louiz.org>2011-01-12 20:09:48 +0100
commit6d4e5c069ec1a953f01c1abacc398a05c5a1485d (patch)
treeccd61410874686d9b500d53c8813e40ee139f387 /src
parentce1fc18e104c9ed963347c50c48a7e40f755027e (diff)
downloadpoezio-6d4e5c069ec1a953f01c1abacc398a05c5a1485d.tar.gz
poezio-6d4e5c069ec1a953f01c1abacc398a05c5a1485d.tar.bz2
poezio-6d4e5c069ec1a953f01c1abacc398a05c5a1485d.tar.xz
poezio-6d4e5c069ec1a953f01c1abacc398a05c5a1485d.zip
Finish the two default themes
And remove the automatic copy of the config files
Diffstat (limited to 'src')
-rw-r--r--src/poezio.py1
-rw-r--r--src/theme.py18
-rw-r--r--src/windows.py30
3 files changed, 27 insertions, 22 deletions
diff --git a/src/poezio.py b/src/poezio.py
index 8362cd19..cbe30f2a 100644
--- a/src/poezio.py
+++ b/src/poezio.py
@@ -32,6 +32,7 @@ from core import core
if __name__ == '__main__':
signal.signal(signal.SIGINT, signal.SIG_IGN) # ignore ctrl-c
+ sys.stderr = open('/dev/null', 'a')
if options.debug:
logging.basicConfig(filename=options.debug,level=logging.DEBUG)
if not connection.start(): # Connect to remote server
diff --git a/src/theme.py b/src/theme.py
index e3ddc12b..830284bb 100644
--- a/src/theme.py
+++ b/src/theme.py
@@ -20,12 +20,14 @@ used when drawing the interface (mainly colors)
"""
import curses
-import shutil
import glob
import imp
import os
from config import config
+import logging
+log = logging.getLogger(__name__)
+
## Define the default colors
## Do not change these colors, create a theme file instead.
@@ -50,6 +52,7 @@ CHAR_STATUS = ' '
# Separators
COLOR_VERTICAL_SEPARATOR = 4
COLOR_NEW_TEXT_SEPARATOR = 2
+COLOR_MORE_INDICATOR = 6
# Time
COLOR_TIME_SEPARATOR = 6
@@ -79,14 +82,19 @@ COLOR_STATUS_AWAY = 35
COLOR_STATUS_CHAT = 28
COLOR_STATUS_UNAVAILABLE = 57
COLOR_STATUS_ONLINE = 41
+
# Bars
COLOR_INFORMATION_BAR = 42
COLOR_TOPIC_BAR = 42
COLOR_PRIVATE_ROOM_BAR = 28
COLOR_SCROLLABLE_NUMBER = 39
+COLOR_SELECTED_ROW = 42
+COLOR_PRIVATE_NAME = 42
+COLOR_CONVERSATION_NAME = 42
+COLOR_GROUPCHAT_NAME = 42
+COLOR_COLUMN_HEADER = 36
# Strings for special messages (like join, quit, nick change, etc)
-
# Special messages
CHAR_JOIN = '---->'
CHAR_QUIT = '<----'
@@ -134,13 +142,9 @@ def reload_theme():
'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', '')
+ theme_name = config.get('theme', '')
if not theme_name:
return
try:
diff --git a/src/windows.py b/src/windows.py
index e1b9db2f..b14bb93f 100644
--- a/src/windows.py
+++ b/src/windows.py
@@ -118,7 +118,7 @@ class UserList(Win):
self.pos = 0
def draw_plus(self, y):
- self.addstr(y, self.width-2, '++', curses.color_pair(42))
+ self.addstr(y, self.width-2, '++', curses.color_pair(theme.COLOR_MORE_INDICATOR))
def refresh(self, users):
with g_lock:
@@ -255,7 +255,7 @@ class PrivateInfoWin(InfoWin):
def write_room_name(self, room):
jid = JID(room.name)
room_name, nick = jid.bare, jid.resource
- self.addstr(nick, curses.color_pair(13))
+ self.addstr(nick, curses.color_pair(theme.COLOR_PRIVATE_NAME))
txt = ' from room %s' % room_name
self.addstr(txt, curses.color_pair(theme.COLOR_INFORMATION_BAR))
@@ -316,7 +316,7 @@ class ConversationInfoWin(InfoWin):
presence = resource.get_presence()
color = RosterWin.color_show[presence]
self.addstr('[', curses.color_pair(theme.COLOR_INFORMATION_BAR))
- self.addstr(" ", curses.color_pair(color))
+ self.addstr(" ", curses.color_pair(theme.COLOR_CONVERSATION_NAME))
self.addstr(']', curses.color_pair(theme.COLOR_INFORMATION_BAR))
def write_contact_informations(self, contact):
@@ -334,7 +334,7 @@ class ConversationInfoWin(InfoWin):
Just write the jid that we are talking to
"""
self.addstr('[', curses.color_pair(theme.COLOR_INFORMATION_BAR))
- self.addstr(jid.full, curses.color_pair(10))
+ self.addstr(jid.full, curses.color_pair(theme.COLOR_CONVERSATION_NAME))
self.addstr('] ', curses.color_pair(theme.COLOR_INFORMATION_BAR))
class ConversationStatusMessageWin(InfoWin):
@@ -393,7 +393,7 @@ class MucInfoWin(InfoWin):
"""
"""
self.addstr('[', curses.color_pair(theme.COLOR_INFORMATION_BAR))
- self.addnstr(room.name, len(room.name), curses.color_pair(13))
+ self.addnstr(room.name, len(room.name), curses.color_pair(theme.COLOR_GROUPCHAT_NAME))
self.addstr('] ', curses.color_pair(theme.COLOR_INFORMATION_BAR))
def write_disconnected(self, room):
@@ -1227,27 +1227,27 @@ class RosterWin(Win):
Draw the indicator that shows that
the list is longer than what is displayed
"""
- self.addstr(y, self.width-5, '++++', curses.color_pair(42))
+ self.addstr(y, self.width-5, '++++', curses.color_pair(theme.COLOR_MORE_INDICATOR))
def draw_roster_information(self, roster):
"""
"""
- self.addstr('%s contacts' % roster.get_contact_len(), curses.color_pair(12))
- self.finish_line(12)
+ self.addstr('Roster: %s contacts' % roster.get_contact_len(), curses.color_pair(theme.COLOR_INFORMATION_BAR))
+ self.finish_line(theme.COLOR_INFORMATION_BAR)
def draw_group(self, y, group, colored):
"""
Draw a groupname on a line
"""
if colored:
- self._win.attron(curses.color_pair(14))
+ self._win.attron(curses.color_pair(theme.COLOR_SELECTED_ROW))
if group.folded:
self.addstr(y, 0, '[+] ')
else:
self.addstr(y, 0, '[-] ')
self.addstr(y, 4, group.name)
if colored:
- self._win.attroff(curses.color_pair(14))
+ self._win.attroff(curses.color_pair(theme.COLOR_SELECTED_ROW))
def draw_contact_line(self, y, contact, colored):
"""
@@ -1277,11 +1277,11 @@ class RosterWin(Win):
self.addstr(y, 2, ' [+]' if contact._folded else ' [-]')
self.addstr(' ')
if colored:
- self.addstr(display_name, curses.color_pair(14))
+ self.addstr(display_name, curses.color_pair(theme.COLOR_SELECTED_ROW))
else:
self.addstr(display_name)
if contact.get_ask() == 'asked':
- self.addstr('?', curses.color_pair(1))
+ self.addstr('?', curses.color_pair(theme.COLOR_HIGHLIGHT_TEXT))
def draw_resource_line(self, y, resource, colored):
"""
@@ -1290,7 +1290,7 @@ class RosterWin(Win):
color = RosterWin.color_show[resource.get_presence()]
self.addstr(y, 4, " ", curses.color_pair(color))
if colored:
- self.addstr(y, 6, resource.get_jid().full, curses.color_pair(14))
+ self.addstr(y, 6, resource.get_jid().full, curses.color_pair(theme.COLOR_SELECTED_ROW))
else:
self.addstr(y, 6, resource.get_jid().full)
@@ -1322,7 +1322,7 @@ class ContactInfoWin(Win):
self.addstr(1, 0, 'Subscription: %s' % (contact.get_subscription(),))
if contact.get_ask():
if contact.get_ask() == 'asked':
- self.addstr(' Ask: %s' % (contact.get_ask(),), curses.color_pair(1))
+ self.addstr(' Ask: %s' % (contact.get_ask(),), curses.color_pair(theme.COLOR_HIGHLIGHT_TEXT))
else:
self.addstr(' Ask: %s' % (contact.get_ask(),))
@@ -1460,7 +1460,7 @@ class ColumnHeaderWin(Win):
txt = col
size = self._columns_sizes[col]
txt += ' ' * (size-len(txt))
- self.addstr(0, x, txt, curses.color_pair(theme.COLOR_STATUS_UNAVAILABLE))
+ self.addstr(0, x, txt, curses.color_pair(theme.COLOR_COLUMN_HEADER))
x += size
self._refresh()