summaryrefslogtreecommitdiff
path: root/src/core/handlers.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2014-04-15 22:57:44 +0200
committermathieui <mathieui@mathieui.net>2014-04-15 22:57:44 +0200
commita784216196df764e2bb790efe7a799e9cad5588b (patch)
tree8c5f1a4c013b92cc1f21ad1341055c3eecc1a759 /src/core/handlers.py
parent80ebe9edc041f7950c8858cd6176830c62b11ada (diff)
downloadpoezio-a784216196df764e2bb790efe7a799e9cad5588b.tar.gz
poezio-a784216196df764e2bb790efe7a799e9cad5588b.tar.bz2
poezio-a784216196df764e2bb790efe7a799e9cad5588b.tar.xz
poezio-a784216196df764e2bb790efe7a799e9cad5588b.zip
Fix #2440 (highlight composing tabs)
- add a show_composing_tabs option, default value: "direct" - todo: find a nice different color for this
Diffstat (limited to 'src/core/handlers.py')
-rw-r--r--src/core/handlers.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/core/handlers.py b/src/core/handlers.py
index b0256246..bc43cc28 100644
--- a/src/core/handlers.py
+++ b/src/core/handlers.py
@@ -565,6 +565,9 @@ def on_chatstate_normal_conversation(self, message, state):
if tab == self.current_tab():
tab.refresh_info_header()
self.doupdate()
+ else:
+ composing_tab_state(tab, state)
+ self.refresh_tab_win()
return True
def on_chatstate_private_conversation(self, message, state):
@@ -580,6 +583,9 @@ def on_chatstate_private_conversation(self, message, state):
if tab == self.current_tab():
tab.refresh_info_header()
self.doupdate()
+ else:
+ composing_tab_state(tab, state)
+ self.refresh_tab_win()
return True
def on_chatstate_groupchat_conversation(self, message, state):
@@ -596,6 +602,9 @@ def on_chatstate_groupchat_conversation(self, message, state):
tab.user_win.refresh(tab.users)
tab.input.refresh()
self.doupdate()
+ else:
+ composing_tab_state(tab, state)
+ self.refresh_tab_win()
### subscription-related handlers ###
@@ -1052,3 +1061,29 @@ def validate_ssl(self, pem):
self.information(_('Unable to write in the config file'), 'Error')
+def composing_tab_state(tab, state):
+ """
+ Set a tab state to or from the "composing" state
+ according to the config and the current tab state
+ """
+ if isinstance(tab, tabs.MucTab):
+ values = ('true', 'muc')
+ elif isinstance(tab, tabs.PrivateTab):
+ values = ('true', 'direct', 'private')
+ elif isinstance(tab, tabs.ConversationTab):
+ values = ('true', 'direct', 'conversation')
+ else:
+ return # should not happen
+
+ show = config.get('show_composing_tabs', 'direct')
+ show = show in values
+
+ if tab.state != 'composing' and state == 'composing':
+ if show:
+ if tabs.STATE_PRIORITY[tab.state] > tabs.STATE_PRIORITY[state]:
+ return
+ tab.save_state()
+ tab.state = 'composing'
+ elif tab.state == 'composing' and state != 'composing':
+ tab.restore_state()
+