From 7ec85ae32831dff00259aa72d5163a03053a733a Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 30 Dec 2012 17:40:27 +0100 Subject: Fix #2143 Fix #2056 Show headline messages in the info buffer, and show error messages (or other errors) with a special style. --- src/core.py | 6 ++++-- src/theming.py | 11 +++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/core.py b/src/core.py index dd8e26af..5f535f48 100644 --- a/src/core.py +++ b/src/core.py @@ -1063,7 +1063,7 @@ class Core(object): log.debug('Did not show the message:\n\t%s> %s', typ, msg) return False colors = get_theme().INFO_COLORS - color = colors.get(typ, colors.get('default', None)) + color = colors.get(typ.lower(), colors.get('default', None)) nb_lines = self.information_buffer.add_message(msg, nickname=typ, nick_color=color) if isinstance(self.current_tab(), tabs.RosterInfoTab): self.refresh_window() @@ -2381,6 +2381,8 @@ class Core(object): body = xhtml.get_body_from_message_stanza(message) if message['type'] == 'error': return self.information(self.get_error_message(message, deprecated=True), 'Error') + elif message['type'] == 'headline': + return self.information('%s says: %s' % (message['from'], message['body']), 'Headline') if not body: return conversation = self.get_conversation_by_jid(jid, create=True) @@ -2887,7 +2889,7 @@ class Core(object): """ tab = self.get_tab_by_name(room_name) error_message = self.get_error_message(error) - self.add_message_to_text_buffer(tab._text_buffer, error_message) + tab._text_buffer.add_message(error_message, highlight=True, nickname='Error', nick_color=get_theme().COLOR_ERROR_MSG) code = error['error']['code'] if code == '401': msg = _('To provide a password in order to join the room, type "/join / password" (replace "password" by the real password)') diff --git a/src/theming.py b/src/theming.py index cc7d0f89..c2c8950f 100644 --- a/src/theming.py +++ b/src/theming.py @@ -161,6 +161,8 @@ class Theme(object): # This is your own nickname COLOR_OWN_NICK = (254, -1) + # This is for in-tab error messages + COLOR_ERROR_MSG = (9, 7, 'b') # Status color COLOR_STATUS_XA = (16, 90) COLOR_STATUS_NONE = (16, 4) @@ -199,10 +201,11 @@ class Theme(object): # Info messages color (the part before the ">") INFO_COLORS = { - 'Info': (5, -1), - 'Error': (16, 1), - 'Roster': (2, 16), - 'default': (0, -1), + 'info': (5, -1), + 'error': (16, 1), + 'roster': (2, 16), + 'headline': (11, -1, 'b'), + 'default': (7, -1), } # This is the default theme object, used if no theme is defined in the conf -- cgit v1.2.3