Beispiel #1
0
 def onRename(self, evt):
     index = self.profileList.Selection
     oldName = self.profileNames[index]
     # Translators: The label of a field to enter a new name for a configuration profile.
     with wx.TextEntryDialog(
             self,
             _("New name:"),
             # Translators: The title of the dialog to rename a configuration profile.
             _("Rename Profile"),
             value=oldName) as d:
         if d.ShowModal() == wx.ID_CANCEL:
             return
         newName = api.filterFileName(d.Value)
     try:
         config.conf.renameProfile(oldName, newName)
     except ValueError:
         # Translators: An error displayed when renaming a configuration profile
         # and a profile with the new name already exists.
         gui.messageBox(
             _("That profile already exists. Please choose a different name."
               ), _("Error"), wx.OK | wx.ICON_ERROR, self)
         return
     except:
         log.debugWarning("", exc_info=True)
         gui.messageBox(_("Error renaming profile."), _("Error"),
                        wx.OK | wx.ICON_ERROR, self)
         return
     self.profileNames[index] = newName
     self.profileList.SetString(
         index, self.getProfileDisplay(newName, includeStates=True))
     self.profileList.Selection = index
     self.profileList.SetFocus()
Beispiel #2
0
	def onRename(self, evt):
		index = self.profileList.Selection
		oldName = self.profileNames[index]
		# Translators: The label of a field to enter a new name for a configuration profile.
		with wx.TextEntryDialog(self, _("New name:"),
				# Translators: The title of the dialog to rename a configuration profile.
				_("Rename Profile"), defaultValue=oldName) as d:
			if d.ShowModal() == wx.ID_CANCEL:
				return
			newName = api.filterFileName(d.Value)
		try:
			config.conf.renameProfile(oldName, newName)
		except ValueError:
			# Translators: An error displayed when renaming a configuration profile
			# and a profile with the new name already exists.
			gui.messageBox(_("That profile already exists. Please choose a different name."),
				_("Error"), wx.OK | wx.ICON_ERROR, self)
			return
		except:
			log.debugWarning("", exc_info=True)
			gui.messageBox(_("Error renaming profile."),
				_("Error"), wx.OK | wx.ICON_ERROR, self)
			return
		self.profileNames[index] = newName
		self.profileList.SetString(index, self.getProfileDisplay(newName, includeStates=True))
		self.profileList.Selection = index
		self.profileList.SetFocus()
Beispiel #3
0
def createVoiceDictFileName(synthName, voiceName):
    """ Creates a filename used for the voice dictionary files.
	this is in the format synthName-voiceName.dic
	"""
    fileNameFormat = u"{synth}-{voice}.dic"
    return fileNameFormat.format(synth=synthName,
                                 voice=api.filterFileName(voiceName))
Beispiel #4
0
 def createFeed(self, address):
     feed = Feed(address)
     feedName = api.filterFileName(feed.getFeedName())
     if os.path.isfile(os.path.join(FEEDS_PATH, "%s.txt" % feedName)):
         feedName = "tempFeed"
     with open(os.path.join(FEEDS_PATH, "%s.txt" % feedName), "w") as f:
         f.write(address)
         f.close()
     return feedName
Beispiel #5
0
def createVoiceDictFileName(synthName, voiceName):
	""" Creates a filename used for the voice dictionary files.
	this is in the format synthName-voiceName.dic
	"""
	fileNameFormat = u"{synth}-{voice}.dic"
	return fileNameFormat.format(
			synth = synthName,
			voice = api.filterFileName(voiceName)
			)
def loadVoiceDict(synth):
	"""Loads appropriate dictionary for the given synthesizer.
It handles case when the synthesizer doesn't support voice setting.
"""
	if synth.isSupported("voice"):
		voiceName = synth.availableVoices[synth.voice].name
		fileName=r"%s\%s-%s.dic"%(speechDictsPath,synth.name,api.filterFileName(voiceName))
	else:
		fileName=r"%s\%s.dic"%(speechDictsPath,synth.name)
	dictionaries["voice"].load(fileName)
