diff --git a/scripts/rainbowizer/icon.jpg b/scripts/rainbowizer/icon.jpg new file mode 100644 index 000000000..2b401afcb Binary files /dev/null and b/scripts/rainbowizer/icon.jpg differ diff --git a/scripts/rainbowizer/rainbow.py b/scripts/rainbowizer/rainbow.py new file mode 100644 index 000000000..b5f8a8651 --- /dev/null +++ b/scripts/rainbowizer/rainbow.py @@ -0,0 +1,47 @@ +from PyQt4.Qt import QAction +from PyQt4.QtCore import QObject +from PyQt4.QtCore import Qt +from PyQt4.QtCore import SIGNAL + +from PyQt4.QtGui import QColor + +import clementine + + +class RainbowizerScript(QObject): + + priority = 1 + colors = [ QColor("#ec1e24"), + QColor("#f45a2c"), + QColor("#fcf204"), + QColor("#3cb64c"), + QColor("#04aeec"), + QColor("#242264"), + QColor("#94268c") ]; + + def __init__(self): + QObject.__init__(self) + + self.action = QAction("rainbowize_playlist", self) + self.action.setText("Rainbowize!") + self.action.setCheckable(True) + self.connect(self.action, SIGNAL("changed()"), self.rainbowize) + + clementine.ui.AddAction('playlist_menu', self.action) + + def rainbowize(self): + for playlist in clementine.playlists.GetAllPlaylists(): + if self.action.isChecked(): + i = 0 + + for item in playlist.GetAllItems(): + i = (i + 1) % len(self.colors) + item.SetBackgroundColor(self.priority, self.colors[i]) + + else: + # undo all rainbow colors + for item in playlist.GetAllItems(): + item.RemoveBackgroundColor(self.priority) + + +script = RainbowizerScript() diff --git a/scripts/rainbowizer/script.ini b/scripts/rainbowizer/script.ini new file mode 100644 index 000000000..c6c2f767b --- /dev/null +++ b/scripts/rainbowizer/script.ini @@ -0,0 +1,9 @@ +[Script] +name=Rainbowizer +description=This is a sample plugin designed to show you how to use the color API of playlist items. It rainbowizes your playlist for better user experience! +author=Pawel Bara +url=http://www.clementine-player.org +icon=icon.jpg + +language=python +script_file=rainbow.py