Wireshark-dev: Re: [Wireshark-dev] Infrastructure for plugins (including Lua-based ones) to add
From: Tony Trinh <[email protected]>
Date: Thu, 12 Jul 2012 03:30:21 -0400
On Tue, Jul 10, 2012 at 10:06 AM, Richard Sharpe <[email protected]> wrote:
Hi folks,

In a previous email I raised the issue of givin Lua plugins the
ability to declare their own menus, not just menu items on existing
menus. Indeed, I would like to go further and to expose facilities for
plugins to add items to other places, like the Filter bar and the
popup menus. 

However, one additional discussion that I think it is important to
have has occurred to me.

It seems to me that there are two approaches that can be taken with
respect to allowing plugins to add menus:

1. A free-for-all, where each plugin can establish its own menu. This
keeps each plugin separate, but could get a bit ugly.

It would be simple to modify the current code to allow Lua to insert anywhere in the menu bar, but I agree that one of the reasons this restriction is in place is likely to prevent menu madness (the "ugliness" you mention) and possible user confusion. Imagine 20 Lua plugins that created their own top-level menus.
2. A single menu for plugins, with each plugin getting its own section.

Hmm. I don't understand the advantage of this approach over the current solution. Can you clarify with an example?

The common goal for these approaches seem to be the separation of each plugin's menus. Menu grouping is already possible with the current release of Wireshark, as shown below. 

    register_menu('PluginA/foo1', foo1_action, MENU_TOOLS_UNSORTED)
    register_menu('PluginA/bar1', bar1_action, MENU_TOOLS_UNSORTED)

    -- note the dash is used for menu separator
    register_menu('-/PluginB/foo2', foo2_action, MENU_TOOLS_UNSORTED)
    register_menu('PluginB/bar2', bar2_action, MENU_TOOLS_UNSORTED)

Menu result:
|-- PluginA
  |-- foo1
  \-- bar1
        ------------------------ (menu separator)
|-- PluginB
\-- foo2
\-- bar2

Another undocumented feature (as of 1.7.0) is keyboard shortcuts (e.g., shortcut on "f" with "PluginA/_foo").

I think it would be nice to add more control over menu items, including the following
  • edit menu text/icon
  • create toggle menu
  • disable menu
  • hide/remove menu
  • add menu after init (it's currently prevented, and IMO, there's no reason to do so)
These additions might call for a new "Menu" [meta]class.