aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2003-04-23 03:13:16 +0000
committerGuy Harris <guy@alum.mit.edu>2003-04-23 03:13:16 +0000
commit6b0b09b402cb6e47f4f78f867ef10dc43af1b42c (patch)
tree24b45abf8b510d149c76c19a0962798dc50e11d1
parent733b96657b9c461e802a6d12c8ba0e09a53dce6d (diff)
Add a routine to create a new menu item under "/Tools/Statistics" for
taps. (It has to be called after we've created the main menu, but GUI taps are registered before that so that they can be referred to by command-line arguments, so that routine will only be usable if we have a "register menu item" routine for all GUI taps.) Disable the entire "/Tools/Statistics/MGCP" menu item, not just the "RTD" item under it, if we don't have an "mgcp" tap. svn path=/trunk/; revision=7539
-rw-r--r--gtk/menu.c41
-rw-r--r--gtk/menu.h11
2 files changed, 49 insertions, 3 deletions
diff --git a/gtk/menu.c b/gtk/menu.c
index 7c871a8a73..92aad426ac 100644
--- a/gtk/menu.c
+++ b/gtk/menu.c
@@ -1,7 +1,7 @@
/* menu.c
* Menu routines
*
- * $Id: menu.c,v 1.89 2003/04/22 04:49:17 guy Exp $
+ * $Id: menu.c,v 1.90 2003/04/23 03:13:16 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -437,7 +437,7 @@ menus_init(void) {
#endif
if(!find_tap_id("mgcp")) {
- set_menu_sensitivity(main_menu_factory, "/Tools/Statistics/MGCP/RTD",
+ set_menu_sensitivity(main_menu_factory, "/Tools/Statistics/MGCP",
FALSE);
}
set_menus_for_captured_packets(FALSE);
@@ -447,6 +447,43 @@ menus_init(void) {
}
/*
+ * Add a new menu item for a statistical tap.
+ * This must be called after we've created the main menu, so it can't
+ * be called from the routine that registers taps - we have to introduce
+ * another per-tap registration routine.
+ */
+void
+register_tap_menu_item(const char *name, GtkItemFactoryCallback callback)
+{
+ static const char statspath[] = "/Tools/Statistics/";
+ char *menupath;
+ size_t menupathlen;
+ GtkItemFactoryEntry *entry;
+
+ /*
+ * Construct the main menu path for the menu item.
+ *
+ * "sizeof statspath" includes the trailing '\0', so the sum
+ * of that and the length of "name" is enough to hold a string
+ * containing their concatenation.
+ */
+ menupathlen = sizeof statspath + strlen(name);
+ menupath = g_malloc(menupathlen);
+ strcpy(menupath, statspath);
+ strcat(menupath, name);
+
+ /*
+ * Construct an item factory entry for the item, and add it to
+ * the main menu.
+ */
+ entry = g_malloc0(sizeof (GtkItemFactoryEntry));
+ entry->path = menupath;
+ entry->callback = callback;
+ gtk_item_factory_create_item(main_menu_factory, entry, NULL, 2);
+}
+
+
+/*
* Enable/disable menu sensitivity.
*/
static void
diff --git a/gtk/menu.h b/gtk/menu.h
index 0d97f54faa..73ec92aeea 100644
--- a/gtk/menu.h
+++ b/gtk/menu.h
@@ -1,7 +1,7 @@
/* menu.h
* Menu definitions
*
- * $Id: menu.h,v 1.7 2002/08/28 21:03:48 jmayer Exp $
+ * $Id: menu.h,v 1.8 2003/04/23 03:13:16 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -34,6 +34,15 @@ void get_main_menu (GtkWidget **, GtkAccelGroup **);
void set_menu_object_data (gchar *path, gchar *key, gpointer data);
gint popup_menu_handler(GtkWidget *widget, GdkEvent *event, gpointer data);
+/*
+ * Add a new menu item for a statistical tap.
+ * This must be called after we've created the main menu, so it can't
+ * be called from the routine that registers taps - we have to introduce
+ * another per-tap registration routine.
+ */
+extern void register_tap_menu_item(const char *name,
+ GtkItemFactoryCallback callback);
+
extern GtkWidget *popup_menu_object;
#ifdef __cplusplus