Skip to content

Commit

Permalink
Fix exception removing accidental code thanks to @Christianlm
Browse files Browse the repository at this point in the history
https://nvdaes.groups.io/g/lista/message/1704

Also close dialog to focus feeds list when open different windows requested by Locutor Antonio
  • Loading branch information
nvdaes committed Sep 29, 2020
1 parent 7e17530 commit c045d86
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions addon/globalPlugins/readFeeds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def __init__(self, parent):
# Translators: The label of a button to open a feed as HTML.
self.openHtmlButton = buttonHelper.addButton(self, label=_("Open feed as &HTML"))
self.openHtmlButton.Bind(wx.EVT_BUTTON, self.onOpenHtml)

# Translators: The label of a button to add a new feed.
newButton = buttonHelper.addButton(self, label=_("&New..."))
newButton.Bind(wx.EVT_BUTTON, self.onNew)
Expand All @@ -178,7 +178,7 @@ def __init__(self, parent):
# Translators: The label of a button to open a folder containing a backup of feeds.
self.openFolderButton = buttonHelper.addButton(self, label=_("Open &folder containing a backup of feeds"))
self.openFolderButton.Bind(wx.EVT_BUTTON, self.onOpenFolder)

feedsListGroupContents.Add(buttonHelper.sizer)
feedsListGroupSizer.Add(feedsListGroupContents, border=guiHelper.BORDER_FOR_DIALOGS, flag=wx.ALL)
sHelper.addItem(feedsListGroupSizer)
Expand All @@ -190,7 +190,6 @@ def __init__(self, parent):
self.Bind(wx.EVT_CLOSE, self.onClose)
self.EscapeId = wx.ID_CLOSE


self.onFeedsListChoice(None)
mainSizer.Add(sHelper.sizer, flag=wx.ALL, border=guiHelper.BORDER_FOR_DIALOGS)
mainSizer.Fit(self)
Expand All @@ -205,7 +204,6 @@ def createFeed(self, address):
try:
feed = Feed(address)
except Exception as e:

wx.CallAfter(
gui.messageBox,
# Translators: Message presented when a feed cannot be added.
Expand Down Expand Up @@ -277,13 +275,15 @@ def onOpen(self, evt):
with open(os.path.join(FEEDS_PATH, "%s.txt" % self.stringSel), "r", encoding="utf-8") as f:
address = f.read()
os.startfile(address)
self.onClose(None)

def onOpenHtml(self, evt):
with open(os.path.join(FEEDS_PATH, "%s.txt" % self.stringSel), "r", encoding="utf-8") as f:
address = f.read()
self.feed = Feed(address)
self.feed.buildHtml()
os.startfile(os.path.join(HTML_PATH, "feed.html"))
self.onClose(None)

def onNew(self, evt):
# Translators: The label of a field to enter an address for a new feed.
Expand All @@ -294,9 +294,11 @@ def onNew(self, evt):
_("New feed")
) as d:
if d.ShowModal() == wx.ID_CANCEL:
self.feedsList.SetFocus()
return
name = self.createFeed(d.Value)
self.feedsList.Append(name)
self.feedsList.SetFocus()

def onDelete(self, evt):
if gui.messageBox(
Expand All @@ -306,11 +308,13 @@ def onDelete(self, evt):
translate("Confirm Deletion"),
wx.YES | wx.NO | wx.ICON_QUESTION, self
) == wx.NO:
self.feedsList.SetFocus()
return
os.remove(os.path.join(FEEDS_PATH, "%s.txt" % self.stringSel))
self.feedsList.Delete(self.sel)
self.feedsList.Selection = 0
self.onFeedsListChoice(None)
self.feedsList.SetFocus()

def onDefault(self, evt):
config.conf["readFeeds"]["addressFile"] = self.stringSel
Expand All @@ -325,6 +329,7 @@ def onRename(self, evt):
_("Rename feed"), value=self.stringSel
) as d:
if d.ShowModal() == wx.ID_CANCEL or not d.Value:
self.feedsList.SetFocus()
return
curName = "%s.txt" % self.stringSel
newName = "%s.txt" % api.filterFileName(d.Value)
Expand All @@ -333,6 +338,7 @@ def onRename(self, evt):
os.path.join(FEEDS_PATH, newName)
)
self.feedsList.SetString(self.sel, os.path.splitext(newName)[0])
self.feedsList.SetFocus()

def onClose(self, evt):
self.Destroy()
Expand All @@ -343,6 +349,7 @@ def onOpenFolder(self, evt):
if not os.path.isdir(path):
os.makedirs(path)
os.startfile(path)
self.onClose(None)

class ArticlesDialog(wx.Dialog):

Expand Down Expand Up @@ -404,7 +411,7 @@ def onClose(self, evt):
self.Parent.Enable()
self.Parent.feedsList.SetFocus()
self.Destroy()
self.parent.feedsList.SetFocus()


class CopyDialog(wx.Dialog):

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" : _("""Add-on for using NVDA as a feed reader."""),
# version
"addon_version" : "10.5-dev",
"addon_version" : "10.6-dev",
# Author(s)
"addon_author" : u"Noelia Ruiz Martínez <[email protected]>, Mesar Hameed <[email protected]>",
# URL for the add-on documentation support
Expand Down

0 comments on commit c045d86

Please sign in to comment.