示例#1
0
    def InitUI(self):
        self.ConCtrlInteractor = ConCtrlInteractor()
        self.ConCtrlInteractor.install(self.ModelFrmSettings,
                                       self.ModelConPool)
        self.FrmNowPlayingInteractor = FrmNowPlayingInteractor()
        self.FrmNowPlayingInteractor.install(self.ModelConPool,
                                             self.ModelFrmNowPlaying)
        #Now Load Config

        self.configPresentor = ConfigPresentor(self.ModelFrmSettings)
        self.configPresentor.load()

        self.ConCtrlInteractor.OnApply(None)

        # Now set model interactions
        self.Con2SettingsInteractor = Connection2SettingsInteractor()
        self.Con2SettingsInteractor.install(self.ModelConPool,
                                            self.ModelFrmSettings)

        #self.tb = TaskBarPresntor(self.ModelGuiThread)
        self.cfg = wx.FileConfig(appName="ApplicationName",
                                 vendorName="VendorName",
                                 localFilename=".squeezetray.cfg",
                                 style=wx.CONFIG_USE_LOCAL_FILE)
        # Now we can set up forms using the art provider
        self.tb = TaskBarIcon(self.ModelGuiThread)
        self.tb.Bind(wx.EVT_CLOSE, self.Exit)

        TIMER_ID = wx.NewId()  # pick a number

        self.CUSTOM_ID = wx.NewId()

        self.timer = wx.Timer(self,
                              TIMER_ID)  # message will be sent to the panel

        self.timer.Start(1000)  # x100 milliseconds
        wx.EVT_TIMER(self, TIMER_ID,
                     self.OnTimer)  # call the on_timer function
        self.taskbarInteractor = TaskBarIconInteractor()
        self.tbPresentor = TaskBarIconPresentor(self.ModelGuiThread, self.tb,
                                                self.taskbarInteractor)

        self.tbPresentor.cbAddReqMdlUpdate(self.setUpdateModel)
        self.tbPresentor.cbAddRequestPopUpMenu(self.CreatePopUp)
        self.tbPresentor.callbacks['on_left_up'][self.leftClick] = 1

        self.interactorWxUpdate = interactorWxUpdate()
        self.interactorWxUpdate.install(self.ModelConPool, self)

        self.count = 0
        self.viewWxToolBarSrc = viewWxToolBarSrc()
        self.viewWxToolBarSrc.install(self.ModelConPool)

        # Now we set up the jrpc server
        self.connectionPool = sConTPool(self.ModelConPool)
        self.jrpc = squeezeConPresentor(self.ModelConPool, self.connectionPool)
        self.connectionPool.cbAddOnMessagesToProcess(self.OnNewMessages)

        #Now we set up the Tray Pup Up menu
        self.tbPopUpMenuInteractor = GuiInteractor()
        self.tbPopUpMenuPresentor = TrayMenuPresentor(
            self.ModelConPool, self.tbPopUpMenuInteractor)
        self.tbPopUpMenuInteractor.cbAddOnExit(self.Exit)
        self.tbPopUpMenuInteractor.cbAddOnSettings(self.SettingsOpen)
        self.tbPopUpMenuInteractor.cbAddOnNowPlaying(self.ShowNowPlaying)

        self.tbPopUpMenuInteractor.cbAddOnPause(self.jrpc.Pause)
        self.tbPopUpMenuInteractor.cbAddOnSeekIndex(self.jrpc.Index)

        self.tbPopUpMenuInteractor.cbAddOnRandomSongs(self.jrpc.PlayRandomSong)
        self.tbPopUpMenuInteractor.cbAddOnPlay(self.jrpc.Play)
        self.tbPopUpMenuInteractor.cbAddOnStop(self.jrpc.Stop)

        #Now load the settings presentor

        self.SettingsPresentor = frmSettingsPresentor(self.ModelFrmSettings)
        self.SettingsPresentor.cbAddOnApply(self.ConCtrlInteractor.OnApply)
        self.SettingsPresentor.cbAddOnSave(self.OnSave)

        self.presentorNowPlaying = frmPlayingPresentor(
            self.ModelFrmNowPlaying, self.tbPopUpMenuInteractor)

        # Now apply the Settings
        #self.ConCtrlInteractor.OnApply(None)
        #print self.ModelFrmSettings.host.get()
        self.messagesUnblock()
        self.jrpc.requestUpdateModel()

        self.ShowNowPlaying()
