Skip to content

Commit

Permalink
Version 7.0-dev
Browse files Browse the repository at this point in the history
* Activation settings shown as a panel under NVDA settings.
* Customize emoticons shown as Emoticons dictionary under speech dictionaries.
* Insert emoticon movet under Tools menu.
* Requires NVDA 2018.2 or later.
* Prevent installation in earlier versions.
  • Loading branch information
nvdaes committed May 14, 2018
1 parent 0094e1c commit e1280c1
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 44 deletions.
64 changes: 30 additions & 34 deletions addon/globalPlugins/emoticons/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: UTF-8 -*-
#Copyright (C) 2013-2017 Noelia Ruiz Martínez, Mesar Hameed, Francisco Javier Estrada Martínez
#Copyright (C) 2013-2018 Noelia Ruiz Martínez, Mesar Hameed, Francisco Javier Estrada Martínez
# Released under GPL 2

import globalPluginHandler
Expand All @@ -13,9 +13,8 @@
import wx
import gui
import addonHandler
from gui.settingsDialogs import SettingsDialog
from gui.settingsDialogs import DictionaryDialog
from gui import guiHelper
from gui.settingsDialogs import NVDASettingsDialog, SettingsPanel, DictionaryDialog
from smileysList import emoticons
from skipTranslation import translate
from globalCommands import SCRCAT_SPEECH, SCRCAT_TOOLS, SCRCAT_CONFIG
Expand All @@ -26,6 +25,11 @@
ADDON_DICTS_PATH = os.path.join(os.path.dirname(__file__), "emoticons")
EXPORT_DICTS_PATH = os.path.join(speechDictHandler.speechDictsPath, "emoticons")
ADDON_DIC_DEFAULT_FILE = os.path.join(ADDON_DICTS_PATH, "emoticons.dic")
ADDON_SUMMARY = addonHandler.getCodeAddon().manifest["summary"]
try:
ADDON_PANEL_TITLE = unicode(ADDON_SUMMARY)
except NameError:
ADDON_PANEL_TITLE = str(ADDON_SUMMARY)

confspec = {
"announcement": "integer(default=0)",
Expand Down Expand Up @@ -82,31 +86,22 @@ def __init__(self):
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.
self.toolsMenu = gui.mainFrame.sysTrayIcon.toolsMenu
self.insertItem = self.toolsMenu.Append(wx.ID_ANY,
# Translators: the name for a menu item.
_("&Insert emoticon..."),
# Translators: the tooltip text for an item of addon submenu.
# 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.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.
self.dicMenu = gui.mainFrame.sysTrayIcon.preferencesMenu.GetMenuItems()[1].GetSubMenu()
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)
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)
NVDASettingsDialog.categoryClasses.append(AddonSettingsPanel)

# Config
if config.conf["emoticons"]["announcement"]:
activateAnnouncement()
Expand All @@ -117,9 +112,11 @@ def __init__(self):

def terminate(self):
try:
self.menu.RemoveItem(self.mainItem)
self.toolsMenun.RemoveItem(self.insertItem)
self.dicMenu.RemoveItem(self.dicItem)
except:
pass
NVDASettingsDialog.categoryClasses.remove(AddonSettingsPanel)
deactivateAnnouncement()
try:
config.configProfileSwitched.unregister(self.handleConfigProfileSwitch)
Expand All @@ -146,8 +143,8 @@ def onEmDicDialog(self, evt):
deactivateAnnouncement()
gui.mainFrame._popupSettingsDialog(EmDicDialog,_("Emoticons dictionary (%s)" % disp), sD)

def onActivateDialog(self, evt):
gui.mainFrame._popupSettingsDialog(ActivateEmoticonsDialog)
def onSettingsPanel(self, evt):
gui.mainFrame._popupSettingsDialog(NVDASettingsDialog, AddonSettingsPanel)

def script_toggleSpeakingEmoticons(self, gesture):
if not globalVars.speechDictionaryProcessing:
Expand Down Expand Up @@ -177,11 +174,11 @@ def script_emDicDialog(self, gesture):
# Translators: Message presented in input help mode.
script_emDicDialog.__doc__ = _("Shows the Emoticons dictionary dialog.")

def script_activateDialog(self, gesture):
wx.CallAfter(self.onActivateDialog, None)
script_activateDialog.category = SCRCAT_CONFIG
def script_settings(self, gesture):
wx.CallAfter(self.onSettingsPanel, None)
script_settings.category = SCRCAT_CONFIG
# Translators: Message presented in input help mode.
script_activateDialog.__doc__ = _("Shows the Emoticons Activation settings dialog.")
script_settings.__doc__ = _("Shows the Emoticons settings.")

