Skip to content

Commit

Permalink
Bookmarks can be deleted from the Notes dialog
Browse files Browse the repository at this point in the history
Requested on #3 issue
  • Loading branch information
nvdaes committed Jun 29, 2017
1 parent 1ab64f0 commit 06ba446
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
36 changes: 36 additions & 0 deletions addon/globalPlugins/placeMarkers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@ def __init__(self, parent, fileName):
# Translators: The label for a button in the Notes dialog.
self.saveButton = bHelper.addButton(self, label=_("&Save note"))
self.Bind(wx.EVT_BUTTON, self.onSave, self.saveButton)
# Translators: The label for a button in the Notes dialog.
self.deleteButton = bHelper.addButton(self, label=_("&Delete..."))
self.deleteButton.Bind(wx.EVT_BUTTON, self.onDelete)
sHelper.addDialogDismissButtons(self.CreateButtonSizer(wx.OK|wx.CANCEL))
self.Bind(wx.EVT_BUTTON, self.onOk, id=wx.ID_OK)
mainSizer.Add(sHelper.sizer, border=gui.guiHelper.BORDER_FOR_DIALOGS, flag=wx.ALL)
Expand All @@ -368,6 +371,39 @@ def onSave(self, evt):
log.debugWarning("Error saving bookmark", exc_info=True)
raise e

def onDelete(self, evt):
if gui.messageBox(
# Translators: The confirmation prompt displayed when the user requests to delete a bookmark.
_("This bookmark will be permanently deleted. This action cannot be undone."),
# Message translated in NVDA core.
translate("Confirm Deletion"),
wx.OK | wx.CANCEL | wx.ICON_QUESTION, self
) != wx.OK:
return
del self.bookmarks[self.pos]
if len(self.bookmarks.keys()) > 0:
try:
cPickle.dump(self.bookmarks, file(self.fileName, "wb"))
self.notesListBox.Delete(self.notesListBox.Selection)
self.notesListBox.Selection = 0
self.onNotesChange(None)
self.notesListBox.SetFocus()
except Exception as e:
log.debugWarning("Error deleting bookmark", exc_info=True)
raise e
else:
try:
os.remove(self.fileName)
self.Destroy()
wx.CallAfter(gui.messageBox,
# Translators: The message presented when all bookmarks have been deleted from the Notes dialog.
_("No bookmarks"),
# Translators: The title of the warning dialog when all bookmarks have been deleted.
_("Bookmarks deleted"),
wx.OK | wx.ICON_WARNING, None)
except WindowsError:
pass

def onOk(self, evt):
self.Destroy()
wx.CallLater(1000, moveToBookmark, self.pos)
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 setting place markers on specific virtual documents"),
# version
"addon_version" : "8.0",
"addon_version" : "9.0-dev-i3",
# Author(s)
"addon_author" : u"Noelia <[email protected]>, Chris <[email protected]>",
# URL for the add-on documentation support
Expand Down
5 changes: 4 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This addon is based on SpecificSearch and Bookmark&Search, developed by the same
* NVDA+k: Moves to the next bookmark.
* shift+NVDA+k: Moves to the previous bookmark.
* control+shift+k: Copies the file name where the place markers data will be saved to the clipboard, without an extension.
* alt+NVDA+k: Opens a dialog with the bookmarks saved for this document. You can write a note for each bookmark; press Save note to save changes. Pressing OK you can move to the selected position.
* alt+NVDA+k: Opens a dialog with the bookmarks saved for this document. You can write a note for each bookmark; press Save note to save changes. Pressing Delete you can remove the selected bookmark. Pressing OK you can move to the selected position.


## Place markers Submenu (NVDA+N) ##
Expand All @@ -31,6 +31,9 @@ Using the Place markers submenu under NVDA's Preferences menu, you can access:
Note: The bookmark position is based on the number of characters; and therefore in dynamic pages it is better to use the specific search, not bookmarks.


## Changes for 9.0
* Bookmarks can be deleted from the Notes dialog.

## Changes for 8.0 ##
* Removed fragment identifiers from bookmark filenames, which can avoid issues in the VitalSource Bookshelf ePUB reader.
* Added a Notes dialog, to associate comments for saved bookmarks and move to the selected position.
Expand Down

0 comments on commit 06ba446

Please sign in to comment.