Fix for thunderbird.

This commit is contained in:
Storm Dragon
2025-12-24 10:18:52 -05:00
parent 200faa9e36
commit 763ae5303b
3 changed files with 107 additions and 1 deletions

View File

@@ -1,10 +1,11 @@
thunderbird_python_sources = files([
'__init__.py',
'script.py',
'script_utilities.py',
'spellcheck.py',
])
python3.install_sources(
thunderbird_python_sources,
subdir: 'cthulhu/scripts/apps/Thunderbird'
)
)

View File

@@ -43,6 +43,7 @@ from cthulhu.ax_object import AXObject
from cthulhu.ax_utilities import AXUtilities
from .spellcheck import SpellCheck
from .script_utilities import Utilities
_settingsManager = settings_manager.getManager()
@@ -97,6 +98,11 @@ class Script(Gecko.Script):
return SpellCheck(self)
def getUtilities(self):
"""Returns the utilities for this script."""
return Utilities(self)
def getAppPreferencesGUI(self):
"""Return a GtkGrid containing the application unique configuration
GUI items for the current application."""
@@ -356,6 +362,8 @@ class Script(Gecko.Script):
[obj, offset] = self.utilities.findFirstCaretContext(documentFrame, 0)
self.utilities.setCaretPosition(obj, offset)
self.updateBraille(obj)
if obj and self._navSuspended and self.utilities.inDocumentContent(obj):
self._setNavigationSuspended(False, "message content loaded")
if _settingsManager.getSetting('pageSummaryOnLoad'):
tokens = ["THUNDERBIRD: Getting page summary for obj", obj]

View 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