Add buffer_modes bar item, used for backlog and encryption status.

This commit is contained in:
poljar (Damir Jelić) 2018-02-22 15:02:42 +01:00
parent 11076f9649
commit f1ddbc841f
4 changed files with 25 additions and 1 deletions

View file

@ -53,7 +53,8 @@ from matrix.server import (
) )
from matrix.bar_items import (init_bar_items, matrix_bar_item_name, from matrix.bar_items import (init_bar_items, matrix_bar_item_name,
matrix_bar_item_plugin, matrix_bar_item_lag) matrix_bar_item_plugin, matrix_bar_item_lag,
matrix_bar_item_buffer_modes)
from matrix.completion import ( from matrix.completion import (
init_completion, matrix_command_completion_cb, init_completion, matrix_command_completion_cb,

View file

@ -85,7 +85,28 @@ def matrix_bar_item_lag(data, item, window, buffer, extra_info):
return "" return ""
@utf8_decode
def matrix_bar_item_buffer_modes(data, item, window, buffer, extra_info):
# pylint: disable=unused-argument
for server in SERVERS.values():
if buffer in server.buffers.values():
room_id = key_from_value(server.buffers, buffer)
room = server.rooms[room_id]
modes = []
if room.encrypted:
modes.append("🔐")
if room.backlog_pending:
modes.append("")
return "".join(modes)
return ""
def init_bar_items(): def init_bar_items():
W.bar_item_new("(extra)buffer_plugin", "matrix_bar_item_plugin", "") W.bar_item_new("(extra)buffer_plugin", "matrix_bar_item_plugin", "")
W.bar_item_new("(extra)buffer_name", "matrix_bar_item_name", "") W.bar_item_new("(extra)buffer_name", "matrix_bar_item_name", "")
W.bar_item_new("(extra)lag", "matrix_bar_item_lag", "") W.bar_item_new("(extra)lag", "matrix_bar_item_lag", "")
W.bar_item_new("(extra)buffer_modes", "matrix_bar_item_buffer_modes", "")

View file

@ -109,6 +109,7 @@ def matrix_fetch_old_messages(server, room_id):
token=prev_batch, token=prev_batch,
limit=OPTIONS.backlog_limit) limit=OPTIONS.backlog_limit)
room.backlog_pending = True room.backlog_pending = True
W.bar_item_update("buffer_modes")
server.send_or_queue(message) server.send_or_queue(message)

View file

@ -344,6 +344,7 @@ class MatrixBacklogEvent(MatrixEvent):
room.prev_batch = self.end_token room.prev_batch = self.end_token
room.backlog_pending = False room.backlog_pending = False
W.bar_item_update("buffer_modes")
class MatrixSyncEvent(MatrixEvent): class MatrixSyncEvent(MatrixEvent):