Fix build (automake) error: WIRESHARK_CUSTOM_HEADERS is ng but WIRESHARK_CUSTOM_HDRS...
[obnox/wireshark/wip.git] / gtk / follow_stream.c
index 074ea8c5e67c6fbca3248c66c16b4816dc5f8b4e..c2bc5ee4ba8cd90a5324dbc115e4c8c28aa7876a 100644 (file)
@@ -45,9 +45,9 @@
 #include <../isprint.h>
 #include <../print.h>
 #include <../simple_dialog.h>
-#include <wiretap/file_util.h>
+#include <wsutil/file_util.h>
 
-#include <gtk/colors.h>
+#include <gtk/color_utils.h>
 #include <gtk/stock_icons.h>
 #include <gtk/dlg_utils.h>
 #include <gtk/follow_stream.h>
 #include <gtk/gui_utils.h>
 #include <gtk/help_dlg.h>
 #include "gtk/main.h"
-#include "gtk/print_mswin.h"
+#include "gtk/old-gtk-compat.h"
 
-
-/* This is backwards-compatibility code for old versions of GTK+ (2.2.1 and
- * earlier).  It defines the new wrap behavior (unknown in earlier versions)
- * as the old (slightly buggy) wrap behavior.
- */
-#ifndef GTK_WRAP_WORD_CHAR
-#define GTK_WRAP_WORD_CHAR GTK_WRAP_WORD
+#ifdef _WIN32
+#include "../tempfile.h"
+#include "win32/print_win32.h"
 #endif
 
 /* static variable declarations to speed up the performance
@@ -74,25 +70,29 @@ static GdkColor server_fg, server_bg;
 static GdkColor client_fg, client_bg;
 static GtkTextTag *server_tag, *client_tag;
 
+static void follow_find_destroy_cb(GtkWidget * win _U_, gpointer data);
+static void follow_find_button_cb(GtkWidget * w, gpointer data);
+static gboolean follow_save_as_ok_cb(GtkWidget * w _U_, gpointer fs);
 static void follow_destroy_cb(GtkWidget *w, gpointer data _U_);
+static void follow_save_as_destroy_cb(GtkWidget * win _U_, gpointer data);
 
 GList *follow_infos = NULL;
 
-frs_return_t
+static frs_return_t
 follow_read_stream(follow_info_t *follow_info,
-                  gboolean (*print_line)(char *, size_t, gboolean, void *),
+                  gboolean (*print_line_fcn_p)(char *, size_t, gboolean, void *),
                   void *arg)
 {
        switch(follow_info->follow_type) {
 
        case FOLLOW_TCP :
-               return follow_read_tcp_stream(follow_info, print_line, arg);
+               return follow_read_tcp_stream(follow_info, print_line_fcn_p, arg);
 
        case FOLLOW_UDP :
-               return follow_read_udp_stream(follow_info, print_line, arg);
+               return follow_read_udp_stream(follow_info, print_line_fcn_p, arg);
 
        case FOLLOW_SSL :
-               return follow_read_ssl_stream(follow_info, print_line, arg);
+               return follow_read_ssl_stream(follow_info, print_line_fcn_p, arg);
 
        default :
                g_assert_not_reached();
@@ -109,7 +109,7 @@ follow_add_to_gtk_text(char *buffer, size_t nchars, gboolean is_server,
        GtkTextIter    iter;
 
        /* While our isprint() hack is in place, we
-        * have to use convert some chars to '.' in order
+        * have to convert some chars to '.' in order
         * to be able to see the data we *should* see
         * in the GtkText widget.
         */
