Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix right-to-left layout direction issues #12181

Merged
merged 17 commits into from
Mar 18, 2021
Merged
18 changes: 14 additions & 4 deletions source/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# This file is covered by the GNU General Public License.
# See the file COPYING for more details.

from typing import Optional
import wx
import languageHandler
from typing import Optional, TYPE_CHECKING
if TYPE_CHECKING:
import wx

"""NVDA core"""

Expand Down Expand Up @@ -88,6 +88,7 @@ def doStartupDialogs():
gui.mainFrame.onToggleSpeechViewerCommand(evt=None)
import inputCore
if inputCore.manager.userGestureMap.lastUpdateContainedError:
import wx
gui.messageBox(_("Your gesture map file contains errors.\n"
"More details about the errors can be found in the log file."),
_("gesture map File Error"), wx.OK|wx.ICON_EXCLAMATION)
Expand All @@ -99,6 +100,7 @@ def doStartupDialogs():
if updateCheck and not config.conf['update']['askedAllowUsageStats']:
# a callback to save config after the usage stats question dialog has been answered.
def onResult(ID):
import wx
if ID in (wx.ID_YES,wx.ID_NO):
try:
config.conf.save()
Expand All @@ -110,6 +112,7 @@ def onResult(ID):
def restart(disableAddons=False, debugLogging=False):
"""Restarts NVDA by starting a new copy."""
if globalVars.appArgs.launcher:
import wx
globalVars.exitCode=3
wx.GetApp().ExitMainLoop()
return
Expand Down Expand Up @@ -147,6 +150,7 @@ def resetConfiguration(factoryDefaults=False):
import brailleInput
import speech
import vision
import languageHandler
import inputCore
import tones
log.debug("Terminating vision")
Expand Down Expand Up @@ -207,7 +211,9 @@ def _setInitialFocus():
log.exception("Error retrieving initial focus")


def getWxLangOrNone() -> Optional[wx.LanguageInfo]:
def getWxLangOrNone() -> Optional['wx.LanguageInfo']:
import languageHandler
import wx
lang = languageHandler.getLanguage()
locale = wx.Locale()
wxLang = locale.FindLanguageInfo(lang)
Expand Down Expand Up @@ -266,6 +272,7 @@ def main():
logHandler.setLogLevelFromConfig()
try:
lang = config.conf["general"]["language"]
import languageHandler
log.debug("setting language to %s"%lang)
languageHandler.setLanguage(lang)
except:
Expand Down Expand Up @@ -301,6 +308,7 @@ def main():
log.debugWarning("Slow starting core (%.2f sec)" % (time.time()-globalVars.startTime))
# Translators: This is spoken when NVDA is starting.
speech.speakMessage(_("Loading NVDA. Please wait..."))
import wx
# wxPython 4 no longer has either of these constants (despite the documentation saying so), some add-ons may rely on
# them so we add it back into wx. https://wxpython.org/Phoenix/docs/html/wx.Window.html#wx.Window.Centre
wx.CENTER_ON_SCREEN = wx.CENTRE_ON_SCREEN = 0x2
Expand Down Expand Up @@ -658,6 +666,7 @@ def requestPump():
return
# This isn't the main thread. wx timers cannot be run outside the main thread.
# Therefore, Have wx start it in the main thread with a CallAfter.
import wx
wx.CallAfter(_pump.Start,PUMP_MAX_DELAY, True)

def callLater(delay, callable, *args, **kwargs):
Expand All @@ -666,6 +675,7 @@ def callLater(delay, callable, *args, **kwargs):
This function should never be used to execute code that brings up a modal UI as it will cause NVDA's core to block.
This function can be safely called from any thread.
"""
import wx
if threading.get_ident() == mainThreadId:
return wx.CallLater(delay, _callLaterExec, callable, args, kwargs)
else:
Expand Down