예제 #1
0
 def OnGuide(self, evt):
     if platform.system() == 'Windows':
         helpfile = os.path.join("help",
                                 "songpress-%s.chm" % (i18n.getLang(), ))
         subprocess.Popen("hh " + glb.AddPath(helpfile))
     else:
         wx.LaunchDefaultBrowser(_("http://www.skeed.it/songpress-manual"))
    def OnOptions(self, evt):
        f = PreferencesDialog(self.frame, wx.ID_ANY, _("Songpress options"))
        if f.ShowModal() == wx.ID_OK:
            face, s = f.GetFont()
            self.text.SetFont(face, s)
            self.config.SetPath("/Editor")
            self.config.Write("Face", face)
            self.config.Write("Size", str(s))

            l = f.GetLanguage()
            lang = i18n.getLang()
            if l != lang:
                msg = _("Language settings will be applied when you restart Songpress.")
                d = wx.MessageDialog(self.frame, msg, _("Songpress"), wx.ICON_INFORMATION | wx.OK)
                d.ShowModal()
            self.config.SetPath("/App")
            self.config.Write("locale", l)
예제 #3
0
	def OnOk(self, evt):
		self.pref.editorFace, self.pref.editorSize = self.GetFont()
		self.pref.updateFrequency = self.GetUpdateFrequency()
		l = self.GetLanguage()
		lang = i18n.getLang()
		if l is not None and l != lang:
			msg = _("Language settings will be applied when you restart Songpress.")
			d = wx.MessageDialog(self, msg, _("Songpress"), wx.ICON_INFORMATION | wx.OK)
			d.ShowModal()
		self.pref.locale = l
		self.pref.SetDefaultNotation(self.GetNotation())
		self.pref.autoAdjustSpuriousLines = self.autoRemoveBlankLines.GetValue()
		self.pref.autoAdjustTab2Chordpro = self.autoTab2Chordpro.GetValue()
		self.pref.autoAdjustEasyKey = self.autoAdjustEasyKey.GetValue()
		for k in self.decoSliders:
			self.pref.SetEasyChordsGroup(k, self.decoSliders[k].slider.GetValue())
		self.pref.defaultExtension = self.extension.GetString(self.extension.GetSelection())
		evt.Skip(True)
예제 #4
0
    def check_for_updates():
        """
		Check and return available updates.
		
		Honour the frequency of update checking unless force is True.
		
		Return list of pair (version, description),
		where description is an html-formatted text.
		Raise an exception if anything goes wrong.
		"""
        if (force or preferences.updateLastCheck is None
                or datetime.datetime.now() > preferences.updateLastCheck +
                datetime.timedelta(days=preferences.updateFrequency)):
            tr = RequestsTransport()
            s = Server(preferences.updateUrl, transport=tr)
            # method returns a dictionary with those keys:
            # 'new_url': if defined, new url of the webservice
            # 'updates': list of 3-tuples (version, description, downloadUrl)
            u = s.checkForUpdates(
                glb.VERSION,
                preferences.updateFrequency,
                platform.system(),
                platform.architecture(),
                platform.platform(),
                platform.python_version(),
                wx.version(),
                i18n.getLang(),
            )
            u2 = [
                x for x in u['updates']
                if x[0] not in preferences.ignoredUpdates
            ]
            preferences.updateLastCheck = datetime.datetime.now()
            if 'new_url' in u:
                preferences.updateUrl = u['new_url']
            return u2
        return []
