Ejemplo n.º 1
0
 def __init__(self):
     super(globalPluginHandler.GlobalPlugin, self).__init__()
     for em in emoticons:
         if em.isEmoji:
             # Translators: A prefix to each emoticon name, added to the temporary speech dictionary, visible in temporary speech dictionary dialog when the addon is active, to explain an entry.
             emType = _("Emoji")
         else:
             # Translators: A prefix to each emoticon name, added to the temporary speech dictionary, visible in temporary speech dictionary dialog when the addon is active, to explain an entry.
             emType = _("Emoticon")
         comment = u"{type}: {name}".format(type=emType, name=em.name)
         otherReplacement = " %s; " % em.name
         # Case and reg are always True
         defaultDic.append(
             speechDictHandler.SpeechDictEntry(
                 em.pattern, otherReplacement, comment, True,
                 speechDictHandler.ENTRY_TYPE_REGEXP))
     self.loadDic()
     # Gui
     self.menu = gui.mainFrame.sysTrayIcon.preferencesMenu
     self.emMenu = wx.Menu()
     self.mainItem = self.menu.AppendSubMenu(
         self.emMenu,
         # Translators: the name of addon submenu.
         _("Manag&e emoticons"),
         # Translators: the tooltip text for addon submenu.
         _("Emoticons menu"))
     self.insertItem = self.emMenu.Append(
         wx.ID_ANY,
         # Translators: the name for an item of addon submenu.
         _("&Insert emoticon..."),
         # Translators: the tooltip text for an item of addon submenu.
         _("Shows a dialog to insert a smiley"))
     gui.mainFrame.sysTrayIcon.Bind(wx.EVT_MENU,
                                    self.onInsertEmoticonDialog,
                                    self.insertItem)
     self.dicItem = self.emMenu.Append(
         wx.ID_ANY,
         # Translators: the name for an item of addon submenu.
         _("&Customize emoticons..."),
         # Translators: the tooltip text for an item of addon submenu.
         _("Shows a dictionary dialog to customize emoticons"))
     gui.mainFrame.sysTrayIcon.Bind(wx.EVT_MENU, self.onEmDicDialog,
                                    self.dicItem)
     self.activateItem = self.emMenu.Append(
         wx.ID_ANY,
         # Translators: the name for an item of addon submenu.
         _("&Activation settings..."),
         # Translators: the tooltip text for an item of addon submenu.
         _("Shows a dialog to choose when emoticons speaking should be activated"
           ))
     gui.mainFrame.sysTrayIcon.Bind(wx.EVT_MENU, self.onActivateDialog,
                                    self.activateItem)
     # Config
     if config.conf["emoticons"]["announcement"]:
         activateAnnouncement()
     try:
         config.configProfileSwitched.register(
             self.handleConfigProfileSwitch)
     except AttributeError:
         pass
Ejemplo n.º 2
0
	def onOk(self, evt):
		if not self.patternTextCtrl.GetValue():
			gui.messageBox(
				# Translators: This is an error message to let the user know that the pattern field
				# in the dictionary entry is not valid.
				_("A pattern is required."),
				# Translators: The title of an error message raised by the Dictionary Entry dialog
				_("Dictionary Entry Error"),
				wx.OK | wx.ICON_WARNING,
				self
			)
			self.patternTextCtrl.SetFocus()
			return
		try:
			dictEntry = self.dictEntry = speechDictHandler.SpeechDictEntry(
				self.patternTextCtrl.GetValue(),
				self.replacementTextCtrl.GetValue(),
				self.commentTextCtrl.GetValue(),
				bool(self.caseSensitiveCheckBox.GetValue()),
				self.getType()
			)
			dictEntry.sub("test")  # Ensure there are no grouping error (#11407)
		except Exception as e:
			log.debugWarning("Could not add dictionary entry due to (regex error) : %s" % e)
			gui.messageBox(
				# Translators: This is an error message to let the user know that the dictionary entry is not valid.
				_("Regular Expression error: \"%s\".") % e,
				# Translators: The title of an error message raised by the Dictionary Entry dialog
				_("Dictionary Entry Error"),
				wx.OK | wx.ICON_WARNING,
				self
			)
			return
		evt.Skip()
 def __init__(self):
     super(GlobalPlugin, self).__init__()
     self.digitRule = speechDictHandler.SpeechDictEntry(
         r"(\d)(?=\d+(\D|\b))",
         r"\1 ",
         "numberToDigit",
         caseSensitive=False,
         type=speechDictHandler.ENTRY_TYPE_REGEXP)
     tempDict = speechDictHandler.dictionaries["temp"]
     _config.load()
     config_value = _config.numberConfig["number_announce"]
     if config_value == 'single_digit':
         tempDict.append(self.digitRule)
     elif config_value == 'double_digits':
         pass
