From e615a8e2e387cb0929b8406a47c5bc2098df937a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Fri, 2 Nov 2018 22:21:15 +0100 Subject: [PATCH] Add possibility to get windows by jid This also makes it possible to get windows by an account/jid combination --- gajim/common/app.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/gajim/common/app.py b/gajim/common/app.py index 63b7e2e61..c5995fa3f 100644 --- a/gajim/common/app.py +++ b/gajim/common/app.py @@ -630,19 +630,22 @@ def prefers_app_menu(): return False return app.prefers_app_menu() -def get_app_window(cls, account=None): +def get_app_window(cls, account=None, jid=None): for win in app.get_windows(): if isinstance(cls, str): - if type(win).__name__ == cls: - if account is not None: - if account != win.account: - continue - return win - elif isinstance(win, cls): - if account is not None: - if account != win.account: - continue - return win + if type(win).__name__ != cls: + continue + elif not isinstance(win, cls): + continue + + if account is not None: + if account != win.account: + continue + + if jid is not None: + if jid != win.jid: + continue + return win return None def load_css_config():