예제 #5
0
	def check_for_updates():
		"""
		Check and return available updates.
		
		Honour the frequency of update checking unless force is True.
		
		Return list of pair (version, description),
		where description is an html-formatted text.
		Raise an exception if anything goes wrong.
		"""
		if(
			force
			or preferences.updateLastCheck is None
			or datetime.datetime.now() > preferences.updateLastCheck + datetime.timedelta(days=preferences.updateFrequency)
		):
			tr = ProxyTransport()
			s = Server(preferences.updateUrl, transport = tr)
			# method returns a dictionary with those keys:
			# 'new_url': if defined, new url of the webservice
			# 'updates': list of 3-tuples (version, description, downloadUrl)
			u = s.checkForUpdates(
				glb.VERSION,
				preferences.updateFrequency,
				platform.system(),
				platform.architecture(),
				platform.platform(),
				platform.python_version(),
				wx.version(),
				i18n.getLang(),
			)
			u2 = [x for x in u['updates'] if x[0] not in preferences.ignoredUpdates]
			preferences.updateLastCheck = datetime.datetime.now()
			if 'new_url' in u:
				preferences.updateUrl = u['new_url']
			return u2
		return []
예제 #6
0
 def OnOk(self, evt):
     self.pref.editorFace, self.pref.editorSize = self.GetFont()
     self.pref.updateFrequency = self.GetUpdateFrequency()
     l = self.GetLanguage()
     lang = i18n.getLang()
     if l is not None and l != lang:
         msg = _(
             "Language settings will be applied when you restart Songpress."
         )
         d = wx.MessageDialog(self, msg, _("Songpress"),
                              wx.ICON_INFORMATION | wx.OK)
         d.ShowModal()
     self.pref.locale = l
     self.pref.SetDefaultNotation(self.GetNotation())
     self.pref.autoAdjustSpuriousLines = self.autoRemoveBlankLines.GetValue(
     )
     self.pref.autoAdjustTab2Chordpro = self.autoTab2Chordpro.GetValue()
     self.pref.autoAdjustEasyKey = self.autoAdjustEasyKey.GetValue()
     for k in self.decoSliders:
         self.pref.SetEasyChordsGroup(k,
                                      self.decoSliders[k].slider.GetValue())
     self.pref.defaultExtension = self.extension.GetString(
         self.extension.GetSelection())
     evt.Skip(True)
예제 #7
0
	def Load(self):
		self.notices = {}
		self.config.SetPath('/Format')
		l = self.config.Read('ChorusLabel')
		if l:
			self.chorusLabel = l
			self.decoratorFormat.SetChorusLabel(l)
		else:
			self.chorusLabel = None
		showChords = int(self.config.Read('ShowChords', "2"))
		self.config.SetPath('/Format/Font')
		face = self.config.Read('Face')
		if face:
			self.fontFace = face
		else:
			self.fontFace = "Arial"
		self.SetFont(self.fontFace, showChords)
		self.config.SetPath('/Format/Style')
		labelVerses = self.config.Read('LabelVerses')
		if labelVerses:
			self.labelVerses = bool(int(labelVerses))
		else:
			self.labelVerses = True
		self.config.SetPath('/Editor')
		self.editorFace = self.config.Read('Face')
		self.editorSize = self.config.Read('Size')
		if not self.editorFace:
			self.editorFace = wx.SystemSettings().GetFont(wx.SYS_ANSI_FIXED_FONT).GetFaceName() # "Lucida Console"
			self.editorSize = 12
		else:
			self.editorSize = int(self.editorSize)
		n = self.config.Read('DefaultNotation')
		if n:
			self.defaultNotation = n
			self.notations = [x for x in self.notations if x.id == n] + [x for x in self.notations if x.id != n]
		else:
			lang = i18n.getLang()
			if lang in defaultLangNotation:
				n = defaultLangNotation[lang].id
				self.notations = [x for x in self.notations if x.id == n] + [x for x in self.notations if x.id != n]
				self.defaultNotation = None
		self.config.SetPath('/AutoAdjust')
		spuriousLines = self.config.Read('spuriousLines')
		if spuriousLines:
			self.autoAdjustSpuriousLines = bool(int(spuriousLines))
		else:
			self.autoAdjustSpuriousLines = True
		tab2chordpro = self.config.Read('tab2chordpro')
		if tab2chordpro:
			self.autoAdjustTab2Chordpro = bool(int(tab2chordpro))
		else:
			self.autoAdjustTab2Chordpro = True
		easyKey = self.config.Read('easyKey')
		if easyKey:
			self.autoAdjustEasyKey = bool(int(easyKey))
		else:
			self.autoAdjustEasyKey = False
			self.notices['firstTimeEasyKey'] = True
		self.config.SetPath('/AutoAdjust/EasyChordsGroups')
		for k in easyChordsOrder:
			l = self.config.Read(k)
			if l:
				l = int(l)
			else:
				l = easyChords[k][2]
			self.SetEasyChordsGroup(k, l)
		self.config.SetPath('/App')
		ext = self.config.Read('defaultExtension')
		if not ext:
			self.defaultExtension = 'crd'
		else:
			self.defaultExtension = ext
		lang = self.config.Read('locale')
		if not lang:
			self.locale = None
		else:
			self.locale = lang
		self.config.SetPath('/AutoUpdate')
		f = self.config.Read('frequency')
		if not f:
			self.updateFrequency = 7
		else:
			self.updateFrequency = int(f)
		i = self.config.Read('ignored')
		if not i:
			self.ignoredUpdates = set()
		else:
			self.ignoredUpdates = set(i.split(','))
		u = self.config.Read('url')
		if not u:
			self.updateUrl = 'https://songpress.skeed.it/xmlrpc'
		else:
			self.updateUrl = u
		d = self.config.Read('lastCheck')
		if not d:
			self.updateLastCheck = None
		else:
			self.updateLastCheck = datetime.datetime.fromordinal(int(d))
