Make it possible to add menus and menuitems from outside of main_menubar.c.
authoretxrab <etxrab@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 1 Sep 2011 15:35:09 +0000 (15:35 +0000)
committeretxrab <etxrab@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 1 Sep 2011 15:35:09 +0000 (15:35 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@38843 f5534014-38df-0310-8fa8-9805f1628bb7

gtk/gui_stat_menu.h
gtk/main_menubar.c

index d14c48214e95b4d10c639f9340c44414a5d28e02..0e6c74070fb301550a4181b2b89a17d4619fa9ec 100644 (file)
@@ -217,6 +217,9 @@ void gtk_rpcprogs_cb(GtkWidget *w, gpointer data);
 void mcaststream_launch(GtkAction *action, gpointer user_data);
 void wlanstat_launch(GtkAction *action, gpointer user_data);
 
+/** Adds a callback to be executed when the menubar is ready to have menus and items added to it */
+void ws_add_build_menubar_items_callback(gpointer callback);
+
 #else
 extern void register_stat_menu_item_stock(
     const char *name,
index 6a9312afead3762608354f02f02584fa6220bbf3..6ee0f20197e2ffd1abfe684ad74aedeed24e8686 100644 (file)
@@ -133,6 +133,7 @@ static GSList *popup_menu_list = NULL;
 static GtkAccelGroup *grp;
 
 static GList *merge_lua_menu_items_list = NULL;
+static GList *build_menubar_items_callback_list = NULL;
 
 GtkWidget *popup_menu_object;
 
@@ -141,6 +142,7 @@ static void add_recent_items (guint merge_id, GtkUIManager *ui_manager);
 
 static void menus_init(void);
 static void merge_lua_menu_items(GList *node);
+static void ws_menubar_build_external_menus(void);
 static void set_menu_sensitivity (GtkUIManager *ui_manager, const gchar *, gint);
 static void set_menu_visible(GtkUIManager *ui_manager, const gchar *path, gint val);
 static void show_hide_cb(GtkWidget *w, gpointer data, gint action);
@@ -3497,6 +3499,10 @@ menus_init(void) {
         menu_dissector_filter(&cfile);
                /* Only LUA uses this currently. NOTE that "placeholders" must exist in the GUI description */
                merge_lua_menu_items(merge_lua_menu_items_list);
+
+               /* Add external menus and items */
+               ws_menubar_build_external_menus();
+
         /* Initialize enabled/disabled state of menu items */
         set_menus_for_capture_file(NULL);
 #if 0
@@ -3526,6 +3532,28 @@ menus_init(void) {
     }
 }
 
+/* Get a merge id for the menubar */
+void
+ws_add_build_menubar_items_callback(gpointer callback)
+{
+        build_menubar_items_callback_list = g_list_append(build_menubar_items_callback_list, callback);
+
+}
+
+static void
+ws_menubar_build_external_menus(void)
+{
+       void (*callback)(gpointer);
+
+       while(build_menubar_items_callback_list != NULL) {
+               callback = build_menubar_items_callback_list->data;
+               callback(ui_manager_main_menubar);
+               build_menubar_items_callback_list = g_list_next(build_menubar_items_callback_list);
+       }
+
+
+}
+
 typedef struct _menu_item {
     const char   *gui_path;
     const char   *name;