Beispiel #7
0
def loadVoiceDict(synth):
	"""Loads appropriate dictionary for the given synthesizer.
It handles case when the synthesizer doesn't support voice setting.
"""
	if synth.isSupported("voice"):
		voiceName = synth.availableVoices[synth.voice].name
		fileName=r"%s\%s-%s.dic"%(speechDictsPath,synth.name,api.filterFileName(voiceName))
	else:
		fileName=r"%s\%s.dic"%(speechDictsPath,synth.name)
	dictionaries["voice"].load(fileName)
Beispiel #8
0
 def onRename(self, evt):
     # Translators: The label of a field to enter a new name for a feed.
     with wx.TextEntryDialog(
             self,
             _("New name:"),
             # Translators: The title of a dialog to rename a feed.
             _("Rename feed"),
             value=self.stringSel) as d:
         if d.ShowModal() == wx.ID_CANCEL or not d.Value:
             return
         curName = "%s.txt" % self.stringSel
         newName = "%s.txt" % api.filterFileName(d.Value)
     os.rename(os.path.join(FEEDS_PATH, curName),
               os.path.join(FEEDS_PATH, newName))
     self.feedsList.SetString(self.sel, os.path.splitext(newName)[0])
Beispiel #9
0
 def onAdd(self, evt):
     # Translators: Message displayed when adding a new library.
     message = _('Enter library name please')
     # Translators: Title of dialog.
     caption = _('Add Library')
     name = addLibrary(message, caption)
     #log.info(name)
     if not name:
         return
     filename = api.filterFileName(name) + '.json'
     filepath = os.path.join(self.LIBRARIES_DIR, filename)
     #log.info('filepath to add: %s'%filepath)
     try:
         with open(filepath, 'w') as f:
             f.write("{}")
     except Exception as e:
         raise e
     LibraryDialog.libraryFiles.append(name)
     LibraryDialog.libraryFiles.sort()
     self.refreshLibraries(str=name)
Beispiel #10
0
 def onRename(self, evt):
     # Translators: Message displayed when renaming a library
     message = _('Enter new name please')
     # Translators: Title of dialog to enter new name.
     caption = _('rename')
     oldName = self.listBox.GetStringSelection()
     i = LibraryDialog.libraryFiles.index(oldName)
     LibraryDialog.libraryFiles.remove(oldName)
     newname = addLibrary(message, caption, oldName)
     #log.info('newname: %s'%newname)
     if not newname or newname == oldName:
         LibraryDialog.libraryFiles.insert(i, oldName)
         return
     else:
         newname = api.filterFileName(newname)
         os.rename(os.path.join(self.LIBRARIES_DIR, oldName + '.json'),
                   os.path.join(self.LIBRARIES_DIR, newname + '.json'))
         #log.info(LibraryDialog.libraryFiles)
         LibraryDialog.libraryFiles.append(newname)
         LibraryDialog.libraryFiles.sort()
         self.refreshLibraries(str=newname)