@@ -125,10 +125,10 @@ follow_add_to_gtk_text(char *buffer, size_t nchars, gboolean is_server,
 
        gtk_text_buffer_get_end_iter(buf, &iter);
        if (is_server) {
-               gtk_text_buffer_insert_with_tags(buf, &iter, buffer, nchars,
+               gtk_text_buffer_insert_with_tags(buf, &iter, buffer, (gint) nchars,
                                                 server_tag, NULL);
        } else {
-               gtk_text_buffer_insert_with_tags(buf, &iter, buffer, nchars,
+               gtk_text_buffer_insert_with_tags(buf, &iter, buffer, (gint) nchars,
                                                 client_tag, NULL);
        }
        return TRUE;
@@ -141,7 +141,7 @@ follow_add_to_gtk_text(char *buffer, size_t nchars, gboolean is_server,
  * lines of what's done when displaying this in a window, as per Warren Young's
  * suggestion.
  */
-gboolean
+static gboolean
 follow_print_text(char *buffer, size_t nchars, gboolean is_server _U_,
                  void *arg)
 {
@@ -168,7 +168,7 @@ follow_print_text(char *buffer, size_t nchars, gboolean is_server _U_,
        return TRUE;
 }
 
-gboolean
+static gboolean
 follow_write_raw(char *buffer, size_t nchars, gboolean is_server _U_, void *arg)
 {
        FILE *fh = arg;
@@ -182,7 +182,7 @@ follow_write_raw(char *buffer, size_t nchars, gboolean is_server _U_, void *arg)
 }
 
 /* Handles the display style toggling */
-void
+static void
 follow_charset_toggle_cb(GtkWidget * w _U_, gpointer data)
 {
        follow_info_t   *follow_info = data;
@@ -193,7 +193,7 @@ follow_charset_toggle_cb(GtkWidget * w _U_, gpointer data)
         * delivered.  We only want to reprocess the display once,
         * so we do it only when the button goes on.
         */
-       if (GTK_TOGGLE_BUTTON(w)->active) {
+       if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))) {
                if (w == follow_info->ebcdic_bt)
                        follow_info->show_type = SHOW_EBCDIC;
                else if (w == follow_info->hexdump_bt)
@@ -259,17 +259,13 @@ follow_filter_out_stream(GtkWidget * w _U_, gpointer data)
        return;
 }
 
-#if GTK_CHECK_VERSION(2,4,0)
-void
+static void
 follow_find_cb(GtkWidget * w _U_, gpointer data)
 {
        follow_info_t           *follow_info = data;
-       GtkTooltips             *tooltips;
        GtkWidget               *find_dlg_w, *main_vb, *buttons_row, *find_lb;
        GtkWidget               *find_hb, *find_text_box, *find_bt, *cancel_bt;
 
-       tooltips = gtk_tooltips_new();
-
        if (follow_info->find_dlg_w != NULL) {
                /* There's already a dialog box; reactivate it. */
                reactivate_window(follow_info->find_dlg_w);
@@ -290,7 +286,7 @@ follow_find_cb(GtkWidget * w _U_, gpointer data)
 
        /* Main vertical box */
        main_vb = gtk_vbox_new(FALSE, 3);
-       gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
+       gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
        gtk_container_add(GTK_CONTAINER(find_dlg_w), main_vb);
 
        /* Horizontal box for find label, entry field and up/down radio
@@ -307,7 +303,7 @@ follow_find_cb(GtkWidget * w _U_, gpointer data)
        /* Find field */
        find_text_box = gtk_entry_new();
        gtk_box_pack_start(GTK_BOX(find_hb), find_text_box, FALSE, FALSE, 0);
-       gtk_tooltips_set_tip(tooltips, find_text_box, "Text to search for (case sensitive)", NULL);
+       gtk_widget_set_tooltip_text(find_text_box, "Text to search for (case sensitive)");
        gtk_widget_show(find_text_box);
 
        /* Buttons row */
@@ -330,7 +326,7 @@ follow_find_cb(GtkWidget * w _U_, gpointer data)
        window_present(find_dlg_w);
 }
 
-void
+static void
 follow_find_button_cb(GtkWidget * w, gpointer data)
 {
        gboolean                found;
@@ -378,7 +374,7 @@ follow_find_button_cb(GtkWidget * w, gpointer data)
 
 }
 
-void
+static void
 follow_find_destroy_cb(GtkWidget * win _U_, gpointer data)
 {
        follow_info_t   *follow_info = data;
@@ -386,25 +382,41 @@ follow_find_destroy_cb(GtkWidget * win _U_, gpointer data)
        /* Note that we no longer have a dialog box. */
        follow_info->find_dlg_w = NULL;
 }
-#endif /* GTK_CHECK_VERSION(2,4,0) */
 
-void
+static void
 follow_print_stream(GtkWidget * w _U_, gpointer data)
 {
        print_stream_t  *stream;
-       gboolean                to_file;
+       gboolean         to_file;
        char            *print_dest;
        follow_info_t   *follow_info = data;
 #ifdef _WIN32
-       gboolean win_printer = FALSE;
+       gboolean         win_printer = FALSE;
+       int              tmp_fd;
+       char             *tmp_namebuf;
 #endif
 
        switch (prefs.pr_dest) {
        case PR_DEST_CMD:
 #ifdef _WIN32
                win_printer = TRUE;
-               /*XXX should use temp file stuff in util routines */
-               print_dest = g_strdup(tmpnam(NULL));
+               /* (The code for creating a temp filename is adapted from print_dlg.c).   */
+               /* We currently don't have a function in util.h to create just a tempfile */
+               /* name, so simply create a tempfile using the "official" function,       */
+               /* then delete this file again. After this, the name MUST be available.   */
+               /* */
+               /* Don't use tmpnam() or such, as this will fail under some ACL           */
+               /* circumstances: http://bugs.wireshark.org/bugzilla/show_bug.cgi?id=358  */
+               /* Also: tmpnam is "insecure" and should not be used.                     */
+               tmp_fd = create_tempfile(&tmp_namebuf, "wshprint");
+               if(tmp_fd == -1) {
+                       simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+                                     "Couldn't create temporary file for printing:\n%s", tmp_namebuf);
+                       return;
+               }
+               ws_close(tmp_fd);
+               ws_unlink(tmp_namebuf);
+               print_dest = tmp_namebuf;
                to_file = TRUE;
 #else
                print_dest = prefs.pr_cmd;
@@ -438,7 +450,7 @@ follow_print_stream(GtkWidget * w _U_, gpointer data)
        }
        if (stream == NULL) {
                if (to_file) {
-                       open_failure_alert_box(prefs.pr_file, errno, TRUE);
+                       open_failure_alert_box(print_dest, errno, TRUE);
                } else {
                        simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
                                      "Couldn't run print command %s.",
@@ -467,7 +479,7 @@ follow_print_stream(GtkWidget * w _U_, gpointer data)
 
        if (!destroy_print_stream(stream)) {
                if (to_file) {
-                       write_failure_alert_box(prefs.pr_file, errno);
+                       write_failure_alert_box(print_dest, errno);
                } else {
                        simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
                                      "Error closing print destination.");
@@ -478,18 +490,18 @@ follow_print_stream(GtkWidget * w _U_, gpointer data)
                print_mswin(print_dest);
 
                /* trash temp file */
-               eth_remove(print_dest);
+               ws_remove(print_dest);
        }
 #endif
        return;
 
  print_error:
        if (to_file) {
-               write_failure_alert_box(prefs.pr_file, errno);
+               write_failure_alert_box(print_dest, errno);
        } else {
                simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
                              "Error writing to print command: %s",
-                             strerror(errno));
+                             g_strerror(errno));
        }
        /* XXX - cancel printing? */
        destroy_print_stream(stream);
@@ -497,32 +509,35 @@ follow_print_stream(GtkWidget * w _U_, gpointer data)
 #ifdef _WIN32
        if (win_printer) {
                /* trash temp file */
-               eth_remove(print_dest);
+               ws_remove(print_dest);
        }
 #endif
 }
 
 /*
- * Keep a static pointer to the current "Save TCP Follow Stream As" window, if
+ * Keep a static pointer to the current "Save Follow Stream As" window, if
  * any, so that if somebody tries to do "Save"
- * while there's already a "Save TCP Follow Stream" window up, we just pop
+ * while there's already a "Save Follow Stream" window up, we just pop
  * up the existing one, rather than creating a new one.
  */
-void
+
+static void
 follow_save_as_cmd_cb(GtkWidget *w _U_, gpointer data)
 {
        GtkWidget               *new_win;
        follow_info_t   *follow_info = data;
 
+#if 0  /* XXX: GtkFileChooserDialog/gtk_dialog_run currently being used is effectively modal so this is not req'd */
        if (follow_info->follow_save_as_w != NULL) {
                /* There's already a dialog box; reactivate it. */
                reactivate_window(follow_info->follow_save_as_w);
                return;
        }
-
+#endif
        new_win = file_selection_new("Wireshark: Save Follow Stream As",
                                     FILE_SELECTION_SAVE);
        follow_info->follow_save_as_w = new_win;
+       gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(new_win), TRUE);
 
        /* Tuck away the follow_info object into the window */
        g_object_set_data(G_OBJECT(new_win), E_FOLLOW_INFO_KEY, follow_info);
@@ -530,34 +545,37 @@ follow_save_as_cmd_cb(GtkWidget *w _U_, gpointer data)
        g_signal_connect(new_win, "destroy", G_CALLBACK(follow_save_as_destroy_cb),
                       follow_info);
 
-#if GTK_CHECK_VERSION(2,4,0)
+#if 0
        if (gtk_dialog_run(GTK_DIALOG(new_win)) == GTK_RESPONSE_ACCEPT)
                {
                        follow_save_as_ok_cb(new_win, new_win);
                } else {
                window_destroy(new_win);
        }
-#else
-       /* Connect the ok_button to file_save_as_ok_cb function and pass along a
-          pointer to the file selection box widget */
-       g_signal_connect(GTK_FILE_SELECTION(new_win)->ok_button,
-                      "clicked", G_CALLBACK(follow_save_as_ok_cb), new_win);
-
-       window_set_cancel_button(new_win,
-                                GTK_FILE_SELECTION(new_win)->cancel_button,
-                                window_cancel_button_cb);
-
-       gtk_file_selection_set_filename(GTK_FILE_SELECTION(new_win), "");
-
-       g_signal_connect(new_win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
-
-       gtk_widget_show_all(new_win);
-       window_present(new_win);
 #endif
+       /* "Run" the GtkFileChooserDialog.                                              */
+       /* Upon exit: If "Accept" run the OK callback.                                  */
+       /*            If the OK callback returns with a FALSE status, re-run the dialog.*/
+       /*            If not accept (ie: cancel) destroy the window.                    */
+       /* XXX: If the OK callback pops up an alert box (eg: for an error) it *must*    */
+       /*      return with a TRUE status so that the dialog window will be destroyed.  */
+       /*      Trying to re-run the dialog after popping up an alert box will not work */
+       /*       since the user will not be able to dismiss the alert box.              */
+       /*      The (somewhat unfriendly) effect: the user must re-invoke the           */
+       /*      GtkFileChooserDialog whenever the OK callback pops up an alert box.     */
+       /*                                                                              */
+       /*      ToDo: use GtkFileChooserWidget in a dialog window instead of            */
+       /*            GtkFileChooserDialog.                                             */
+       while (gtk_dialog_run(GTK_DIALOG(new_win)) == GTK_RESPONSE_ACCEPT) {
+               if (follow_save_as_ok_cb(NULL, new_win)) {
+                   break; /* we're done */
+               }
+       }
+       window_destroy(new_win);
 }
 
 
-void
+static gboolean
 follow_save_as_ok_cb(GtkWidget * w _U_, gpointer fs)
 {
        gchar           *to_name;
@@ -566,11 +584,7 @@ follow_save_as_ok_cb(GtkWidget * w _U_, gpointer fs)
        print_stream_t  *stream = NULL;
        gchar           *dirname;
 
-#if GTK_CHECK_VERSION(2,4,0)
-       to_name = g_strdup(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fs)));
-#else
-       to_name = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(fs)));
-#endif
+       to_name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fs));
 
        /* Perhaps the user specified a directory instead of a file.
           Check whether they did. */
