forked from osmocom/wireshark
* rename REGISTER_STAT_GROUP_E -> register_stat_group_t
* Add a "Tools" menu * allow wslua's register_menu to register menu items into more menus svn path=/trunk/; revision=19338
This commit is contained in:
parent
e21c2fe5b5
commit
2e7726b3ff
|
@ -30,7 +30,7 @@
|
|||
|
||||
typedef struct _funnel_menu_t {
|
||||
const char *name;
|
||||
REGISTER_STAT_GROUP_E group;
|
||||
register_stat_group_t group;
|
||||
void (*callback)(gpointer);
|
||||
gpointer callback_data;
|
||||
gboolean retap;
|
||||
|
@ -44,7 +44,7 @@ const funnel_ops_t* funnel_get_funnel_ops() { return ops; }
|
|||
void funnel_set_funnel_ops(const funnel_ops_t* o) { ops = o; }
|
||||
|
||||
void funnel_register_menu(const char *name,
|
||||
REGISTER_STAT_GROUP_E group,
|
||||
register_stat_group_t group,
|
||||
void (*callback)(gpointer),
|
||||
gpointer callback_data,
|
||||
gboolean retap) {
|
||||
|
|
|
@ -91,14 +91,14 @@ extern void funnel_set_funnel_ops(const funnel_ops_t*);
|
|||
|
||||
|
||||
extern void funnel_register_menu(const char *name,
|
||||
REGISTER_STAT_GROUP_E group,
|
||||
register_stat_group_t group,
|
||||
void (*callback)(gpointer),
|
||||
gpointer callback_data,
|
||||
gboolean retap);
|
||||
|
||||
|
||||
typedef void (*funnel_registration_cb_t)(const char *name,
|
||||
REGISTER_STAT_GROUP_E group,
|
||||
register_stat_group_t group,
|
||||
void (*callback)(gpointer),
|
||||
gpointer callback_data,
|
||||
gboolean retap);
|
||||
|
|
|
@ -34,12 +34,14 @@ my $wtap_encaps_table = '';
|
|||
my $ft_types_table = '';
|
||||
my $bases_table = '';
|
||||
my $expert_pi = '';
|
||||
my $menu_groups = '';
|
||||
|
||||
my %replacements = %{{
|
||||
WTAP_ENCAPS => \$wtap_encaps_table,
|
||||
FT_TYPES => \$ft_types_table,
|
||||
BASES => \$bases_table,
|
||||
EXPERT => \$expert_pi,
|
||||
MENU_GROUPS => \$menu_groups,
|
||||
}};
|
||||
|
||||
|
||||
|
@ -110,6 +112,23 @@ while(<PROTO_H>) {
|
|||
}
|
||||
close PROTO_H;
|
||||
|
||||
# register_stat_group_t
|
||||
|
||||
|
||||
$menu_groups .= "-- menu groups for register_menu \n";
|
||||
my $menu_i = 0;
|
||||
|
||||
open STAT_MENU, "< $WSROOT/stat_menu.h";
|
||||
while(<STAT_MENU>) {
|
||||
if (/REGISTER_([A-Z]+)_GROUP_([A-Z]+)/) {
|
||||
$menu_groups .= "MENU_$1_$2 = $menu_i\n";
|
||||
$menu_groups =~ s/_NONE//;
|
||||
$menu_i++;
|
||||
}
|
||||
}
|
||||
close STAT_MENU;
|
||||
|
||||
|
||||
$bases_table .= "}\n\n";
|
||||
$expert_pi .= "\n\n";
|
||||
|
||||
|
|
|
@ -51,8 +51,17 @@ end
|
|||
-- have print() call info() instead.
|
||||
print = info
|
||||
|
||||
-- %WTAP_ENCAPS%
|
||||
|
||||
-- a Console to execute commands in lua
|
||||
-- %FT_TYPES%
|
||||
|
||||
-- %BASES%
|
||||
|
||||
-- %EXPERT%
|
||||
|
||||
-- %MENU_GROUPS%
|
||||
|
||||
-- Console to execute commands in lua
|
||||
function wslua_console()
|
||||
local w = TextWindow.new("Lua Console")
|
||||
w:set_editable(TRUE)
|
||||
|
@ -73,14 +82,5 @@ function wslua_console()
|
|||
w:add_button("Evaluate",eval)
|
||||
end
|
||||
|
||||
register_menu("Lua Console",wslua_console)
|
||||
|
||||
|
||||
-- %WTAP_ENCAPS%
|
||||
|
||||
-- %FT_TYPES%
|
||||
|
||||
-- %BASES%
|
||||
|
||||
-- %EXPERT%
|
||||
register_menu("Lua Console",wslua_console,MENU_TOOLS)
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* lua_gui.c
|
||||
* wslua_gui.c
|
||||
*
|
||||
* (c) 2006, Luis E. Garcia Ontanon <luis.ontanon@gmail.com>
|
||||
*
|
||||
|
@ -31,7 +31,6 @@ static const funnel_ops_t* ops = NULL;
|
|||
struct _lua_menu_data {
|
||||
lua_State* L;
|
||||
int cb_ref;
|
||||
int data_ref;
|
||||
};
|
||||
|
||||
static int menu_cb_error_handler(lua_State* L) {
|
||||
|
@ -50,9 +49,9 @@ void lua_menu_callback(gpointer data) {
|
|||
|
||||
lua_pushcfunction(md->L,menu_cb_error_handler);
|
||||
lua_rawgeti(md->L, LUA_REGISTRYINDEX, md->cb_ref);
|
||||
lua_rawgeti(md->L, LUA_REGISTRYINDEX, md->data_ref);
|
||||
|
||||
lua_pcall(md->L,1,0,1);
|
||||
|
||||
/* XXX handle error */
|
||||
lua_pcall(md->L,0,0,1);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -60,33 +59,31 @@ void lua_menu_callback(gpointer data) {
|
|||
WSLUA_FUNCTION wslua_register_menu(lua_State* L) { /* Register a menu item in the Statistics menu. */
|
||||
#define WSLUA_ARG_register_menu_NAME 1 /* The name of the menu item. */
|
||||
#define WSLUA_ARG_register_menu_ACTION 2 /* The function to be called when the menu item is invoked. */
|
||||
#define WSLUA_OPTARG_register_menu_USERDATA 3 /* To be passed to the action. */
|
||||
|
||||
#define WSLUA_ARG_register_menu_GROUP 3 /* The menu group into which the menu item is to be inserted. */
|
||||
|
||||
const gchar* name = luaL_checkstring(L,WSLUA_ARG_register_menu_NAME);
|
||||
struct _lua_menu_data* md;
|
||||
gboolean retap = FALSE;
|
||||
|
||||
register_stat_group_t group = luaL_optnumber(L,WSLUA_ARG_register_menu_GROUP,REGISTER_STAT_GROUP_GENERIC);
|
||||
|
||||
if ( group > REGISTER_TOOLS_GROUP_NONE)
|
||||
WSLUA_ARG_ERROR(register_menu,GROUP,"must be a defined MENU_* (see init.lua)");
|
||||
|
||||
if(!name)
|
||||
WSLUA_ARG_ERROR(register_menu,NAME,"must be a string");
|
||||
|
||||
if (!lua_isfunction(L,WSLUA_ARG_register_menu_ACTION))
|
||||
WSLUA_ARG_ERROR(register_menu,ACTION,"must be a function");
|
||||
|
||||
|
||||
md = g_malloc(sizeof(struct _lua_menu_data));
|
||||
md->L = L;
|
||||
|
||||
lua_pushvalue(L, 2);
|
||||
md->cb_ref = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||
|
||||
if ( lua_gettop(L) > 2) {
|
||||
lua_pushvalue(L, WSLUA_OPTARG_register_menu_USERDATA);
|
||||
md->data_ref = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||
} else {
|
||||
md->data_ref = LUA_NOREF;
|
||||
}
|
||||
|
||||
lua_pushvalue(L, 2);
|
||||
md->cb_ref = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||
lua_remove(L,2);
|
||||
|
||||
funnel_register_menu(name,
|
||||
REGISTER_STAT_GROUP_GENERIC,
|
||||
group,
|
||||
lua_menu_callback,
|
||||
md,
|
||||
retap);
|
||||
|
|
|
@ -544,7 +544,7 @@ static void our_menu_callback(void* unused _U_, gpointer data) {
|
|||
}
|
||||
|
||||
static void register_menu_cb(const char *name,
|
||||
REGISTER_STAT_GROUP_E group,
|
||||
register_stat_group_t group,
|
||||
void (*callback)(gpointer),
|
||||
gpointer callback_data,
|
||||
gboolean retap) {
|
||||
|
|
|
@ -63,7 +63,7 @@ extern "C" {
|
|||
*/
|
||||
extern void register_stat_menu_item(
|
||||
const char *name,
|
||||
REGISTER_STAT_GROUP_E group,
|
||||
register_stat_group_t group,
|
||||
GtkItemFactoryCallback callback,
|
||||
gboolean (*selected_packet_enabled)(frame_data *, epan_dissect_t *),
|
||||
gboolean (*selected_tree_row_enabled)(field_info *),
|
||||
|
|
13
gtk/menu.c
13
gtk/menu.c
|
@ -598,7 +598,8 @@ static GtkItemFactoryEntry menu_items[] =
|
|||
init_conversation_notebook_cb, 0, WIRESHARK_STOCK_CONVERSATIONS),
|
||||
ITEM_FACTORY_STOCK_ENTRY("/Statistics/Endpoints", NULL,
|
||||
init_hostlist_notebook_cb, 0, WIRESHARK_STOCK_ENDPOINTS),
|
||||
ITEM_FACTORY_ENTRY("/_Help", NULL, NULL, 0, "<Branch>", NULL),
|
||||
ITEM_FACTORY_ENTRY("/_Tools", NULL, NULL, 0, "<Branch>", NULL),
|
||||
ITEM_FACTORY_ENTRY("/_Help", NULL, NULL, 0, "<Branch>", NULL),
|
||||
ITEM_FACTORY_STOCK_ENTRY("/Help/_Contents", "F1", topic_menu_cb, HELP_CONTENT, GTK_STOCK_HELP),
|
||||
ITEM_FACTORY_ENTRY("/Help/_Supported Protocols", NULL, supported_cb, 0, NULL, NULL),
|
||||
#if (GLIB_MAJOR_VERSION >= 2)
|
||||
|
@ -914,7 +915,7 @@ static GList * tap_menu_item_add(
|
|||
void
|
||||
register_stat_menu_item(
|
||||
const char *name,
|
||||
REGISTER_STAT_GROUP_E group,
|
||||
register_stat_group_t group,
|
||||
GtkItemFactoryCallback callback,
|
||||
gboolean (*selected_packet_enabled)(frame_data *, epan_dissect_t *),
|
||||
gboolean (*selected_tree_row_enabled)(field_info *),
|
||||
|
@ -942,6 +943,7 @@ register_stat_menu_item(
|
|||
case(REGISTER_STAT_GROUP_TELEPHONY): toolspath = "/Statistics/"; break;
|
||||
case(REGISTER_STAT_GROUP_NONE): toolspath = "/Statistics/"; break;
|
||||
case(REGISTER_ANALYZE_GROUP_NONE): toolspath = "/Analyze/"; break;
|
||||
case(REGISTER_TOOLS_GROUP_NONE): toolspath = "/Tools/"; break;
|
||||
default:
|
||||
g_assert(0);
|
||||
toolspath = NULL;
|
||||
|
@ -1067,6 +1069,8 @@ static guint merge_tap_menus_layered(GList *node, gint group) {
|
|||
break;
|
||||
case(REGISTER_ANALYZE_GROUP_NONE):
|
||||
break;
|
||||
case(REGISTER_TOOLS_GROUP_NONE):
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
@ -1139,6 +1143,11 @@ void merge_all_tap_menus(GList *node) {
|
|||
entry->path = "/Analyze/";
|
||||
/*gtk_item_factory_create_item(main_menu_factory, entry, NULL, 2);*/
|
||||
}
|
||||
if (merge_tap_menus_layered(node, REGISTER_TOOLS_GROUP_NONE)) {
|
||||
/*gtk_item_factory_create_item(main_menu_factory, entry, NULL, 2);*/
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ tap_dfilter_dlg_cb(GtkWidget *w, gpointer data);
|
|||
*/
|
||||
void
|
||||
register_dfilter_stat(tap_dfilter_dlg *info, const char *name,
|
||||
REGISTER_STAT_GROUP_E group)
|
||||
register_stat_group_t group)
|
||||
{
|
||||
char *full_name;
|
||||
|
||||
|
|
|
@ -50,8 +50,9 @@ typedef enum {
|
|||
REGISTER_STAT_GROUP_RESPONSE_TIME,
|
||||
REGISTER_STAT_GROUP_TELEPHONY,
|
||||
/* XXX - split into telephony and VoIP? */
|
||||
REGISTER_ANALYZE_GROUP_NONE
|
||||
} REGISTER_STAT_GROUP_E;
|
||||
REGISTER_ANALYZE_GROUP_NONE,
|
||||
REGISTER_TOOLS_GROUP_NONE,
|
||||
} register_stat_group_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
27
tap-funnel.c
27
tap-funnel.c
|
@ -1,6 +1,29 @@
|
|||
/*
|
||||
* tap-funnel.c
|
||||
*
|
||||
*
|
||||
* EPAN's GUI mini-API
|
||||
*
|
||||
* (c) 2006, Luis E. Garcia Ontanon <luis.ontanon@gmail.com>
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.org>
|
||||
* Copyright 1998 Gerald Combs
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
|
||||
|
@ -126,7 +149,7 @@ static void init_funnel_cmd(const char *optarg, void* data ) {
|
|||
}
|
||||
|
||||
static void register_menu_cb(const char *name,
|
||||
REGISTER_STAT_GROUP_E group _U_,
|
||||
register_stat_group_t group _U_,
|
||||
void (*callback)(gpointer),
|
||||
gpointer callback_data,
|
||||
gboolean retap _U_) {
|
||||
|
|
|
@ -67,7 +67,7 @@ typedef struct _tap_dfilter_dlg {
|
|||
* We register it both as a command-line stat and a menu item stat.
|
||||
*/
|
||||
void register_dfilter_stat(tap_dfilter_dlg *info, const char *name,
|
||||
REGISTER_STAT_GROUP_E group);
|
||||
register_stat_group_t group);
|
||||
|
||||
/* This will update the titles of the dialog windows when we load a new capture file. */
|
||||
void tap_dfilter_dlg_update (void);
|
||||
|
|
Loading…
Reference in New Issue