frontends: define the constants with classes and inheritance instance of using __builtin__

This commit is contained in:
souliane 2013-11-23 10:21:40 +01:00
commit f5dd3f2265

View file

@ -31,7 +31,7 @@ from sat_frontends.wix.profile_manager import ProfileManager
import os.path
from sat.tools.jid import JID
from logging import debug, info, warning, error
import sat_frontends.wix.constants
from sat_frontends.wix.constants import Const
idCONNECT,\
idDISCONNECT,\
@ -72,7 +72,7 @@ class MainWindow(wx.Frame, QuickApp):
#ToolBar
self.tools=self.CreateToolBar()
self.statusBox = wx.ComboBox(self.tools, -1, "Online", choices=[status[1] for status in const_STATUS],
self.statusBox = wx.ComboBox(self.tools, -1, "Online", choices=[status[1] for status in Const.PRESENCE],
style=wx.CB_DROPDOWN | wx.CB_READONLY)
self.tools.AddControl(self.statusBox)
self.tools.AddSeparator()
@ -122,7 +122,7 @@ class MainWindow(wx.Frame, QuickApp):
connectMenu.Append(idDISCONNECT, _("&Disconnect CTRL-d"),_(" Disconnect from the server"))
connectMenu.Append(idPARAM,_("&Parameters"),_(" Configure the program"))
connectMenu.AppendSeparator()
connectMenu.Append(idABOUT,_("A&bout"),_(" About %s") % APP_NAME)
connectMenu.Append(idABOUT, _("A&bout"), _(" About %s") % Const.APP_NAME)
connectMenu.Append(idEXIT,_("E&xit"),_(" Terminate the program"))
contactMenu = wx.Menu()
contactMenu.Append(idADD_CONTACT, _("&Add contact"),_(" Add a contact to your list"))
@ -212,10 +212,10 @@ class MainWindow(wx.Frame, QuickApp):
def setStatusOnline(self, online=True):
"""enable/disable controls, must be called when local user online status change"""
if online:
self.SetStatusText(msgONLINE)
self.SetStatusText(Const.msgONLINE)
self.tools.Enable()
else:
self.SetStatusText(msgOFFLINE)
self.SetStatusText(Const.msgOFFLINE)
self.tools.Disable()
return
@ -351,7 +351,7 @@ class MainWindow(wx.Frame, QuickApp):
self.bridge.disconnect(self.profile)
def __updateStatus(self):
show = filter(lambda x:x[1] == self.statusBox.GetValue(), const_STATUS)[0][0]
show = filter(lambda x:x[1] == self.statusBox.GetValue(), Const.PRESENCE)[0][0]
status = self.statusTxt.GetValue()
self.bridge.setPresence(show=show, statuses={'default':status}, profile_key=self.profile) #FIXME: manage multilingual statuses
@ -367,15 +367,15 @@ class MainWindow(wx.Frame, QuickApp):
def onAbout(self, e):
about = wx.AboutDialogInfo()
about.SetName(APP_NAME)
about.SetName(Const.APP_NAME)
about.SetVersion (unicode(self.bridge.getVersion()))
about.SetCopyright(u"(C) 2009, 2010, 2011, 2012, 2013 Jérôme Poisson aka Goffi")
about.SetDescription( _(u"%(name)s is a SàT (Salut à Toi) frontend\n"+
u"%(name)s is based on WxPython, and is the standard graphic interface of SàT") % {'name':APP_NAME})
u"%(name)s is based on WxPython, and is the standard graphic interface of SàT") % {'name': Const.APP_NAME})
about.SetWebSite(("http://www.goffi.org", "Goffi's non-hebdo (french)"))
about.SetDevelopers([ "Goffi (Jérôme Poisson)"])
try:
with open(LICENCE_PATH,"r") as licence:
with open(Const.LICENCE_PATH, "r") as licence:
about.SetLicence(''.join(licence.readlines()))
except:
pass