Fix for thunderbird.
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
thunderbird_python_sources = files([
|
thunderbird_python_sources = files([
|
||||||
'__init__.py',
|
'__init__.py',
|
||||||
'script.py',
|
'script.py',
|
||||||
|
'script_utilities.py',
|
||||||
'spellcheck.py',
|
'spellcheck.py',
|
||||||
])
|
])
|
||||||
|
|
||||||
python3.install_sources(
|
python3.install_sources(
|
||||||
thunderbird_python_sources,
|
thunderbird_python_sources,
|
||||||
subdir: 'cthulhu/scripts/apps/Thunderbird'
|
subdir: 'cthulhu/scripts/apps/Thunderbird'
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ from cthulhu.ax_object import AXObject
|
|||||||
from cthulhu.ax_utilities import AXUtilities
|
from cthulhu.ax_utilities import AXUtilities
|
||||||
|
|
||||||
from .spellcheck import SpellCheck
|
from .spellcheck import SpellCheck
|
||||||
|
from .script_utilities import Utilities
|
||||||
|
|
||||||
_settingsManager = settings_manager.getManager()
|
_settingsManager = settings_manager.getManager()
|
||||||
|
|
||||||
@@ -97,6 +98,11 @@ class Script(Gecko.Script):
|
|||||||
|
|
||||||
return SpellCheck(self)
|
return SpellCheck(self)
|
||||||
|
|
||||||
|
def getUtilities(self):
|
||||||
|
"""Returns the utilities for this script."""
|
||||||
|
|
||||||
|
return Utilities(self)
|
||||||
|
|
||||||
def getAppPreferencesGUI(self):
|
def getAppPreferencesGUI(self):
|
||||||
"""Return a GtkGrid containing the application unique configuration
|
"""Return a GtkGrid containing the application unique configuration
|
||||||
GUI items for the current application."""
|
GUI items for the current application."""
|
||||||
@@ -356,6 +362,8 @@ class Script(Gecko.Script):
|
|||||||
[obj, offset] = self.utilities.findFirstCaretContext(documentFrame, 0)
|
[obj, offset] = self.utilities.findFirstCaretContext(documentFrame, 0)
|
||||||
self.utilities.setCaretPosition(obj, offset)
|
self.utilities.setCaretPosition(obj, offset)
|
||||||
self.updateBraille(obj)
|
self.updateBraille(obj)
|
||||||
|
if obj and self._navSuspended and self.utilities.inDocumentContent(obj):
|
||||||
|
self._setNavigationSuspended(False, "message content loaded")
|
||||||
|
|
||||||
if _settingsManager.getSetting('pageSummaryOnLoad'):
|
if _settingsManager.getSetting('pageSummaryOnLoad'):
|
||||||
tokens = ["THUNDERBIRD: Getting page summary for obj", obj]
|
tokens = ["THUNDERBIRD: Getting page summary for obj", obj]
|
||||||
|
|||||||
97
src/cthulhu/scripts/apps/Thunderbird/script_utilities.py
Normal file
97
src/cthulhu/scripts/apps/Thunderbird/script_utilities.py
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
#
|
||||||
|
# Copyright (c) 2024 Stormux
|
||||||
|
# Copyright (c) 2010-2012 The Orca Team
|
||||||
|
# Copyright (c) 2012 Igalia, S.L.
|
||||||
|
# Copyright (c) 2005-2010 Sun Microsystems Inc.
|
||||||
|
#
|
||||||
|
# This library is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2.1 of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This library is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with this library; if not, write to the
|
||||||
|
# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
|
||||||
|
# Boston MA 02110-1301 USA.
|
||||||
|
#
|
||||||
|
# Fork of Orca Screen Reader (GNOME)
|
||||||
|
# Original source: https://gitlab.gnome.org/GNOME/orca
|
||||||
|
|
||||||
|
"""Thunderbird-specific utility overrides."""
|
||||||
|
|
||||||
|
__id__ = "$Id$"
|
||||||
|
__version__ = "$Revision$"
|
||||||
|
__date__ = "$Date$"
|
||||||
|
__copyright__ = "Copyright (c) 2010 Joanmarie Diggs."
|
||||||
|
__license__ = "LGPL"
|
||||||
|
|
||||||
|
import cthulhu.debug as debug
|
||||||
|
from cthulhu.ax_object import AXObject
|
||||||
|
from cthulhu.ax_utilities import AXUtilities
|
||||||
|
from cthulhu.scripts.toolkits.Gecko.script_utilities import Utilities as GeckoUtilities
|
||||||
|
|
||||||
|
|
||||||
|
class Utilities(GeckoUtilities):
|
||||||
|
|
||||||
|
def __init__(self, script):
|
||||||
|
super().__init__(script)
|
||||||
|
|
||||||
|
def getDocumentForObject(self, obj):
|
||||||
|
document = super().getDocumentForObject(obj)
|
||||||
|
if document:
|
||||||
|
return document
|
||||||
|
|
||||||
|
documentFrame = self._messageDocumentFrameFor(obj)
|
||||||
|
if not documentFrame:
|
||||||
|
return None
|
||||||
|
|
||||||
|
tokens = ["THUNDERBIRD: Treating document frame as document:", documentFrame]
|
||||||
|
debug.printTokens(debug.LEVEL_INFO, tokens, True)
|
||||||
|
return documentFrame
|
||||||
|
|
||||||
|
def getTopLevelDocumentForObject(self, obj):
|
||||||
|
document = super().getTopLevelDocumentForObject(obj)
|
||||||
|
if document:
|
||||||
|
return document
|
||||||
|
|
||||||
|
documentFrame = self._messageDocumentFrameFor(obj)
|
||||||
|
if not documentFrame:
|
||||||
|
return None
|
||||||
|
|
||||||
|
tokens = ["THUNDERBIRD: Treating document frame as top-level document:", documentFrame]
|
||||||
|
debug.printTokens(debug.LEVEL_INFO, tokens, True)
|
||||||
|
return documentFrame
|
||||||
|
|
||||||
|
def _messageDocumentFrameFor(self, obj):
|
||||||
|
if not obj:
|
||||||
|
return None
|
||||||
|
|
||||||
|
if AXUtilities.is_document_frame(obj) and self._isMessageDocumentFrame(obj):
|
||||||
|
return obj
|
||||||
|
|
||||||
|
documentFrame = AXObject.find_ancestor(obj, AXUtilities.is_document_frame)
|
||||||
|
if documentFrame and self._isMessageDocumentFrame(documentFrame):
|
||||||
|
return documentFrame
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
def _isMessageDocumentFrame(self, obj):
|
||||||
|
if not obj or not AXUtilities.is_document_frame(obj):
|
||||||
|
return False
|
||||||
|
|
||||||
|
uri = self.documentFrameURI(obj)
|
||||||
|
if uri:
|
||||||
|
for prefix in ("about:message", "mailbox:", "imap:", "imaps:",
|
||||||
|
"news:", "nntp:", "pop:", "pop3:",
|
||||||
|
"smtp:", "smtps:"):
|
||||||
|
if uri.startswith(prefix):
|
||||||
|
return True
|
||||||
|
|
||||||
|
name = (AXObject.get_name(obj) or "").lower()
|
||||||
|
return "message" in name
|
||||||
Reference in New Issue
Block a user