Handle -I in the options processing.
[obnox/wireshark/wip.git] / gtk / menus.c
index c22e271e56f4627f03ca3e33bb8d26e62ebf59af..911f95d5dcf49b97b96f5a7db7dfc3d28c24a47f 100644 (file)
@@ -93,6 +93,7 @@
 #include "gtk/main_welcome.h"
 #include "gtk/uat_gui.h"
 #include "gtk/gui_utils.h"
+#include "gtk/manual_addr_resolv.h"
 
 #ifdef NEW_PACKET_LIST
 #include "gtk/new_packet_list.h"
@@ -131,6 +132,7 @@ static void set_menu_sensitivity (GtkItemFactory *, const gchar *, gint);
 static void show_hide_cb(GtkWidget *w, gpointer data, gint action);
 static void timestamp_format_cb(GtkWidget *w, gpointer d, gint action);
 static void timestamp_precision_cb(GtkWidget *w, gpointer d, gint action);
+static void timestamp_seconds_time_cb(GtkWidget *w, gpointer d, gint action);
 static void name_resolution_cb(GtkWidget *w, gpointer d, gint action);
 #ifdef HAVE_LIBPCAP
 static void auto_scroll_live_cb(GtkWidget *w, gpointer d);
@@ -518,11 +520,27 @@ static GtkItemFactoryEntry menu_items[] =
     {"/Edit/Find Previous Mark", "<shift><control>B", GTK_MENU_FUNC(find_prev_mark_cb),
                        0, NULL, NULL,},
 #ifdef NEW_PACKET_LIST
-    {"/Edit/Mark _All Packets", "<control>A", GTK_MENU_FUNC(new_packet_list_mark_all_frames_cb), 0, NULL, NULL,},
+    {"/Edit/Mark _All Displayed Packets", "<control>A", GTK_MENU_FUNC(new_packet_list_mark_all_frames_cb), 0, NULL, NULL,},
     {"/Edit/_Unmark All Packets", "<control>D", GTK_MENU_FUNC(new_packet_list_unmark_all_frames_cb), 0, NULL, NULL,},
 #else
-    {"/Edit/Mark _All Packets", "<control>A", GTK_MENU_FUNC(packet_list_mark_all_frames_cb), 0, NULL, NULL,},
+    {"/Edit/Mark _All Displayed Packets", "<control>A", GTK_MENU_FUNC(packet_list_mark_all_frames_cb), 0, NULL, NULL,},
     {"/Edit/_Unmark All Packets", "<control>D", GTK_MENU_FUNC(packet_list_unmark_all_frames_cb), 0, NULL, NULL,},
