summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2014-04-02 21:33:17 +0200
committermathieui <mathieui@mathieui.net>2014-04-02 21:33:17 +0200
commit52e6334c8c95ec873ccbcf17bf42de12eec0475d (patch)
treed83bccb0ccd319821670f4b00642ee47d995e8fe
parent65c247399d4b5d8d78953e72cab89b7cf6b890fa (diff)
downloadpoezio-52e6334c8c95ec873ccbcf17bf42de12eec0475d.tar.gz
poezio-52e6334c8c95ec873ccbcf17bf42de12eec0475d.tar.bz2
poezio-52e6334c8c95ec873ccbcf17bf42de12eec0475d.tar.xz
poezio-52e6334c8c95ec873ccbcf17bf42de12eec0475d.zip
Fix #2340 (change tab priority when the input is not empty)
-rw-r--r--src/tabs/basetabs.py3
-rw-r--r--src/tabs/conversationtab.py5
-rw-r--r--src/tabs/muctab.py5
-rw-r--r--src/tabs/privatetab.py6
-rw-r--r--src/theming.py2
5 files changed, 18 insertions, 3 deletions
diff --git a/src/tabs/basetabs.py b/src/tabs/basetabs.py
index 7b300b18..c58efc26 100644
--- a/src/tabs/basetabs.py
+++ b/src/tabs/basetabs.py
@@ -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,
diff --git a/src/tabs/conversationtab.py b/src/tabs/conversationtab.py
index 82483046..f999ddcd 100644
--- a/src/tabs/conversationtab.py
+++ b/src/tabs/conversationtab.py
@@ -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('//')):
diff --git a/src/tabs/muctab.py b/src/tabs/muctab.py
index b80903d4..5a271736 100644
--- a/src/tabs/muctab.py
+++ b/src/tabs/muctab.py
@@ -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()
diff --git a/src/tabs/privatetab.py b/src/tabs/privatetab.py
index bafee073..5599ec45 100644
--- a/src/tabs/privatetab.py
+++ b/src/tabs/privatetab.py
@@ -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)
diff --git a/src/theming.py b/src/theming.py
index 0e271018..af8c7d36 100644
--- a/src/theming.py
+++ b/src/theming.py
@@ -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)