Handle -I in the options processing.
[obnox/wireshark/wip.git] / gtk / menus.c
index f613328e0e79f8270c5e923a916415b0fa5eeeec..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);
@@ -589,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,},
@@ -834,6 +838,8 @@ static GtkItemFactoryEntry packet_list_menu_items[] =
 #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,},
@@ -2161,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)
@@ -2366,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) {
@@ -2769,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",
@@ -3318,9 +3368,9 @@ 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)) {