예제 #8
0
    def __init__(self, parent, preferences, easyChords):
        self.pref = preferences
        self.frame = self
        PreferencesDialog.__init__(self, parent)

        self.easyChords = easyChords

        self.fontCB.Bind(wx.EVT_TEXT_ENTER, self.OnFontSelected, self.fontCB)
        self.fontCB.Bind(wx.EVT_COMBOBOX, self.OnFontSelected, self.fontCB)

        previewSong = _(
            "{t:My Bonnie}\n\nMy [D]Bonnie lies [G]over the [D]ocean\noh [G]bring back my [A]Bonnie to [D]me!\n\n{soc}\n[D]Bring back, [E-]bring back,\n[A]bring back my Bonnie to [D]me!\n{eoc}"
        )
        self.editor.SetText(previewSong)
        self.editor.SetFont(self.pref.editorFace, self.pref.editorSize)
        self.editor.SetReadOnly(True)
        self.autoRemoveBlankLines.SetValue(self.pref.autoAdjustSpuriousLines)
        self.autoTab2Chordpro.SetValue(self.pref.autoAdjustTab2Chordpro)
        self.autoAdjustEasyKey.SetValue(self.pref.autoAdjustEasyKey)
        if self.pref.locale is None:
            lang = i18n.getLang()
        else:
            lang = self.pref.locale
        for l in glb.languages:
            i = self.langCh.Append(glb.languages[l])
            self.langCh.SetClientData(i, l)
            if lang == l:
                self.langCh.SetSelection(i)
        exts = ["crd", "pro", "chopro", "chordpro", "cho"]
        i = 0
        for e in exts:
            self.extension.Append(e)
            if e == self.pref.defaultExtension:
                self.extension.SetSelection(i)
            i += 1

        # Default notation
        for n in self.pref.notations:
            i = self.notationCh.Append(n.desc)
            self.notationCh.SetClientData(i, n.id)
        self.notationCh.SetSelection(0)

        # Update frequency
        sel = 0
        uf = get_update_frequencies()
        for k in uf:
            i = self.frequency.Append(uf[k])
            self.frequency.SetClientData(i, k)
            if k == self.pref.updateFrequency:
                sel = i
        self.frequency.SetSelection(sel)

        # Easy chords
        simplifyGrid = wx.FlexGridSizer(len(easyChords), 2, 0, 0)
        simplifyGrid.AddGrowableCol(1, 1)
        self.simplifyPanel.SetSizer(simplifyGrid)
        self.simplifyPanel.Layout()

        self.decoSliders = {}
        for k in easyChordsOrder:
            simplifyGrid.Add(
                wx.StaticText(self.simplifyPanel, wx.ID_ANY,
                              getEasyChordsDescription(easyChords[k]),
                              wx.DefaultPosition, wx.DefaultSize, 0), 0,
                wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 5)
            ds = MyDecoSlider(self.simplifyPanel)
            self.decoSliders[k] = ds
            ds.slider.SetValue(self.pref.GetEasyChordsGroup(k))
            simplifyGrid.Add(ds, 1, wx.EXPAND, 5)

        simplifyGrid.FitInside(self.simplifyPanel)
