Writing Kupfer plugins basics [Fwd: Firefox profile kupfer plugin]



Hi everyone,

forwarded to the mailing list because maybe it can serve as a light
tutorial/introduction.


---------- Forwarded message ----------
From: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: 2010/9/20
Subject: Re: Firefox profile kupfer plugin
To: chiraag nataraj gmail com


2010/9/19 Chiraag Nataraj <chiraag nataraj gmail com>
>
> Dear Ulrik,
> I was wondering how exactly one would go about creating a Kupfer plugin that launches a specific Firefox profile.  I have no Python experience whatsoever, but I will learn it.  Also, I will publish the plugin if/when it works.
> -----------------------------


Hi,

I really like that you take interest in Kupfer. I haven't had much
time to spend on Kupfer in the latest, so my email will be short.

In principle this should be very simple, and if you want to do this,
make a *new* plugin for simplicity's sake.

I will point you at Kupfer's documentation for implementation stuff --
information for contributors: http://kaizer.se/wiki/kupfer/Manual/
the information there is basic, and a bit incomplete, but the basics
are the most important.

What you need is simple
------------------------------------
1. Represent the object -- the specific profile -- as a 'Leaf' (see
contributor manual), let's call it a "Profile"  for now. The
'represented object' (see contributor manual) can be its exact name or
the file system path. A Leaf does not need to be more than this -- a
represented object (the real data), then a display name (the name the
user will find it under)


2. Find & tell kupfer about the objects in (1). Make a 'Source', let's
call it "ProfilesSource"
for now. A source will find and enumerate the firefox profiles for the
current user, and construct "Profile" objects, 1 per profile, and
return them in a list in it's "get_items" method.


3. Make an action to open a "Profile" object. The most logical name
for this action is "Open"(!!). You create a new 'Action' object. The
'activate' method will open a specific firefox profile -- the one that
it is handed to it.  Then we go back to "Profile" in (1) and make sure
it returns _your_ "Open" action as a built-in action.


Now before you start -- look at a preexisting file and use it as an
example. We take here 'notes.py' that contains all parts 1, 2 and 3 in
one plugin.

Look at 'class Note (Leaf)' as example for (1). Look at 'class
NotesSource' for (2) (but inherit from Source directly). Look at
'class Open (Action) for (3). Your firefox functionality should have
no complexity -- take notes.py and start removing everything you don't
need. The only complexity is the stuff you have to fill in yourself --
in step 2, how to find out which profiles are active, and in step 3,
how do I start firefox with a specific profile?

HTH!

(Can I send a copy to Kupfer's mailing list?)

Ulrik


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