@@ -580,26 +594,29 @@ follow_save_as_ok_cb(GtkWidget * w _U_, gpointer fs)
                set_last_open_dir(to_name);
                g_free(to_name);
                file_selection_set_current_folder(fs, get_last_open_dir());
-               return;
+               gtk_file_chooser_set_current_name(fs, "");
+               return FALSE; /* do gtk_dialog_run again */
        }
 
        follow_info = g_object_get_data(G_OBJECT(fs), E_FOLLOW_INFO_KEY);
+
        if (follow_info->show_type == SHOW_RAW) {
                /* Write the data out as raw binary data */
-               fh = eth_fopen(to_name, "wb");
+               fh = ws_fopen(to_name, "wb");
        } else {
                /* Write it out as text */
-               fh = eth_fopen(to_name, "w");
+               fh = ws_fopen(to_name, "w");
        }
        if (fh == NULL) {
                open_failure_alert_box(to_name, errno, TRUE);
                g_free(to_name);
-               return;
+               return TRUE;
        }
 
+#if 0 /* handled by caller (for now) .... */
        gtk_widget_hide(GTK_WIDGET(fs));
        window_destroy(GTK_WIDGET(fs));
-
+#endif
        if (follow_info->show_type == SHOW_RAW) {
                switch (follow_read_stream(follow_info, follow_write_raw, fh)) {
                case FRS_OK:
@@ -642,9 +659,10 @@ follow_save_as_ok_cb(GtkWidget * w _U_, gpointer fs)
        dirname = get_dirname(to_name);  /* Overwrites to_name */
        set_last_open_dir(dirname);
        g_free(to_name);
+       return TRUE;
 }
 
-void
+static void
 follow_save_as_destroy_cb(GtkWidget * win _U_, gpointer data)
 {
        follow_info_t   *follow_info = data;
@@ -653,37 +671,30 @@ follow_save_as_destroy_cb(GtkWidget * win _U_, gpointer data)
        follow_info->follow_save_as_w = NULL;
 }
 
-/* XXX - can I emulate follow_charset_toggle_cb() instead of having
- * 3 different functions here?
- * That might not be a bad idea, as it might mean we only reload
- * the window once, not twice - see follow_charset_toggle_cb()
- * for an explanation. */
-void
-follow_stream_om_both(GtkWidget *w _U_, gpointer data)
+static void
+follow_stream_direction_changed(GtkWidget *w, gpointer data)
 {
-       follow_info_t   *follow_info = data;
-       follow_info->show_stream = BOTH_HOSTS;
-       follow_load_text(follow_info);
-}
+       follow_info_t *follow_info = data;
 
-void
-follow_stream_om_client(GtkWidget *w _U_, gpointer data)
-{
-       follow_info_t   *follow_info = data;
-       follow_info->show_stream = FROM_CLIENT;
-       follow_load_text(follow_info);
-}
+       switch(gtk_combo_box_get_active(GTK_COMBO_BOX(w))) {
 
-void
-follow_stream_om_server(GtkWidget *w _U_, gpointer data)
-{
-       follow_info_t   *follow_info = data;
-       follow_info->show_stream = FROM_SERVER;
-       follow_load_text(follow_info);
+       case 0 :
+               follow_info->show_stream = BOTH_HOSTS;
+               follow_load_text(follow_info);
+               break;
+       case 1 :
+               follow_info->show_stream = FROM_CLIENT;
+               follow_load_text(follow_info);
+               break;
+       case 2 :
+               follow_info->show_stream = FROM_SERVER;
+               follow_load_text(follow_info);
+               break;
+       }
 }
 
 /* Add a "follow_info_t" structure to the list. */
-void
+static void
 remember_follow_info(follow_info_t *follow_info)
 {
        follow_infos = g_list_append(follow_infos, follow_info);
@@ -691,7 +702,7 @@ remember_follow_info(follow_info_t *follow_info)
 
 #define IS_SHOW_TYPE(x) (follow_info->show_type == x ? 1 : 0)
 /* Remove a "follow_info_t" structure from the list. */
-void
+static void
 forget_follow_info(follow_info_t *follow_info)
 {
        follow_infos = g_list_remove(follow_infos, follow_info);
@@ -704,9 +715,8 @@ follow_stream(gchar *title, follow_info_t *follow_info,
 {
        GtkWidget       *streamwindow, *vbox, *txt_scrollw, *text;
        GtkWidget       *hbox, *bbox, *button, *radio_bt;
-       GtkWidget       *stream_fr, *stream_vb;
-       GtkWidget       *stream_om, *stream_menu, *stream_mi;
-       GtkTooltips     *tooltips;
+       GtkWidget       *stream_fr, *stream_vb, *direction_hbox;
+       GtkWidget       *stream_cmb;
        follow_stats_t stats;
 
        follow_info->show_type = SHOW_RAW;
@@ -719,11 +729,9 @@ follow_stream(gchar *title, follow_info_t *follow_info,
        gtk_widget_set_name(streamwindow, title);
        gtk_window_set_default_size(GTK_WINDOW(streamwindow),
                                    DEF_WIDTH, DEF_HEIGHT);
-       gtk_container_border_width(GTK_CONTAINER(streamwindow), 6);
+       gtk_container_set_border_width(GTK_CONTAINER(streamwindow), 6);
 
        /* setup the container */
-       tooltips = gtk_tooltips_new ();
-
        vbox = gtk_vbox_new(FALSE, 6);
        gtk_container_add(GTK_CONTAINER(streamwindow), vbox);
 
@@ -754,151 +762,140 @@ follow_stream(gchar *title, follow_info_t *follow_info,
        gtk_container_add(GTK_CONTAINER(txt_scrollw), text);
        follow_info->text = text;
 
+       /* direction hbox */
+       direction_hbox = gtk_hbox_new(FALSE, 1);
+       gtk_box_pack_start(GTK_BOX(stream_vb), direction_hbox, FALSE, FALSE, 0);
+
+       stream_cmb = gtk_combo_box_text_new();
+
+       gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(stream_cmb),
+                                 both_directions_string);
+       follow_info->show_stream = BOTH_HOSTS;
+
+       gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(stream_cmb),
+                                 server_to_client_string);
+
+       gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(stream_cmb),
+                                  client_to_server_string);
+
+       gtk_combo_box_set_active(GTK_COMBO_BOX(stream_cmb), 0); /* Do this before signal_connect  */
+                                                               /*  so callback not triggered     */
+
+       g_signal_connect(stream_cmb, "changed",
+                        G_CALLBACK(follow_stream_direction_changed),
+                        follow_info);
+
+       gtk_widget_set_tooltip_text(stream_cmb, "Select the stream direction to display");
+       gtk_box_pack_start(GTK_BOX(direction_hbox), stream_cmb, TRUE, TRUE, 0);
+
        /* stream hbox */
        hbox = gtk_hbox_new(FALSE, 1);
        gtk_box_pack_start(GTK_BOX(stream_vb), hbox, FALSE, FALSE, 0);
 
-#if GTK_CHECK_VERSION(2,4,0)
        /* Create Find Button */
        button = gtk_button_new_from_stock(GTK_STOCK_FIND);
        g_signal_connect(button, "clicked", G_CALLBACK(follow_find_cb), follow_info);
-       gtk_tooltips_set_tip (tooltips, button, "Find text in the displayed content", NULL);
-       gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
-#endif
+       gtk_widget_set_tooltip_text(button, "Find text in the displayed content");
+       gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
 
        /* Create Save As Button */
        button = gtk_button_new_from_stock(GTK_STOCK_SAVE_AS);
        g_signal_connect(button, "clicked", G_CALLBACK(follow_save_as_cmd_cb), follow_info);
-       gtk_tooltips_set_tip (tooltips, button, "Save the content as currently displayed", NULL);
-       gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
+       gtk_widget_set_tooltip_text(button, "Save the content as currently displayed");
+       gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
 
        /* Create Print Button */
-        button = gtk_button_new_from_stock(GTK_STOCK_PRINT);
-        g_signal_connect(button, "clicked", G_CALLBACK(follow_print_stream), follow_info);
-        gtk_tooltips_set_tip(tooltips, button, "Print the content as currently displayed", NULL);
-        gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
+       button = gtk_button_new_from_stock(GTK_STOCK_PRINT);
+       g_signal_connect(button, "clicked", G_CALLBACK(follow_print_stream), follow_info);
+       gtk_widget_set_tooltip_text(button, "Print the content as currently displayed");
+       gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
 
        /* Stream to show */
        follow_stats(&stats);
 
        follow_info->is_ipv6 = stats.is_ipv6;
 
-       stream_om = gtk_option_menu_new();
-       stream_menu = gtk_menu_new();
-
-       stream_mi = gtk_menu_item_new_with_label(both_directions_string);
-       g_signal_connect(stream_mi, "activate", G_CALLBACK(follow_stream_om_both),
-                       follow_info);
-       gtk_menu_append(GTK_MENU(stream_menu), stream_mi);
-       gtk_widget_show(stream_mi);
-       follow_info->show_stream = BOTH_HOSTS;
-
-       stream_mi = gtk_menu_item_new_with_label(server_to_client_string);
-       g_signal_connect(stream_mi, "activate", G_CALLBACK(follow_stream_om_client),
-                       follow_info);
-       gtk_menu_append(GTK_MENU(stream_menu), stream_mi);
-       gtk_widget_show(stream_mi);
-
-       stream_mi = gtk_menu_item_new_with_label(client_to_server_string);
-       g_signal_connect(stream_mi, "activate", G_CALLBACK(follow_stream_om_server),
-                       follow_info);
-       gtk_menu_append(GTK_MENU(stream_menu), stream_mi);
-       gtk_widget_show(stream_mi);
-
-       gtk_option_menu_set_menu(GTK_OPTION_MENU(stream_om), stream_menu);
-       /* Set history to 0th item, i.e., the first item. */
-       gtk_option_menu_set_history(GTK_OPTION_MENU(stream_om), 0);
-       gtk_tooltips_set_tip (tooltips, stream_om,
-                             "Select the stream direction to display", NULL);
-       gtk_box_pack_start(GTK_BOX(hbox), stream_om, FALSE, FALSE, 0);
-
        /* ASCII radio button */
        radio_bt = gtk_radio_button_new_with_label(NULL, "ASCII");
-       gtk_tooltips_set_tip (tooltips, radio_bt, "Stream data output in \"ASCII\" format", NULL);
+       gtk_widget_set_tooltip_text(radio_bt, "Stream data output in \"ASCII\" format");
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_bt),
                IS_SHOW_TYPE(SHOW_ASCII));
-       gtk_box_pack_start(GTK_BOX(hbox), radio_bt, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(hbox), radio_bt, TRUE, TRUE, 0);
        g_signal_connect(radio_bt, "toggled", G_CALLBACK(follow_charset_toggle_cb),
-                       follow_info);
+                      follow_info);
        follow_info->ascii_bt = radio_bt;
 
        /* EBCDIC radio button */
-       radio_bt = gtk_radio_button_new_with_label(gtk_radio_button_group
+       radio_bt = gtk_radio_button_new_with_label(gtk_radio_button_get_group
                                                   (GTK_RADIO_BUTTON(radio_bt)),
                                                   "EBCDIC");
-       gtk_tooltips_set_tip (tooltips, radio_bt, "Stream data output in \"EBCDIC\" format", NULL);
+       gtk_widget_set_tooltip_text(radio_bt, "Stream data output in \"EBCDIC\" format");
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_bt),
                IS_SHOW_TYPE(SHOW_EBCDIC));
