Beispiel #1
0
 def cb_bInfos_clicked(self, widget):
     selection = self.__treeview.get_selection()
     model, iter = selection.get_selected()
 
     if iter is not None:
         idstr = model.get(iter, 2)[0]
         plugin = self.get_plugin_by_filename(idstr)
         if plugin is not None:
             icon = os.path.join(functions.install_dir(), "plugins", idstr, "%s.png" % idstr)
             if os.path.exists(icon):
                 pb = gtk.gdk.pixbuf_new_from_file(icon)
             else:
                 pb = gtk.gdk.pixbuf_new_from_file_at_size(os.path.join(functions.install_dir(), "images", "plugin.png"), 92, 92)
             dialog = gtk.AboutDialog()
             dialog.set_name(plugin['name'])
             dialog.set_logo(pb)
             dialog.set_version(plugin['version'])
             if plugin['copyright'] != "": 
                 dialog.set_copyright(plugin['copyright'])
             dialog.set_comments(plugin['description'])
             if plugin['license'] != "": 
                 dialog.set_license(functions.license2text(plugin['license']))
             if plugin['homepage'] != "": 
                 dialog.set_website(plugin['homepage'])
             dialog.set_authors(plugin['author'].split(","))
             dialog.set_logo(None)
             dialog.run()
             dialog.set_modal(True)
             dialog.destroy()
Beispiel #2
0
 def set_image(self, widget, uri):
     w, h = gtk.icon_size_lookup(self.get_icon_size())
     if not os.path.exists(uri):
         if os.path.exists(os.path.join(functions.install_dir(), "images", uri)):
             uri = os.path.join(functions.install_dir(), "images", uri)
     pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(uri, w, h)
     img = gtk.Image()
     img.set_from_pixbuf(pixbuf)
     img.show()
     widget.set_icon_widget(img)
Beispiel #3
0
 def download(self, track):
     uri = track.stream #.replace('mp31', 'mp32')
     if uri in self.retries:
         if self.retries[uri]>9:
             return
         time.sleep(self.retries[uri]**2)
     tmp = os.path.join(functions.install_dir(), "cache")
     if not os.path.isdir(tmp):
         os.mkdir(tmp)
     if not os.path.isdir(os.path.join(tmp, str(track.artist_id))):
         os.mkdir(os.path.join(tmp, str(track.artist_id)))
     tmp = os.path.join(tmp, str(track.artist_id))
     if not os.path.isdir(os.path.join(tmp, str(track.album_id))):
         os.mkdir(os.path.join(tmp, str(track.album_id)))
     tmp = os.path.join(tmp, str(track.album_id))
     target = os.path.join(tmp, str(track.id)) + '.mp3'
     #print "[!] downloading %s to %s" % (uri, target)
     cmd='(wget -c -O %s.part -q "%s" && mv %s.part %s)' % (target, uri, target, target)
     #print "[!] command:", cmd
     os.system(cmd)
     mp3 = magic.open(magic.MAGIC_NONE)
     mp3.load()
     type = mp3.file(target)
     print uri
     print 'file type',type
     if type[:4] == 'MPEG' or type[:5] == 'Audio':
         track.local = target
     else:
         os.unlink(target)
         self.retries[uri]=self.retries.get(uri,0)+1
         print "[!] failed to download %s, putting back in queue (retry:%d)" % (target,self.retries[uri])
         self.queue_push(track)
Beispiel #4
0
    def __init__(self, parent=None):
        ## Pointer to Pyjama
        self.parent = parent
        home = functions.preparedirs()
        install_dir = functions.install_dir()

        ## stores the config file URI
        self.home_config = os.path.join(home, 'pyjama.cfg')

        ## Parser Object Pointer
        self.config = ConfigParser.SafeConfigParser()
        self.config.readfp(open(os.path.join(install_dir, 'pyjama.cfg')))
        self.config.read([self.home_config])

        ## List holding options from pyjama.cfg
        self.options = {}

        sections = self.config.sections()
        for section in sections:
            items = self.config.items(section)
            for item, value in items:
                pos = value.find("#")
                pos = value.find(";")
                if pos > -1:
                    value = value[0:pos]
                if value.isdigit():
                    self.options[item] = int(value)
                elif (self.isbool(value)):
                    self.options[item] = self.parsebool(value)
                else:
                    self.options[item] = value
