[haiku-development] Re: Help regarding GSoC idea : Tracker add-on for a version control system

  • From: Hrishi Hiraskar <hrishihiraskar@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Tue, 27 Mar 2018 04:51:09 +0000

Hi Rene

I was able to pass the top level menu to the add on and was able to
manipulate it.

Thank you for your valuable guidance.
This code was necessary for my GSoC proposal.

Regards
Hrishikesh Hiraskar

On Tue, Mar 27, 2018 at 12:04 AM Rene Gollent <anevilyak@xxxxxxxxx> wrote:

On Mon, Mar 26, 2018 at 2:22 PM, Hrishi Hiraskar
<hrishihiraskar@xxxxxxxxx> wrote:
But now that I can call `populate_menu (entry_ref dir_ref, BMessage *msg,
BMenuItem* item)`,  where I'm passing the BMenuItem of the add on item
created at

https://github.com/Hrily/haiku/blob/63ede39cc8b8149b906969666c0f1bc7ad80193c/src/kits/tracker/ContainerWindow.cpp#L235

I can neither access `item->Submenu()` nor `item->Menu()`. Both turned
out
to be null.

A BMenuItem won't have a Submenu() unless it was constructed with one
(c.f.
https://git.haiku-os.org/haiku/tree/headers/os/interface/MenuItem.h#n26
). So you may need to make further changes/additions to the API here
in order for you to be able to do that. The Menu() call returns a
pointer to the parent menu that the item is part of in any case, and
it hasn't yet been added to one at the point where this code is being
called, hence getting NULL in both cases. In this case though, since
I'm guessing you want to be able to add items to the top level context
menu itself rather than the add-ons submenu anyways. As such, you may
want to take a slightly different approach here, where either the
add-on API is extended to add another call that can be passed the top
level menu so that the add-on can then manipulate it directly, or
alternatively a call that allows the add-on to return a list of items
rather than being given one up front to modify as was previously the
case.

Regards,

Rene


Other related posts: