From 6494949fd6c8aa7631295c04c6d100b39c0a327f Mon Sep 17 00:00:00 2001 From: mush42 Date: Thu, 12 Dec 2019 22:43:01 +0200 Subject: [PATCH] Completed documentations. The Active audio theme is muted when editing or creating audio themes. --- addon/globalPlugins/audiothemes/__init__.py | 2 +- .../audiothemes/studio/__init__.py | 27 +++++++++++++++---- buildVars.py | 2 +- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/addon/globalPlugins/audiothemes/__init__.py b/addon/globalPlugins/audiothemes/__init__.py index 3d8fc4a..d7e5d97 100644 --- a/addon/globalPlugins/audiothemes/__init__.py +++ b/addon/globalPlugins/audiothemes/__init__.py @@ -69,7 +69,7 @@ def terminate(self): def on_studio_item_clicked(self, event): # Translators: title for the audio themes studio dialog - with AudioThemesStudioStartupDialog(_("Audio Themes Studio")) as dlg: + with AudioThemesStudioStartupDialog(self, _("Audio Themes Studio")) as dlg: dlg.ShowModal() def script_speakObject(self, gesture): diff --git a/addon/globalPlugins/audiothemes/studio/__init__.py b/addon/globalPlugins/audiothemes/studio/__init__.py index 2443ccd..6ee4bdc 100644 --- a/addon/globalPlugins/audiothemes/studio/__init__.py +++ b/addon/globalPlugins/audiothemes/studio/__init__.py @@ -7,6 +7,7 @@ import wx import config import gui +from contextlib import contextmanager from tempfile import TemporaryDirectory from wx.adv import CommandLinkButton from ..handler import AudioTheme, AudioThemesHandler, audiotheme_changed @@ -35,7 +36,7 @@ def addControls(self, sizer, parent): themeAuthorLabel = wx.StaticText(parent, -1, _("Theme Author")) self.themeAuthorEdit = wx.TextCtrl(parent, -1, name="author") # Translators: label for a text field - themeSummaryLabel = wx.StaticText(parent, -1, _("Theme Summary")) + themeSummaryLabel = wx.StaticText(parent, -1, _("Theme Description")) self.themeSummaryEdit = wx.TextCtrl( parent, -1, style=wx.TE_MULTILINE, name="summary" ) @@ -96,6 +97,11 @@ def selected_theme(self): class AudioThemesStudioStartupDialog(BaseDialog): + + def __init__(self, plugin, *args, **kwargs): + self.plugin = plugin + super().__init__(*args, **kwargs) + def addControls(self, sizer, parent): # Translators: instruction message in the audio themes studio startup dialog dialogMessage = wx.StaticText(self, -1, _(WELCOME_MSG)) @@ -134,6 +140,15 @@ def getButtons(self, parent): btnsizer.Realize() return btnsizer + @contextmanager + def audio_theme_muted(self): + theme_state = self.plugin.handler.enabled + self.plugin.handler.enabled = False + try: + yield + finally: + self.plugin.handler.enabled = theme_state + def onCreateNewTheme(self, event): self.Close() theme_info = None @@ -152,8 +167,9 @@ def onCreateNewTheme(self, event): theme=new_theme, editing=False, ) - with dlg: - dlg.ShowModal() + with self.audio_theme_muted(): + with dlg: + dlg.ShowModal() def onEditExistingTheme(self, event): self.Close() @@ -178,6 +194,7 @@ def onEditExistingTheme(self, event): _("Editing Audio Theme: {name}").format(name=selected_theme.name), theme=selected_theme, ) - with dlg: - dlg.ShowModal() + with self.audio_theme_muted(): + with dlg: + dlg.ShowModal() audiotheme_changed.notify() diff --git a/buildVars.py b/buildVars.py index 72b2a14..3700e70 100644 --- a/buildVars.py +++ b/buildVars.py @@ -20,7 +20,7 @@ "addon_summary" : _("Audio Themes"), # Add-on description # Translators: Long description to be shown for this add-on on add-on information from add-ons manager - "addon_description" : _("""This add-on creates a virtual audio display that plays sounds when focusing or navigating objects, the audio will be played in a location that corresponds to the object's location in the visual display. The add-on also enables you to activate, install, remove, edit, create, and distribute audio theme packages."""), + "addon_description" : _("""This add-on creates a virtual audio display that plays sounds when focusing or navigating objects, the audio will be played in a location that corresponds to the object's location in the visual display. The add-on also enables you to add, remove, edit, create, and distribute audio theme packages."""), # version "addon_version" : "6.0", # Author(s)