Exemple #1
0
	def makeSettings(self, sizer: wx.Sizer) -> None:
		"""Populate the dialog with WX controls.
		@param sizer: The sizer to which to add the WX controls.
		@type sizer: wx.Sizer
		"""
		sHelper = gui.guiHelper.BoxSizerHelper(self, sizer=sizer)
		self.gesturesList = sHelper.addLabeledControl(
			# Translators: Label above the list of found gestures
			_("Select a gesture from the list"),
			AutoWidthColumnListCtrl,
			autoSizeColumn=1,  # The replacement column is likely to need the most space
			itemTextCallable=None,
			style=wx.LC_REPORT | wx.LC_SINGLE_SEL
		)
		# Translators: The label for a first column in the list of gestures
		self.gesturesList.InsertColumn(0, _("Gesture"), width=150)
		# Translators: The label for the second column in the list of gestures
		self.gesturesList.InsertColumn(1, _("Script description or function name"))
		# Translators: The label for the third column in the list of gestures
		self.gesturesList.InsertColumn(2, _("Category"), width=150)

		sizer.Fit(self)
		self.Center(wx.BOTH | wx.Center)

		# Fill in the list of available input gestures
		gestureDisplayText = lambda gest: "{1} ({0})".format(*getDisplayTextForGestureIdentifier(gest))  # noqa E731 do not assign a lambda expression, use a def
		for gesture in sorted(self.gestures, key=lambda x: x.gesture):
			self.gesturesList.Append((
				gestureDisplayText(gesture.gesture),
				gesture.displayName or gesture.scriptName,
				gesture.category or f"[{gesture.moduleName}]"
			))
		self.gesturesList.SetFocus()
		self.gesturesList.Focus(0)
		self.gesturesList.Select(0)
Exemple #2
0
def getGestureLabel(gesture):
	source, main = inputCore.getDisplayTextForGestureIdentifier(
		inputCore.normalizeGestureIdentifier(gesture)
	)
	if gesture.startswith("kb:"):
		return main
	return u"{main} ({source})".format(source=source, main=main)
 def getDisplayString(self):
     gestures = ""
     for identifier in self.gestures.keys():
         source, main = inputCore.getDisplayTextForGestureIdentifier(
             identifier)
         gestures += main + " "
     #g = inputCore.getDisplayTextForGestureIdentifier(identifier)
     return self.name + " " + gestures
Exemple #4
0
def getRuleLabel(rule):
	label = rule.name
	if rule._gestureMap:
		label += u" ({gestures})".format(gestures=u", ".join(
			inputCore.getDisplayTextForGestureIdentifier(identifier)[1]
			for identifier in rule._gestureMap.keys()
		))
	return label
Exemple #5
0
def _formatGesture(identifier):
    try:
        source, main = inputCore.getDisplayTextForGestureIdentifier(identifier)
        # Translators: Describes a gesture in the Input Gestures dialog.
        # {main} is replaced with the main part of the gesture; e.g. alt+tab.
        # {source} is replaced with the gesture's source; e.g. laptop keyboard.
        return _("{main} ({source})").format(main=main, source=source)
    except LookupError:
        return identifier
Exemple #6
0
	def adjustGesture (self, identifier):
		"""
		This method corrects the gestures provided as parameter, inspired from the NVDA core (module gui/settingsDialog.py, class InputGesturesDialog, method _formatGesture).
		"""
		try:
			source, main = inputCore.getDisplayTextForGestureIdentifier(identifier)
			return _("{main} ({source})").format(main=main, source=source)
		except LookupError:
			return identifier
	def doGui(self):
		self.initList()
		self.docList = sorted([doc for doc in self.docToScript])
		choice = []
		for doc in self.docList:
			script = self.docToScript[doc]
			identifier = self.scriptToIdentifier[script]
			source, main = inputCore.getDisplayTextForGestureIdentifier(identifier.lower())
			choice.append("%s: %s" % (doc, main))

		from gui import guiHelper
		mainSizer = wx.BoxSizer(wx.VERTICAL)
		sHelper = guiHelper.BoxSizerHelper(self, orientation=wx.VERTICAL)

		# Translators: This is the label of the list
