server: Turn the connected flag into a property.

This way we update the necessary bar items automatically, when we change
the flag.
This commit is contained in:
Damir Jelić 2019-01-24 11:54:22 +01:00
parent 25f4f43b3f
commit 92ff15943c

View file

@ -229,7 +229,7 @@ class MatrixServer(object):
self.timer_hook = None # type: Optional[str]
self.numeric_address = "" # type: Optional[str]
self.connected = False # type: bool
self._connected = False # type: bool
self.connecting = False # type: bool
self.keys_queried = False # type: bool
self.reconnect_delay = 0 # type: int
@ -286,6 +286,16 @@ class MatrixServer(object):
).format(prefix=W.prefix("error"))
W.prnt("", message)
@property
def connected(self):
return self._connected
@connected.setter
def connected(self, value):
self._connected = value
W.bar_item_update("buffer_modes")
W.bar_item_update("matrix_modes")
def get_session_path(self):
home_dir = W.info_get("weechat_dir", "")
return os.path.join(home_dir, "matrix", self.name)