예제 #9
0
	def Load(self):
		self.notices = {}
		self.config.SetPath('/Format')
		l = self.config.Read('ChorusLabel')
		if l:
			self.chorusLabel = l
			self.decoratorFormat.SetChorusLabel(l)
		else:
			self.chorusLabel = None
		showChords = int(self.config.Read('ShowChords', "2"))
		self.config.SetPath('/Format/Font')
		face = self.config.Read('Face')
		if face:
			self.fontFace = face
		else:
			self.fontFace = "Arial"
		self.SetFont(self.fontFace, showChords)
		self.config.SetPath('/Format/Style')
		labelVerses = self.config.Read('LabelVerses')
		if labelVerses:
			self.labelVerses = bool(int(labelVerses))
		else:
			self.labelVerses = True
		self.config.SetPath('/Editor')
		self.editorFace = self.config.Read('Face')
		self.editorSize = self.config.Read('Size')
		if not self.editorFace:
			self.editorFace = "Lucida Console"
			self.editorSize = 12
		else:
			self.editorSize = int(self.editorSize)
		n = self.config.Read('DefaultNotation')
		if n:
			self.defaultNotation = n
			self.notations = [x for x in self.notations if x.id == n] + [x for x in self.notations if x.id != n]
		else:
			lang = i18n.getLang()
			if lang in defaultLangNotation:
				n = defaultLangNotation[lang].id
				self.notations = [x for x in self.notations if x.id == n] + [x for x in self.notations if x.id != n]
				self.defaultNotation = None
		self.config.SetPath('/AutoAdjust')
		spuriousLines = self.config.Read('spuriousLines')
		if spuriousLines:
			self.autoAdjustSpuriousLines = bool(int(spuriousLines))
		else:
			self.autoAdjustSpuriousLines = True
		tab2chordpro = self.config.Read('tab2chordpro')
		if tab2chordpro:
			self.autoAdjustTab2Chordpro = bool(int(tab2chordpro))
		else:
			self.autoAdjustTab2Chordpro = True
		easyKey = self.config.Read('easyKey')
		if easyKey:
			self.autoAdjustEasyKey = bool(int(easyKey))
		else:
			self.autoAdjustEasyKey = False
			self.notices['firstTimeEasyKey'] = True
		self.config.SetPath('/AutoAdjust/EasyChordsGroups')
		for k in easyChordsOrder:
			l = self.config.Read(k)
			if l:
				l = int(l)
			else:
				l = easyChords[k][2]
			self.SetEasyChordsGroup(k, l)
		self.config.SetPath('/App')
		ext = self.config.Read('defaultExtension')
		if not ext:
			self.defaultExtension = 'crd'
		else:
			self.defaultExtension = ext
		lang = self.config.Read('locale')
		if not lang:
			self.locale = None
		else:
			self.locale = lang
		self.config.SetPath('/AutoUpdate')
		f = self.config.Read('frequency')
		if not f:
			self.updateFrequency = 7
		else:
			self.updateFrequency = int(f)
		i = self.config.Read('ignored')
		if not i:
			self.ignoredUpdates = set()
		else:
			self.ignoredUpdates = set(i.split(','))
		u = self.config.Read('url')
		if not u:
			self.updateUrl = 'http://songpress.skeed.it/xmlrpc'
		else:
			self.updateUrl = u
		d = self.config.Read('lastCheck')
		if not d:
			self.updateLastCheck = None
		else:
			self.updateLastCheck = datetime.datetime.fromordinal(int(d))
