Fix #2340 (change tab priority when the input is not empty)

This commit is contained in:
mathieui 2014-04-02 21:33:17 +02:00
parent 65c247399d
commit 52e6334c8c
5 changed files with 18 additions and 3 deletions

View file

@ -44,6 +44,7 @@ MIN_HEIGHT = 6
STATE_COLORS = {
'disconnected': lambda: get_theme().COLOR_TAB_DISCONNECTED,
'scrolled': lambda: get_theme().COLOR_TAB_SCROLLED,
'nonempty': lambda: get_theme().COLOR_TAB_NONEMPTY,
'joined': lambda: get_theme().COLOR_TAB_JOINED,
'message': lambda: get_theme().COLOR_TAB_NEW_MESSAGE,
'highlight': lambda: get_theme().COLOR_TAB_HIGHLIGHT,
@ -55,6 +56,7 @@ STATE_COLORS = {
VERTICAL_STATE_COLORS = {
'disconnected': lambda: get_theme().COLOR_VERTICAL_TAB_DISCONNECTED,
'scrolled': lambda: get_theme().COLOR_VERTICAL_TAB_SCROLLED,
'nonempty': lambda: get_theme().COLOR_VERTICAL_TAB_NONEMPTY,
'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,
@ -71,6 +73,7 @@ STATE_PRIORITY = {
'normal': -1,
'current': -1,
'disconnected': 0,
'nonempty': 0.1,
'scrolled': 0.5,
'message': 1,
'joined': 1,

View file

@ -315,7 +315,10 @@ class ConversationTab(ChatTab):
resource = contact.get_highest_priority_resource()
else:
resource = None
self.state = 'normal'
if self.input.text:
self.state = 'nonempty'
else:
self.state = 'normal'
self.text_win.remove_line_separator()
self.text_win.add_line_separator(self._text_buffer)
if config.get_by_tabname('send_chat_states', True, self.general_jid, True) and (not self.input.get_text() or not self.input.get_text().startswith('//')):

View file

@ -768,7 +768,10 @@ class MucTab(ChatTab):
def on_lose_focus(self):
if self.joined:
self.state = 'normal'
if self.input.text:
self.state = 'nonempty'
else:
self.state = 'normal'
else:
self.state = 'disconnected'
self.text_win.remove_line_separator()

View file

@ -280,7 +280,11 @@ class PrivateTab(ChatTab):
return False
def on_lose_focus(self):
self.state = 'normal'
if self.input.text:
self.state = 'nonempty'
else:
self.state = 'normal'
self.text_win.remove_line_separator()
self.text_win.add_line_separator(self._text_buffer)
tab = self.core.get_tab_by_name(safeJID(self.name).bare, MucTab)

View file

@ -201,6 +201,7 @@ class Theme(object):
# Tabs
COLOR_TAB_NORMAL = (7, 4)
COLOR_TAB_NONEMPTY = (7, 4)
COLOR_TAB_SCROLLED = (5, 4)
COLOR_TAB_JOINED = (82, 4)
COLOR_TAB_CURRENT = (7, 6)
@ -211,6 +212,7 @@ class Theme(object):
COLOR_TAB_DISCONNECTED = (7, 8)
COLOR_VERTICAL_TAB_NORMAL = (4, -1)
COLOR_VERTICAL_TAB_NONEMPTY = (4, -1)
COLOR_VERTICAL_TAB_JOINED = (82, -1)
COLOR_VERTICAL_TAB_SCROLLED = (66, -1)
COLOR_VERTICAL_TAB_CURRENT = (7, 4)