2011-01-18 23:56:47 +01:00
|
|
|
import clementine
|
|
|
|
|
2011-05-30 16:53:18 +02:00
|
|
|
from PythonQt.QtGui import QAction
|
2011-01-18 23:56:47 +01:00
|
|
|
|
2011-05-30 16:53:18 +02:00
|
|
|
import logging
|
2011-01-18 23:56:47 +01:00
|
|
|
import sys
|
|
|
|
|
2011-05-30 16:53:18 +02:00
|
|
|
LOGGER = logging.getLogger("system-shutdown")
|
|
|
|
|
|
|
|
|
2011-01-18 23:56:47 +01:00
|
|
|
class Plugin:
|
|
|
|
def __init__(self):
|
|
|
|
self.enabled = False
|
2011-05-30 16:53:18 +02:00
|
|
|
clementine.player.connect("PlaylistFinished()", self.PlaylistFinished)
|
2011-01-18 23:56:47 +01:00
|
|
|
self.action = QAction("Shutdown at end", None)
|
|
|
|
self.action.setCheckable(True)
|
2011-05-30 16:53:18 +02:00
|
|
|
self.action.connect("triggered(bool)", self.Enabled)
|
2011-01-18 23:56:47 +01:00
|
|
|
clementine.ui.AddAction("playlist_menu", self.action)
|
|
|
|
|
|
|
|
def PlaylistFinished(self):
|
|
|
|
if self.enabled:
|
2011-05-30 16:53:18 +02:00
|
|
|
LOGGER.info("Reached the end of the playlist - shutting down")
|
2011-01-18 23:56:47 +01:00
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
def Enabled(self, enabled):
|
2011-05-30 16:53:18 +02:00
|
|
|
LOGGER.info("Shutdown at end of playlist enabled: %s" % str(enabled))
|
2011-01-18 23:56:47 +01:00
|
|
|
self.enabled = enabled
|
|
|
|
|
2011-05-30 16:53:18 +02:00
|
|
|
|
2011-01-18 23:56:47 +01:00
|
|
|
plugin = Plugin()
|