
On Mon, 2007-05-14 at 22:20 +0000, Gerrit . wrote:
This weekend, I finally found the time to play a little with Inkscape and try out your suggestions. I got the layer flipping working, not yet as an extension however.
Cool, it's not crucial that it is an extension, though it's always nice.
Here's what I did:
- Added 2 actions to the key mappings in keys/default.xml
Looks good.
- Added 2 verbs for these actions to Verb::_base_verbs[] in verbs.cpp,
defined in verbs.h.
Looks good. I'm hoping you added entries to verbs.h also, but if it works, you probably did.
- Wrote 2 case blocks for the verbs.
Yup. Looks good.
This works, and so far it's all I need, but I'd still like to know how I would implement this as an extension. I didn't, because I couldn't figure out:
Okay, I'd like that too.
- How to register extensions with keys. The verbs all seem to be mapped to
internal functions.
Basically there are two types of verbs. The ones that you're looking at are all static verbs, they're created with fixed IDs mostly at compile time. There are also dynamic verbs that are created at run time, the extensions all fall into this category. There are actually a few other verbs that do this, but by and far, the majority are static. If you look at the two Verb constructors, you can see that one knows the code, and the other creates it -- those are the two categories.
- How to call the extension's effect method. It's nonstatic, so I'd think
need an object pointer somehow. Where can I fetch it?
The effect method gets called by the verb. Basically the verb that gets created is a subclass of the global Verb, called an EffectVerb. The effect verb calls the effect function. That's all taken care of, you just need to subclass Implementation.
For some reason, I couldn't find the corresponding code blocks for Grid or BlurEdge...
/src/extension/internal/grid.[cpp,h] /src/extension/internal/bluredge.[cpp,h]
You'll also need to modify:
/src/extension/internal/init.cpp
To add a line for initializing your extension. You can just search for "Internal::Grid::init()" and put it in that list. I'm working on cleaning this little messy-ness up, but haven't done so yet. (feel free if you'd like :) )
I think the biggest trick here is in that init function, basically this is where you're creating the extension. Don't forget the N_() on some of the strings, as that is how they get marked for translation.
--Ted