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;
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) {
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);
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,
}};
}
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";
-- have print() call info() instead.
print = info
+-- %WTAP_ENCAPS%
+
+-- %FT_TYPES%
+
+-- %BASES%
--- a Console to execute commands in lua
+-- %EXPERT%
+
+-- %MENU_GROUPS%
+
+-- Console to execute commands in lua
function wslua_console()
local w = TextWindow.new("Lua Console")
w:set_editable(TRUE)
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)
/*
- * lua_gui.c
+ * wslua_gui.c
*
* (c) 2006, Luis E. Garcia Ontanon <luis.ontanon@gmail.com>
*
struct _lua_menu_data {
lua_State* L;
int cb_ref;
- int data_ref;
};
static int menu_cb_error_handler(lua_State* L) {
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;
}
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);
}
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) {
*/
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 *),
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)
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 *),
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;
break;
case(REGISTER_ANALYZE_GROUP_NONE):
break;
+ case(REGISTER_TOOLS_GROUP_NONE):
+ break;
default:
g_assert_not_reached();
}
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);*/
+ }
+
+
}
*/
void
register_dfilter_stat(tap_dfilter_dlg *info, const char *name,
- REGISTER_STAT_GROUP_E group)
+ register_stat_group_t group)
{
char *full_name;
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
}
/*
* 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.
*/
}
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_) {
* 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);