bar_items: Return sane defaults if we're not on our own buffer.

This commit is contained in:
Damir Jelić 2019-02-22 09:29:42 +01:00
parent 2ab1885b5f
commit 12bf9c85c4

View file

@ -32,7 +32,10 @@ def matrix_bar_item_plugin(data, item, window, buffer, extra_info):
name=server.name,
)
return ""
ptr_plugin = W.buffer_get_pointer(buffer, "plugin")
name = W.plugin_get_name(ptr_plugin)
return name
@utf8_decode
@ -66,6 +69,24 @@ def matrix_bar_item_name(data, item, window, buffer, extra_info):
name=server.name,
)
name = W.buffer_get_string(buffer, "name")
if name:
localvar_type = W.buffer_get_string(buffer, "localvar_type")
is_channel = localvar_type == "channel"
if is_channel:
name = W.buffer_get_string(buffer, "localvar_channel")
return "{}{}{}{}{}{}".format(
W.color("bar_delim") if is_channel else "",
"(" if is_channel else "",
W.color("status_name"),
name,
W.color("bar_delim") if is_channel else "",
")" if is_channel else "",
)
return ""
@ -127,6 +148,12 @@ def matrix_bar_nicklist_count(data, item, window, buffer, extra_info):
room = room_buffer.room
return str(room.member_count)
nick_count = W.buffer_get_integer(buffer, "nicklist_nicks_count")
nicklist_enabled = bool(W.buffer_get_integer(buffer, "nicklist"))
if nicklist_enabled:
return str(nick_count)
return ""