From f00dd1b8feedf4ec9dade18617ce855d447b420c Mon Sep 17 00:00:00 2001 From: mathieui Date: Sat, 9 Mar 2013 22:38:31 +0100 Subject: Fix #2254 (add a new theming option, too) --- src/tabs.py | 13 ++++++++++++- src/theming.py | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/tabs.py b/src/tabs.py index 3e7dc5f3..7f879aab 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -68,6 +68,7 @@ NS_MUC_USER = 'http://jabber.org/protocol/muc#user' STATE_COLORS = { 'disconnected': lambda: get_theme().COLOR_TAB_DISCONNECTED, + 'scrolled': lambda: get_theme().COLOR_TAB_SCROLLED, 'joined': lambda: get_theme().COLOR_TAB_JOINED, 'message': lambda: get_theme().COLOR_TAB_NEW_MESSAGE, 'highlight': lambda: get_theme().COLOR_TAB_HIGHLIGHT, @@ -79,6 +80,7 @@ STATE_COLORS = { VERTICAL_STATE_COLORS = { 'disconnected': lambda: get_theme().COLOR_VERTICAL_TAB_DISCONNECTED, + 'scrolled': lambda: get_theme().COLOR_VERTICAL_TAB_SCROLLED, 'joined': lambda: get_theme().COLOR_VERTICAL_TAB_JOINED, 'message': lambda: get_theme().COLOR_VERTICAL_TAB_NEW_MESSAGE, 'highlight': lambda: get_theme().COLOR_VERTICAL_TAB_HIGHLIGHT, @@ -93,6 +95,7 @@ STATE_PRIORITY = { 'normal': -1, 'current': -1, 'disconnected': 0, + 'scrolled': 0.5, 'message': 1, 'joined': 1, 'highlight': 2, @@ -173,7 +176,8 @@ class Tab(object): if not value in STATE_COLORS: log.debug("Invalid value for tab state: %s", value) elif STATE_PRIORITY[value] < STATE_PRIORITY[self._state] and \ - value not in ('current', 'disconnected'): + value not in ('current', 'disconnected') and \ + not (self._state == 'scrolled' and value == 'disconnected'): log.debug("Did not set state because of lower priority, asked: %s, kept: %s", value, self._state) elif self._state == 'disconnected' and value not in ('joined', 'current'): log.debug('Did not set state because disconnected tabs remain visible') @@ -655,6 +659,10 @@ class ChatTab(Tab): def get_conversation_messages(self): return self._text_buffer.messages + def check_scrolled(self): + if self.text_win.pos != 0: + self.state = 'scrolled' + def command_say(self, line, correct=False): pass @@ -1361,6 +1369,7 @@ class MucTab(ChatTab): self.text_win.add_line_separator(self._text_buffer) if config.get_by_tabname('send_chat_states', 'true', self.general_jid, True) == 'true' and not self.input.get_text(): self.send_chat_state('inactive') + self.check_scrolled() def on_gain_focus(self): self.state = 'current' @@ -1970,6 +1979,7 @@ class PrivateTab(ChatTab): 'send_chat_states', 'true', self.general_jid, True) == 'true'\ and not self.input.get_text() and self.on: self.send_chat_state('inactive') + self.check_scrolled() def on_gain_focus(self): self.state = 'current' @@ -3158,6 +3168,7 @@ class ConversationTab(ChatTab): if config.get_by_tabname('send_chat_states', 'true', self.general_jid, True) == 'true' and (not self.input.get_text() or not self.input.get_text().startswith('//')): if resource: self.send_chat_state('inactive') + self.check_scrolled() def on_gain_focus(self): contact = roster[self.get_dest_jid()] diff --git a/src/theming.py b/src/theming.py index 210a5889..3f9df2e2 100644 --- a/src/theming.py +++ b/src/theming.py @@ -139,6 +139,7 @@ class Theme(object): # Tabs COLOR_TAB_NORMAL = (7, 4) + COLOR_TAB_SCROLLED = (5, 4) COLOR_TAB_JOINED = (82, 4) COLOR_TAB_CURRENT = (7, 6) COLOR_TAB_NEW_MESSAGE = (7, 5) @@ -149,6 +150,7 @@ class Theme(object): COLOR_VERTICAL_TAB_NORMAL = (4, -1) COLOR_VERTICAL_TAB_JOINED = (82, -1) + COLOR_VERTICAL_TAB_SCROLLED = (66, -1) COLOR_VERTICAL_TAB_CURRENT = (7, 4) COLOR_VERTICAL_TAB_NEW_MESSAGE = (5, -1) COLOR_VERTICAL_TAB_HIGHLIGHT = (3, -1) -- cgit v1.2.3