1# Orca 2# 3# Copyright 2018 Igalia, S.L. 4# 5# Author: Joanmarie Diggs <jdiggs@igalia.com> 6# 7# This library is free software; you can redistribute it and/or 8# modify it under the terms of the GNU Lesser General Public 9# License as published by the Free Software Foundation; either 10# version 2.1 of the License, or (at your option) any later version. 11# 12# This library is distributed in the hope that it will be useful, 13# but WITHOUT ANY WARRANTY; without even the implied warranty of 14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15# Lesser General Public License for more details. 16# 17# You should have received a copy of the GNU Lesser General Public 18# License along with this library; if not, write to the 19# Free Software Foundation, Inc., Franklin Street, Fifth Floor, 20# Boston MA 02110-1301 USA. 21 22"""Custom chat module for Smuxi.""" 23 24__id__ = "$Id$" 25__version__ = "$Revision$" 26__date__ = "$Date$" 27__copyright__ = "Copyright (c) 2018 Igalia, S.L." 28__license__ = "LGPL" 29 30import pyatspi 31 32import orca.chat as chat 33 34 35class Chat(chat.Chat): 36 37 def __init__(self, script, buddyListAncestries): 38 39 super().__init__(script, buddyListAncestries) 40 41 def isFocusedChat(self, obj): 42 """Returns True if we plan to treat this chat as focused.""" 43 44 isPageTab = lambda x: x and x.getRole() == pyatspi.ROLE_PAGE_TAB 45 pageTab = pyatspi.findAncestor(obj, isPageTab) 46 if pageTab is None: 47 return super().isFocusedChat(obj) 48 49 return pageTab.getState().contains(pyatspi.STATE_SHOWING) 50