-       gtk_box_pack_start(GTK_BOX(hbox), radio_bt, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(hbox), radio_bt, TRUE, TRUE, 0);
        g_signal_connect(radio_bt, "toggled", G_CALLBACK(follow_charset_toggle_cb),
-                       follow_info);
+                      follow_info);
        follow_info->ebcdic_bt = radio_bt;
 
        /* HEX DUMP radio button */
-       radio_bt = gtk_radio_button_new_with_label(gtk_radio_button_group
+       radio_bt = gtk_radio_button_new_with_label(gtk_radio_button_get_group
                                                   (GTK_RADIO_BUTTON(radio_bt)),
                                                   "Hex Dump");
-       gtk_tooltips_set_tip (tooltips, radio_bt, "Stream data output in \"Hexdump\" format", NULL);
+       gtk_widget_set_tooltip_text(radio_bt, "Stream data output in \"Hexdump\" format");
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_bt),
                IS_SHOW_TYPE(SHOW_HEXDUMP));
-       gtk_box_pack_start(GTK_BOX(hbox), radio_bt, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(hbox), radio_bt, TRUE, TRUE, 0);
        g_signal_connect(radio_bt, "toggled", G_CALLBACK(follow_charset_toggle_cb),
-                       follow_info);
+                      follow_info);
        follow_info->hexdump_bt = radio_bt;
 
        /* C Array radio button */