Beispiel #5
0
 def info(self, title="Information", text=""):
     dialog = MyDialog(title,self.window, \
         gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, \
         (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT), gtk.STOCK_DIALOG_INFO, text)
     dialog.set_icon_from_file(os.path.join(functions.install_dir(), "images", "hspbp-burnstation.png"))
     dialog.run()
     dialog.destroy()
Beispiel #6
0
    def draw_menu_items(self, play=None):
        self.mnuShow = gtk.ImageMenuItem(_("Show Pyjama"))
        w, h = gtk.icon_size_lookup(gtk.ICON_SIZE_MENU)
        image = "hspbp-burnstation.png"
        img = gtk.Image()
        if not os.path.exists(image):
            image = os.path.join(functions.install_dir(), "images", image)
            if not os.path.exists(image):
                print ("Image not found")
            else:
                pix = gtk.gdk.pixbuf_new_from_file_at_size(image, w, h)
                img.set_from_pixbuf(pix)
                self.mnuShow.set_image(img)
        self.mnuShow.connect('activate', self.main.window.show_window)


        self.mnuPlay = gtk.ImageMenuItem(gtk.STOCK_MEDIA_PLAY)
        self.mnuPlay.connect('activate', self.main.window.on_bPlay_clicked)


        self.mnuNext = gtk.ImageMenuItem(gtk.STOCK_MEDIA_NEXT)
        self.mnuNext.connect('activate', self.main.window.on_bNext_clicked)

        self.mnuPrev = gtk.ImageMenuItem(gtk.STOCK_MEDIA_PREVIOUS)
        self.mnuPrev.connect('activate', self.main.window.on_bPrev_clicked)

        self.mnuQuit = gtk.ImageMenuItem(gtk.STOCK_QUIT)
        self.mnuQuit.connect('activate', self.main.window.really_quit)


        self.append(self.mnuShow)
        self.append(self.mnuPlay)
        self.append(self.mnuNext)
        self.append(self.mnuPrev)
        self.append(self.mnuQuit)
Beispiel #7
0
 def download(self, track):
     uri = track.stream #.replace('mp31', 'mp32')
     tmp = os.path.join(functions.install_dir(), "cache")
     if not os.path.isdir(tmp):
         os.mkdir(tmp)
     if not os.path.isdir(os.path.join(tmp, str(track.artist_id))):
         os.mkdir(os.path.join(tmp, str(track.artist_id)))
     tmp = os.path.join(tmp, str(track.artist_id))
     if not os.path.isdir(os.path.join(tmp, str(track.album_id))):
         os.mkdir(os.path.join(tmp, str(track.album_id)))
     tmp = os.path.join(tmp, str(track.album_id))
     target = os.path.join(tmp, str(track.id)) + '.mp3'
     #print "[!] downloading %s to %s" % (uri, target)
     cmd='(wget -c -O %s.part -q "%s" && mv %s.part %s)' % (target, uri, target, target)
     #print "[!] command:", cmd
     os.system(cmd)
     mp3 = magic.open(magic.MAGIC_NONE)
     mp3.load()
     type = mp3.file(target)
     print uri
     print type
     if type[:4] == 'MPEG':
         track.local = target
     else:
         print "[!] failed to download %s, putting back in queue" % (target)
         os.unlink(target)
         self.queue_push(track)
Beispiel #8
0
    def __init__(self, parent, title = "Pyjama", text = "Python Jamendo Audiocenter"):
        self.parent = parent
        self.menu = TrayMenu(parent)
        if NOTIFICATIONS:
            pynotify.init("pynotify")
        self.notify = None
#        self.icon=gtk.status_icon_new_from_icon_name("warning")
        self.icon = gtk.status_icon_new_from_file(os.path.join(functions.install_dir(), "images", "pyjama.png"))
        self.icon.set_visible(False)
#        self.icon.connect('activate', self.parent.switch_window_state)
        self.icon.connect('activate', self.parent.window.show_window)
        self.icon.connect('popup-menu', self.cb_popup_menu, self.menu)
        self.icon.connect('scroll-event', self.cb_scroll)
        self.icon.set_tooltip("%s\n%s" % (title, text))
        self.icon.set_visible(True)
