Hello,
I am writing a telnet interface plugin to rhythmbox in python. It's small and 
called rhythmcurse, http://github.com/sameltvom/rhythmcurse
One of the thing I want to do is to list all artists in the database. The code 
I use now for sending a list of artists to the client connected looks like this:
---------------------------------------------------------------------------------try:  
  # reset to all artists    for p in 
self.shell.props.library_source.get_property_views():        if p.props.prop == 
rhythmdb.PROP_ARTIST:            artistNow = p.get_selection()            
p.set_selection([""])            break
    # make the changes take effect    gtk.gdk.threads_leave()    # python 
doesn't have Thread.yield as in Java    time.sleep(0.01)    
gtk.gdk.threads_enter()
    # find all artists    artists = set()    for row in 
self.shell.props.selected_source.props.query_model:        entry = row[0]       
 artist = self.shell.props.db.entry_get(entry, rhythmdb.PROP_ARTIST)        
artists.add(artist)    id = 0
    # sorted list    artists_sorted = sorted(artists)    for artist in 
artists_sorted:        reply = "%d - %s\r\n" % (id, artist)        
self.clientSocket.send(reply)        id+=1
    # reset the artist    for p in 
self.shell.props.library_source.get_property_views():        if p.props.prop == 
rhythmdb.PROP_ARTIST:            p.set_selection(artistNow)            break    
reply = ""
except:    reply = "couldn't list 
artists\r\n"---------------------------------------------------------------------------------
First of all, this just seems like a very bad way to do this and second, it 
will be buggy if there are many artists in the database.
I have really tried to find out how to do this in a good manner by using the 
set_query method in RhythmDBQueryResults. But I can't figure out how to create 
the query.
I would appreciate some help on this.
Kind regards,Samuel Skånberg

_______________________________________________
rhythmbox-devel mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/rhythmbox-devel

Reply via email to