9 new commits in Emoticons:
https://bitbucket.org/nvdaaddonteam/emoticons/commits/d870dc7f67f9/
Changeset: d870dc7f67f9
Branch: None
User: FranciscoJavier Estrada
Date: 2016-10-25 10:05:30+00:00
Summary: Modified: InsertEmoticonDialog.
Added filter text field.
Added radio buttons to show just all emoticons, standard emoticons or
emojis.
Combobox has been replaced by a list.
Added EmoticonFilter classes:
InsertEmoticonDialog uses EmoticonFilter and subclasses to
delegate the filtering process.
Affected #: 1 file
diff --git a/addon/globalPlugins/emoticons/__init__.py
b/addon/globalPlugins/emoticons/__init__.py
index 29def01..7261037 100644
--- a/addon/globalPlugins/emoticons/__init__.py
+++ b/addon/globalPlugins/emoticons/__init__.py
@@ -1,5 +1,5 @@
# -*- coding: UTF-8 -*-
-#Copyright (C) 2013-2016 Noelia Ruiz Martínez, Mesar Hameed
+#Copyright (C) 2013-2016 Noelia Ruiz Martínez, Mesar Hameed, Francisco Javier
Estrada Martínez
# Released under GPL 2
import globalPluginHandler
@@ -154,30 +154,115 @@ class GlobalPlugin(globalPluginHandler.GlobalPlugin):
"kb:NVDA+i": "insertEmoticon",
}
-class InsertEmoticonDialog(SettingsDialog):
-
- # Translators: This is the label for the InsertEmoticon dialog.
- title = _("Insert emoticon")
-
- def makeSettings(self, settingsSizer):
- smileysListSizer = wx.BoxSizer(wx.HORIZONTAL)
- # Translators: The label for a setting in Insert emoticons to
select a smiley.
- availableEmoticonsLabel = _("Available emoticons")
- smileysListLabel = wx.StaticText(self,-1,label=u"{labelString}
({labelInt})".format(labelString=availableEmoticonsLabel,
labelInt=str(len(emoticons))))
- smileysListSizer.Add(smileysListLabel)
- smileysListID = wx.NewId()
- # Translators: A combo box to choose a smiley.
- self.smileysList=wx.Choice(self ,smileysListID,
name=_("Available smileys to insert:"), choices= [emoticon.name for emoticon in
emoticons])
- self.smileysList.SetSelection(0)
- smileysListSizer.Add(self.smileysList)
- settingsSizer.Add(smileysListSizer, border=10, flag=wx.BOTTOM)
-
- def postInit(self):
- self.smileysList.SetFocus()
-
- def onOk(self,evt):
- super(InsertEmoticonDialog, self).onOk(evt)
- icon = emoticons[self.smileysList.GetSelection()]
+class EmoticonFilter(object):
+
+ def filter(self, emoticonsList, pattern):
+ """Filter for all emoticons."""
+ if pattern == "": return emoticonsList
+ else: return filter(lambda emoticon: pattern.upper() in
emoticon.name.upper(), emoticonsList)
+
+class FilterStandard(EmoticonFilter):
+
+ def filter(self, emoticonsList, pattern):
+ """Filter just for standard emoticons."""
+ filtered = super(FilterStandard, self).filter(emoticonsList,
pattern)
+ return filter(lambda emoticon: not(emoticon.isEmoji), filtered)
+
+class FilterEmoji(EmoticonFilter):
+
+ def filter(self, emoticonsList, pattern):
+ """Filter just for emojis."""
+ filtered = super(FilterEmoji, self).filter(emoticonsList,
pattern)
+ return filter(lambda emoticon: emoticon.isEmoji, filtered)
+
+class InsertEmoticonDialog(wx.Dialog):
+ """ A dialog to insert emoticons from a list. """
+
+ filteredEmoticons = emoticons
+ filter = EmoticonFilter()
+ def __init__(self, parent):
+ # Translators: Title of the dialog.
+ wx.Dialog.__init__(self, parent, title= _("Insert emoticon"),
pos = wx.DefaultPosition, size = (500, 600))
+ # Filter panel.
+ # Translators: A text field to filter emoticons.
+ self.lblFilter = wx.StaticText(self, label= _("&Filter:"), pos
= (-1, -1))
+ self.txtFilter = wx.TextCtrl(self)
+ self.Bind(wx.EVT_TEXT, self.onFilterChange, self.txtFilter)
+ self.sizerFilter = wx.BoxSizer(wx.HORIZONTAL)
+ self.sizerFilter.Add(self.lblFilter, 0, wx.FIXED_MINSIZE)
+ self.sizerFilter.Add(self.txtFilter, 1, wx.EXPAND)
+ # Radio buttons to choose the emoticon set.
+ # Translators: Kind of emoticons to show.
+ self.lblShow = wx.StaticText(self, label= _("&Show:"), pos =
(-1, -1))
+ # Translators: A radio button to choose all types of emoticons.
+ self.rdAll = wx.RadioButton(self, label = _("&All"), style =
wx.RB_GROUP)
+ self.Bind(wx.EVT_RADIOBUTTON, self.onAllEmoticons, self.rdAll)
+ # Translators: A radio button to choose only standard emoticons.
+ self.rdStandard = wx.RadioButton(self, label = _("&Standard"))
+ self.Bind(wx.EVT_RADIOBUTTON, self.onStandardEmoticons,
self.rdStandard)
+ # Translators: A radio button to choose only emojis.
+ self.rdEmojis = wx.RadioButton(self, label = _("Emoj&is"))
+ self.Bind(wx.EVT_RADIOBUTTON, self.onEmojis, self.rdEmojis)
+ self.sizerRadio = wx.BoxSizer(wx.HORIZONTAL)
+ self.sizerRadio.Add(self.lblShow, 0, wx.FIXED_MINSIZE)
+ self.sizerRadio.Add(self.rdAll, 0, wx.FIXED_MINSIZE)
+ self.sizerRadio.Add(self.rdStandard, 0, wx.FIXED_MINSIZE)
+ self.sizerRadio.Add(self.rdEmojis, 0, wx.FIXED_MINSIZE)
+ # List of emoticons.
+ # Translators: Label for the smileys list.
+ self.lblList = wx.StaticText(self, label= _("List of
smilies:"), pos = (-1, -1))
+ self.smileysList = wx.ListCtrl(self, size=(490, 400),
style=wx.LC_REPORT | wx.BORDER_SUNKEN)
+ # Translators: Column which specifies the type of emoticon
(standard or emoji).
+ self.smileysList.InsertColumn(0, _("Type"), width = 100)
+ # Translators: The column which contains the emoticon.
+ self.smileysList.InsertColumn(1, _("Emoticon"), width = 390)
+ self.smileysList.Bind(wx.EVT_KEY_DOWN, self.onEnterOnList)
+ self.sizerList = wx.BoxSizer(wx.VERTICAL)
+ self.sizerList.Add(self.lblList, 0, wx.FIXED_MINSIZE)
+ self.sizerList.Add(self.smileysList, 1, wx.EXPAND)
+ self._loadEmoticons()
+ # Buttons.
+ self.sizerButtons = self.CreateButtonSizer(wx.OK | wx.CANCEL)
+ btnOk = self.FindWindowById(self.GetAffirmativeId())
+ self.Bind(wx.EVT_BUTTON, self.onOk, btnOk)
+ #btnOk.SetDefault()
+ self.FindWindowById(self.GetAffirmativeId()).SetDefault()
+ # Vertical layout
+ self.sizerLayout = wx.BoxSizer(wx.VERTICAL)
+ self.sizerLayout.Add(self.sizerFilter, 0, wx.FIXED_MINSIZE)
+ self.sizerLayout.Add(self.sizerRadio, 0, wx.FIXED_MINSIZE)
+ self.sizerLayout.Add(self.sizerList, 1, wx.EXPAND)
+ self.sizerLayout.Add(self.sizerButtons, 0, wx.EXPAND)
+
+ self.SetSizer(self.sizerLayout)
+ self.SetAutoLayout(1)
+ self.sizerLayout.Fit(self)
+ self.Show(True)
+ self.txtFilter.SetFocus()
+
+ def _formatIsEmoji(self, isEmoji):
+ # Translators: Label for emojis in the list.
+ if isEmoji: return _("Emoji")
+ # Translators: Label for standard emoticons in the list.
+ else: return _("Standard")
+
+ def _loadEmoticons(self):
+ self.smileysList.DeleteAllItems()
+ for emoticon in self.filteredEmoticons:
+
self.smileysList.Append([self._formatIsEmoji(emoticon.isEmoji),
_(emoticon.name)])
+
+ def onFilterChange(self, event):
+ # print("Filter changed to ", self.txtFilter.GetValue())
+ self.filteredEmoticons = self.filter.filter(emoticons,
self.txtFilter.GetValue())
+ self._loadEmoticons()
+
+ def onEnterOnList(self, evt):
+ keycode = evt.GetKeyCode()
+ if keycode == wx.WXK_RETURN: self.onOk(evt)
+ evt.Skip(True)
+
+ def onOk(self, evt):
+ icon = self.filteredEmoticons[self.smileysList.GetFocusedItem()]
if not icon.isEmoji:
iconToInsert = unicode(icon.chars)
else:
@@ -187,6 +272,25 @@ class InsertEmoticonDialog(SettingsDialog):
wx.CallLater(100, ui.message, _("Smiley copied to
clipboard, ready for you to paste."))
else:
wx.CallLater(100, ui.message, _("Cannot copy smiley."))
+ self.Destroy()
+
+ def onAllEmoticons(self, event):
+ # print("Todos los emoticonos visibles.")
+ self.filter = EmoticonFilter()
+ self.filteredEmoticons = self.filter.filter(emoticons,
self.txtFilter.GetValue())
+ self._loadEmoticons()
+
+ def onStandardEmoticons(self, event):
+ # print("Emoticonos tradicionales visibles.")
+ self.filter = FilterStandard()
+ self.filteredEmoticons = self.filter.filter(emoticons,
self.txtFilter.GetValue())
+ self._loadEmoticons()
+
+ def onEmojis(self, event):
+ # print("Emojis visibles.")
+ self.filter = FilterEmoji()
+ self.filteredEmoticons = self.filter.filter(emoticons,
self.txtFilter.GetValue())
+ self._loadEmoticons()
class EmDicDialog(DictionaryDialog):
https://bitbucket.org/nvdaaddonteam/emoticons/commits/79e4d7c91379/
Changeset: 79e4d7c91379
Branch: None
User: FranciscoJavier Estrada
Date: 2016-10-25 12:24:36+00:00
Summary: dified InsertEmoticonDialog:
Changed smileys list to show emoticons [char field] instead of name.
Some comments has been added.
Some unnecessary code has been removed.
Affected #: 1 file
diff --git a/addon/globalPlugins/emoticons/__init__.py
b/addon/globalPlugins/emoticons/__init__.py
index 7261037..388ac1a 100644
--- a/addon/globalPlugins/emoticons/__init__.py
+++ b/addon/globalPlugins/emoticons/__init__.py
@@ -155,23 +155,24 @@ class GlobalPlugin(globalPluginHandler.GlobalPlugin):
}
class EmoticonFilter(object):
-
+ """Filter for all emoticons."""
+
def filter(self, emoticonsList, pattern):
- """Filter for all emoticons."""
+ """Filters the input list with the specified pattern."""
if pattern == "": return emoticonsList
else: return filter(lambda emoticon: pattern.upper() in
emoticon.name.upper(), emoticonsList)
class FilterStandard(EmoticonFilter):
-
+ """Filter just for standard emoticons."""
+
def filter(self, emoticonsList, pattern):
- """Filter just for standard emoticons."""
filtered = super(FilterStandard, self).filter(emoticonsList,
pattern)
return filter(lambda emoticon: not(emoticon.isEmoji), filtered)
class FilterEmoji(EmoticonFilter):
-
+ """Filter just for emojis."""
+
def filter(self, emoticonsList, pattern):
- """Filter just for emojis."""
filtered = super(FilterEmoji, self).filter(emoticonsList,
pattern)
return filter(lambda emoticon: emoticon.isEmoji, filtered)
@@ -180,6 +181,7 @@ class InsertEmoticonDialog(wx.Dialog):
filteredEmoticons = emoticons
filter = EmoticonFilter()
+
def __init__(self, parent):
# Translators: Title of the dialog.
wx.Dialog.__init__(self, parent, title= _("Insert emoticon"),
pos = wx.DefaultPosition, size = (500, 600))
@@ -225,8 +227,6 @@ class InsertEmoticonDialog(wx.Dialog):
self.sizerButtons = self.CreateButtonSizer(wx.OK | wx.CANCEL)
btnOk = self.FindWindowById(self.GetAffirmativeId())
self.Bind(wx.EVT_BUTTON, self.onOk, btnOk)
- #btnOk.SetDefault()
- self.FindWindowById(self.GetAffirmativeId()).SetDefault()
# Vertical layout
self.sizerLayout = wx.BoxSizer(wx.VERTICAL)
self.sizerLayout.Add(self.sizerFilter, 0, wx.FIXED_MINSIZE)
@@ -241,27 +241,34 @@ class InsertEmoticonDialog(wx.Dialog):
self.txtFilter.SetFocus()
def _formatIsEmoji(self, isEmoji):
+ """Converts boolean isEmoji property to text."""
# Translators: Label for emojis in the list.
if isEmoji: return _("Emoji")
# Translators: Label for standard emoticons in the list.
else: return _("Standard")
def _loadEmoticons(self):
+ """Reload the emoticons list."""
self.smileysList.DeleteAllItems()
for emoticon in self.filteredEmoticons:
-
self.smileysList.Append([self._formatIsEmoji(emoticon.isEmoji),
_(emoticon.name)])
+ if not emoticon.isEmoji:
+
self.smileysList.Append([self._formatIsEmoji(emoticon.isEmoji),
unicode(emoticon.chars)])
+ else:
+
self.smileysList.Append([self._formatIsEmoji(emoticon.isEmoji),
emoticon.chars.decode("utf-8")])
def onFilterChange(self, event):
- # print("Filter changed to ", self.txtFilter.GetValue())
+ """Updates the emoticon list when the filter field changes its
content."""
self.filteredEmoticons = self.filter.filter(emoticons,
self.txtFilter.GetValue())
self._loadEmoticons()
def onEnterOnList(self, evt):
+ """Same effect as click OK button when pressing enter on
smileys list."""
keycode = evt.GetKeyCode()
if keycode == wx.WXK_RETURN: self.onOk(evt)
evt.Skip(True)
def onOk(self, evt):
+ """Copy to clipboard the focused emoticon on the list."""
icon = self.filteredEmoticons[self.smileysList.GetFocusedItem()]
if not icon.isEmoji:
iconToInsert = unicode(icon.chars)
@@ -275,19 +282,19 @@ class InsertEmoticonDialog(wx.Dialog):
self.Destroy()
def onAllEmoticons(self, event):
- # print("Todos los emoticonos visibles.")
+ """Changes the filter to all emoticons and reload the emoticon
list."""
self.filter = EmoticonFilter()
self.filteredEmoticons = self.filter.filter(emoticons,
self.txtFilter.GetValue())
self._loadEmoticons()
def onStandardEmoticons(self, event):
- # print("Emoticonos tradicionales visibles.")
+ """Changes the filter to standard emoticons and reloads the
emoticon list."""
self.filter = FilterStandard()
self.filteredEmoticons = self.filter.filter(emoticons,
self.txtFilter.GetValue())
self._loadEmoticons()
def onEmojis(self, event):
- # print("Emojis visibles.")
+ """Changes the filter to emojis and reloads the emoticon
list."""
self.filter = FilterEmoji()
self.filteredEmoticons = self.filter.filter(emoticons,
self.txtFilter.GetValue())
self._loadEmoticons()
https://bitbucket.org/nvdaaddonteam/emoticons/commits/25f68e0c73f5/
Changeset: 25f68e0c73f5
Branch: None
User: FranciscoJavier Estrada
Date: 2016-10-30 18:21:37+00:00
Summary: dified InsertEmoticonDialog:
Added shortcut to emoticon list.
Added column for emoticon's name on list.
Updated _loadEmoticonsto insert the name.
Affected #: 1 file
diff --git a/addon/globalPlugins/emoticons/__init__.py
b/addon/globalPlugins/emoticons/__init__.py
index 388ac1a..1e693de 100644
--- a/addon/globalPlugins/emoticons/__init__.py
+++ b/addon/globalPlugins/emoticons/__init__.py
@@ -212,12 +212,14 @@ class InsertEmoticonDialog(wx.Dialog):
self.sizerRadio.Add(self.rdEmojis, 0, wx.FIXED_MINSIZE)
# List of emoticons.
# Translators: Label for the smileys list.
- self.lblList = wx.StaticText(self, label= _("List of
smilies:"), pos = (-1, -1))
+ self.lblList = wx.StaticText(self, label= _("&List of
smilies:"), pos = (-1, -1))
self.smileysList = wx.ListCtrl(self, size=(490, 400),
style=wx.LC_REPORT | wx.BORDER_SUNKEN)
+ # Translators: Column which specifies the name of emoticon.
+ self.smileysList.InsertColumn(0, _("Name"))
# Translators: Column which specifies the type of emoticon
(standard or emoji).
- self.smileysList.InsertColumn(0, _("Type"), width = 100)
+ self.smileysList.InsertColumn(1, _("Type"))
# Translators: The column which contains the emoticon.
- self.smileysList.InsertColumn(1, _("Emoticon"), width = 390)
+ self.smileysList.InsertColumn(2, _("Emoticon"))
self.smileysList.Bind(wx.EVT_KEY_DOWN, self.onEnterOnList)
self.sizerList = wx.BoxSizer(wx.VERTICAL)
self.sizerList.Add(self.lblList, 0, wx.FIXED_MINSIZE)
@@ -252,9 +254,9 @@ class InsertEmoticonDialog(wx.Dialog):
self.smileysList.DeleteAllItems()
for emoticon in self.filteredEmoticons:
if not emoticon.isEmoji:
-
self.smileysList.Append([self._formatIsEmoji(emoticon.isEmoji),
unicode(emoticon.chars)])
+ self.smileysList.Append([emoticon.name,
self._formatIsEmoji(emoticon.isEmoji), unicode(emoticon.chars)])
else:
-
self.smileysList.Append([self._formatIsEmoji(emoticon.isEmoji),
emoticon.chars.decode("utf-8")])
+ self.smileysList.Append([emoticon.name,
self._formatIsEmoji(emoticon.isEmoji), emoticon.chars.decode("utf-8")])
def onFilterChange(self, event):
"""Updates the emoticon list when the filter field changes its
content."""
https://bitbucket.org/nvdaaddonteam/emoticons/commits/a9be290f4940/
Changeset: a9be290f4940
Branch: None
User: FranciscoJavier Estrada
Date: 2016-10-30 18:41:11+00:00
Summary: dified InsertEmoticonDialog:
Now the dialog is centered after setup controls.
Affected #: 1 file
diff --git a/addon/globalPlugins/emoticons/__init__.py
b/addon/globalPlugins/emoticons/__init__.py
index 1e693de..cb580a5 100644
--- a/addon/globalPlugins/emoticons/__init__.py
+++ b/addon/globalPlugins/emoticons/__init__.py
@@ -239,6 +239,7 @@ class InsertEmoticonDialog(wx.Dialog):
self.SetSizer(self.sizerLayout)
self.SetAutoLayout(1)
self.sizerLayout.Fit(self)
+ self.Center()
self.Show(True)
self.txtFilter.SetFocus()
https://bitbucket.org/nvdaaddonteam/emoticons/commits/40c9390c5b36/
Changeset: 40c9390c5b36
Branch: None
User: FranciscoJavier Estrada
Date: 2016-11-03 11:00:48+00:00
Summary: dified InsertEmoticonDialog:
Now it can be only one instance of this dialog at a time.
Replaced call to gui.mainFrame._popupSettingsDialog in method
onInsertEmoticonDialog because it is
private and it shouldn't be called this way.
Affected #: 1 file
diff --git a/addon/globalPlugins/emoticons/__init__.py
b/addon/globalPlugins/emoticons/__init__.py
index cb580a5..c79525b 100644
--- a/addon/globalPlugins/emoticons/__init__.py
+++ b/addon/globalPlugins/emoticons/__init__.py
@@ -15,6 +15,7 @@ import addonHandler
from gui.settingsDialogs import SettingsDialog
from gui.settingsDialogs import DictionaryDialog
from smileysList import emoticons
+from logHandler import log
try:
from globalCommands import SCRCAT_SPEECH, SCRCAT_TOOLS
@@ -118,7 +119,10 @@ class GlobalPlugin(globalPluginHandler.GlobalPlugin):
pass
def onInsertEmoticonDialog(self, evt):
- gui.mainFrame._popupSettingsDialog(InsertEmoticonDialog)
+ gui.mainFrame.prePopup()
+ d = InsertEmoticonDialog(gui.mainFrame)
+ d.Show(True)
+ gui.mainFrame.postPopup()
def onEmDicDialog(self, evt):
global shouldActivateEmoticons
@@ -179,12 +183,23 @@ class FilterEmoji(EmoticonFilter):
class InsertEmoticonDialog(wx.Dialog):
""" A dialog to insert emoticons from a list. """
- filteredEmoticons = emoticons
- filter = EmoticonFilter()
+ _instance = None
+ _filteredEmoticons = None
+ _filter = None
+ def __new__(cls, *args, **kwargs):
+ if InsertEmoticonDialog._instance is None:
+ return super(InsertEmoticonDialog, cls).__new__(cls,
*args, **kwargs)
+ return InsertEmoticonDialog._instance
+
def __init__(self, parent):
+ if InsertEmoticonDialog._instance is not None:
+ return
+ InsertEmoticonDialog._instance = self
# Translators: Title of the dialog.
- wx.Dialog.__init__(self, parent, title= _("Insert emoticon"),
pos = wx.DefaultPosition, size = (500, 600))
+ super(InsertEmoticonDialog, self).__init__(parent, title=
_("Insert emoticon"), pos = wx.DefaultPosition, size = (500, 600))
+ self._filteredEmoticons = emoticons
+ self._filter = EmoticonFilter()
# Filter panel.
# Translators: A text field to filter emoticons.
self.lblFilter = wx.StaticText(self, label= _("&Filter:"), pos
= (-1, -1))
@@ -240,7 +255,6 @@ class InsertEmoticonDialog(wx.Dialog):
self.SetAutoLayout(1)
self.sizerLayout.Fit(self)
self.Center()
- self.Show(True)
self.txtFilter.SetFocus()
def _formatIsEmoji(self, isEmoji):
@@ -253,7 +267,7 @@ class InsertEmoticonDialog(wx.Dialog):
def _loadEmoticons(self):
"""Reload the emoticons list."""
self.smileysList.DeleteAllItems()
- for emoticon in self.filteredEmoticons:
+ for emoticon in self._filteredEmoticons:
if not emoticon.isEmoji:
self.smileysList.Append([emoticon.name,
self._formatIsEmoji(emoticon.isEmoji), unicode(emoticon.chars)])
else:
@@ -261,7 +275,7 @@ class InsertEmoticonDialog(wx.Dialog):
def onFilterChange(self, event):
"""Updates the emoticon list when the filter field changes its
content."""
- self.filteredEmoticons = self.filter.filter(emoticons,
self.txtFilter.GetValue())
+ self._filteredEmoticons = self._filter.filter(emoticons,
self.txtFilter.GetValue())
self._loadEmoticons()
def onEnterOnList(self, evt):
@@ -272,7 +286,7 @@ class InsertEmoticonDialog(wx.Dialog):
def onOk(self, evt):
"""Copy to clipboard the focused emoticon on the list."""
- icon = self.filteredEmoticons[self.smileysList.GetFocusedItem()]
+ icon =
self._filteredEmoticons[self.smileysList.GetFocusedItem()]
if not icon.isEmoji:
iconToInsert = unicode(icon.chars)
else:
@@ -286,21 +300,24 @@ class InsertEmoticonDialog(wx.Dialog):
def onAllEmoticons(self, event):
"""Changes the filter to all emoticons and reload the emoticon
list."""
- self.filter = EmoticonFilter()
- self.filteredEmoticons = self.filter.filter(emoticons,
self.txtFilter.GetValue())
+ self._filter = EmoticonFilter()
+ self._filteredEmoticons = self._filter.filter(emoticons,
self.txtFilter.GetValue())
self._loadEmoticons()
def onStandardEmoticons(self, event):
"""Changes the filter to standard emoticons and reloads the
emoticon list."""
- self.filter = FilterStandard()
- self.filteredEmoticons = self.filter.filter(emoticons,
self.txtFilter.GetValue())
+ self._filter = FilterStandard()
+ self._filteredEmoticons = self._filter.filter(emoticons,
self.txtFilter.GetValue())
self._loadEmoticons()
def onEmojis(self, event):
"""Changes the filter to emojis and reloads the emoticon
list."""
- self.filter = FilterEmoji()
- self.filteredEmoticons = self.filter.filter(emoticons,
self.txtFilter.GetValue())
+ self._filter = FilterEmoji()
+ self._filteredEmoticons = self._filter.filter(emoticons,
self.txtFilter.GetValue())
self._loadEmoticons()
+
+ def __del__(self):
+ InsertEmoticonDialog._instance = None
class EmDicDialog(DictionaryDialog):
https://bitbucket.org/nvdaaddonteam/emoticons/commits/ae470be3dead/
Changeset: ae470be3dead
Branch: None
User: FranciscoJavier Estrada
Date: 2016-11-03 11:11:13+00:00
Summary: dified InsertEmoticonDialog:
Order of filter field and radio buttons has been changed.
Affected #: 1 file
diff --git a/addon/globalPlugins/emoticons/__init__.py
b/addon/globalPlugins/emoticons/__init__.py
index c79525b..c797a9a 100644
--- a/addon/globalPlugins/emoticons/__init__.py
+++ b/addon/globalPlugins/emoticons/__init__.py
@@ -246,8 +246,8 @@ class InsertEmoticonDialog(wx.Dialog):
self.Bind(wx.EVT_BUTTON, self.onOk, btnOk)
# Vertical layout
self.sizerLayout = wx.BoxSizer(wx.VERTICAL)
- self.sizerLayout.Add(self.sizerFilter, 0, wx.FIXED_MINSIZE)
self.sizerLayout.Add(self.sizerRadio, 0, wx.FIXED_MINSIZE)
+ self.sizerLayout.Add(self.sizerFilter, 0, wx.FIXED_MINSIZE)
self.sizerLayout.Add(self.sizerList, 1, wx.EXPAND)
self.sizerLayout.Add(self.sizerButtons, 0, wx.EXPAND)
https://bitbucket.org/nvdaaddonteam/emoticons/commits/9ca41502e14f/
Changeset: 9ca41502e14f
Branch: None
User: norrumar
Date: 2016-11-09 10:16:31+00:00
Summary: Make Emoticons dictionary dialog consistent with speech
dictionaries dialogs of NVDA.
Affected #: 1 file
diff --git a/addon/globalPlugins/emoticons/__init__.py
b/addon/globalPlugins/emoticons/__init__.py
index c797a9a..805ec9f 100644
--- a/addon/globalPlugins/emoticons/__init__.py
+++ b/addon/globalPlugins/emoticons/__init__.py
@@ -1,5 +1,5 @@
# -*- coding: UTF-8 -*-
-#Copyright (C) 2013-2016 Noelia Ruiz Martínez, Mesar Hameed, Francisco Javier
Estrada Martínez
+#Copyright (C) 2013-2016 Noelia Ruiz Martínez, Mesar Hameed
# Released under GPL 2
import globalPluginHandler
@@ -11,11 +11,11 @@ import api
import ui
import wx
import gui
+from gui import guiHelper
import addonHandler
from gui.settingsDialogs import SettingsDialog
from gui.settingsDialogs import DictionaryDialog
from smileysList import emoticons
-from logHandler import log
try:
from globalCommands import SCRCAT_SPEECH, SCRCAT_TOOLS
@@ -69,12 +69,8 @@ class GlobalPlugin(globalPluginHandler.GlobalPlugin):
global sD, defaultDic
sD.load(dicFile)
for em in emoticons:
- if not 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.
- comment = _("Emoticon: %s") % em.name
- 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.
- comment = _("Emoji: %s") % em.name
+ # 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.
+ comment = _("Emoticon: %s") % 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))
@@ -119,10 +115,7 @@ class GlobalPlugin(globalPluginHandler.GlobalPlugin):
pass
def onInsertEmoticonDialog(self, evt):
- gui.mainFrame.prePopup()
- d = InsertEmoticonDialog(gui.mainFrame)
- d.Show(True)
- gui.mainFrame.postPopup()
+ gui.mainFrame._popupSettingsDialog(InsertEmoticonDialog)
def onEmDicDialog(self, evt):
global shouldActivateEmoticons
@@ -158,220 +151,53 @@ class GlobalPlugin(globalPluginHandler.GlobalPlugin):
"kb:NVDA+i": "insertEmoticon",
}
-class EmoticonFilter(object):
- """Filter for all emoticons."""
-
- def filter(self, emoticonsList, pattern):
- """Filters the input list with the specified pattern."""
- if pattern == "": return emoticonsList
- else: return filter(lambda emoticon: pattern.upper() in
emoticon.name.upper(), emoticonsList)
-
-class FilterStandard(EmoticonFilter):
- """Filter just for standard emoticons."""
-
- def filter(self, emoticonsList, pattern):
- filtered = super(FilterStandard, self).filter(emoticonsList,
pattern)
- return filter(lambda emoticon: not(emoticon.isEmoji), filtered)
-
-class FilterEmoji(EmoticonFilter):
- """Filter just for emojis."""
-
- def filter(self, emoticonsList, pattern):
- filtered = super(FilterEmoji, self).filter(emoticonsList,
pattern)
- return filter(lambda emoticon: emoticon.isEmoji, filtered)
-
-class InsertEmoticonDialog(wx.Dialog):
- """ A dialog to insert emoticons from a list. """
-
- _instance = None
- _filteredEmoticons = None
- _filter = None
-
- def __new__(cls, *args, **kwargs):
- if InsertEmoticonDialog._instance is None:
- return super(InsertEmoticonDialog, cls).__new__(cls,
*args, **kwargs)
- return InsertEmoticonDialog._instance
-
- def __init__(self, parent):
- if InsertEmoticonDialog._instance is not None:
- return
- InsertEmoticonDialog._instance = self
- # Translators: Title of the dialog.
- super(InsertEmoticonDialog, self).__init__(parent, title=
_("Insert emoticon"), pos = wx.DefaultPosition, size = (500, 600))
- self._filteredEmoticons = emoticons
- self._filter = EmoticonFilter()
- # Filter panel.
- # Translators: A text field to filter emoticons.
- self.lblFilter = wx.StaticText(self, label= _("&Filter:"), pos
= (-1, -1))
- self.txtFilter = wx.TextCtrl(self)
- self.Bind(wx.EVT_TEXT, self.onFilterChange, self.txtFilter)
- self.sizerFilter = wx.BoxSizer(wx.HORIZONTAL)
- self.sizerFilter.Add(self.lblFilter, 0, wx.FIXED_MINSIZE)
- self.sizerFilter.Add(self.txtFilter, 1, wx.EXPAND)
- # Radio buttons to choose the emoticon set.
- # Translators: Kind of emoticons to show.
- self.lblShow = wx.StaticText(self, label= _("&Show:"), pos =
(-1, -1))
- # Translators: A radio button to choose all types of emoticons.
- self.rdAll = wx.RadioButton(self, label = _("&All"), style =
wx.RB_GROUP)
- self.Bind(wx.EVT_RADIOBUTTON, self.onAllEmoticons, self.rdAll)
- # Translators: A radio button to choose only standard emoticons.
- self.rdStandard = wx.RadioButton(self, label = _("&Standard"))
- self.Bind(wx.EVT_RADIOBUTTON, self.onStandardEmoticons,
self.rdStandard)
- # Translators: A radio button to choose only emojis.
- self.rdEmojis = wx.RadioButton(self, label = _("Emoj&is"))
- self.Bind(wx.EVT_RADIOBUTTON, self.onEmojis, self.rdEmojis)
- self.sizerRadio = wx.BoxSizer(wx.HORIZONTAL)
- self.sizerRadio.Add(self.lblShow, 0, wx.FIXED_MINSIZE)
- self.sizerRadio.Add(self.rdAll, 0, wx.FIXED_MINSIZE)
- self.sizerRadio.Add(self.rdStandard, 0, wx.FIXED_MINSIZE)
- self.sizerRadio.Add(self.rdEmojis, 0, wx.FIXED_MINSIZE)
- # List of emoticons.
- # Translators: Label for the smileys list.
- self.lblList = wx.StaticText(self, label= _("&List of
smilies:"), pos = (-1, -1))
- self.smileysList = wx.ListCtrl(self, size=(490, 400),
style=wx.LC_REPORT | wx.BORDER_SUNKEN)
- # Translators: Column which specifies the name of emoticon.
- self.smileysList.InsertColumn(0, _("Name"))
- # Translators: Column which specifies the type of emoticon
(standard or emoji).
- self.smileysList.InsertColumn(1, _("Type"))
- # Translators: The column which contains the emoticon.
- self.smileysList.InsertColumn(2, _("Emoticon"))
- self.smileysList.Bind(wx.EVT_KEY_DOWN, self.onEnterOnList)
- self.sizerList = wx.BoxSizer(wx.VERTICAL)
- self.sizerList.Add(self.lblList, 0, wx.FIXED_MINSIZE)
- self.sizerList.Add(self.smileysList, 1, wx.EXPAND)
- self._loadEmoticons()
- # Buttons.
- self.sizerButtons = self.CreateButtonSizer(wx.OK | wx.CANCEL)
- btnOk = self.FindWindowById(self.GetAffirmativeId())
- self.Bind(wx.EVT_BUTTON, self.onOk, btnOk)
- # Vertical layout
- self.sizerLayout = wx.BoxSizer(wx.VERTICAL)
- self.sizerLayout.Add(self.sizerRadio, 0, wx.FIXED_MINSIZE)
- self.sizerLayout.Add(self.sizerFilter, 0, wx.FIXED_MINSIZE)
- self.sizerLayout.Add(self.sizerList, 1, wx.EXPAND)
- self.sizerLayout.Add(self.sizerButtons, 0, wx.EXPAND)
-
- self.SetSizer(self.sizerLayout)
- self.SetAutoLayout(1)
- self.sizerLayout.Fit(self)
- self.Center()
- self.txtFilter.SetFocus()
-
- def _formatIsEmoji(self, isEmoji):
- """Converts boolean isEmoji property to text."""
- # Translators: Label for emojis in the list.
- if isEmoji: return _("Emoji")
- # Translators: Label for standard emoticons in the list.
- else: return _("Standard")
-
- def _loadEmoticons(self):
- """Reload the emoticons list."""
- self.smileysList.DeleteAllItems()
- for emoticon in self._filteredEmoticons:
- if not emoticon.isEmoji:
- self.smileysList.Append([emoticon.name,
self._formatIsEmoji(emoticon.isEmoji), unicode(emoticon.chars)])
- else:
- self.smileysList.Append([emoticon.name,
self._formatIsEmoji(emoticon.isEmoji), emoticon.chars.decode("utf-8")])
-
- def onFilterChange(self, event):
- """Updates the emoticon list when the filter field changes its
content."""
- self._filteredEmoticons = self._filter.filter(emoticons,
self.txtFilter.GetValue())
- self._loadEmoticons()
-
- def onEnterOnList(self, evt):
- """Same effect as click OK button when pressing enter on
smileys list."""
- keycode = evt.GetKeyCode()
- if keycode == wx.WXK_RETURN: self.onOk(evt)
- evt.Skip(True)
-
- def onOk(self, evt):
- """Copy to clipboard the focused emoticon on the list."""
- icon =
self._filteredEmoticons[self.smileysList.GetFocusedItem()]
- if not icon.isEmoji:
- iconToInsert = unicode(icon.chars)
- else:
- iconToInsert = icon.chars.decode("utf-8")
+class InsertEmoticonDialog(SettingsDialog):
+
+ # Translators: This is the label for the InsertEmoticon dialog.
+ title = _("Insert emoticon")
+
+ def makeSettings(self, settingsSizer):
+ smileysListSizer = wx.BoxSizer(wx.HORIZONTAL)
+ # Translators: The label for a setting in Insert emoticons to
select a smiley.
+ availableEmoticonsLabel = _("Available emoticons")
+ smileysListLabel = wx.StaticText(self,-1,label=u"{labelString}
({labelInt})".format(labelString=availableEmoticonsLabel,
labelInt=str(len(emoticons))))
+ smileysListSizer.Add(smileysListLabel)
+ smileysListID = wx.NewId()
+ # Translators: A combo box to choose a smiley.
+ self.smileysList=wx.Choice(self ,smileysListID,
name=_("Available smileys to insert:"), choices= [emoticon.name for emoticon in
emoticons])
+ self.smileysList.SetSelection(0)
+ smileysListSizer.Add(self.smileysList)
+ settingsSizer.Add(smileysListSizer, border=10, flag=wx.BOTTOM)
+
+ def postInit(self):
+ self.smileysList.SetFocus()
+
+ def onOk(self,evt):
+ super(InsertEmoticonDialog, self).onOk(evt)
+ iconToInsert =
unicode(emoticons[self.smileysList.GetSelection()].chars)
if api.copyToClip(iconToInsert):
# Translators: This is the message when smiley has been
copied to the clipboard.
wx.CallLater(100, ui.message, _("Smiley copied to
clipboard, ready for you to paste."))
else:
wx.CallLater(100, ui.message, _("Cannot copy smiley."))
- self.Destroy()
-
- def onAllEmoticons(self, event):
- """Changes the filter to all emoticons and reload the emoticon
list."""
- self._filter = EmoticonFilter()
- self._filteredEmoticons = self._filter.filter(emoticons,
self.txtFilter.GetValue())
- self._loadEmoticons()
-
- def onStandardEmoticons(self, event):
- """Changes the filter to standard emoticons and reloads the
emoticon list."""
- self._filter = FilterStandard()
- self._filteredEmoticons = self._filter.filter(emoticons,
self.txtFilter.GetValue())
- self._loadEmoticons()
-
- def onEmojis(self, event):
- """Changes the filter to emojis and reloads the emoticon
list."""
- self._filter = FilterEmoji()
- self._filteredEmoticons = self._filter.filter(emoticons,
self.txtFilter.GetValue())
- self._loadEmoticons()
-
- def __del__(self):
- InsertEmoticonDialog._instance = None
class EmDicDialog(DictionaryDialog):
def makeSettings(self, settingsSizer):
- dictListID=wx.NewId()
- entriesSizer=wx.BoxSizer(wx.VERTICAL)
- # Translators: The label for the combo box of dictionary
entries in speech dictionary dialog.
- entriesLabel=wx.StaticText(self,-1,label=_("&Dictionary
entries"))
- entriesSizer.Add(entriesLabel)
-
self.dictList=wx.ListCtrl(self,dictListID,style=wx.LC_REPORT|wx.LC_SINGLE_SEL,size=(550,350))
- # Translators: The label for a column in dictionary entries
list used to identify comments for the entry.
- self.dictList.InsertColumn(0,_("Comment"),width=150)
- # Translators: The label for a column in dictionary entries
list used to identify pattern (original word or a pattern).
- self.dictList.InsertColumn(1,_("Pattern"),width=150)
- # Translators: The label for a column in dictionary entries
list and in a list of symbols from symbol pronunciation dialog used to identify
replacement for a pattern or a symbol
- self.dictList.InsertColumn(2,_("Replacement"),width=150)
- # Translators: The label for a column in dictionary entries
list used to identify whether the entry is case sensitive or not.
- self.dictList.InsertColumn(3,_("case"),width=50)
- # Translators: The label for a column in dictionary entries
list used to identify whether the entry is a regular expression, matches whole
words, or matches anywhere.
- self.dictList.InsertColumn(4,_("Type"),width=50)
- self.offOn = (_("off"),_("on"))
- for entry in self.tempSpeechDict:
-
self.dictList.Append((entry.comment,entry.pattern,entry.replacement,self.offOn[int(entry.caseSensitive)],DictionaryDialog.TYPE_LABELS[entry.type]))
- self.editingIndex=-1
- entriesSizer.Add(self.dictList,proportion=8)
- settingsSizer.Add(entriesSizer)
- entryButtonsSizer=wx.BoxSizer(wx.HORIZONTAL)
- addButtonID=wx.NewId()
- # Translators: The label for a button in speech dictionaries
dialog to add new entries.
-
addButton=wx.Button(self,addButtonID,_("&Add"),wx.DefaultPosition)
- entryButtonsSizer.Add(addButton)
- editButtonID=wx.NewId()
- # Translators: The label for a button in speech dictionaries
dialog to edit existing entries.
-
editButton=wx.Button(self,editButtonID,_("&Edit"),wx.DefaultPosition)
- entryButtonsSizer.Add(editButton)
- removeButtonID=wx.NewId()
-
removeButton=wx.Button(self,removeButtonID,_("&Remove"),wx.DefaultPosition)
- entryButtonsSizer.Add(removeButton)
+ sHelper = guiHelper.BoxSizerHelper(self, sizer=settingsSizer)
+ bHelper = guiHelper.ButtonHelper(orientation=wx.HORIZONTAL)
resetButtonID = wx.NewId()
- resetButton =
wx.Button(self,resetButtonID,_("Rese&t"),wx.DefaultPosition)
- self.Bind(wx.EVT_BUTTON,self.OnAddClick,id=addButtonID)
- self.Bind(wx.EVT_BUTTON,self.OnEditClick,id=editButtonID)
- self.Bind(wx.EVT_BUTTON,self.OnRemoveClick,id=removeButtonID)
- self.Bind(wx.EVT_BUTTON,self.OnResetClick,id=resetButtonID)
- settingsSizer.Add(entryButtonsSizer)
- fileButtonsSizer = wx.BoxSizer(wx.HORIZONTAL)
+ # Translators: The label for a button in the Emoticons
dictionary dialog.
+ bHelper.addButton(self, resetButtonID, _("Re&set"),
wx.DefaultPosition)
exportButtonID = wx.NewId()
- # Translators: The label for a button in speech dictionaries
dialog to add new entries.
- exportButton = wx.Button(self,exportButtonID,_("Save and
e&xport dictionary"),wx.DefaultPosition)
- fileButtonsSizer.Add(exportButton)
- self.Bind(wx.EVT_BUTTON,self.OnExportClick,id=exportButtonID)
- settingsSizer.Add(fileButtonsSizer)
-
- def OnResetClick(self,evt):
+ # Translators: The label for a button in the Emoticons
dictionary dialog.
+ bHelper.addButton(self, exportButtonID, _("Save and e&xport
dictionary"), wx.DefaultPosition)
+ sHelper.addItem(bHelper)
+ super(EmDicDialog, self).makeSettings(settingsSizer)
+ self.Bind(wx.EVT_BUTTON, self.OnResetClick, id=resetButtonID)
+ self.Bind(wx.EVT_BUTTON, self.OnExportClick, id=exportButtonID)
+
+ def OnResetClick(self, evt):
self.dictList.DeleteAllItems()
self.tempSpeechDict = []
self.tempSpeechDict.extend(defaultDic)
@@ -393,7 +219,7 @@ class EmDicDialog(DictionaryDialog):
activateEmoticons()
shouldActivateEmoticons = False
- def OnExportClick(self,evt):
+ def OnExportClick(self, evt):
self.onOk(None)
sD.save(os.path.join(speechDictHandler.speechDictsPath,
"emoticons.dic"))
https://bitbucket.org/nvdaaddonteam/emoticons/commits/4869afa86496/
Changeset: 4869afa86496
Branch: readingDialogs
User: norrumar
Date: 2016-11-09 10:59:41+00:00
Summary: Use guiHelper to enhance the visual presentation of the activation
settings dialog.
Affected #: 2 files
diff --git a/addon/globalPlugins/emoticons/__init__.py
b/addon/globalPlugins/emoticons/__init__.py
index 805ec9f..6ad399d 100644
--- a/addon/globalPlugins/emoticons/__init__.py
+++ b/addon/globalPlugins/emoticons/__init__.py
@@ -16,6 +16,7 @@ import addonHandler
from gui.settingsDialogs import SettingsDialog
from gui.settingsDialogs import DictionaryDialog
from smileysList import emoticons
+from skipTranslation import translate
try:
from globalCommands import SCRCAT_SPEECH, SCRCAT_TOOLS
@@ -188,7 +189,7 @@ class EmDicDialog(DictionaryDialog):
bHelper = guiHelper.ButtonHelper(orientation=wx.HORIZONTAL)
resetButtonID = wx.NewId()
# Translators: The label for a button in the Emoticons
dictionary dialog.
- bHelper.addButton(self, resetButtonID, _("Re&set"),
wx.DefaultPosition)
+ bHelper.addButton(self, resetButtonID, _("Rese&t"),
wx.DefaultPosition)
exportButtonID = wx.NewId()
# Translators: The label for a button in the Emoticons
dictionary dialog.
bHelper.addButton(self, exportButtonID, _("Save and e&xport
dictionary"), wx.DefaultPosition)
@@ -229,25 +230,16 @@ class ActivateEmoticonsDialog(SettingsDialog):
title = _("Activation settings")
def makeSettings(self, settingsSizer):
- activateSizer=wx.BoxSizer(wx.HORIZONTAL)
+ sHelper = guiHelper.BoxSizerHelper(self, sizer=settingsSizer)
# Translators: The label for a setting in Activate emoticons
dialog.
- activateLabel=wx.StaticText(self,-1,label=_("&Activate speaking
of emoticons at start:"))
- activateSizer.Add(activateLabel)
- activateListID = wx.NewId()
- self.activateChoices = [
- # Translators: a choice of Activateemoticons dialog.
- _("off"),
- # Translators: a choice of Activateemoticons dialog.
- _("On")]
+ activateLabel = _("&Activate speaking of emoticons at start:")
+ self.activateChoices = (translate("off"), translate("on"))
# Translators: a combo box in Emoticons dialog.
- self.activateList = wx.Choice(self, activateListID,
name=_("Activate at start"), choices=[x for x in self.activateChoices])
- self.activateList.SetSelection(conf["Activation
settings"]["activateAtStart"])
- activateSizer.Add(self.activateList)
- settingsSizer.Add(activateSizer,border=10,flag=wx.BOTTOM)
+ self.activateList = sHelper.addLabeledControl(activateLabel,
wx.Choice, choices=self.activateChoices)
+ self.activateList.Selection = conf["Activation
settings"]["activateAtStart"]
# Translators: The label for a setting in Activate emoticons
dialog to copy activation settings.
- self.copyActivationCheckBox = wx.CheckBox(self, wx.NewId(),
label=_("&Copy activation settings"))
- self.copyActivationCheckBox.SetValue(False)
-
settingsSizer.Add(self.copyActivationCheckBox,border=10,flag=wx.BOTTOM)
+ self.copyActivationCheckBox = sHelper.addItem(wx.CheckBox(self,
label=_("&Copy activation settings")))
+ self.copyActivationCheckBox.Value = False
def postInit(self):
self.activateList.SetFocus()
diff --git a/addon/globalPlugins/emoticons/skipTranslation.py
b/addon/globalPlugins/emoticons/skipTranslation.py
new file mode 100644
index 0000000..ea074a6
--- /dev/null
+++ b/addon/globalPlugins/emoticons/skipTranslation.py
@@ -0,0 +1,9 @@
+# -*- coding: UTF-8 -*-
+# skipTranslation: Module to get translated texts from NVDA
+# Based on implementation made by Alberto Buffolino
+# https://github.com/nvaccess/nvda/issues/4652
+#Copyright (C) 2016 Noelia Ruiz Martínez
+# Released under GPL 2
+
+def translate(text):
+ return _(text)
Repository URL: https://bitbucket.org/nvdaaddonteam/emoticons/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.