# appearing on Shell Scripts List Dialog.
		labelText = _("scripts:")
		self.scriptsListBox = sHelper.addLabeledControl(
			labelText,
			wx.ListBox,
			id=wx.ID_ANY,
			choices=choice,
			style=wx.LB_SINGLE,
			size=(700, 280))
		if self.scriptsListBox.GetCount():
			self.scriptsListBox.SetSelection(0)
		# Buttons
		bHelper = sHelper.addDialogDismissButtons(guiHelper.ButtonHelper(wx.HORIZONTAL))
		# Translators: This is a label of a button
		# appearing on Shell Scripts List Dialog.
		runScriptButton = bHelper.addButton(
			self,
			id=wx.ID_ANY,
			label=_("&Run script"))
		runScriptButton.SetDefault()
		closeButton = bHelper.addButton(
			self,
			id=wx.ID_CLOSE,
			label=NVDAString("&Close"))
		mainSizer.Add(sHelper.sizer, border=guiHelper.BORDER_FOR_DIALOGS, flag=wx.ALL)
		mainSizer.Fit(self)
		self.SetSizer(mainSizer)
		# Events
		runScriptButton.Bind(wx.EVT_BUTTON, self.onRunScriptButton)
		closeButton.Bind(wx.EVT_BUTTON, lambda evt: self.Destroy())
		self.SetEscapeId(wx.ID_CLOSE)
 def updateGesturesList(self, newGestureIdentifier=None):
     self.gesturesList.Clear()
     i = 0
     sel = 0
     for gestureIdentifier in self.gestureMapValue:
         gestureSource, gestureMain = inputCore.getDisplayTextForGestureIdentifier(
             gestureIdentifier)
         actionStr = self.markerManager.getActions()[
             self.gestureMapValue[gestureIdentifier]]
         self.gesturesList.Append("%s = %s" % (gestureMain, actionStr),
                                  gestureIdentifier)
         if gestureIdentifier == newGestureIdentifier:
             sel = i
         i += 1
     if len(self.gestureMapValue) > 0:
         self.gesturesList.SetSelection(sel)
     self.onGesturesListChoice(None)
     self.gesturesList.SetFocus()
Exemple #9
0
	def _captureFunc(self, gesture):
		oldValue = self.inputShortcut.Value
		if gesture.isModifier:
			return False
		gestureIdentifier = None
		# Search the shortest gesture identifier (without source)
		for identifier in gesture.normalizedIdentifiers:
			if gestureIdentifier is None:
				gestureIdentifier = identifier
			elif len(identifier) < len(gestureIdentifier):
				gestureIdentifier = identifier

		source, main = inputCore.getDisplayTextForGestureIdentifier(
			gestureIdentifier
		)

		if gestureIdentifier not in [
			"kb:tab",
			"kb:shift+tab",
			"kb:escape",
			"kb:enter",
		]:
			# TODO: Why isn't braille refreshed?
			self.inputShortcut.Value = main
			global resultShortcut
			resultShortcut = gestureIdentifier
			if oldValue != main:
				wx.CallAfter(
					wx.CallLater,
					100,
					ui.message,
					_(u"Shortcut set to %s" % main)
				)
		elif gestureIdentifier == "kb:tab":
			return True
		elif gestureIdentifier == "kb:shift+tab":
			return True
		elif gestureIdentifier == "kb:escape":
			self.onCancel(None)
		elif gestureIdentifier == "kb:enter":
			speech.cancelSpeech()
			self.onOk(None)
		return False
Exemple #10
0
 def updateGesturesList(self, newGestureIdentifier=None):
     self.gesturesList.Clear()
     i = 0
     sel = 0
     for gestureIdentifier in self.gestureMapValue:
         gestureSource, gestureMain = \
          inputCore.getDisplayTextForGestureIdentifier(gestureIdentifier)
         actionStr = self.markerManager.getActions()[
             self.gestureMapValue[gestureIdentifier]]
         self.gesturesList.Append("%s = %s" % (gestureMain, actionStr),
                                  gestureIdentifier)
         if gestureIdentifier == newGestureIdentifier:
             sel = i
         i += 1
     if len(self.gestureMapValue) > 0:
         self.gesturesList.SetSelection(sel)
     self.onGesturesListChoice(None)
     self.gesturesList.SetFocus()
     self.Sizer.Layout()
     if not self.IsMaximized():
         self.Fit()
         if not self.hasMoved:
             self.CenterOnScreen()
    def selectGestureAction(self, gesture):
        self.gesturesList.Delete(0)
        speechOn()
        gestureIdentifier = None
        # search the shortest gesture identifier(without source)
        for identifier in gesture.identifiers:
            if gestureIdentifier is None:
                gestureIdentifier = identifier
            elif len(identifier) < len(gestureIdentifier):
                gestureIdentifier = identifier

        source, main = inputCore.getDisplayTextForGestureIdentifier(identifier)
        menuTitle = u"Choisir l'action associee au raccourci %s" % main

        # popup menu
        menu = wx.Menu(menuTitle, style=0)
        for action, description in self.markerManager.getActions().items():
            item = menu.Append(wx.ID_ANY, description)
            self.Bind(wx.EVT_MENU,
                      lambda evt, gestureIdentifier=gestureIdentifier, action=
                      action: self.addGestureAction(gestureIdentifier, action),
                      item)
        self.PopupMenu(menu)
 def getDisplayString(self):
     return u" ".join([self.name] + [
         inputCore.getDisplayTextForGestureIdentifier(identifier)[1]
         for identifier in self._gestureMap.keys()
     ])