+#endif /* NEW_PACKET_LIST */
+    {"/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
+#ifdef NEW_PACKET_LIST
+    {"/Edit/_Ignore Packet (toggle)", "<control>X", GTK_MENU_FUNC(new_packet_list_ignore_frame_cb),
+                       0, NULL, NULL,},
+    {"/Edit/Ignore All Displayed Packets", "<alt><shift><control>X", GTK_MENU_FUNC(new_packet_list_ignore_all_frames_cb),
+                       0, NULL, NULL,},
+    {"/Edit/U_n-Ignore All Packets", "<shift><control>X", GTK_MENU_FUNC(new_packet_list_unignore_all_frames_cb),
+                       0, NULL, NULL,},
+#else
+    {"/Edit/_Ignore Packet (toggle)", "<control>X", GTK_MENU_FUNC(packet_list_ignore_frame_cb),
+                       0, NULL, NULL,},
+    {"/Edit/Ignore All Displayed Packets", "<alt><shift><control>X", GTK_MENU_FUNC(packet_list_ignore_all_frames_cb),
+                       0, NULL, NULL,},
+    {"/Edit/U_n-Ignore All Packets", "<shift><control>X", GTK_MENU_FUNC(packet_list_unignore_all_frames_cb),
+                       0, NULL, NULL,},
 #endif /* NEW_PACKET_LIST */
     {"/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
     {"/Edit/Set Time Reference (toggle)", "<control>T", GTK_MENU_FUNC(reftime_frame_cb),
@@ -573,6 +591,8 @@ static GtkItemFactoryEntry menu_items[] =
                         TS_PREC_FIXED_USEC, "/View/Time Display Format/Automatic (File Format Precision)", NULL,},
     {"/View/Time Display Format/Nanoseconds:   0.123456789", NULL, GTK_MENU_FUNC(timestamp_precision_cb),
                         TS_PREC_FIXED_NSEC, "/View/Time Display Format/Automatic (File Format Precision)", NULL,},
+    {"/View/Time Display Format/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
+    {"/View/Time Display Format/Display Seconds with hours and minutes", "<alt><control>0", GTK_MENU_FUNC(timestamp_seconds_time_cb), 0, "<CheckItem>", NULL,},
     {"/View/Name Resol_ution", NULL, NULL, 0, "<Branch>", NULL,},
     {"/View/Name Resolution/_Resolve Name", NULL, GTK_MENU_FUNC(resolve_name_cb), 0, NULL, NULL,},
     {"/View/Name Resolution/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
@@ -811,11 +831,15 @@ static GtkItemFactoryEntry packet_list_menu_items[] =
 {
 #ifdef NEW_PACKET_LIST
     {"/Mark Packet (toggle)", NULL, GTK_MENU_FUNC(new_packet_list_mark_frame_cb), 0, NULL, NULL,},
+    {"/Ignore Packet (toggle)", NULL, GTK_MENU_FUNC(new_packet_list_ignore_frame_cb), 0, NULL, NULL,},
 #else
     {"/Mark Packet (toggle)", NULL, GTK_MENU_FUNC(packet_list_mark_frame_cb), 0, NULL, NULL,},
+    {"/Ignore Packet (toggle)", NULL, GTK_MENU_FUNC(packet_list_ignore_frame_cb), 0, NULL, NULL,},
 #endif /* NEW_PACKET_LIST */
     {"/Set Time Reference (toggle)", NULL, GTK_MENU_FUNC(reftime_frame_cb), REFTIME_TOGGLE, "<StockItem>", WIRESHARK_STOCK_TIME,},
 
+    {"/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
+    {"/Manually Resolve Address", NULL, GTK_MENU_FUNC(manual_addr_resolv_dlg), 0, NULL, NULL,},
     {"/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
 
     {"/Apply as Filter", NULL, NULL, 0, "<Branch>", NULL,},
@@ -1858,7 +1882,7 @@ menu_open_filename(gchar *cf_name)
 
     /* open and read the capture file (this will close an existing file) */
     if (cf_open(&cfile, cf_name, FALSE, &err) == CF_OK) {
-        cf_read(&cfile);
+        cf_read(&cfile, FALSE);
     } else {
         /* the capture file apparently no longer exists; remove menu item    */
         /* XXX: ask user to remove item, it's maybe only a temporary problem */
@@ -1886,7 +1910,7 @@ menu_open_recent_file_cmd(GtkWidget *w)
 
     /* open and read the capture file (this will close an existing file) */
     if (cf_open(&cfile, cf_name, FALSE, &err) == CF_OK) {
-        cf_read(&cfile);
+        cf_read(&cfile, FALSE);
     } else {
         /* the capture file apparently no longer exists; remove menu item    */
         /* XXX: ask user to remove item, it's maybe only a temporary problem */
@@ -2143,6 +2167,24 @@ timestamp_precision_cb(GtkWidget *w _U_, gpointer d _U_, gint action)
     }
 }
 
+static void
+timestamp_seconds_time_cb(GtkWidget *w, gpointer d _U_, gint action _U_)
+{
+    if (GTK_CHECK_MENU_ITEM(w)->active) {
+        recent.gui_seconds_format = TS_SECONDS_HOUR_MIN_SEC;
+    } else {
+        recent.gui_seconds_format = TS_SECONDS_DEFAULT;
+    }
+    timestamp_set_seconds_type (recent.gui_seconds_format);
+
+#ifdef NEW_PACKET_LIST
+    /* This call adjusts column width */
+    cf_timestamp_auto_precision(&cfile);
+    new_packet_list_queue_draw();
+#else
+    cf_change_time_formats(&cfile);
+#endif
+}
 
 void
 menu_name_resolution_changed(void)
@@ -2348,6 +2390,30 @@ menu_recent_read_finished(void) {
     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), FALSE);
     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
 
+    /* don't change the seconds format, if we had a command line value */
+    if (timestamp_get_seconds_type() != TS_SECONDS_NOT_SET) {
+        recent.gui_seconds_format = timestamp_get_seconds_type();
+    }
+
+    menu = gtk_item_factory_get_widget(main_menu_factory,
+            "/View/Time Display Format/Display Seconds with hours and minutes");
+    switch (recent.gui_seconds_format) {
+    case TS_SECONDS_DEFAULT:
+        recent.gui_seconds_format = -1;
+        /* set_active will not trigger the callback when deactivating an inactive item! */
+        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
+        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), FALSE);
+        break;
+    case TS_SECONDS_HOUR_MIN_SEC:
+        recent.gui_seconds_format = -1;
+        /* set_active will not trigger the callback when activating an active item! */
+        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), FALSE);
+        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
+        break;
+    default:
+        g_assert_not_reached();
+    }
+
     menu_colorize_changed(recent.packet_list_colorize);
 
     switch (recent.gui_bytes_view) {
@@ -2408,7 +2474,7 @@ popup_menu_handler(GtkWidget *widget, GdkEvent *event, gpointer data)
     }
 
     /* Check if we are on tree_view object */
-    if (widget == tree_view) {
+    if (widget == tree_view_gbl) {
         tree_view_select(widget, (GdkEventButton *) event);
     }
 
@@ -2428,13 +2494,13 @@ popup_menu_handler(GtkWidget *widget, GdkEvent *event, gpointer data)
     }
 
     /* Check if we are on byte_view object */
-    if(widget == get_notebook_bv_ptr(byte_nb_ptr)) {
+    if(widget == get_notebook_bv_ptr(byte_nb_ptr_gbl)) {
         byte_view_select(widget, (GdkEventButton *) event);
     }
 
     /* GDK_2BUTTON_PRESS is a doubleclick -> expand/collapse tree row */
     /* GTK version 1 seems to be doing this automatically */
-    if (widget == tree_view && event->type == GDK_2BUTTON_PRESS) {
+    if (widget == tree_view_gbl && event->type == GDK_2BUTTON_PRESS) {
         GtkTreePath      *path;
 
         if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget),
@@ -2713,10 +2779,18 @@ set_menus_for_selected_packet(capture_file *cf)
                          cf->current_frame != NULL);
     set_menu_sensitivity(main_menu_factory, "/Edit/Find Previous Mark",
                          cf->current_frame != NULL);
-    set_menu_sensitivity(main_menu_factory, "/Edit/Mark All Packets",
+    set_menu_sensitivity(main_menu_factory, "/Edit/Mark All Displayed Packets",
                          cf->current_frame != NULL);
     set_menu_sensitivity(main_menu_factory, "/Edit/Unmark All Packets",
                          cf->current_frame != NULL);
+    set_menu_sensitivity(main_menu_factory, "/Edit/Ignore Packet (toggle)",
+                         cf->current_frame != NULL);
+    set_menu_sensitivity(main_menu_factory, "/Edit/Ignore All Displayed Packets",
+                         cf->current_frame != NULL);
+    set_menu_sensitivity(main_menu_factory, "/Edit/Un-Ignore All Packets",
+                         cf->current_frame != NULL);
+    set_menu_sensitivity(packet_list_menu_factory, "/Ignore Packet (toggle)",
+                         cf->current_frame != NULL);
     set_menu_sensitivity(main_menu_factory, "/Edit/Set Time Reference (toggle)",
                          cf->current_frame != NULL);
     set_menu_sensitivity(packet_list_menu_factory, "/Set Time Reference (toggle)",
@@ -2743,6 +2817,8 @@ set_menus_for_selected_packet(capture_file *cf)
                          cf->current_frame != NULL);
     set_menu_sensitivity(packet_list_menu_factory, "/Show Packet in New Window",
                          cf->current_frame != NULL);
+    set_menu_sensitivity(packet_list_menu_factory, "/Manually Resolve Address",
+                         cf->current_frame != NULL ? ((cf->edt->pi.ethertype == ETHERTYPE_IP)||(cf->edt->pi.ethertype == ETHERTYPE_IPv6)) : FALSE);
     set_menu_sensitivity(packet_list_menu_factory, "/SCTP",
                          cf->current_frame != NULL ? (cf->edt->pi.ipproto == IP_PROTO_SCTP) : FALSE);
     set_menu_sensitivity(main_menu_factory, "/Analyze/Follow TCP Stream",
@@ -3161,7 +3237,7 @@ add_protocol_prefs_menu (pref_t *pref, gpointer data)
 }
 
 static void
-rebuild_protocol_prefs_menu (module_t *prefs, gboolean preferences)
+rebuild_protocol_prefs_menu (module_t *prefs_module_p, gboolean preferences)
 {
     GtkWidget *menu_preferences, *menu_item;
     GtkWidget *sub_menu;
@@ -3173,7 +3249,7 @@ rebuild_protocol_prefs_menu (module_t *prefs, gboolean preferences)
         sub_menu = gtk_menu_new();
         gtk_menu_item_set_submenu (GTK_MENU_ITEM(menu_preferences), sub_menu);
 
-        label = g_strdup_printf ("%s Preferences...", prefs->description);
+        label = g_strdup_printf ("%s Preferences...", prefs_module_p->description);
         menu_item = gtk_image_menu_item_new_with_label (label);
         gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(menu_item), 
                                        gtk_image_new_from_stock(GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU));
@@ -3187,7 +3263,7 @@ rebuild_protocol_prefs_menu (module_t *prefs, gboolean preferences)
         gtk_menu_shell_append (GTK_MENU_SHELL(sub_menu), menu_item);
         gtk_widget_show (menu_item);
 
-        prefs_pref_foreach(prefs, add_protocol_prefs_menu, prefs);
+        prefs_pref_foreach(prefs_module_p, add_protocol_prefs_menu, prefs_module_p);
     } else {
         /* No preferences, remove sub menu */
         gtk_menu_item_set_submenu (GTK_MENU_ITEM(menu_preferences), NULL);
@@ -3292,15 +3368,15 @@ set_menus_for_selected_tree_row(capture_file *cf)
         set_menu_sensitivity(main_menu_factory, "/View/Expand Subtrees", cf->finfo_selected->tree_type != -1);
         set_menu_sensitivity(tree_view_menu_factory, "/Expand Subtrees", cf->finfo_selected->tree_type != -1);
         set_menu_sensitivity(tree_view_menu_factory, "/Wiki Protocol Page",
-                             TRUE);
+                             (id == -1) ? FALSE : TRUE);
         set_menu_sensitivity(tree_view_menu_factory, "/Filter Field Reference",
-                             TRUE);
+                             (id == -1) ? FALSE : TRUE);
         
         prev_abbrev = g_object_get_data(G_OBJECT(tree_view_menu_factory), "menu_abbrev");
         if (!prev_abbrev || (strcmp (prev_abbrev, abbrev) != 0)) {
             /* No previous protocol or protocol changed - update Protocol Preferences menu */
-            module_t *prefs = prefs_find_module(abbrev);
-            rebuild_protocol_prefs_menu (prefs, properties);
+            module_t *prefs_module_p = prefs_find_module(abbrev);
+            rebuild_protocol_prefs_menu (prefs_module_p, properties);
 
             g_object_set_data(G_OBJECT(tree_view_menu_factory), "menu_abbrev", g_strdup(abbrev));
             g_free (prev_abbrev);