示例#2
0
 def InitUI(self):
     self.ConCtrlInteractor = ConCtrlInteractor()
     self.ConCtrlInteractor.install(self.ModelFrmSettings, self.ModelConPool)
     self.FrmNowPlayingInteractor = FrmNowPlayingInteractor()
     self.FrmNowPlayingInteractor.install(self.ModelConPool, self.ModelFrmNowPlaying)
     #Now Load Config
     self.configPresentor = ConfigPresentor(self.ModelFrmSettings)
     self.configPresentor.load()
     self.ConCtrlInteractor.OnApply(None)
     # Now set model interactions
     self.Con2SettingsInteractor = Connection2SettingsInteractor()
     self.Con2SettingsInteractor.install(self.ModelConPool, self.ModelFrmSettings)
     #self.tb = TaskBarPresntor(self.ModelGuiThread)
     self.cfg = wx.FileConfig(appName="ApplicationName",
                              vendorName="VendorName",
                              localFilename=".squeezetray.cfg",
                              style=wx.CONFIG_USE_LOCAL_FILE)
     # Now we can set up forms using the art provider
     self.tb = TaskBarIcon(self.ModelGuiThread)
     self.tb.Bind(wx.EVT_CLOSE, self.Exit)
     TIMER_ID = wx.NewId()  # pick a number
     self.CUSTOM_ID = wx.NewId()
     self.timer = wx.Timer(self, TIMER_ID)  # message will be sent to the panel
     self.timer.Start(1000)  # x100 milliseconds
     wx.EVT_TIMER(self, TIMER_ID, self.OnTimer)  # call the on_timer function
     self.taskbarInteractor = TaskBarIconInteractor()
     self.tbPresentor =  TaskBarIconPresentor(self.ModelGuiThread, self.tb, self.taskbarInteractor)
     self.tbPresentor.cbAddReqMdlUpdate(self.setUpdateModel)
     self.tbPresentor.cbAddRequestPopUpMenu(self.CreatePopUp)
     self.tbPresentor.callbacks['on_left_up'][self.leftClick] = 1
     self.interactorWxUpdate = interactorWxUpdate()
     self.interactorWxUpdate.install(self.ModelConPool, self)
     self.count = 0
     self.viewWxToolBarSrc = viewWxToolBarSrc()
     self.viewWxToolBarSrc.install(self.ModelConPool)
     # Now we set up the jrpc server
     self.connectionPool = sConTPool(self.ModelConPool)
     self.jrpc = squeezeConPresentor(self.ModelConPool, self.connectionPool)
     self.connectionPool.cbAddOnMessagesToProcess(self.OnNewMessages)
     #Now we set up the Tray Pup Up menu
     self.tbPopUpMenuInteractor = GuiInteractor()
     self.tbPopUpMenuPresentor = TrayMenuPresentor(self.ModelConPool, self.tbPopUpMenuInteractor)
     self.tbPopUpMenuInteractor.cbAddOnExit(self.Exit)
     self.tbPopUpMenuInteractor.cbAddOnSettings(self.SettingsOpen)
     self.tbPopUpMenuInteractor.cbAddOnNowPlaying(self.ShowNowPlaying)
     self.tbPopUpMenuInteractor.cbAddOnPause(self.jrpc.Pause)
     self.tbPopUpMenuInteractor.cbAddOnSeekIndex(self.jrpc.Index)
     self.tbPopUpMenuInteractor.cbAddOnRandomSongs(self.jrpc.PlayRandomSong)
     self.tbPopUpMenuInteractor.cbAddOnPlay(self.jrpc.Play)
     self.tbPopUpMenuInteractor.cbAddOnStop(self.jrpc.Stop)
     #Now load the settings presentor
     self.SettingsPresentor  = frmSettingsPresentor(self.ModelFrmSettings)
     self.SettingsPresentor.cbAddOnApply(self.ConCtrlInteractor.OnApply)
     self.SettingsPresentor.cbAddOnSave(self.OnSave)
     self.presentorNowPlaying = frmPlayingPresentor(self.ModelFrmNowPlaying, self.tbPopUpMenuInteractor)
     # Now apply the Settings
     #self.ConCtrlInteractor.OnApply(None)
     #print self.ModelFrmSettings.host.get()
     self.messagesUnblock()
     self.jrpc.requestUpdateModel()
     self.ShowNowPlaying()
