Re: [Rhythmbox-devel] Writing a Python Plugin



On Wed, Mar 16, 2011 at 3:03 PM, Payton Yao <pepsiboy gmail com> wrote:
> Hi!
>
> I've been writing a plugin for Rhythmbox in Python that allows boolean
> operators on searches (kind of like Winamp's advanced search).
>
> I've gotten most of it working, but I'm having some trouble getting a
> reference to the LibraryBrowser, so I can set the query model. (Right now,
> it's a lot of hard-coded get_children calls.) I was hoping to find out if
> there was a better way to do this. Also, I have no idea how to set the
> playlist for other sources, so the current version of the plugin just dies
> for them.

I haven't looked at your code, but it sounds like you've taken
slightly the wrong approach.

The intended way to do this is that you'd implement an RBSourceSearch
subclass that converts search text into rhythmdb queries (sounds like
you've already got this code), then attach that to the search bar as
follows:

- create a GtkAction for your search type; the label for this action
will appear in the search bar
- associate your search object with the action;
search.action_attach(action), more or less
- attach a handler to the RBSourceHeader get-search-actions signal -
you can get at this object via the shell's source-header property. The
handler would return an array containing the name of your GtkAction
- trigger the refresh-search-bar signal on the source header to ensure
it picks up your new search action

I used to have a simple example plugin that added a 'location' search
type, but I seem to have lost it somewhere along the line.

This will work for any source that uses the search bar, and it filters
through the library browser correctly too.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]