Beispiel #9
0
    def __init_widgets(self):
        # Get the widgets from preferences.glade and
        # do some usefull stuff with them
        xml = gtk.glade.XML(os.path.join(functions.install_dir(), "preferences.glade"))
        self.dialog = xml.get_widget("dialog1")
        pixbuf = gtk.gdk.pixbuf_new_from_file(os.path.join(functions.install_dir(), "images", "pyjama.png"))
        self.dialog.set_icon(pixbuf)
        self.dialog.set_default_size(640, 480)

        self.caption = xml.get_widget("caption")

        self.viewport = xml.get_widget("viewport1")
        sw = xml.get_widget("scrolledwindow1")
        self.treeview = xml.get_widget("treeview1")

        # TREEVIEW
        self.model = gtk.TreeStore(gobject.TYPE_STRING)
        self.treeview.set_model(self.model)
        renderer = gtk.CellRendererText()
        column = gtk.TreeViewColumn("Module", renderer, markup=0)
        self.treeview.append_column(column)

        self.treeview.connect("button-press-event", self.cb_treeview_button_press)
        self.treeview.connect("row-activated", self.cb_treeview_row_activated)
Beispiel #10
0
 def set_item_image(self, menuitem, image, size=gtk.ICON_SIZE_MENU):
     if image in gtk.stock_list_ids():
         # StockIcon
         img = gtk.Image()
         img.set_from_stock(image, gtk.ICON_SIZE_MENU)
         menuitem.set_image(img)
     else:
         # from file
         w, h = gtk.icon_size_lookup(size)
         img = gtk.Image()
         if not os.path.exists(image):
             image = os.path.join(functions.install_dir(), "images", image)
             if not os.path.exists(image):
                 print ("Image not found")
                 return -1
         pix = gtk.gdk.pixbuf_new_from_file_at_size(image, w, h)
         img.set_from_pixbuf(pix)
         menuitem.set_image(img)
Beispiel #11
0
    def create_plugin(self):
        self.plugin_vbox = gtk.VBox()
        self.plugin_vbox.show()
        img = gtk.Image()
        img.set_from_file(os.path.join(functions.install_dir(), "images", "plugin.png"))
        img.show()
        self.plugin_vbox.pack_start(img, False, True, 10)
        l = gtk.Label(_("<-- To configure a plugins, select if from the list on the left side."))
        l.show()
        self.plugin_vbox.pack_start(l, False, True, 10)

        # Plugins Button
        hbox = gtk.HBox()
        #        hbox.show()
        #        l = gtk.Label("(Un)select plugins with\nthe plugin dialog:")
        #        l.show()
        #        hbox.pack_start(l)
        l = clWidgets.MyLinkButton("", "Select and unselect plugins")
        l.set_tooltip_text("Click here to choose which plugin should be loaded")
        l.connect("clicked", self.pyjama.show_plugins)
        l.show()
        #        hbox.pack_start(l)
        self.plugin_vbox.pack_start(l, False, True, 20)

        # Documentation button
        url = "http://xn--ngel-5qa.de/pyjama/html"
        hbox = gtk.HBox()
        hbox.show()
        l = gtk.Label(_("Learn more about\npyjama's plugin interface:"))
        l.show()
        hbox.pack_start(l)
        l = clWidgets.MyLinkButton(url, _("Pyjama's Documentation"))
        l.set_tooltip_text(url)
        l.connect("clicked", self.cb_visit_documentation)
        l.show()
        hbox.pack_start(l)
        self.plugin_vbox.pack_end(hbox, False, True, 20)
        return self.plugin_vbox
Beispiel #12
0
#!/usr/bin/env python

import re, sys
import os, os.path
import mp3info, ogg.vorbis, functions
from string import replace
from popen2 import popen3
from time import sleep
if (sys.platform != "win32"):
    from popen2 import Popen3


logPath=os.path.join(functions.install_dir(), "log")
spoolPath=os.path.join(functions.install_dir(), "spool")
tmpPath=os.path.join(functions.install_dir(), "tmp/")
logfile = 'decoder.log'
RE=re.compile('cdrskin: Media : (.*)')

class Logger:
    def debug(self,msg):
        print 'debug-',msg
    def error(self,msg):
        print 'error-',msg
    def info(self,msg):
        print 'info-',msg
    def warn(self,msg):
        print 'warn-',msg
logger=Logger()

def cmdexec(cmd):
    """ Executes a command in a subshell and returns (return_value, (stdout, stderr)). """
Beispiel #13
0
 def get_local_name(self, track):
     tmp = os.path.join(functions.install_dir(), "cache")
     tmp = os.path.join(tmp, str(track.artist_id))
     tmp = os.path.join(tmp, str(track.album_id))
     return os.path.join(tmp, str(track.id)) + '.mp3'