-       radio_bt = gtk_radio_button_new_with_label(gtk_radio_button_group
+       radio_bt = gtk_radio_button_new_with_label(gtk_radio_button_get_group
                                                   (GTK_RADIO_BUTTON(radio_bt)),
                                                   "C Arrays");
-       gtk_tooltips_set_tip (tooltips, radio_bt, "Stream data output in \"C Array\" format", NULL);
+       gtk_widget_set_tooltip_text(radio_bt, "Stream data output in \"C Array\" format");
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_bt),
                IS_SHOW_TYPE(SHOW_CARRAY));
-       gtk_box_pack_start(GTK_BOX(hbox), radio_bt, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(hbox), radio_bt, TRUE, TRUE, 0);
        g_signal_connect(radio_bt, "toggled", G_CALLBACK(follow_charset_toggle_cb),
-                       follow_info);
+                      follow_info);
        follow_info->carray_bt = radio_bt;
 
        /* Raw radio button */
-       radio_bt = gtk_radio_button_new_with_label(gtk_radio_button_group
+       radio_bt = gtk_radio_button_new_with_label(gtk_radio_button_get_group
                                                   (GTK_RADIO_BUTTON(radio_bt)),
                                                   "Raw");
-       gtk_tooltips_set_tip (tooltips, radio_bt, "Stream data output in \"Raw\" (binary) format. As this contains non printable characters, the screen output will be in ASCII format", NULL);
+       gtk_widget_set_tooltip_text(radio_bt,
+                                    "Stream data output in \"Raw\" (binary) format. "
+                                    "As this contains non printable characters, "
+                                    "the screen output will be in ASCII format");
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_bt),
                IS_SHOW_TYPE(SHOW_RAW));
