From 06ba44641528426a851ea560c2ebb1abd49d972e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noelia=20Ruiz=20Mart=C3=ADnez?= Date: Thu, 29 Jun 2017 09:06:57 +0200 Subject: [PATCH] Bookmarks can be deleted from the Notes dialog Requested on #3 issue --- addon/globalPlugins/placeMarkers/__init__.py | 36 ++++++++++++++++++++ buildVars.py | 2 +- readme.md | 5 ++- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/addon/globalPlugins/placeMarkers/__init__.py b/addon/globalPlugins/placeMarkers/__init__.py index 5d2995ef..04b1f4e0 100644 --- a/addon/globalPlugins/placeMarkers/__init__.py +++ b/addon/globalPlugins/placeMarkers/__init__.py @@ -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) @@ -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) diff --git a/buildVars.py b/buildVars.py index 964d1855..9fd7688c 100755 --- a/buildVars.py +++ b/buildVars.py @@ -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 , Chris ", # URL for the add-on documentation support diff --git a/readme.md b/readme.md index f55a0041..d79808e3 100644 --- a/readme.md +++ b/readme.md @@ -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) ## @@ -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.