summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core.py7
-rw-r--r--src/tabs.py53
-rw-r--r--src/theming.py71
3 files changed, 81 insertions, 50 deletions
diff --git a/src/core.py b/src/core.py
index 230253de..3c4af5d9 100644
--- a/src/core.py
+++ b/src/core.py
@@ -809,6 +809,7 @@ class Core(object):
stdscr.keypad(True)
curses.start_color()
curses.use_default_colors()
+ theming.reload_theme()
curses.ungetch(" ") # H4X: without this, the screen is
stdscr.getkey() # erased on the first "getkey()"
@@ -886,7 +887,7 @@ class Core(object):
self.command_win('%s' % tab.nb)
return
for tab in self.tabs:
- if tab.get_color_state() == theme.COLOR_TAB_DISCONNECTED:
+ if tab.get_color_state() == get_theme().COLOR_TAB_DISCONNECTED:
self.command_win('%s' % tab.nb)
return
for tab in self.tabs:
@@ -1179,9 +1180,7 @@ class Core(object):
self.xmpp.plugin['xep_0030'].get_items(jid=server, block=False, callback=list_tab.on_muc_list_item_received)
def command_theme(self, arg):
- """
- """
- # get_theme().reload_theme()
+ theming.reload_theme()
self.refresh_window()
def command_win(self, arg):
diff --git a/src/tabs.py b/src/tabs.py
index 88d8ad7f..1b0406f2 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -799,7 +799,8 @@ class MucTab(ChatTab):
room.users.append(new_user)
if from_nick == room.own_nick:
room.joined = True
- self.send_chat_state('active')
+ if self.core.current_tab() == self and self.core.status.show not in ('xa', 'away'):
+ self.send_chat_state('active')
new_user.color = get_theme().COLOR_OWN_NICK
room.add_message(_("\x195}Your nickname is \x193}%s") % (from_nick))
if '170' in status_codes:
@@ -999,10 +1000,12 @@ class PrivateTab(ChatTab):
# keys
self.key_func['^I'] = self.completion
# commands
- #self.commands['info'] = (self.command_info, _('Usage: /info\nInfo: Display some information about the user in the MUC: '), None)
+ self.commands['info'] = (self.command_info, _('Usage: /info\nInfo: Display some information about the user in the MUC: '), None)
self.commands['unquery'] = (self.command_unquery, _("Usage: /unquery\nUnquery: close the tab"), None)
self.commands['part'] = (self.command_unquery, _("Usage: /part\nPart: close the tab"), None)
+ self.commands['version'] = (self.command_version, _('Usage: /version\nVersion: get the software version of the current interlocutor (usually its XMPP client and Operating System)'), None)
self.resize()
+ self.parent_muc = self.core.get_tab_by_name(JID(room.name).bare, MucTab)
self.on = True
def completion(self):
@@ -1019,7 +1022,8 @@ class PrivateTab(ChatTab):
msg['body'] = xhtml.clean_text(line)
msg['xhtml_im'] = xhtml.poezio_colors_to_html(line)
if config.get('send_chat_states', 'true') == 'true' and self.remote_wants_chatstates is not False:
- msg['chat_state'] = 'active'
+ needed = 'inactive' if self.core.status.show in ('xa', 'away') else 'active'
+ msg['chat_state'] = needed
msg.send()
self.core.add_message_to_text_buffer(self.get_room(), line, None, self.core.own_nick or self.get_room().own_nick)
logger.log_message(JID(self.get_name()).bare, self.core.own_nick, line)
@@ -1033,6 +1037,31 @@ class PrivateTab(ChatTab):
"""
self.core.close_tab()
+ def command_version(self, arg):
+ """
+ /version
+ """
+ def callback(res):
+ if not res:
+ return self.core.information('Could not get the software version from %s' % (jid,), 'Warning')
+ version = '%s is running %s version %s on %s' % (jid,
+ res.get('name') or _('an unknown software'),
+ res.get('version') or _('unknown'),
+ res.get('os') or _('on an unknown platform'))
+ self.core.information(version, 'Info')
+ jid = self.get_room().name
+ self.core.xmpp.plugin['xep_0092'].get_version(jid, callback=callback)
+
+ def command_info(self, arg):
+ """
+ /info
+ """
+ if arg:
+ self.parent_muc.command_info(arg)
+ else:
+ user = JID(self.get_room().name).resource
+ self.parent_muc.command_info(user)
+
def resize(self):
if self.core.information_win_size >= self.height-3 or not self.visible:
return
@@ -1124,22 +1153,25 @@ class PrivateTab(ChatTab):
"""
The user left the associated MUC
"""
+ self.deactivate()
if not status_message:
self.get_room().add_message(_('\x191}%(spec)s \x193}%(nick)s\x195} has left the room') % {'nick':from_nick.replace('"', '\\"'), 'spec':get_theme().CHAR_QUIT.replace('"', '\\"')})
else:
self.get_room().add_message(_('\x191}%(spec)s \x193}%(nick)s\x195} has left the room (%(status)s)"') % {'nick':from_nick.replace('"', '\\"'), 'spec':get_theme().CHAR_QUIT, 'status': status_message.replace('"', '\\"')})
- self.deactivate()
- self.refresh()
- self.core.doupdate()
+ if self.core.current_tab() is self:
+ self.refresh()
+ self.core.doupdate()
def user_rejoined(self, nick):
"""
The user (or at least someone with the same nick) came back in the MUC
"""
- self.get_room().add_message('\x194}%(spec)s \x193}%(nick)s\x195} joined the room' % {'nick':nick, 'spec':get_theme().CHAR_JOIN})
self.activate()
- self.refresh()
- self.core.doupdate()
+ self.get_room().add_message('\x194}%(spec)s \x193}%(nick)s\x195} joined the room' % {'nick':nick, 'spec':get_theme().CHAR_JOIN})
+ if self.core.current_tab() is self:
+ self.refresh()
+ self.core.doupdate()
+
def activate(self):
self.on = True
@@ -1527,7 +1559,8 @@ class ConversationTab(ChatTab):
msg['body'] = xhtml.clean_text(line)
msg['xhtml_im'] = xhtml.poezio_colors_to_html(line)
if config.get('send_chat_states', 'true') == 'true' and self.remote_wants_chatstates is not False:
- msg['chat_state'] = 'active'
+ needed = 'inactive' if self.core.status.show in ('xa', 'away') else 'active'
+ msg['chat_state'] = needed
msg.send()
self.core.add_message_to_text_buffer(self.get_room(), line, None, self.core.own_nick)
logger.log_message(JID(self.get_name()).bare, self.core.own_nick, line)
diff --git a/src/theming.py b/src/theming.py
index eecd749c..382a3146 100644
--- a/src/theming.py
+++ b/src/theming.py
@@ -34,24 +34,18 @@ is a string and can contain one or more of these characteres:
For example, (200, 208, 'bu') is bold, underlined and pink foreground on orange background.
-A theme file is a python file containing two objects named 'theme' and 'theme8', which both are
-instances of two classes (derived from the Theme class) defined in that same file.
-For example, in darktheme.py:
+A theme file is a python file containing one object named 'theme', which is an
+instance of a class (derived from the Theme class) defined in that same file.
+For example, in pinkytheme.py:
import theming
-class DarkTheme(theming.Theme):
+class PinkyTheme(theming.Theme):
COLOR_NORMAL_TEXT = (200, -1)
- [...]
-class DarkTheme8(theming.Theme):
- COLOR_NORMAL_TEXT = (1, -1)
- [...]
+theme = PinkyTheme()
-theme = DarkTheme()
-theme8 = DarkTheme8()
-
-if the command '/theme darktheme' is issued, we import the darktheme.py file
-and set the global variable 'theme' to darktheme.theme.
+if the command '/theme pinkytheme' is issued, we import the pinkytheme.py file
+and set the global variable 'theme' to pinkytheme.theme.
And in poezio's code we just use theme.COLOR_NORMAL_TEXT etc
@@ -84,14 +78,14 @@ class Theme(object):
"""
# Message text color
COLOR_NORMAL_TEXT = (-1, -1)
- COLOR_INFORMATION_TEXT = (137, -1)
- COLOR_HIGHLIGHT_NICK = (208, 22)
+ COLOR_INFORMATION_TEXT = (137, -1) # TODO
+ COLOR_HIGHLIGHT_NICK = (3, 5, 'b')
# User list color
- COLOR_USER_VISITOR = (13, -1)
- COLOR_USER_PARTICIPANT = (7, -1)
- COLOR_USER_NONE = (243, -1)
- COLOR_USER_MODERATOR = (160, -1)
+ COLOR_USER_VISITOR = (0, -1)
+ COLOR_USER_PARTICIPANT = (4, -1)
+ COLOR_USER_NONE = (0, -1)
+ COLOR_USER_MODERATOR = (1, -1)
# nickname colors
COLOR_REMOTE_USER = (5, -1)
@@ -106,7 +100,7 @@ class Theme(object):
COLOR_MORE_INDICATOR = (6, 4)
# Time
- COLOR_TIME_SEPARATOR = (6, -1)
+ COLOR_TIME_SEPARATOR = (106, -1)
COLOR_TIME_LIMITER = (0, -1)
CHAR_TIME_LEFT = ''
CHAR_TIME_RIGHT = ''
@@ -115,32 +109,35 @@ class Theme(object):
# Tabs
COLOR_TAB_NORMAL = (7, 4)
COLOR_TAB_CURRENT = (7, 6)
- COLOR_TAB_NEW_MESSAGE = (7, 3)
- COLOR_TAB_HIGHLIGHT = (7, 9)
+ COLOR_TAB_NEW_MESSAGE = (7, 5)
+ COLOR_TAB_HIGHLIGHT = (7, 1)
COLOR_TAB_PRIVATE = (7, 2)
COLOR_TAB_DISCONNECTED = (7, 8)
# Nickname colors
- LIST_COLOR_NICKNAMES = [(1, -1), (2, -1), (3, -1), (4, -1), (5, -1), (6, -1), (7, -1), (8, -1), (21, -1), (154, -1), (202, -1), (123, -1), (216, -1)]
+ # A list of colors randomly attributed to nicks in MUCs
+ # Setting more colors makes it harder to have two nicks with the same color,
+ # avoiding confusions.
+ LIST_COLOR_NICKNAMES = [(1, -1), (2, -1), (3, -1), (4, -1), (5, -1), (6, -1), (7, -1), (8, -1), (9, -1), (10, -1), (11, -1), (12, -1), (13, -1), (14, -1), (23, -1), (23, -1), (88, -1), (99, -1), (100, -1), (154, -1), (213, -1), (216, -1), (227, -1)]
+ # This is your own nickname
COLOR_OWN_NICK = (254, -1)
# Status color
- COLOR_STATUS_XA = (234, 90)
- COLOR_STATUS_NONE = (234, 4)
- COLOR_STATUS_DND = (234, 1)
- COLOR_STATUS_AWAY = (234, 3)
- COLOR_STATUS_CHAT = (234, 2)
+ COLOR_STATUS_XA = (16, 90)
+ COLOR_STATUS_NONE = (16, 4)
+ COLOR_STATUS_DND = (16, 1)
+ COLOR_STATUS_AWAY = (16, 3)
+ COLOR_STATUS_CHAT = (16, 2)
COLOR_STATUS_UNAVAILABLE = (-1, 247)
- COLOR_STATUS_ONLINE = (234, 4)
+ COLOR_STATUS_ONLINE = (16, 4)
# Bars
COLOR_INFORMATION_BAR = (7, 4)
COLOR_TOPIC_BAR = (7, 4)
- COLOR_PRIVATE_ROOM_BAR = (-1, 4)
- COLOR_SCROLLABLE_NUMBER = (214, 4, 'b')
+ COLOR_SCROLLABLE_NUMBER = (220, 4, 'b')
COLOR_SELECTED_ROW = (-1, 33)
COLOR_PRIVATE_NAME = (-1, 4)
- COLOR_CONVERSATION_NAME = (4, 4)
+ COLOR_CONVERSATION_NAME = (2, 4)
COLOR_GROUPCHAT_NAME = (7, 4)
COLOR_COLUMN_HEADER = (36, 4)
@@ -223,7 +220,7 @@ def to_curses_attr(color_tuple):
curses_pair = curses_pair | curses.A_BOLD
if 'u' in additional_val:
curses_pair = curses_pair | curses.A_UNDERLINE
- if 'x' in additional_val:
+ if 'a' in additional_val:
curses_pair = curses_pair | curses.A_BLINK
return curses_pair
@@ -247,11 +244,13 @@ def reload_theme():
if not theme_name:
return
try:
- new_theme = imp.load_source('theme', os.path.join(themes_dir, theme_name))
+ file_path = os.path.join(themes_dir, theme_name)+'.py'
+ log.debug('Theme file to load: %s' %(file_path,))
+ new_theme = imp.load_source('theme', os.path.join(themes_dir, theme_name)+'.py')
except: # TODO warning: theme not found
return
global theme
- theme = new_theme
+ theme = new_theme.theme
if __name__ == '__main__':
"""
@@ -260,7 +259,7 @@ if __name__ == '__main__':
s = curses.initscr()
curses.start_color()
curses.use_default_colors()
- s.addstr('%s' % curses.COLORS, to_curses_attr((3, -1, 'x')))
+ s.addstr('%s' % curses.COLORS, to_curses_attr((3, -1, 'a')))
s.refresh()
s.getkey()
curses.endwin()