Beispiel #11
0
	def onOk(self, evt):
		confTrigs = config.conf.triggersToProfiles
		spec, disp, manualEdit = self.triggers[self.triggerChoice.Selection]
		if spec in confTrigs and gui.messageBox(
			# Translators: The confirmation prompt presented when creating a new configuration profile
			# and the selected trigger is already associated.
			_("This trigger is already associated with another profile. "
				"If you continue, it will be removed from that profile and associated with this one.\n"
				"Are you sure you want to continue?"),
			_("Warning"), wx.ICON_WARNING | wx.YES | wx.NO, self
		) == wx.NO:
			return

		name = self.profileName.Value
		if not name:
			gui.messageBox(
				# Translators: An error displayed when the user attempts to create a configuration profile
				# with an empty name.
				_("You must choose a name for this profile."),
				# Translators: The title of an error message dialog.
				caption=_("Error"),
				style=wx.ICON_ERROR,
				parent=self
			)
			self.profileName.SetFocus()
			return
		name = api.filterFileName(name)
		try:
			config.conf.createProfile(name)
		except ValueError:
			# Translators: An error displayed when the user attempts to create a configuration profile which already exists.
			gui.messageBox(_("That profile already exists. Please choose a different name."),
				_("Error"), wx.OK | wx.ICON_ERROR, self)
			return
		except:
			log.debugWarning("", exc_info=True)
			# Translators: An error displayed when creating a configuration profile fails.
			gui.messageBox(_("Error creating profile - probably read only file system."),
				_("Error"), wx.OK | wx.ICON_ERROR, self)
			self.onCancel(evt)
			return
		if spec:
			confTrigs[spec] = name
			self.Parent.saveTriggers(parentWindow=self)

		parent = self.Parent
		if manualEdit:
			if gui.messageBox(
				# Translators: The prompt asking the user whether they wish to
				# manually activate a configuration profile that has just been created.
				_("To edit this profile, you will need to manually activate it. "
					"Once you have finished editing, you will need to manually deactivate it to resume normal usage.\n"
					"Do you wish to manually activate it now?"),
				# Translators: The title of the confirmation dialog for manual activation of a created profile.
				_("Manual Activation"), wx.YES | wx.NO | wx.ICON_QUESTION, self
			) == wx.YES:
				config.conf.manualActivateProfile(name)
			else:
				# Return to the Profiles dialog.
				parent.profileNames.append(name)
				parent.profileList.Append(name)
				parent.profileList.Selection = parent.profileList.Count - 1
				parent.onProfileListChoice(None)
				parent.profileList.SetFocus()
				parent.Enable()
				self.Destroy()
				return
		else:
			# Ensure triggers are enabled so the user can edit the profile.
			config.conf.enableProfileTriggers()

		# The user is done with the Profiles dialog;
		# let them get on with editing the profile.
		parent.Destroy()
		# Also nullify the instance flag as the profiles dialog itself is dead.
		ProfilesDialog._instance = None
Beispiel #12
0
	def onOk(self, evt):
		confTrigs = config.conf.triggersToProfiles
		spec, disp, manualEdit = self.triggers[self.triggerChoice.Selection]
		if spec in confTrigs and gui.messageBox(
			# Translators: The confirmation prompt presented when creating a new configuration profile
			# and the selected trigger is already associated.
			_("This trigger is already associated with another profile. "
				"If you continue, it will be removed from that profile and associated with this one.\n"
				"Are you sure you want to continue?"),
			_("Warning"), wx.ICON_WARNING | wx.YES | wx.NO, self
		) == wx.NO:
			return

		name = api.filterFileName(self.profileName.Value)
		if not name:
			return
		try:
			config.conf.createProfile(name)
		except ValueError:
			# Translators: An error displayed when the user attempts to create a configuration profile which already exists.
			gui.messageBox(_("That profile already exists. Please choose a different name."),
				_("Error"), wx.OK | wx.ICON_ERROR, self)
			return
		except:
			log.debugWarning("", exc_info=True)
			# Translators: An error displayed when creating a configuration profile fails.
			gui.messageBox(_("Error creating profile - probably read only file system."),
				_("Error"), wx.OK | wx.ICON_ERROR, self)
			self.onCancel(evt)
			return
		if spec:
			confTrigs[spec] = name
			self.Parent.saveTriggers(parentWindow=self)

		parent = self.Parent
		if manualEdit:
			if gui.messageBox(
				# Translators: The prompt asking the user whether they wish to
				# manually activate a configuration profile that has just been created.
				_("To edit this profile, you will need to manually activate it. "
					"Once you have finished editing, you will need to manually deactivate it to resume normal usage.\n"
					"Do you wish to manually activate it now?"),
				# Translators: The title of the confirmation dialog for manual activation of a created profile.
				_("Manual Activation"), wx.YES | wx.NO | wx.ICON_QUESTION, self
			) == wx.YES:
				config.conf.manualActivateProfile(name)
			else:
				# Return to the Profiles dialog.
				parent.profileNames.append(name)
				parent.profileList.Append(name)
				parent.profileList.Selection = parent.profileList.Count - 1
				parent.onProfileListChoice(None)
				parent.profileList.SetFocus()
				parent.Enable()
				self.Destroy()
				return
		else:
			# Ensure triggers are enabled so the user can edit the profile.
			config.conf.enableProfileTriggers()

		# The user is done with the Profiles dialog;
		# let them get on with editing the profile.
		parent.Destroy()