Wireshark-dev: Re: [Wireshark-dev] Adding a new menu in the MenuBar
From: Richard Sharpe <[email protected]>
Date: Mon, 9 Jul 2012 11:01:42 -0700
On Mon, Jul 9, 2012 at 10:28 AM, Jeff Morriss <[email protected]> wrote:
> Richard Sharpe wrote:
>> On Sun, Jul 8, 2012 at 10:15 PM, Tony Trinh <[email protected]> wrote:
>>> On Mon, Jul 9, 2012 at 1:01 AM, Richard Sharpe <[email protected]> wrote:
>>>> Hi folks,
>>>>
>>>> I would like to add a new menu in the Menubar, like "Menubar/Blah" and
>>>> place it before help, and after the tools menu (and probably before
>>>> Internals).
>>>>
>>>> I would like to do it from Lua.
>>>>
>>>> I think I can see how to do this, but I wonder if anyone else has done
>>>> that before?
>>>>
>>> WSLua does not support adding main menus. Currently, you can only add submenus to
>>> existing menus.
>>
>> You are correct. The problem would seem to be twofold:
>>
>> 1. There is no function for doing that, and
>>
>> 2. In ui/gtk/funnel_stat.c, the stat_group_name function contains a
>> static value_string of the relationships between values like
>> REGISTER_STAT_GROUP_UNSORTED and the string to use for the menu item.
>>
>> Functions/methods would have to be added to allow new menu items to be
>> added to allow the addition of whole new menus, but
>> register_lua_menu_bar_menu_items and its subsidiary functions seem
>> capable of this, as well as functions/methods to enter new values in
>> VALS_GROUP_NAMES and to retrieve the index based on the string.
>
> I had to make a bunch of changes to this code (in r41591) to get the Lua
> menus working again.  And I wasn't terribly happy with the result; it
> seems quite a bit of a mess to me.  But I didn't have a better idea at
> the time...

Sure. I don't really have any criticism of your work. I would only
suggest that VALS_GROUP_NAMES should be all lower case so that it does
not look like a macro etc, unless, that is, there is a rule covering
this case.

In addition, I think that what is there is fine for current needs.

I just have new needs, which I think others might have as well.

However, I should post a new message about this. I can see two approaches:

1. A free-for-all by Lua plugins where they can add their own menus
and things become ugly, or

2. A single plugins menu where each Lua plugin gets its own section in
a well defined manner.

However, for backward compatibility, the current situation would have
to be supported as well.


-- 
Regards,
Richard Sharpe
(何以解憂?唯有杜康。--曹操)