-       gtk_box_pack_start(GTK_BOX(hbox), radio_bt, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(hbox), radio_bt, TRUE, TRUE, 0);
        g_signal_connect(radio_bt, "toggled", G_CALLBACK(follow_charset_toggle_cb),
-                       follow_info);
+                      follow_info);
        follow_info->raw_bt = radio_bt;
 
-       /* Button row: (help), filter out, close button */
-       if(topic_available(HELP_FILESET_DIALOG)) {
-               bbox = dlg_button_row_new(WIRESHARK_STOCK_FILTER_OUT_STREAM,
-                                         GTK_STOCK_CLOSE, GTK_STOCK_HELP,
-                                         NULL);
-       } else {
-               bbox = dlg_button_row_new(WIRESHARK_STOCK_FILTER_OUT_STREAM,
-                                         GTK_STOCK_CLOSE, NULL);
-       }
+       /* Button row: help, filter out, close button */
+       bbox = dlg_button_row_new(WIRESHARK_STOCK_FILTER_OUT_STREAM,
+                                 GTK_STOCK_CLOSE, GTK_STOCK_HELP,
+                                 NULL);
        gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5);
 
 
        button = g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_FILTER_OUT_STREAM);
-       gtk_tooltips_set_tip (tooltips, button,
-                             "Build a display filter which cuts this stream from the capture", NULL);
+       gtk_widget_set_tooltip_text(button, "Build a display filter which cuts this stream from the capture");
        g_signal_connect(button, "clicked", G_CALLBACK(follow_filter_out_stream),
                       follow_info);
 
        button = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
        window_set_cancel_button(streamwindow, button, window_cancel_button_cb);
