Skip to content

Commit

Permalink
Replace checkboxes with CheckListbox.
Browse files Browse the repository at this point in the history
Add a donation module.
It is now possible to suppress suggestion list while typing in the address bar.
NVDA 2023.1 compatibility.
  • Loading branch information
beqabeqa473 committed Apr 4, 2023
1 parent 7e67939 commit 2c7b208
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 13 deletions.
24 changes: 15 additions & 9 deletions addon/appModules/msedge/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# MSEdgeDiscardAnnouncements: An appModule to discard some of notifications generated by Microsoft Edge
# Copyright (C) 2022 Beqa Gozalishvili
# Copyright (C) 2022-2023 Beqa Gozalishvili
# Released under GPL 2

import addonHandler
import api
import appModuleHandler
import config
import gui
from NVDAObjects.UIA import UIA
import wx
from .settings import settingItems

Expand All @@ -32,6 +33,12 @@ def terminate(self):
if (MSEdgeDiscardAnnouncementsPanel in categoryClasses):
gui.settingsDialogs.NVDASettingsDialog.categoryClasses.remove(MSEdgeDiscardAnnouncementsPanel)

def event_NVDAObject_init(self, obj):
if not "ShowSuggestions" in self.activityIDs:
return
if isinstance(obj, UIA) and obj.UIAElement.CurrentClassName == "OmniboxResultView":
obj.isDescendantOf = lambda obj: False

def getActivityIDsFromConfig(self):
edgeConf = config.conf[addonName]
self.activityIDs = [k for k, v in edgeConf.items() if type(v) == bool and v == False]
Expand All @@ -54,13 +61,12 @@ class MSEdgeDiscardAnnouncementsPanel(gui.settingsDialogs.SettingsPanel):

def makeSettings(self, sizer):
self.config = config.conf[addonName]
self.helper = gui.guiHelper.BoxSizerHelper(self, sizer=sizer)
for setting in settingItems:
widget = self.helper.addItem(wx.CheckBox(self, label=setting.label, name=setting.configKey))
widget.SetValue(self.config[setting.configKey])
sHelper = gui.guiHelper.BoxSizerHelper(self, sizer=sizer)
notificationsLabel = _("&Configure MSEdge notifications")
self.settingChoices = [setting.label for setting in settingItems]
self.settingList=sHelper.addLabeledControl(notificationsLabel, gui.nvdaControls.CustomCheckListBox, choices=self.settingChoices)
self.settingList.CheckedItems = [index for index, setting in enumerate(settingItems) if self.config[setting.configKey]]
self.settingList.Select(0)

def onSave(self):
for child in self.helper.sizer.GetChildren():
widget = child.GetWindow()
if isinstance(widget, wx.CheckBox):
self.config[widget.Name] = widget.IsChecked()
[self.config.__setitem__(setting.configKey, self.settingList.IsChecked(index)) for index, setting in enumerate(settingItems)]
40 changes: 40 additions & 0 deletions addon/appModules/msedge/donate_dialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#donatedialog.py
# Copyright (C) 2022-2023 Beqa Gozalishvili <[email protected]>
#This file is covered by the GNU General Public License.
#See the file COPYING for more details.

import addonHandler
import gui
import webbrowser
import wx

addonHandler.initTranslation()


class DonationDialog(gui.nvdaControls.MessageDialog):
YOOMONEY_URL = "https://yoomoney.ru/to/4100117727255296"
PAYPAL_URL = "https://paypal.me/gozaltech"

def __init__(self, parent, title, message):
super().__init__(parent, title, message, dialogType=gui.nvdaControls.MessageDialog.DIALOG_TYPE_WARNING)

def _addButtons(self, buttonHelper):
paypalBtn = buttonHelper.addButton(self, label=_("Donate via Paypal"), name="PAYPAL_URL")
yoomoneyBtn = buttonHelper.addButton(self, label=_("Donate via Yoomoney"), name="YOOMONEY_URL")
paypalBtn.Bind(wx.EVT_BUTTON, self.onDonate)
yoomoneyBtn.Bind(wx.EVT_BUTTON, self.onDonate)
cancelBtn = buttonHelper.addButton(self, id=wx.ID_CANCEL)
cancelBtn.Bind(wx.EVT_BUTTON, lambda evt: self.EndModal(wx.CANCEL))

