示例#1
0
 def activatefilelist(self):
     # before recentering we remove the focus from the playlist in order
     # to prevent wrong songchanged events being issued (which would lead to
     # wrong songs being played on the secondary player)
     self.bottom()
     self.playlist._recenter()
     hub.notify(events.activatefilelist())
示例#2
0
 def activatefilelist(self):
     # before recentering we remove the focus from the playlist in order
     # to prevent wrong songchanged events being issued (which would lead to
     # wrong songs being played on the secondary player)
     self.bottom()
     self.playlist._recenter()
     hub.notify(events.activatefilelist())
示例#3
0
 def searchhandler(self, searchstring, key):
     if key == curses.KEY_BACKSPACE:
         if self.searchpositions:
             self.items.selectbynr(self.searchpositions.pop())
     elif key in self.keybindings["repeatsearch"]:
         self.items.selectbyregexp(searchstring, includeselected=False)
     elif key == ord("\n"):
         self.searchpositions = []
         self.searchstring = searchstring
         hub.notify(events.activatefilelist())
     elif key == 1023:
         if self.searchpositions:
             self.items.selectbynr(self.searchpositions.pop())
         self.searchpositions = []
         self.searchstring = searchstring
         hub.notify(events.activatefilelist())
     else:
         self.searchpositions.append(self.items.selected)
         self.items.selectbyregexp(searchstring)
         # We explicitely issue a selectionchanged event because the
         # selectbyregexp doesn't do this due to the focus being on the
         # searchstring input window
     hub.notify(events.selectionchanged(self.items.getselected()))
     self.update()
示例#4
0
 def searchhandler(self, searchstring, key):
     if key == curses.KEY_BACKSPACE:
         if self.searchpositions:
             self.items.selectbynr(self.searchpositions.pop())
     elif key in self.keybindings["repeatsearch"]:
         self.items.selectbyregexp(searchstring, includeselected=False)
     elif key == ord("\n"):
         self.searchpositions = []
         self.searchstring = searchstring
         hub.notify(events.activatefilelist())
     elif key == 1023:
         if self.searchpositions:
             self.items.selectbynr(self.searchpositions.pop())
         self.searchpositions = []
         self.searchstring = searchstring
         hub.notify(events.activatefilelist())
     else:
         self.searchpositions.append(self.items.selected)
         self.items.selectbyregexp(searchstring)
         # We explicitely issue a selectionchanged event because the
         # selectbyregexp doesn't do this due to the focus being on the
         # searchstring input window
     hub.notify(events.selectionchanged(self.items.getselected()))
     self.update()
示例#5
0
 def keypressed(self, event):
     key = event.key
     if key in self.keybindings["refresh"]:
         self.refresh()
     elif key in self.keybindings["playlistdeleteplayedsongs"]:
         hub.notify(events.playlistdeleteplayedsongs())
     elif key in self.keybindings["playlistclear"]:
         hub.notify(events.playlistclear())
         hub.notify(events.activatefilelist())
     elif key in self.keybindings["playlistreplay"]:
         hub.notify(events.playlistreplay())
     elif key in self.keybindings["playlistsave"]:
         hub.notify(events.playlistsave())
     elif key in self.keybindings["playlistload"]:
         hub.notify(events.playlistload())
     elif key in self.keybindings["playlisttoggleautoplaymode"]:
         hub.notify(events.playlisttoggleautoplaymode())
     elif key in self.keybindings["showhelp"]:
         if self.filelistwin.hasfocus():
             context = "filelistwindow"
         elif self.playlistwin.hasfocus():
             context = "playlistwindow"
         else:
             context = None
         self.helpwin.showhelp(context)
     elif key in self.keybindings["showlog"]:
         self.logwin.show()
     elif key in self.keybindings["showstats"]:
         self.statswin.show()
     elif key in self.keybindings["showiteminfolong"]:
         self.iteminfowinlong.show()
     elif key in self.keybindings["showlyrics"]:
         self.lyricswin.show()
     elif key in self.keybindings["togglelayout"]:
         self.layout = self.layout == "onecolumn" and "twocolumn" or "onecolumn"
         self.resizeterminal()
     else:
         log.debug("unknown key: %d" % key)
