Re: [Rhythmbox-devel] Plugin Activation/Deactivation



> > On Dec 26, 2007 12:24 PM, Nicholas S. Clarkson
> > <nclarkson sporadicspeculations com> wrote:
> >                I am writing a Rhythmbox plugin to save and restore the
> >         playing song. I
> >         have got my plugin to work through a menu option but I would
> >         rather it
> >         work on load and close. However, it appears that the db and
> >         play
> >         functions I am trying to use are not available to my plugin at
> >         activation/deactivation. Is there a way to adjust the time at
> >         which my
> >         plugin is activate/deactivated so that the necessary functions
> >         are
> >         available?
> > 
> > Nice plugin idea. Would it be too much to ask you to post the source
> > for your plugin? I don't have a ready answer to your question, but I'm
> > wondering if we might be able to figure something clever out.
> > 
> > Off the top of my head, I'm wondering if we move the code from
> > activate() to a new function if that'd make a difference.

A rather horrible approach would be to set a timeout in the activate()
function for long enough that rhythmbox is *likely* to be ready... You'd
have to catch an exception in the case that it wasn't ready (and
presumably continue the timer instead of stopping it).

If that's the approach you want to take, look at the gobject.timeout_add
function. It's called like:

gobject.timeout_add(6 * 60 * 60 * 1000, self.__update_catalogue)

with the first argument being the number of milliseconds to wait, and
the second being the function to call. If the function returns False
then the timeout is discarded. If it returns anything else, then the
timeout function is called again in another n milliseconds.

Like I said, it's probably not a very "clean" way to do it, but it would
likely work.

--
Adam Zimmerman <adam_zimmerman sfu ca>

CREATIVITY  - http://mirrors.creativecommons.org/movingimages/Building_on_the_Past.mpg
ALWAYS      - http://www.musiccreators.ca/
BUILDS      - http://www.ubuntu.com/
ON THE PAST - http://www.theopencd.org/
--

Work consists of whatever a body is obliged to do.
Play consists of whatever a body is not obliged to do.
		-- Mark Twain



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