Skip to content

Commit

Permalink
Simplify code a bit
Browse files Browse the repository at this point in the history
Move settings into a separate module
Update addon version
  • Loading branch information
beqabeqa473 committed Jan 5, 2022
1 parent d5a3332 commit 0e9ae43
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
23 changes: 4 additions & 19 deletions appModules/msedge/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,24 @@
# Released under GPL 2

import appModuleHandler
from collections import namedtuple
import config
import gui
import wx

Settings = namedtuple("Settings", "configKey, label, defaultValue")
settingItems = [
Settings("PageLoading", _("Announce loading of pages"), "boolean(default=false)"),
Settings("RefreshingPage", _("Announce page refresh"), "boolean(default=false)"),
Settings("ClosingTab", _("Announce closing of tab"), "boolean(default=false)"),
Settings("OpeningNewTab", _("Announce Opening of new tab"), "boolean(default=false)"),
Settings("OpeningWindow", _("Announce window opening"), "boolean(default=false)"),
Settings("HubDownloadsNewDownload", _("Announce starting file download"), "boolean(default=true)"),
Settings("HubDownloadsCompleteState", _("Announce download completion"), "boolean(default=true)"),
Settings("GoingBack", _("Announce navigating back"), "boolean(default=false)"),
Settings("ToolbarButtonRemoved", _("Announce removing toolbar buttons"), "boolean(default=false)"),
Settings("SearchMode", _("Announce of search mode"), "boolean(default=false)"),
Settings("SearchModeAvailable", _("Announce availability of search mode"), "boolean(default=false)"),
]

from .settings import settingItems

config.conf.spec["MSEdgeDiscardAnnouncements"] = {setting.configKey: setting.defaultValue for setting in settingItems}

class AppModule(appModuleHandler.AppModule):
activityIDs = []

def __init__(self, processID, appName):
super(AppModule, self).__init__(processID, appName)
super().__init__(processID, appName)
categoryClasses = gui.settingsDialogs.NVDASettingsDialog.categoryClasses
if not (MSEdgeDiscardAnnouncementsPanel in categoryClasses):
categoryClasses.append(MSEdgeDiscardAnnouncementsPanel)

def terminate(self):
super(AppModule, self).terminate()
super().terminate()
gui.settingsDialogs.NVDASettingsDialog.categoryClasses.remove(MSEdgeDiscardAnnouncementsPanel)

def getActivityIDsFromConfig(self):
Expand Down
16 changes: 16 additions & 0 deletions appModules/msedge/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from collections import namedtuple

Settings = namedtuple("Settings", "configKey, label, defaultValue")
settingItems = [
Settings("PageLoading", _("Announce loading of pages"), "boolean(default=false)"),
Settings("RefreshingPage", _("Announce page refresh"), "boolean(default=false)"),
Settings("ClosingTab", _("Announce closing of tab"), "boolean(default=false)"),
Settings("OpeningNewTab", _("Announce Opening of new tab"), "boolean(default=false)"),
Settings("OpeningWindow", _("Announce window opening"), "boolean(default=false)"),
Settings("HubDownloadsNewDownload", _("Announce starting file download"), "boolean(default=true)"),
Settings("HubDownloadsCompleteState", _("Announce download completion"), "boolean(default=true)"),
Settings("GoingBack", _("Announce navigating back"), "boolean(default=false)"),
Settings("ToolbarButtonRemoved", _("Announce removing toolbar buttons"), "boolean(default=false)"),
Settings("SearchMode", _("Announce of search mode"), "boolean(default=false)"),
Settings("SearchModeAvailable", _("Announce availability of search mode"), "boolean(default=false)")
]
2 changes: 1 addition & 1 deletion manifest.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = MSEdgeDiscardAnnouncements
summary = Microsoft Edge discard announcements
version = 0.3
version = 0.4
author = """Beqa Gozalishvili <[email protected]>"""
description = """Discards UIA announcements in Microsoft Edge such as page loading and refreshing, opening and closing tabs and windows."""
url = https://gozaltech.org
Expand Down

0 comments on commit 0e9ae43

Please sign in to comment.