Ejemplo n.º 1
0
    def ev_import_stared_albums(self, widget):
        # username
        result = clEntry.input_box(title=_('Import Stared Albums'),
            message=_('To import (your) stared albums from jamendo\nplease enter the corresponding jamendo username.'),
            default_text=_("MeAtJamendo"))
        if result is None:
            return
        name = str(result).replace(" ", "+")

        albums = self.import_stared_albums(name)
        if albums == []:
            self.pyjama.Events.raise_event("error", None, "No albums found for this user")
        else:
            stared = self.pyjama.settings.get_value("STAR PLUGIN", "STARED ALBUMS", "")
            for album in albums:
                album = str(album)
                if not album in stared:
                    # add album to stared
                    stared = "%s+%s" % (stared, album)
            self.pyjama.settings.set_value("STAR PLUGIN", "STARED ALBUMS", stared)
            self.pyjama.reload_current_page()

            dia = MyDialog(_('Imported albums from user %s' % name),
                              self.pyjama.window.get_toplevel(),
                              gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, 
                                (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT), gtk.STOCK_DIALOG_INFO, _("Succesfully imported %i albums from '%s'." % (len(albums), name)))
            dia.run()
            dia.destroy()
Ejemplo n.º 2
0
    def add_bookmark(self, widget, name=None):

        data = self.pyjama.historyCurrent
        content = serialize(data)

        if name is None:
            # ask for name
            result = clEntry.input_box(title=_('Bookmark'),
                message=_('Please enter a Name for this bookmark'),
                default_text=_("Bookmark"))
            if result is None:
                return
            name = str(result)
        else:
            name = self.home_bookmark_name
        
        # Save bookmark
        self.pyjama.settingsdb.set_value("bookmarks", name, content)

        if name is not None:
            # Append menu entry
            menu = self.pyjama.window.menubar
            entry = menu.append_entry(menu.get_rootmenu("Bookmarks"), name, base64.b64encode(name))
            entry.connect("activate", self.ev_load_bookmark, name)
            entry.show()
            self.bookmarks.append({'name':name, 'hash':content})
Ejemplo n.º 3
0
        def on_sbExportFavs_clicked(self, ev):
            result = clEntry.input_box(title=_('Enter your Jamendo username'),
                message=_('Exporting stared albums to jamendo DOES NOT WORK automatically.\n \
                1) Visit jamendo.com and login with your default webbrowser\n \
                2) Enter your username in this box \n \
                Pyjama will now open any album you have stared in pyjama and which is not stared on jamendo.com.\n \
                3) Now you can star each album manually within your browser.'),
                default_text="USERNAME")
            if result is None:
                return None
                
            name = str(result).replace(" ", "+")
            
            self.pyjama.jamendo.set_ignore_cache(True)
            albums = self.pyjama.plugins.loaded['starred_albums'].import_stared_albums(name)
            stared = self.pyjama.settings.get_value("STAR PLUGIN", "STARED ALBUMS", "")
            stared = stared.split("+")[1:]

            open_uris = []

            try:
                for stared_album in stared:
                    if not int(stared_album) in albums:
                        uri = self.pyjama.settings.get_value("URLs", "ALBUM_URL").replace("URL", "%s" % stared_album)
                        open_uris.append(uri)
            except Exception, inst:
                print ("Fehler", inst)
                return
Ejemplo n.º 4
0
 def on_sbJumpToPage_clicked(self, ev):
     result = clEntry.input_box(title=_('Jump to page'),
         message=_('Enter Page'),
         default_text="%i" % (self.layout.cur_page+10))
     if result is None:
         return None
     elif not result.isdigit():
         dia = clWidget.MyDialog(_('invalid expression'),
                           self.get_toplevel(),
                           gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, 
                             (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT),        gtk.STOCK_DIALOG_WARNING, _('\'%s\' is not a valid page') % str(result))
         dia.run()
         dia.destroy()
         return None
     else:
         page = int(result)
     self.pyjama.layouts.show_layout("top", self.layout.results_per_page, self.layout.ordering, page, self.layout.tag, who_called = "on_sbjumptopage_clicked")
     self.layout.check_next_possible()
     self.layout.check_prev_possible()
Ejemplo n.º 5
0
    def cb_addnew_playlist_activate(self, activate, track):
        # ask for name
        result = clEntry.input_box(
            title=_("Playlist"),
            message=_("Please enter a name for your new playlist.\nExisting playlists will be overwritten"),
            default_text="MyPlaylist",
        )
        if result is None:
            return
        name = str(result)

        pl_string = "-SEP-%s" % str(track.id)
        # Append to bookmarks and write to config
        self.pyjama.settingsdb.set_value("playlists", name, pl_string)

        # this part needs to be fixed - the dict submenu
        # is not needed any more, use get_childs instead!
        if not name in self.pyjama.window.menubar.submenus:
            # Append menu entry
            menu = self.pyjama.window.menubar
            playlist = menu.append_entry(menu.get_rootmenu("Playlists"), name, name)
            playlist.connect("activate", self.cb_load_playlist, name)