Hello,
I'm attempting to write a patch that adds a margin when setting page size through the "Fit page to selection" button in document properties. I've already added the ui elements (RegisteredScalarUnit's) for marginTop, marginLeft, etc, but I can't figure out how to get the values to the function that resizes the page.
Here's how the page currently gets resized: 1. When clicked, "Fit page to selection" fires src/ui/widget/page-sizer.cpp:487: PageSizer::fire_fit_canvas_to_selection_or_drawing() { Verb *verb = Verb::get( SP_VERB_FIT_CANVAS_TO_SELECTION_OR_DRAWING ); SPAction *action = verb->get_action(dt); sp_action_perform(action, NULL); }
2. sp_action_perform eventually calls src/verbs.cpp:2149: FitCanvasVerb::perform(SPAction *action, void *data, void */*pdata*/) { fit_canvas_to_selection_or_drawing(dt); }
where the void *pdata parameter is the second argument from sp_action_perform.
3. This eventually calls src/document.cpp:601: SPDocument::fitToRect(Geom::Rect const &rect)
My plan was to add marginTop, marginLeft, etc as parameters to SPDocument::fitToRect, and somehow pass these parameters through the void *data parameter in sp_action_perform. However, all the other calls to sp_action_perform in inkscape set the void *data parameter to NULL, and it looks like the action handler doesn't have any code to call free on the parameter after all the action listeners are serviced.
Am I trying to do this completely wrong?
Thanks, - Alex
(Attached is a patch that adds the margin UI elements in document properties)