XMLGUI: preventing merges into a specific toolbar

David Faure faure at kde.org
Mon Apr 28 21:12:13 BST 2008


On Monday 28 April 2008, Vladimir Prus wrote:
> 
> Is it possible, using XMLGUI to specify that a given toolbar defined 
> by the application should never get any actions added from new xmlgui clients.
> In other words, the toolbar should only have actions from applications's
> actionCollection().

No.

Which is one of the issues with XMLGUI indeed: the part, or client, has too much power,
compared to the application. One idea (which I had around the time of the liveui discussions)
was to let apps request for actions in named groups ("give me all your 'edit' actions,
give me all your 'config' actions, etc. -- like KonqPopupMenu does), but this still has
to be done in xmlgui somehow.
Another idea would be to implement xmlgui filters, where the host (application) could
do some filtering on the client's DOM tree before it gets merged in; this might be tricky
coding (of the filters) though.

> Here's what we have in kdevelui.rc now:
> 
> <ToolBar name="mainToolBar" position="Top" noMerge="1">
>   <text>Main Toolbar</text>
>   <Action name="file_new" />
> </ToolBar>
> 
> When a new XMLGUI client is added via the call to KXMLGuiFactory::addClient,
> new items appear in this toolbar, even though it has no merge point defined.

<Merge> is implicitely at the end, if it's not somewhere else.

> Looking at kxmlguifactory_p.cpp:BuilderHelper::processActionElement, it
> appears the an action is added even if no merge point is found.

Yes.

> Is this a bug? 

No, certainly not. That's on purpose, and I would bet there is code relying on it.
I don't know which apps use this, off hand - but try commenting it out, I think you'll
see breakages quickly :)

> If it's not a bug, how do I get the behaviour I need? 
> (I had written a code to achieve the desired effect 
> in KDevelop, but it's seriously scary).

It's just a stupid suggestion from me, but it still seems like the easiest solution:
why not rename this toolbar? mainToolBar is the most common toolbar, make it something
else if it shouldn't be the same as that most common toolbar...
But this would of course only move the client's actions to other toolbars, not make them
disappear completely. However those other toolbars can be hidden by default I guess.

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).




More information about the kde-core-devel mailing list