示例#3
0
class mainApp(wx.App):
    def __init__(self):
        super(mainApp, self).__init__()
        self.log = logging.getLogger("mainApp")
        # Used to decide the connection string
        self.ModelConPool = squeezeConMdle()
        self.ModelGuiThread = taskBarMdle()
        self.ModelFrmSettings = mdlFrmSettings()
        self.ModelFrmNowPlaying = mdlFrmNowPlaying()

    def InitUI(self):
        self.ConCtrlInteractor = ConCtrlInteractor()
        self.ConCtrlInteractor.install(self.ModelFrmSettings,
                                       self.ModelConPool)
        self.FrmNowPlayingInteractor = FrmNowPlayingInteractor()
        self.FrmNowPlayingInteractor.install(self.ModelConPool,
                                             self.ModelFrmNowPlaying)
        #Now Load Config

        self.configPresentor = ConfigPresentor(self.ModelFrmSettings)
        self.configPresentor.load()

        self.ConCtrlInteractor.OnApply(None)

        # Now set model interactions
        self.Con2SettingsInteractor = Connection2SettingsInteractor()
        self.Con2SettingsInteractor.install(self.ModelConPool,
                                            self.ModelFrmSettings)

        #self.tb = TaskBarPresntor(self.ModelGuiThread)
        self.cfg = wx.FileConfig(appName="ApplicationName",
                                 vendorName="VendorName",
                                 localFilename=".squeezetray.cfg",
                                 style=wx.CONFIG_USE_LOCAL_FILE)
        # Now we can set up forms using the art provider
        self.tb = TaskBarIcon(self.ModelGuiThread)
        self.tb.Bind(wx.EVT_CLOSE, self.Exit)

        TIMER_ID = wx.NewId()  # pick a number

        self.CUSTOM_ID = wx.NewId()

        self.timer = wx.Timer(self,
                              TIMER_ID)  # message will be sent to the panel

        self.timer.Start(1000)  # x100 milliseconds
        wx.EVT_TIMER(self, TIMER_ID,
                     self.OnTimer)  # call the on_timer function
        self.taskbarInteractor = TaskBarIconInteractor()
        self.tbPresentor = TaskBarIconPresentor(self.ModelGuiThread, self.tb,
                                                self.taskbarInteractor)

        self.tbPresentor.cbAddReqMdlUpdate(self.setUpdateModel)
        self.tbPresentor.cbAddRequestPopUpMenu(self.CreatePopUp)
        self.tbPresentor.callbacks['on_left_up'][self.leftClick] = 1

        self.interactorWxUpdate = interactorWxUpdate()
        self.interactorWxUpdate.install(self.ModelConPool, self)

        self.count = 0
        self.viewWxToolBarSrc = viewWxToolBarSrc()
        self.viewWxToolBarSrc.install(self.ModelConPool)

        # Now we set up the jrpc server
        self.connectionPool = sConTPool(self.ModelConPool)
        self.jrpc = squeezeConPresentor(self.ModelConPool, self.connectionPool)
        self.connectionPool.cbAddOnMessagesToProcess(self.OnNewMessages)

        #Now we set up the Tray Pup Up menu
        self.tbPopUpMenuInteractor = GuiInteractor()
        self.tbPopUpMenuPresentor = TrayMenuPresentor(
            self.ModelConPool, self.tbPopUpMenuInteractor)
        self.tbPopUpMenuInteractor.cbAddOnExit(self.Exit)
        self.tbPopUpMenuInteractor.cbAddOnSettings(self.SettingsOpen)
        self.tbPopUpMenuInteractor.cbAddOnNowPlaying(self.ShowNowPlaying)

        self.tbPopUpMenuInteractor.cbAddOnPause(self.jrpc.Pause)
        self.tbPopUpMenuInteractor.cbAddOnSeekIndex(self.jrpc.Index)

        self.tbPopUpMenuInteractor.cbAddOnRandomSongs(self.jrpc.PlayRandomSong)
        self.tbPopUpMenuInteractor.cbAddOnPlay(self.jrpc.Play)
        self.tbPopUpMenuInteractor.cbAddOnStop(self.jrpc.Stop)

        #Now load the settings presentor

        self.SettingsPresentor = frmSettingsPresentor(self.ModelFrmSettings)
        self.SettingsPresentor.cbAddOnApply(self.ConCtrlInteractor.OnApply)
        self.SettingsPresentor.cbAddOnSave(self.OnSave)

        self.presentorNowPlaying = frmPlayingPresentor(
            self.ModelFrmNowPlaying, self.tbPopUpMenuInteractor)

        # Now apply the Settings
        #self.ConCtrlInteractor.OnApply(None)
        #print self.ModelFrmSettings.host.get()
        self.messagesUnblock()
        self.jrpc.requestUpdateModel()

        self.ShowNowPlaying()

    def OnNewMessages(self, details):
        self.log.debug('OnNewMessages')
        evt = SomeNewEvent(attr1="on_msg")
        #post the event
        wx.PostEvent(self, evt)

    def messagesBlock(self):
        self.block = True

    def messagesUnblock(self):
        self.block = False

    def onTaskBarPopUpMenu(self, evt):
        self.log.debug("onTaskBarPopUpMenu=%s", (None))
        self.CreatePopUp()

    def EventRevived(self, evt):
        self.log.debug("EventRevived=%s", (evt.attr1))
        if self.block:
            return
        if evt.attr1 == "on_msg":
            self.jrpc.requestUpdateModel()

            #print self.ModelConPool.Players
        self.setUpdateModel(evt)

    def OnSave(self, presentor):
        self.ConCtrlInteractor.OnApply(presentor)
        self.configPresentor.save()

    def OnTimer(self, event):
        self.jrpc.requestUpdateModel()
        self.presentorNowPlaying.Update()
        return

    def on_event(self, event):
        self.log.debug("on_event")

    def Exit(self):
        self.presentorNowPlaying.ViewClose()

        self.messagesBlock()
        self.connectionPool.wait_completion()
        self.SettingClose(None)

        self.tb.Destroy()

    def CreatePopUp(self):
        newMenu = self.tbPopUpMenuPresentor.getMenu()
        return newMenu

    def setUpdateModel(self, param):

        toolTip = self.viewWxToolBarSrc.gettoolTip()
        self.tbPresentor._OnToolTipChange(toolTip)
        currentIcon = self.viewWxToolBarSrc.getIconName()
        #self.log.debug("setUpdateModel")
        self.ModelGuiThread.currentIconName.update(currentIcon)
        #self.log.debug("setUpdateModel=%s" % (currentIcon))

    def leftClick(self):
        if self.presentorNowPlaying.settingsOpen == False:
            self.presentorNowPlaying.ViewOpen()
        else:
            self.presentorNowPlaying.ViewClose()

    def ShowNowPlaying(self):
        self.presentorNowPlaying.ViewOpen()

    def SettingsOpen(self):
        self.SettingsPresentor.SettingsOpen()

    def SettingClose(self, evnt):
        self.SettingsPresentor.SettingClose(None)

    def doCbOnPlay(self, player):

        self.jrpc.Play(player)

    def doCbOnPause(self, player):
        results = {}
        for item in self.callbacks["on_pause"]:
            results[item] = item()
        return results

    def doCbOnSeekForward(self, player):
        results = {}
        for item in self.callbacks["on_seek_forward"]:
            results[item] = item()
        return results

    def doCbOnSeekBackwards(self, player):
        results = {}
        for item in self.callbacks["on_seek_backwards"]:
            results[item] = item()
        return results

    def doCbOnRandomSongs(self, player):
        self.jrpc.PlayRandomSong(player)