__gestures = {
"kb:NVDA+e": "toggleSpeakingEmoticons",
Expand Down Expand Up @@ -398,10 +395,10 @@ def OnExportClick(self, evt):
savePath = os.path.join(EXPORT_DICTS_PATH, "emoticons.dic")
sD.save(savePath)

class ActivateEmoticonsDialog(SettingsDialog):
class AddonSettingsPanel(SettingsPanel):

# Translators: this is the label for the Emoticons activate dialog.
title = _("Activation settings")
title = ADDON_PANEL_TITLE

def makeSettings(self, settingsSizer):
sHelper = guiHelper.BoxSizerHelper(self, sizer=settingsSizer)
Expand All @@ -417,11 +414,10 @@ def makeSettings(self, settingsSizer):
def postInit(self):
self.activateList.SetFocus()

def onOk(self,evt):
def onSave(self):
config.conf["emoticons"]["announcement"] = self.activateList.GetSelection()
if config.conf["emoticons"]["announcement"]:
activateAnnouncement()
else:
deactivateAnnouncement()
config.conf["emoticons"]["cleanDicts"] = self.removeCheckBox.Value
super(ActivateEmoticonsDialog, self).onOk(evt)
3 changes: 2 additions & 1 deletion addon/installTasks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: UTF-8 -*-
#Copyright (C) 2013-2017 Noelia Ruiz Martínez, other contributors
#Copyright (C) 2013-2018 Noelia Ruiz Martínez, other contributors
# Released under GPL2

import config
Expand All @@ -14,6 +14,7 @@
addonHandler.initTranslation()

def onInstall():
from gui import SettingsPanel, NVDASettingsDialog
import speechDictHandler
import globalVars
import os
Expand Down
2 changes: 1 addition & 1 deletion buildVars.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# Translators: Long description to be shown for this add-on on add-on information from add-ons manager
"addon_description" : _("Enables the announcement of emoticon names instead of the character Representation."),
# version
"addon_version" : "6.4",
"addon_version" : "7.0-dev",
# Author(s)
"addon_author" : u"Chris Leo <llajta2012@gmail.com>, Noelia Ruiz Martínez <nrm1977@gmail.com>, Mesar Hameed <mhameed@src.gnome.org>, Francisco Javier Estrada Martínez <Fjestrad@hotmail.com>",
# URL for the add-on documentation support
Expand Down
23 changes: 15 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Sometimes an image is worth a 1000 words: use the new emoji to liven up your ins

When you are unsure of the characters for a particular smiley, this addon enables you to select and insert it into your text such as in a chat.

Press NVDA+I, or from menu Preferences -> Manage emoticons -> Insert emoticon, to open a dialog with the provided emoticons or emoji.
Press NVDA+I, or from menu Tools -> Insert emoticon, to open a dialog with the provided emoticons or emoji.

This dialog allows you to choose an emoticon and to view the emoticons that interest you:

Expand All @@ -26,37 +26,44 @@ This dialog allows you to choose an emoticon and to view the emoticons that inte

When you press OK, the characters for the chosen emoticon will be copied to your clipboard, ready for pasting.

## Customize emoticons ##
## Emoticons dictionary ##

Emoticons add-on allows to have differents speech-dictionaries using configuration profiles.

This means that you can create or edit a specific speech-dictionary for each your custom profile.

From NVDA MENU, Preferences -> Manage emoticons -> Customize emoticons, you can open a dialog setting to add or to edit available emoticons.
From NVDA MENU, Preferences -> Speech dictionaries -> Emoticons dictionary, you can open a dialog to add or to edit available emoticons.

Saving your customizations, the new reading settings of emoticons will only apply to the profile you are currently editing.

For example, you may wish that NVDA spoken custom emoticons only in XxChat program, but not in other chat programs: you can do this by creating a profile for the XxChat application and assign to it a speech dictionary from Customize Emoticons menu. See below for activation setting in relation to the configuration profiles.
For example, you may wish that NVDA spoken custom emoticons only in XxChat program, but not in other chat programs: you can do this by creating a profile for the XxChat application and assign to it a speech dictionary from Speech dictionaries menu, Emoticons dictionary option. See below for Emoticons settings in relation to the configuration profiles.

You can also export each custom speech-dictionary pressing "Save and export dictionary" button: in this way your speech-dictionaries will be saved in your user config folder, speechDicts/emoticons subfolder.

The exact name and location of the dictionary file will be based on the editing configuration profile, which will be shown in the title of the Emoticons dictionary dialog.

## Activation settings ##
## Emoticons settings ##

From menu Preferences -> Manage Emoticons -> Activation-settings opens a dialog to configure the activation of your speech-dictionaries for each profile.
From menu Preferences -> Settings -> Emoticons opens a panel to configure the activation of your speech-dictionaries for each profile.

In activation-setting dialog you can choose whether or not speech-dictionary should automatically activate when NVDA switches to the profile you are currently editing. By default it is disabled in normal configuration of NVDA and in all your new profiles.
In Emoticons settings panel you can choose whether or not speech-dictionary should automatically activate when NVDA switches to the profile you are currently editing. By default it is disabled in normal configuration of NVDA and in all your new profiles.

If you may wish to keep clean your configuration folders, in this dialog it is also possible to choose if dictionaries not used (associated with non existing profiles) will be removed from the add-on when it is unloaded.

## Key Commands: ##

These are the key command available by default, you can edit those or add new key to open Activation settings dialog or Emoticon Dictionary dialog:
These are the key commands available by default, you can edit those or add new key to open Emoticons settings panel or Emoticon Dictionary dialog:

* NVDA+E: speaking emoticons on/off, toggles between speaking text as it is written, or with the emoticons replaced by the human description.
* NVDA+I: show a dialog to select an emoticon you want to copy.


## Changes for 7.0 ##

* The Activation settings dialog has been moved to a panel in NVDA settings, so that the current profile will be shown in the title of the NVDA settings dialog.
* The Manage Emoticons menu has been removed: now Insert emoticon will be found under the Tools menu, and Customize Emoticons will be shown under Speech dictionaries like Emoticons dictionary.
* Requires NVDA 2018.2 or later.

## Changes for 6.0 ##

* Added support for configuration profiles.
Expand Down

0 comments on commit e1280c1

Please sign in to comment.