示例#6
0
            del config.keybindings.general.volumeup
            del config.keybindings.general.volumedown

        # now we start the plugins
        for pluginmodule, pluginconfig in plugins:
            plugin_class = pluginmodule.plugin
            if plugin_class:
                plugin = plugin_class(self.channel, pluginconfig, self)
                plugin.start()

        self.channel.subscribe(events.keypressed, self.keypressed)
        self.channel.subscribe(events.activateplaylist, self.activateplaylist)
        self.channel.subscribe(events.activatefilelist, self.activatefilelist)
        self.channel.subscribe(events.quit, self.quit)

        hub.notify(events.activatefilelist())

    def run(self):
        """ main loop of control thread """
        skipcount = 0
        while not self.done:
            try:
                key = self.screen.getch()

                if key==27:
                    # handle escape sequence (e.g. alt+key)
                    key = self.screen.getch()+1024

                if key==curses.KEY_MOUSE:
                    mouse = curses.getmouse()
                    x, y = mouse[1:3]
示例#7
0
    def __init__(self, screen, songdbids, playerids, plugins):
        self.screen = screen
        self.layout = config.general.layout
        self.h, self.w = self.getmaxyx()
        log.debug("h=%d, w=%d" % (self.h, self.w))
        self.channel = hub.newchannel()
        self.keybindings = config.keybindings.general
        self.done = False

        self.statusbar = statusbar.statusbar(screen, self.h-1, self.w, self.channel)

        # first we setup the input window in order to have it as first window
        # in the keypressed events lists.
        if config.inputwindow.type=="popup":
            self.inputwin = inputwin.popupinputwin(screen, self.h, self.w, self.channel)
        else:
            self.inputwin = inputwin.statusbarinputwin(screen, self.h, self.w, self.channel)

        # setup the four main windows
        windowslayout = self.calclayout()
        self.playerwin = playerwin.playerwin(screen, windowslayout["playerwin"], self.channel, playerids[0])
        self.iteminfowin = iteminfowin.iteminfowin(screen, windowslayout["iteminfowin"], self.channel, playerids, playerids[1])
        self.filelistwin = filelistwin.filelistwin(screen, windowslayout["filelistwin"], self.channel, songdbids)
        self.playlistwin = playlistwin.playlistwin(screen, windowslayout["playlistwin"], self.channel, "main")
        self.connectborders()

        # setup additional windows which appear on demand
        self.helpwin = helpwin.helpwin(screen, self.h, self.w, self.channel)

        self.logwin = logwin.logwin(screen, self.h, self.w, self.channel)
        self.statswin = statswin.statswin(screen, self.h, self.w, self.channel, len(songdbids))

        self.iteminfowinlong = iteminfowin.iteminfowinlong(screen, self.h, self.w, self.channel)
        self.lyricswin = lyricswin.lyricswin(screen, self.h, self.w, self.channel)

        self.mixerwin = None
        if config.mixer.device:
            try:
                if config.mixerwindow.type=="popup":
                    self.mixerwin = mixerwin.popupmixerwin(screen, self.h, self.w, self.channel)
                else:
                    self.mixerwin = mixerwin.statusbarmixerwin(screen, self.h, self.w, self.channel)

            except IOError as e:
                log.warning('error "%s" during mixer init - disabling mixer' % e)
        else:
            # disbable keybindings to obtain correct help window contents
            del config.keybindings.general.volumeup
            del config.keybindings.general.volumedown

        # now we start the plugins
        for pluginmodule, pluginconfig in plugins:
            plugin_class = pluginmodule.plugin
            if plugin_class:
                plugin = plugin_class(self.channel, pluginconfig, self)
                plugin.start()

        self.channel.subscribe(events.keypressed, self.keypressed)
        self.channel.subscribe(events.activateplaylist, self.activateplaylist)
        self.channel.subscribe(events.activatefilelist, self.activatefilelist)
        self.channel.subscribe(events.quit, self.quit)

        hub.notify(events.activatefilelist())