Пример #1
0
    def __drag_data_received(self, ctx, x, y, sel, tid, etime):
        if tid == 1: uris = sel.get_uris()
        if tid == 2:
            uri = sel.data.decode('utf16', 'replace').split('\n')[0]
            uris = [uri.encode('ascii', 'replace')]

        dirs = []
        error = False
        for uri in uris:
            try: uri = URI(uri)
            except ValueError: continue

            if uri.is_filename:
                loc = os.path.normpath(uri.filename)
                if os.path.isdir(loc): dirs.append(loc)
                else:
                    loc = os.path.realpath(loc)
                    if loc not in self.__library:
                        self.__library.add_filename(loc)
            elif player.can_play_uri(uri):
                if uri not in self.__library:
                    self.__library.add([RemoteFile(uri)])
            else:
                error = True
                break
        ctx.finish(not error, False, etime)
        if error:
            ErrorMessage(
                self, _("Unable to add songs"),
                _("<b>%s</b> uses an unsupported protocol.") % uri).run()
        else:
            if dirs:
                copool.add(
                    self.__library.scan, dirs, self.__status.bar.progress,
                    cofuncid="library", funcid="library")
Пример #2
0
 def open_location(self, action):
     name = GetStringDialog(self, _("Add a Location"),
         _("Enter the location of an audio file:"),
         okbutton=gtk.STOCK_ADD).run()
     if name:
         if not util.uri_is_valid(name):
             ErrorMessage(
                 self, _("Unable to add location"),
                 _("<b>%s</b> is not a valid location.") %(
                 util.escape(name))).run()
         elif not player.can_play_uri(name):
             ErrorMessage(
                 self, _("Unable to add location"),
                 _("<b>%s</b> uses an unsupported protocol.") %(
                 util.escape(name))).run()
         else:
             if name not in self.__library:
                 self.__library.add([RemoteFile(name)])
Пример #3
0
        model, rows = selection.get_selected_rows()
        names = filter(None, [model[row][self.KEY] for row in rows])
        config.set("browsers", "radio", "\n".join(names))

    def scroll(self, song):
        # nothing we care about
        if song not in self.__stations and song not in self.__fav_stations:
            return

        path = None
        for row in self.view.get_model():
            if row[self.TYPE] == self.TYPE_FILTER:
                if self.filters.query(row[self.KEY]).search(song):
                    path = row.path
                    break
        else:
            # in case nothing matches, select all
            path = (0,)

        self.view.scroll_to_cell(path, use_align=True, row_align=0.5)
        self.view.set_cursor(path)

    def statusbar(self, i):
        return ngettext("%(count)d station", "%(count)d stations", i)


from quodlibet import player
if player.can_play_uri("http://"):
    browsers = [InternetRadio]
else: browsers = []