Beispiel #14
0
    def __init__(self, parent, options):
        ## Holds a bool indicating if pyjama is running verbose
        self.verbose = options.verbose
        ## Holds a bool indicating if pyjama is running in debugging mode
        self.debug = options.debug
        ## Holds a bool indicating if pyjama is running in debugging extreme mode
        self.debug_extreme = options.debug_extreme
#        self.print_tracebacks = options.print_tracebacks
        
        ## Hold pyjama's current version
        self.version = functions.VERSION
        if GNOME_UI_AVAILABLE:
            gnome.init("Pyjama", self.version)
        print "PYJAMA FOUND IN %s" % functions.install_dir()


        ## In some cases to many windows pop up on pyjama's
        # startup. If you want to popup a message on startup
        # please wait until need_attention is False!
        self.need_attention = False

        ## Pyjama's Event class
        self.Events = clEvent.Events()
        # Create some events:
        self.Events.add_event("pluginloaded")
        self.Events.add_event("nowplaying")
        self.Events.add_event("alldone")
        self.Events.add_event("showing_album_page")
        self.Events.add_event("showing_artist_page")
        self.Events.add_event("firstrun")
        self.Events.add_event("error")
        self.Events.add_event("info")
        self.Events.add_event("info")
        self.Events.add_event("layout_changed")
        self.Events.add_event("populate_listmenu")
        self.Events.add_event("populate_playlistmenu")
        self.Events.add_event("scrolled_window_resized")
        self.Events.add_event("playlist_tooltip")
        self.Events.add_event("quit")
        self.Events.add_event("albuminfo_created")
        self.Events.add_event("hide_controls")
        self.Events.add_event("show_controls")


        ## Connect to some events
        self.Events.connect_event("pluginloaded", self.ev_plugin_loaded)
        self.Events.connect_event("error", self.error)
        self.Events.connect_event("info", self.info)
        
        self.home_fkt = self.go_home_fkt

        ## Pyjama's Settings class
        # Use for simple general settings
        # data will be stored in a pyjama.cfg
        self.settings = clSettings.settings(self)

        ## Pyjama's database setting class
        # Use this, if you need to store many
        # values.
        self.settingsdb = dbthreaded.DB_Settings(self)
#        self.settingsdb = clDB.DB_Settings(self)
        ## Database class  clDB.DB
        self.db = dbthreaded.DB(self)
#        self.db = clDB.DB(self)

        ## Some database-dump tools
        self.dump_tools = download_db.dump_tools(self)
        ## The clWindow.gtkWIN reference 
        self.window = parent
        ## The notification TrayIcon class notification.TrayIcon
        self.icon = notification.TrayIcon(self)
        ## The Audio class clGstreamer010.Player
        self.player = PLAYER.Player(self, sink=self.__get_audio_interface())
        ## Pyjama's class for jamendo's get2 api clJamendo.Jamendo
        self.jamendo = clJamendo.Jamendo(self)
        ## The browser class clBrowserInterfacce.Browser for handling
        # different browser calls
        self.browser = clBrowserInterface.Browser(self)
        ## Pyjama's clLayouts.Layouts is referenced here
        # it is most important for anything to show up in the
        # main paned field
        self.layouts = clLayouts.Layouts(self)
        ## Preferences
        self.preferences = clPreferences.Preferences(self)

        if XMLRPC_AVAILABLE:
            self.xmlrpc = clXMLRPC.XMLRPC(self)
        
            for item in sys.argv:
                if item.endswith(".m3u"):
                    if self.xmlrpc.role == "client":
                        try:
                            self.xmlrpc.server.test("test123")
                        except Exception, inst:
                            print ("Could not connect to server: %s" % inst)
                            break
Beispiel #15
0
    def __init__(self, window):
        ## Reference to pyjama
        self.pyjama = window.main

        gtk.Toolbar.__init__(self)
        show_toolbar_text = self.pyjama.settings.get_value("PYJAMA", "SHOW_TOOLBAR_TEXT", True)
#        if show_toolbar_text == None:
#            self.pyjama.settings.set_value("PYJAMA", "SHOW_TOOLBAR_TEXT", True)
        if show_toolbar_text:
            self.set_style(gtk.TOOLBAR_BOTH)
        else:
            self.set_style(gtk.TOOLBAR_ICONS)
        self.set_icon_size(gtk.ICON_SIZE_LARGE_TOOLBAR)# (gtk.ICON_SIZE_DIALOG) # large_toolbar
        self.set_show_arrow(True)