示例#4
0
class mainApp(wx.App):
    def __init__(self):
        super(mainApp, self).__init__()
        self.log = logging.getLogger("mainApp")
        # Used to decide the connection string
        self.ModelConPool = squeezeConMdle()
        self.ModelGuiThread = taskBarMdle()
        self.ModelFrmSettings = mdlFrmSettings()
        self.ModelFrmNowPlaying = mdlFrmNowPlaying()

    def InitUI(self):
        self.ConCtrlInteractor = ConCtrlInteractor()
        self.ConCtrlInteractor.install(self.ModelFrmSettings, self.ModelConPool)
        self.FrmNowPlayingInteractor = FrmNowPlayingInteractor()
        self.FrmNowPlayingInteractor.install(self.ModelConPool, self.ModelFrmNowPlaying)
        #Now Load Config
        self.configPresentor = ConfigPresentor(self.ModelFrmSettings)
        self.configPresentor.load()
        self.ConCtrlInteractor.OnApply(None)
        # Now set model interactions
        self.Con2SettingsInteractor = Connection2SettingsInteractor()
        self.Con2SettingsInteractor.install(self.ModelConPool, self.ModelFrmSettings)
        #self.tb = TaskBarPresntor(self.ModelGuiThread)
        self.cfg = wx.FileConfig(appName="ApplicationName",
                                 vendorName="VendorName",
                                 localFilename=".squeezetray.cfg",
                                 style=wx.CONFIG_USE_LOCAL_FILE)
        # Now we can set up forms using the art provider
        self.tb = TaskBarIcon(self.ModelGuiThread)
        self.tb.Bind(wx.EVT_CLOSE, self.Exit)
        TIMER_ID = wx.NewId()  # pick a number
        self.CUSTOM_ID = wx.NewId()
        self.timer = wx.Timer(self, TIMER_ID)  # message will be sent to the panel
        self.timer.Start(1000)  # x100 milliseconds
        wx.EVT_TIMER(self, TIMER_ID, self.OnTimer)  # call the on_timer function
        self.taskbarInteractor = TaskBarIconInteractor()
        self.tbPresentor =  TaskBarIconPresentor(self.ModelGuiThread, self.tb, self.taskbarInteractor)
        self.tbPresentor.cbAddReqMdlUpdate(self.setUpdateModel)
        self.tbPresentor.cbAddRequestPopUpMenu(self.CreatePopUp)
        self.tbPresentor.callbacks['on_left_up'][self.leftClick] = 1
        self.interactorWxUpdate = interactorWxUpdate()
        self.interactorWxUpdate.install(self.ModelConPool, self)
        self.count = 0
        self.viewWxToolBarSrc = viewWxToolBarSrc()
        self.viewWxToolBarSrc.install(self.ModelConPool)
        # Now we set up the jrpc server
        self.connectionPool = sConTPool(self.ModelConPool)
        self.jrpc = squeezeConPresentor(self.ModelConPool, self.connectionPool)
        self.connectionPool.cbAddOnMessagesToProcess(self.OnNewMessages)
        #Now we set up the Tray Pup Up menu
        self.tbPopUpMenuInteractor = GuiInteractor()
        self.tbPopUpMenuPresentor = TrayMenuPresentor(self.ModelConPool, self.tbPopUpMenuInteractor)
        self.tbPopUpMenuInteractor.cbAddOnExit(self.Exit)
        self.tbPopUpMenuInteractor.cbAddOnSettings(self.SettingsOpen)
        self.tbPopUpMenuInteractor.cbAddOnNowPlaying(self.ShowNowPlaying)
        self.tbPopUpMenuInteractor.cbAddOnPause(self.jrpc.Pause)
        self.tbPopUpMenuInteractor.cbAddOnSeekIndex(self.jrpc.Index)
        self.tbPopUpMenuInteractor.cbAddOnRandomSongs(self.jrpc.PlayRandomSong)
        self.tbPopUpMenuInteractor.cbAddOnPlay(self.jrpc.Play)
        self.tbPopUpMenuInteractor.cbAddOnStop(self.jrpc.Stop)
        #Now load the settings presentor
        self.SettingsPresentor  = frmSettingsPresentor(self.ModelFrmSettings)
        self.SettingsPresentor.cbAddOnApply(self.ConCtrlInteractor.OnApply)
        self.SettingsPresentor.cbAddOnSave(self.OnSave)
        self.presentorNowPlaying = frmPlayingPresentor(self.ModelFrmNowPlaying, self.tbPopUpMenuInteractor)
        # Now apply the Settings
        #self.ConCtrlInteractor.OnApply(None)
        #print self.ModelFrmSettings.host.get()
        self.messagesUnblock()
        self.jrpc.requestUpdateModel()
        self.ShowNowPlaying()

    def OnNewMessages (self, details):
        self.log.debug('OnNewMessages')
        evt = SomeNewEvent(attr1="on_msg")
        #post the event
        wx.PostEvent(self, evt)

    def messagesBlock(self):
        self.block = True

    def messagesUnblock(self):
        self.block = False

    def onTaskBarPopUpMenu(self, evt):
        self.log.debug("onTaskBarPopUpMenu=%s", (None))
        self.CreatePopUp()

    def EventRevived(self, evt):
        self.log.debug("EventRevived=%s", (evt.attr1 ))
        if self.block:
            return
        if evt.attr1 == "on_msg":
            self.jrpc.requestUpdateModel()
        self.setUpdateModel(evt)

    def OnSave(self, presentor):
        self.ConCtrlInteractor.OnApply(presentor)
        self.configPresentor.save()

    def OnTimer(self, event):
        self.jrpc.requestUpdateModel()
        self.presentorNowPlaying.Update()
        return

    def on_event(self, event):
        self.log.debug("on_event")

    def Exit(self):
        self.presentorNowPlaying.ViewClose()
        self.messagesBlock()
        self.connectionPool.wait_completion()
        self.SettingClose(None)
        self.tb.Destroy()

    def CreatePopUp(self):
        newMenu = self.tbPopUpMenuPresentor.getMenu()
        return newMenu

    def setUpdateModel(self, param):

        toolTip = self.viewWxToolBarSrc.gettoolTip()
        self.tbPresentor._OnToolTipChange(toolTip)
        currentIcon = self.viewWxToolBarSrc.getIconName()
        #self.log.debug("setUpdateModel")
        self.ModelGuiThread.currentIconName.update(currentIcon)
        #self.log.debug("setUpdateModel=%s" % (currentIcon))

    def leftClick(self):
        if self.presentorNowPlaying.settingsOpen == False:
            self.presentorNowPlaying.ViewOpen()
        else:
            self.presentorNowPlaying.ViewClose()

    def ShowNowPlaying(self):
        self.presentorNowPlaying.ViewOpen()

    def SettingsOpen(self):
        self.SettingsPresentor.SettingsOpen()

    def SettingClose(self, evnt):
        self.SettingsPresentor.SettingClose(None)

    def doCbOnPlay(self, player):

        self.jrpc.Play(player)

    def doCbOnPause(self, player):
        results = {}
        for item in self.callbacks["on_pause"]:
            results[item] = item()
        return results

    def doCbOnSeekForward(self, player):
        results = {}
        for item in self.callbacks["on_seek_forward"]:
            results[item] = item()
        return results

    def doCbOnSeekBackwards(self, player):
        results = {}
        for item in self.callbacks["on_seek_backwards"]:
            results[item] = item()
        return results

    def doCbOnRandomSongs(self, player):
        self.jrpc.PlayRandomSong(player)