def onDonate(self, evt):
donateBtn = evt.GetEventObject()
donateUrl = getattr(self, donateBtn.Name)
webbrowser.open(donateUrl)
self.EndModal(wx.OK)

def requestDonations(addonName, parentWindow):
title = _("Request for contributions to {name}").format(name=addonName)
message = _("{name} is a free add-on for NVDA.\n"
"You can make a donation to its author to support further development of this and other free projects.\n"
"Do you want to donate now? Choose one of the available payment methods. You will be redirected to the corresponding website to complete a donation").format(name=addonName)
return DonationDialog(parentWindow, title, message).ShowModal()
5 changes: 3 additions & 2 deletions addon/appModules/msedge/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# MSEdgeDiscardAnnouncements: An appModule to discard some of notifications generated by Microsoft Edge
# Copyright (C) 2022 Beqa Gozalishvili
# Copyright (C) 2022-2023 Beqa Gozalishvili
# Released under GPL 2

import addonHandler
Expand All @@ -25,5 +25,6 @@
Settings("SearchMode", _("Announce of search mode"), "boolean(default=false)"),
Settings("SearchModeAvailable", _("Announce availability of search mode"), "boolean(default=false)"),
Settings("NotificationAppear", _("Announce appearing of notifications"), "boolean(default=false)"),
Settings("HubDownloadsIndeterminateProgressState", _("Announce indeterminate progress state of current download"), "boolean(default=false)")
Settings("HubDownloadsIndeterminateProgressState", _("Announce indeterminate progress state of current download"), "boolean(default=false)"),
Settings("ShowSuggestions", _("Show suggestions while typing in addressbar"), "boolean(default=true)")
]
19 changes: 19 additions & 0 deletions addon/installTasks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import addonHandler
import gui
import os.path
import sys

addon = addonHandler.getCodeAddon()
addonName = addon.name
addonDir = os.path.abspath(os.path.join(os.path.dirname(__file__), "appModules", "msedge"))
sys.path.append(addonDir)
from donate_dialog import requestDonations
sys.path.remove(sys.path[-1])
import wx

addonHandler.initTranslation()

def onInstall():
gui.mainFrame.prePopup()
wx.CallAfter(requestDonations, addonName, gui.mainFrame)
gui.mainFrame.postPopup()
4 changes: 2 additions & 2 deletions buildVars.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def _(arg):
# Translators: Long description to be shown for this add-on on add-on information from add-ons manager
"addon_description": _("""Discards UIA announcements in Microsoft Edge such as page loading and refreshing, opening and closing tabs and windows."""),
# version
"addon_version": "0.7",
"addon_version": "0.8",
# Author(s)
"addon_author": "Beqa Gozalishvili <[email protected]>",
# URL for the add-on documentation support
Expand All @@ -35,7 +35,7 @@ def _(arg):
# Minimum NVDA version supported (e.g. "2018.3.0", minor version is optional)
"addon_minimumNVDAVersion": "2019.3.0",
# Last NVDA version supported/tested (e.g. "2018.4.0", ideally more recent than minimum version)
"addon_lastTestedNVDAVersion": "2022.2.0",
"addon_lastTestedNVDAVersion": "2023.1.0",
# Add-on update channel (default is None, denoting stable releases,
# and for development releases, use "dev".)
# Do not change unless you know what you are doing!
Expand Down
6 changes: 6 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
This addon is used to suppress some of annoying notifications generated by Microsof edge browser.
All notifications can be configured in corresponding addon category of NVDA settings.

## Changes for 0.8 ##
* Replaced checkboxes with CheckListbox.
* Added a donation module.
* It is now possible to suppress suggestion list while typing in the address bar.
* NVDA 2023.1 compatibility.

## Changes for 0.7 ##
* Added some more notification IDs;
* Fixed a case, when there was a flud of download notifications when more than one window of Microsoft edge was opened;
Expand Down

0 comments on commit 2c7b208

Please sign in to comment.