예제 #10
0
	def OnGuide(self, evt):
		if platform.system() == 'Windows':
			helpfile = os.path.join("help", "songpress-%s.chm" % (i18n.getLang(), ))
			subprocess.Popen("hh " + glb.AddPath(helpfile))
		else:
			wx.LaunchDefaultBrowser(_("http://www.skeed.it/songpress-manual"))
예제 #11
0
	def __init__(self, parent, preferences, easyChords):
		self.pref = preferences
		self.frame = self
		PreferencesDialog.__init__(self, parent)

		self.easyChords = easyChords

		self.fontCB.Bind(wx.EVT_TEXT_ENTER, self.OnFontSelected, self.fontCB)
		self.fontCB.Bind(wx.EVT_COMBOBOX, self.OnFontSelected, self.fontCB)

		previewSong = _("{t:My Bonnie}\n\nMy [D]Bonnie lies [G]over the [D]ocean\noh [G]bring back my [A]Bonnie to [D]me!\n\n{soc}\n[D]Bring back, [E-]bring back,\n[A]bring back my Bonnie to [D]me!\n{eoc}")
		self.editor.SetText(previewSong)
		self.editor.SetFont(self.pref.editorFace, self.pref.editorSize)
		self.editor.SetReadOnly(True)
		self.autoRemoveBlankLines.SetValue(self.pref.autoAdjustSpuriousLines)
		self.autoTab2Chordpro.SetValue(self.pref.autoAdjustTab2Chordpro)
		self.autoAdjustEasyKey.SetValue(self.pref.autoAdjustEasyKey)
		if self.pref.locale is None:
			lang = i18n.getLang()
		else:
			lang = self.pref.locale
		for l in glb.languages:
			i = self.langCh.Append(glb.languages[l])
			self.langCh.SetClientData(i, l)
			if lang == l:
				self.langCh.SetSelection(i)
		exts = ["crd", "pro", "chopro", "chordpro", "cho"]
		i = 0
		for e in exts:
			self.extension.Append(e)
			if e == self.pref.defaultExtension:
				self.extension.SetSelection(i)
			i += 1
				
		# Default notation
		for n in self.pref.notations:
			i = self.notationCh.Append(n.desc)
			self.notationCh.SetClientData(i, n.id)
		self.notationCh.SetSelection(0)		

		# Update frequency
		sel = 0
		uf = get_update_frequencies()
		for k in uf:
			i = self.frequency.Append(uf[k])
			self.frequency.SetClientData(i, k)
			if k == self.pref.updateFrequency:
				sel = i
		self.frequency.SetSelection(sel)

		# Easy chords
		simplifyGrid = wx.FlexGridSizer(len(easyChords), 2, 0, 0)
		simplifyGrid.AddGrowableCol(1, 1)
		self.simplifyPanel.SetSizer(simplifyGrid)
		self.simplifyPanel.Layout()

		self.decoSliders = {}
		for k in easyChordsOrder:
			simplifyGrid.Add(wx.StaticText(self.simplifyPanel, wx.ID_ANY, getEasyChordsDescription(easyChords[k]), wx.DefaultPosition, wx.DefaultSize, 0), 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 5)
			ds = MyDecoSlider(self.simplifyPanel)
			self.decoSliders[k] = ds
			ds.slider.SetValue(self.pref.GetEasyChordsGroup(k))
			simplifyGrid.Add(ds, 1, wx.EXPAND, 5)

		simplifyGrid.FitInside(self.simplifyPanel)
	def __init__(self, parent, id, title):
		wx.Dialog.__init__(self, parent, id, title, size=wx.Size(540, 320))
		
		self.config = wx.Config.Get()
		self.config.SetPath('/Editor')
		font = self.config.Read('Face')
		size = self.config.Read('Size')

		# Font face and size
		hSizer1 = wx.BoxSizer(wx.HORIZONTAL)
		
		m_staticText1 = wx.StaticText(self, wx.ID_ANY, _("Editor font"))
		m_staticText1.Wrap(-1);
		hSizer1.Add(m_staticText1, 0, wx.ALL, 5)
		
		self.fontCB = FontComboBox(self, wx.ID_ANY, font)
		self.Bind(wx.EVT_COMBOBOX, self.OnFontSelected, self.fontCB)
		self.fontCB.Bind(wx.EVT_KILL_FOCUS, self.OnFontSelected, self.fontCB)
		self.fontCB.Bind(wx.EVT_TEXT_ENTER, self.OnFontSelected, self.fontCB)
		hSizer1.Add(self.fontCB, 5, wx.EXPAND | wx.ALL, 5)
		
		m_staticText3 = wx.StaticText(self, wx.ID_ANY, _("Size"))
		m_staticText3.Wrap(-1);
		hSizer1.Add(m_staticText3, 0, wx.ALL, 5)
		
		self.sizeCB = wx.ComboBox(self, wx.ID_ANY, size)
		self.sizeCB.AppendItems([str(x) for x in [7,8,9,10,11,12,13,14,16,18,20]])
		self.Bind(wx.EVT_COMBOBOX, self.OnFontSelected, self.sizeCB)
		self.sizeCB.Bind(wx.EVT_KILL_FOCUS, self.OnFontSelected, self.sizeCB)
		self.sizeCB.Bind(wx.EVT_TEXT_ENTER, self.OnFontSelected, self.sizeCB)
		hSizer1.Add(self.sizeCB, 1, wx.EXPAND | wx.ALL, 5)

		# Preview
		hSizer2 = wx.BoxSizer(wx.HORIZONTAL)
		
		m_staticText2 = wx.StaticText(self, wx.ID_ANY, _("Preview"))
		m_staticText2.Wrap(-1)
		hSizer2.Add(m_staticText2, 0, wx.ALL, 5)
		
		self.frame = self
		self.editor = Editor.Editor(self, False)
		self.editor.SetText(previewSong)
		self.editor.SetFont(font, int(size))
		self.editor.SetReadOnly(True)
		
		hSizer2.Add(self.editor, 1, wx.EXPAND | wx.ALL, 5)

		# Language
		hSizer3 = wx.BoxSizer(wx.HORIZONTAL)
		m_staticText1 = wx.StaticText(self, wx.ID_ANY, _("Language"))
		m_staticText1.Wrap(-1);
		hSizer3.Add(m_staticText1, 0, wx.ALL, 5)
		
		self.config.SetPath('/App')
		lang = self.config.Read('locale')
		if not lang:
			lang = i18n.getLang()
		self.langCh = wx.Choice(self, wx.ID_ANY)
		for l in glb.languages:
			i = self.langCh.Append(glb.languages[l])
			self.langCh.SetClientData(i, l)
			if lang == l:
				self.langCh.SetSelection(i)
		hSizer3.Add(self.langCh, 1, wx.EXPAND | wx.ALL, 5)
		
		# Buttons
		hSizerZ = wx.BoxSizer(wx.HORIZONTAL)
		hSizerZ.AddStretchSpacer(1)
		
		self.ok = wx.Button(self, wx.ID_OK, _("OK"))
		hSizerZ.Add(self.ok, 0, wx.ALL, 5 )
		
		self.cancel = wx.Button(self, wx.ID_CANCEL, _("Cancel"))
		hSizerZ.Add(self.cancel, 0, wx.ALL, 5)

		# Pack horizontal sizers vertically
		bSizer1 = wx.BoxSizer(wx.VERTICAL)		
		bSizer1.AddSizer(hSizer1, 0, wx.EXPAND, 5)
		bSizer1.AddSizer(hSizer2, 1, wx.EXPAND, 5)
		bSizer1.AddSizer(hSizer3, 0, wx.EXPAND, 5)
		bSizer1.Add(hSizerZ, 0, wx.EXPAND, 5)
		
		self.SetSizer(bSizer1)
		self.Layout()