Ejemplo n.º 4
0
    def __init__(self):
        super(GlobalPlugin, self).__init__()
        for em in emoticons:
            if em.isEmoji:
                # Translators: A prefix to each emoticon name, added to the temporary speech dictionary, visible in temporary speech dictionary dialog when the addon is active, to explain an entry.
                emType = _("Emoji")
            else:
                # Translators: A prefix to each emoticon name, added to the temporary speech dictionary, visible in temporary speech dictionary dialog when the addon is active, to explain an entry.
                emType = _("Emoticon")
            comment = "{type}: {name}".format(type=emType, name=em.name)
            otherReplacement = " %s; " % em.name
            # Case and reg are always True
            defaultDic.append(
                speechDictHandler.SpeechDictEntry(
                    em.pattern, otherReplacement, comment, True,
                    speechDictHandler.ENTRY_TYPE_REGEXP))
            if not em.isEmoji:
                noEmojisDic.append(
                    speechDictHandler.SpeechDictEntry(
                        em.pattern, otherReplacement, comment, True,
                        speechDictHandler.ENTRY_TYPE_REGEXP))
        global profileName, oldProfileName
        profileName = oldProfileName = config.conf.profiles[-1].name
        loadDic()

        # Gui
        self.toolsMenu = gui.mainFrame.sysTrayIcon.toolsMenu
        self.emoticonsMenu = wx.Menu()
        # Translators: the name of a submenu.
        self.mainItem = self.toolsMenu.AppendSubMenu(self.emoticonsMenu,
                                                     _("&Emoticons"))
        self.dicMenu = gui.mainFrame.sysTrayIcon.preferencesMenu.GetMenuItems(
        )[1].GetSubMenu()
        self.insertItem = self.emoticonsMenu.Append(
            wx.ID_ANY,
            # Translators: the name for a menu item.
            _("&Insert emoticon..."),
            # Translators: the tooltip text for a menu item.
            _("Shows a dialog to insert a smiley"))
        gui.mainFrame.sysTrayIcon.Bind(wx.EVT_MENU,
                                       self.onInsertEmoticonDialog,
                                       self.insertItem)
        self.insertSymbolItem = self.emoticonsMenu.Append(
            wx.ID_ANY,
            # Translators: the name for a menu item.
            _("In&sert symbol..."),
            # Translators: the tooltip text for a menu item.
            _("Shows a dialog to insert a symbol"))
        gui.mainFrame.sysTrayIcon.Bind(wx.EVT_MENU, self.onInsertSymbolDialog,
                                       self.insertSymbolItem)
        self.dicItem = self.dicMenu.Append(
            wx.ID_ANY,
            # Translators: the name for a menu item.
            _("&Emoticons dictionary..."),
            # Translators: the tooltip text for a menu item.
            _("Shows a dictionary dialog to customize emoticons"))
        gui.mainFrame.sysTrayIcon.Bind(wx.EVT_MENU, self.onEmDicDialog,
                                       self.dicItem)
        NVDASettingsDialog.categoryClasses.append(AddonSettingsPanel)

        # Config
        announcement = config.conf["emoticons"]["announcement"]
        if announcement:
            activateAnnouncement()
        config.post_configProfileSwitch.register(
            self.handleConfigProfileSwitch)