示例#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()