-       gtk_tooltips_set_tip (tooltips, button,
-                             "Close the dialog and keep the current display filter", NULL);
+       gtk_widget_set_tooltip_text(button, "Close the dialog and keep the current display filter");
        gtk_widget_grab_default(button);
 
-       if(topic_available(HELP_FILESET_DIALOG)) {
-            button = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
-               g_signal_connect(button, "clicked", G_CALLBACK(topic_cb),
-                              (gpointer)HELP_FOLLOW_TCP_STREAM_DIALOG);
-       }
+       button = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
+       g_signal_connect(button, "clicked", G_CALLBACK(topic_cb),
+                        (gpointer)HELP_FOLLOW_STREAM_DIALOG);
 
        /* Tuck away the follow_info object into the window */
        g_object_set_data(G_OBJECT(streamwindow), E_FOLLOW_INFO_KEY, follow_info);
@@ -912,8 +909,11 @@ follow_stream(gchar *title, follow_info_t *follow_info,
 
        /* Make sure this widget gets destroyed if we quit the main loop,
           so that if we exit, we clean up any temporary files we have
-          for "Follow TCP Stream" windows. */
-       gtk_quit_add_destroy(gtk_main_level(), GTK_OBJECT(streamwindow));
+          for "Follow TCP Stream" windows. 
+       gtk_quit_add_destroy is deprecated and should not be used in newly-written code. 
+       This function is going to be removed in GTK+ 3.0
+       gtk_quit_add_destroy(gtk_main_level(), GTK_OBJECT(streamwindow));
+          */
 
        gtk_widget_show_all(streamwindow);
        window_present(streamwindow);
@@ -935,9 +935,10 @@ follow_destroy_cb(GtkWidget *w, gpointer data _U_)
        switch(follow_info->follow_type) {
 
        case FOLLOW_TCP :
-               i = eth_unlink(follow_info->data_out_filename);
+               i = ws_unlink(follow_info->data_out_filename);
                if(i != 0) {
-                       g_warning("Follow: Couldn't remove temporary file: \"%s\", errno: %s (%u)", follow_info->data_out_filename, strerror(errno), errno);
+                       g_warning("Follow: Couldn't remove temporary file: \"%s\", errno: %s (%u)",
+                                 follow_info->data_out_filename, g_strerror(errno), errno);
                }
                break;
 
@@ -967,60 +968,63 @@ follow_destroy_cb(GtkWidget *w, gpointer data _U_)
                break;
        }
 
+       g_free(follow_info->data_out_filename);
        g_free(follow_info->filter_out_filter);
        g_free((gpointer)follow_info->client_ip.data);
        forget_follow_info(follow_info);
        g_free(follow_info);
+       gtk_widget_destroy(w);
 }
 
 frs_return_t
 follow_show(follow_info_t *follow_info,
-           gboolean (*print_line)(char *, size_t, gboolean, void *),
+           gboolean (*print_line_fcn_p)(char *, size_t, gboolean, void *),
            char *buffer, size_t nchars, gboolean is_server, void *arg,
            guint32 *global_pos, guint32 *server_packet_count,
            guint32 *client_packet_count)
 {
        gchar initbuf[256];
        guint32 current_pos;
-       static const gchar hexchars[16] = "0123456789abcdef";
+       static const gchar hexchars[16] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
 
        switch (follow_info->show_type) {
 
        case SHOW_EBCDIC:
                /* If our native arch is ASCII, call: */
-               EBCDIC_to_ASCII(buffer, nchars);
-               if (!(*print_line) (buffer, nchars, is_server, arg))
+               EBCDIC_to_ASCII(buffer, (guint) nchars);
+               if (!(*print_line_fcn_p) (buffer, nchars, is_server, arg))
                        return FRS_PRINT_ERROR;
                break;
 
        case SHOW_ASCII:
-                /* If our native arch is EBCDIC, call:
-                 * ASCII_TO_EBCDIC(buffer, nchars);
-                 */
-                if (!(*print_line) (buffer, nchars, is_server, arg))
+               /* If our native arch is EBCDIC, call:
+                * ASCII_TO_EBCDIC(buffer, nchars);
+                */
+               if (!(*print_line_fcn_p) (buffer, nchars, is_server, arg))
                        return FRS_PRINT_ERROR;
-                break;
+               break;
 
        case SHOW_RAW:
-                /* Don't translate, no matter what the native arch
-                 * is.
-                 */
-                if (!(*print_line) (buffer, nchars, is_server, arg))
+               /* Don't translate, no matter what the native arch
+                * is.
+                */
+               if (!(*print_line_fcn_p) (buffer, nchars, is_server, arg))
                        return FRS_PRINT_ERROR;
-                break;
+               break;
 
        case SHOW_HEXDUMP:
-                current_pos = 0;
-                while (current_pos < nchars) {
+               current_pos = 0;
+               while (current_pos < nchars) {
                        gchar hexbuf[256];
                        int i;
                        gchar *cur = hexbuf, *ascii_start;
 
-                       /* is_server indentation : put 78 spaces at the
+                       /* is_server indentation : put 4 spaces at the
                         * beginning of the string */
+                       /* XXX - We might want to prepend each line with "C" or "S" instead. */
                        if (is_server && follow_info->show_stream == BOTH_HOSTS) {
-                               memset(cur, ' ', 78);
-                               cur += 78;
+                               memset(cur, ' ', 4);
+                               cur += 4;
                        }
                        cur += g_snprintf(cur, 20, "%08X  ", *global_pos);
                        /* 49 is space consumed by hex chars */
@@ -1051,20 +1055,20 @@ follow_show(follow_info_t *follow_info,
                        (*global_pos) += i;
                        *cur++ = '\n';
                        *cur = 0;
-                       if (!(*print_line) (hexbuf, strlen(hexbuf), is_server, arg))
+                       if (!(*print_line_fcn_p) (hexbuf, strlen(hexbuf), is_server, arg))
                                return FRS_PRINT_ERROR;
-                }
-                break;
+               }
+               break;
 
        case SHOW_CARRAY:
-                current_pos = 0;
-                g_snprintf(initbuf, sizeof(initbuf), "char peer%d_%d[] = {\n",
+               current_pos = 0;
+               g_snprintf(initbuf, sizeof(initbuf), "char peer%d_%d[] = {\n",
                           is_server ? 1 : 0,
                           is_server ? (*server_packet_count)++ : (*client_packet_count)++);
-                if (!(*print_line) (initbuf, strlen(initbuf), is_server, arg))
+               if (!(*print_line_fcn_p) (initbuf, strlen(initbuf), is_server, arg))
                        return FRS_PRINT_ERROR;
 
-                while (current_pos < nchars) {
+               while (current_pos < nchars) {
                        gchar hexbuf[256];
                        int i, cur;
 
@@ -1095,10 +1099,10 @@ follow_show(follow_info_t *follow_info,
                        (*global_pos) += i;
                        hexbuf[cur++] = '\n';
                        hexbuf[cur] = 0;
-                       if (!(*print_line) (hexbuf, strlen(hexbuf), is_server, arg))
+                       if (!(*print_line_fcn_p) (hexbuf, strlen(hexbuf), is_server, arg))
                                return FRS_PRINT_ERROR;
-                }
-                break;
+               }
+               break;
        }
 
        return FRS_OK;