# Copyright (C) 2007 Jason Smith # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 1, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. import gtk, pygtk, plugins PLUGIN_NAME = "Information Panel" PLUGIN_AUTHORS = ['Jason Smith '] PLUGIN_VERSION = '0.0.1' PLUGIN_DESCRIPTION = r"""Will one day display information about the currently playing song""" PLUGIN_ENABLED = False PLUGIN_ICON = None #setup infobox namespace INFOBOX = None CONNS = plugins.SignalContainer() class infobox: def __init__(self): """ Set up variables and create window """ self.WINDOW = None self.window_visible = 0 self.window_ready = 0 self.create_window() def create_window(self): self.WINDOW = gtk.Window(gtk.WINDOW_TOPLEVEL) self.WINDOW.set_title("Information Panel") self.WINDOW.set_border_width(10) #what to do when window is destroyed self.WINDOW.connect("delete_event", self.destroy_window) self.EXTERNAL_BOX = gtk.VBox(homogeneous=False, spacing=0) self.WINDOW.add(self.EXTERNAL_BOX) #create out simple hello world button self.TITLE_LABEL = gtk.Label("") self.EXTERNAL_BOX.pack_start(self.TITLE_LABEL, True, True, 0) #create a second button self.ALBUM_LABEL = gtk.Label("") self.EXTERNAL_BOX.pack_start(self.ALBUM_LABEL, True, True, 0) #make everything show self.WINDOW.show_all() self.window_visible = 1 self.window_ready = 1 def destroy_window(self, widget=None, event=None, data=None): self.WINDOW.destroy() self.window_visible = 0 def update(self, widget=None, args=None): if not self.window_visible: self.create_windoww() #format the string self.TitleText = APP.player.current.title + " - " + APP.player.current.artist self.TITLE_LABEL.set_text(self.TitleText) self.ALBUM_LABEL.set_text(APP.player.current.album) def initialize(): """ Called when the plugin is enabled """ global INFOBOX #create INFOBOX object from infobox() class INFOBOX = infobox() #setup callback on play track CONNS.connect(APP.player, 'play-track', INFOBOX.update) return True def destroy(): """ Called when the plugin is disabled """ INFOBOX.destroy_window() CONNS.disconnect_all() def configure(): """ Called when the user clicks Configure in the Plugin Manager """ dialog = gtk.MessageDialog(APP.window, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, "Configuring...") dialog.run() dialog.destroy()