Re: Dynamic Menus -- Progress!


Subject: Re: Dynamic Menus -- Progress!
From: Joaquín Cuenca Abela (cuenca@pacaterie.u-psud.fr)
Date: Sat Sep 22 2001 - 15:56:48 CDT


On 19 Sep 2001 18:51:42 -0500, Jared Davis wrote:
> File->Thesaurus is a reality.
Nice!

> Of course, that's not quite what we were after. =)
>
> Joaquin, thanks for all your help! This is all coming together now. I'm
> sorry it's taken me so long to do anything with it, I went out of town over
> the weekend and was having all manner of problems getting abi to compile
> today. (Thanks, Dom!)
>
> Anyway, I tried to do it both ways,
> (1) through the EV_Menu->addPath() method and
> (2) by hand.
>
> It ended up that route (1) did not work: it causes an assertation failure
> pEM at ev_UnixGnomeMenu.cpp:95 because there is no
> EV_EditMethodContainer defined for the option, and it doesn't like that
> at all.

yup, addPath was an embrionic attempt to simplify the processus.
It deals with the hard part (finding the right place in the menu, and
creating submenus if needed automatically), but it doesn't put any
Action in the ActionSet

> Route (2) I did get to work, but as mentioned earlier the "Thesaurus" item
> gets added to the File menu. I have found out that the fault seems to be
> that of the EV_Menu_Layout->addLayoutItem function.
>
> My current function call looks like this:
>
> XAP_Menu_Id id = pLayout->addLayoutItem(
> 1,
> EV_MLF_Normal
> );
>
> This seems to add the "Thesaurus" option as the very first option in the
> menu. Changing the "1" to "4" moves it down further on the menu, and so on.
> How do I get it to add to the Tools menu instead?

If you don't need to create any submenu, the code is pretty simple,
basically you should do (I will suppose that you've got the pointers
pLabelSet, pLayout, pActionSet):

// search for the index of "&Tools"
UT_uint32 idx = pLayout->getLayoutIndex(EV_searchMenuLabel(*pLabels,
"&Tools"));
XAP_Menu_Id id = pLayout->addLayoutItem(++idx, EV_MLF_Normal);

If you want to put it after one exact item, for instance after the label
"&Word Count...", just change "&Tools" by "&Word Count...".

(EV_searchMenuLabel is located at ev_Menu.h)

> Aside from that, it looks and functions well. I've managed to get an
> "underline" so you can now do <alt+f> to activate the "file" menu, then
> press <t> to activate the thesaurus that way, so that's all working out
> nicely, and the dialog does pop up correctly and seems to work fine.
>
> My code is in cvs if anyone wants to look at it. (cvs co aiksaurus, cd
> aiksaurus/gtk/abiPlugin)
>
> Other than that, I think I only have two more questions:
> 1. How do I add a <shift+f7> shortcut? <grin>

sorry, here I'm clueless

> 2. What all do I need to delete? In other words, I have made all these
> function calls like pActionSet->addAction(new EV_Menu_Action(...)), are
> these freed by EV_Menu_ActionSet or do I need to construct them outside
> and delete them later?

The action set owns the EV_Menu_Action objects that you pass it. So don't
worry about these objects, the destructor of the ActionSet will delete them
(same for LabelSet & Layout).

Cheers,

-- 
Joaquín Cuenca Abela
cuenca@celium.net



This archive was generated by hypermail 2b25 : Sat Sep 22 2001 - 15:56:19 CDT