#        self.set_border_width(5)


        #
        # ToolButtons
        #
        ## Back Button
        self.bHistoryBack = gtk.ToolButton(_("Back"))
        self.bHistoryBack.set_stock_id(gtk.STOCK_GO_BACK)
        self.bHistoryBack.set_sensitive(False)
        self.bHistoryBack.set_label(_("Back"))
        self.bHistoryBack.set_tooltip_text(_("Show previous page in history"))
        self.bHistoryBack.connect("clicked", self.on_bHistoryBack_clicked)
        self.insert(self.bHistoryBack, -1)

        ## Home Button
        self.bHome = gtk.ToolButton(_("Home"))
        self.bHome.set_stock_id(gtk.STOCK_HOME)
        self.bHome.set_label(_("Home"))
        self.bHome.set_tooltip_text(_("Show start-page"))
        self.bHome.connect("clicked", self.on_bHome_clicked)
        self.insert(self.bHome, -1)

        ## Forward Button
        self.bHistoryForward = gtk.ToolButton(_("Forward"))
        self.bHistoryForward.set_stock_id(gtk.STOCK_GO_FORWARD)
        self.bHistoryForward.set_sensitive(False)
        self.bHistoryForward.set_label(_("Forward"))
        self.bHistoryForward.set_tooltip_text(_("Show next page in history"))
        self.bHistoryForward.connect("clicked", self.on_bHistoryForward_clicked)
        self.insert(self.bHistoryForward, -1)

        ## Burn Button
        self.bBurn = gtk.ToolButton(_("Burn"))
        self.bBurn.set_stock_id(gtk.STOCK_CDROM)
        self.bBurn.set_label(_("Burn"))
        self.bBurn.set_tooltip_text(_("Burn selected playlist"))
        self.bBurn.connect("clicked", self.on_bBurn_clicked)
        self.insert(self.bBurn, -1)

        ## Seperator
        self.Separator1 = gtk.SeparatorToolItem()
        self.insert(self.Separator1, -1)

        # ADD ALBUM TO PLAYLIST
        self.lbAppendAlbum = gtk.ToolButton(label=_("Append"))
        self.lbAppendAlbum.set_stock_id(gtk.STOCK_ADD)
        self.lbAppendAlbum.set_tooltip_text(_("Append this album on playlist"))
        self.lbAppendAlbum.connect("clicked", self.on_lbAppendAlbum_clicked)
        self.insert(self.lbAppendAlbum, -1)
        # GET MORE ALBUMS FROM THIS PLAYLIST
        self.lbMoreAlbumsFromThisArtist2 = gtk.ToolButton(label=_("Artist"))
        self.set_image(self.lbMoreAlbumsFromThisArtist2, os.path.join(functions.install_dir(), "images", "personal.png"))
        self.lbMoreAlbumsFromThisArtist2.set_tooltip_text(_("Get more music from this artist"))
        self.lbMoreAlbumsFromThisArtist2.connect("clicked", self.on_lbMoreAlbumsFromThisArtist_clicked)
        self.insert(self.lbMoreAlbumsFromThisArtist2, -1)

        ## Expander
        self.space_fs = gtk.ToolItem()
        self.space_fs.set_expand(True)
        self.insert(self.space_fs, -1)

        self.bPref = gtk.ToolButton("Preferences")
        #self.bPref.set_stock_id(gtk.STOCK_PREFERENCES)
        #self.bPref.set_tooltip_text(_("Show Preferences"))
        self.bPref.connect("clicked", self.pyjama.show_preferences)
        #self.insert(self.bPref, -1)
        #self.bPref.show()
        

        #
        # Accelerators
        #
        self.accel_group = gtk.AccelGroup()
        self.bHistoryBack.add_accelerator("clicked", self.accel_group, 65361, gtk.gdk.MOD1_MASK, gtk.ACCEL_VISIBLE)
        self.bHome.add_accelerator("clicked", self.accel_group, ord("h"), gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
        self.bHistoryForward.add_accelerator("clicked", self.accel_group, 65363, gtk.gdk.MOD1_MASK, gtk.ACCEL_VISIBLE)
        self.bBurn.add_accelerator("clicked", self.accel_group, ord("b"), gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
        self.bPref.add_accelerator("clicked", self.accel_group, ord("p"), gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
        self.pyjama.window.add_accel_group(self.accel_group)

        self.show_all()