Remove some unnecessary includes: a lot of things don't need globals.h and register.h
[obnox/wireshark/wip.git] / gtk / print_dlg.c
index 131b02b5e965eb24c4afd4be2691b48215ca98f0..4dc2ad263b302e71023070ef66e54865c6628a88 100644 (file)
 
 #include <gtk/gtk.h>
 
-#include "globals.h"
-#include "gtkglobals.h"
-#include "keys.h"
-#include "print.h"
 #include <epan/prefs.h>
-#include "alert_box.h"
-#include "simple_dialog.h"
-#include "capture_file_dlg.h"
-#include "gui_utils.h"
-#include "dlg_utils.h"
-#include "file_dlg.h"
-#include "main.h"
 #include <epan/epan_dissect.h>
 #include <epan/filesystem.h>
-#ifdef _WIN32
-#include "print_mswin.h"
-#endif
-#include "compat_macros.h"
-#include "range_utils.h"
-#include "help_dlg.h"
-#include "file_util.h"
-#include "tempfile.h"
-#include "util.h"
-
-#if GTK_MAJOR_VERSION >= 2 && _WIN32
+
+#include "../print.h"
+#include "../alert_box.h"
+#include "../simple_dialog.h"
+#include "../util.h"
+#include <wsutil/file_util.h>
+
+#include "gtk/gtkglobals.h"
+#include "gtk/keys.h"
+#include "gtk/capture_file_dlg.h"
+#include "gtk/gui_utils.h"
+#include "gtk/dlg_utils.h"
+#include "gtk/file_dlg.h"
+#include "gtk/main.h"
+#include "gtk/stock_icons.h"
+#include "gtk/range_utils.h"
+#include "gtk/help_dlg.h"
+
+#if _WIN32
 #include <gdk/gdkwin32.h>
 #include <windows.h>
-#include "win32-file-dlg.h"
+#include "gtk/file_dlg_win32.h"
+#include "gtk/print_win32.h"
+#include "../tempfile.h"
 #endif
 
 /* dialog output action */
@@ -67,7 +66,8 @@ typedef enum {
   output_action_export_ps,      /* export to postscript */
   output_action_export_psml,    /* export to packet summary markup language */
   output_action_export_pdml,    /* export to packet data markup language */
-  output_action_export_csv      /* export to csv file */
+  output_action_export_csv,     /* export to csv file */
+  output_action_export_carrays  /* export to C array file */
 } output_action_e;
 
 
@@ -95,6 +95,7 @@ static void print_destroy_cb(GtkWidget *win, gpointer user_data);
 #define PRINT_PDML_RB_KEY         "printer_pdml_radio_button"
 #define PRINT_PSML_RB_KEY         "printer_psml_radio_button"
 #define PRINT_CSV_RB_KEY          "printer_csv_radio_button"
+#define PRINT_CARRAYS_RB_KEY      "printer_carrays_radio_button"
 #define PRINT_DEST_CB_KEY         "printer_destination_check_button"
 
 #define PRINT_SUMMARY_CB_KEY      "printer_summary_check_button"
@@ -153,8 +154,8 @@ file_print_cmd(gboolean print_selected)
       args->range.process = range_process_selected;
   }
 
-  print_win = open_print_dialog("Ethereal: Print", output_action_print, args);
-  SIGNAL_CONNECT(print_win, "destroy", print_destroy_cb, &print_win);
+  print_win = open_print_dialog("Wireshark: Print", output_action_print, args);
+  g_signal_connect(print_win, "destroy", G_CALLBACK(print_destroy_cb), &print_win);
 }
 
 void
@@ -186,7 +187,7 @@ export_text_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
 {
   print_args_t *args = &export_text_args;
 
-#if GTK_MAJOR_VERSION >= 2 && _WIN32
+#if _WIN32
   win32_export_file(GDK_WINDOW_HWND(top_level->window), export_type_text);
   return;
 #endif
@@ -213,8 +214,8 @@ export_text_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
   /* init the printing range */
   packet_range_init(&args->range);
 
-  export_text_win = open_print_dialog("Ethereal: Export as \"Plain Text\" File", output_action_export_text, args);
-  SIGNAL_CONNECT(export_text_win, "destroy", print_destroy_cb, &export_text_win);
+  export_text_win = open_print_dialog("Wireshark: Export as \"Plain Text\" File", output_action_export_text, args);
+  g_signal_connect(export_text_win, "destroy", G_CALLBACK(print_destroy_cb), &export_text_win);
 }
 
 
@@ -235,7 +236,7 @@ export_ps_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
 {
   print_args_t *args = &export_ps_args;
 
-#if GTK_MAJOR_VERSION >= 2 && _WIN32
+#if _WIN32
   win32_export_file(GDK_WINDOW_HWND(top_level->window), export_type_ps);
   return;
 #endif
@@ -262,8 +263,8 @@ export_ps_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
   /* init the printing range */
   packet_range_init(&args->range);
 
-  export_ps_win = open_print_dialog("Ethereal: Export as \"PostScript\" file", output_action_export_ps, args);
-  SIGNAL_CONNECT(export_ps_win, "destroy", print_destroy_cb, &export_ps_win);
+  export_ps_win = open_print_dialog("Wireshark: Export as \"PostScript\" file", output_action_export_ps, args);
+  g_signal_connect(export_ps_win, "destroy", G_CALLBACK(print_destroy_cb), &export_ps_win);
 }
 
 
@@ -284,7 +285,7 @@ export_psml_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
 {
   print_args_t *args = &export_psml_args;
 
-#if GTK_MAJOR_VERSION >= 2 && _WIN32
+#if _WIN32
   win32_export_file(GDK_WINDOW_HWND(top_level->window), export_type_psml);
   return;
 #endif
@@ -311,8 +312,8 @@ export_psml_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
   /* init the printing range */
   packet_range_init(&args->range);
 
-  export_psml_win = open_print_dialog("Ethereal: Export as \"PSML\" file", output_action_export_psml, args);
-  SIGNAL_CONNECT(export_psml_win, "destroy", print_destroy_cb, &export_psml_win);
+  export_psml_win = open_print_dialog("Wireshark: Export as \"PSML\" file", output_action_export_psml, args);
+  g_signal_connect(export_psml_win, "destroy", G_CALLBACK(print_destroy_cb), &export_psml_win);
 }
 
 
@@ -333,7 +334,7 @@ export_pdml_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
 {
   print_args_t *args = &export_pdml_args;
 
-#if GTK_MAJOR_VERSION >= 2 && _WIN32
+#if _WIN32
   win32_export_file(GDK_WINDOW_HWND(top_level->window), export_type_pdml);
   return;
 #endif
@@ -360,8 +361,8 @@ export_pdml_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
   /* init the printing range */
   packet_range_init(&args->range);
 
-  export_pdml_win = open_print_dialog("Ethereal: Export as \"PDML\" file", output_action_export_pdml, args);
-  SIGNAL_CONNECT(export_pdml_win, "destroy", print_destroy_cb, &export_pdml_win);
+  export_pdml_win = open_print_dialog("Wireshark: Export as \"PDML\" file", output_action_export_pdml, args);
+  g_signal_connect(export_pdml_win, "destroy", G_CALLBACK(print_destroy_cb), &export_pdml_win);
 }
 
 /*
@@ -380,7 +381,7 @@ export_csv_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
 {
   print_args_t *args = &export_csv_args;
 
-#if GTK_MAJOR_VERSION >= 2 && _WIN32
+#if _WIN32
   win32_export_file(GDK_WINDOW_HWND(top_level->window), export_type_csv);
   return;
 #endif
@@ -407,14 +408,62 @@ export_csv_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
   /* init the printing range */
   packet_range_init(&args->range);
 
-  export_csv_win = open_print_dialog("Ethereal: Export as \"Comma Separated Values\" File", output_action_export_csv, args);
-  SIGNAL_CONNECT(export_csv_win, "destroy", print_destroy_cb, &export_csv_win);
+  export_csv_win = open_print_dialog("Wireshark: Export as \"Comma Separated Values\" File", output_action_export_csv, args);
+  g_signal_connect(export_csv_win, "destroy", G_CALLBACK(print_destroy_cb), &export_csv_win);
+}
+
+/*
+ * Keep a static pointer to the current "Export carrays" window, if any, so that if
+ * somebody tries to do "File:Export to carrays" while there's already a "Export carrays" window
+ * up, we just pop up the existing one, rather than creating a new one.
+ */
+static GtkWidget *export_carrays_win = NULL;
+
+static print_args_t export_carrays_args;
+
+static gboolean export_carrays_prefs_init = FALSE;
+
+void
+export_carrays_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
+{
+  print_args_t *args = &export_carrays_args;
+
+#if _WIN32
+  win32_export_file(GDK_WINDOW_HWND(top_level->window), export_type_carrays);
+  return;
+#endif
+
+  if (export_carrays_win != NULL) {
+    /* There's already a "Export carrays" dialog box; reactivate it. */
+    reactivate_window(export_carrays_win);
+    return;
+  }
+
+  /* get settings from preferences (and other initial values) only once */
+  if(export_carrays_prefs_init == FALSE) {
+      export_carrays_prefs_init = TRUE;
+      args->format              = PR_FMT_TEXT;
+      args->to_file             = TRUE;
+      args->file                = g_strdup("");
+      args->cmd                 = g_strdup("");
+      args->print_summary       = FALSE;
+      args->print_dissections   = print_dissections_none;
+      args->print_hex           = FALSE;
+      args->print_formfeed      = FALSE;
+  }
+
+  /* init the printing range */
+  packet_range_init(&args->range);
+
+  export_carrays_win = open_print_dialog("Wireshark: Export as \"C Arrays\" File",
+                                        output_action_export_carrays, args);
+  g_signal_connect(export_carrays_win, "destroy", G_CALLBACK(print_destroy_cb), &export_carrays_win);
 }
 
 static void
 print_browse_file_cb(GtkWidget *file_bt, GtkWidget *file_te)
 {
-    file_selection_browse(file_bt, file_te, "Ethereal: Print to File",
+    file_selection_browse(file_bt, file_te, "Wireshark: Print to File",
                           FILE_SELECTION_WRITE_BROWSE);
 }
 
@@ -424,15 +473,11 @@ print_browse_file_cb(GtkWidget *file_bt, GtkWidget *file_te)
 static GtkWidget *
 open_print_dialog(const char *title, output_action_e action, print_args_t *args)
 {
-#if GTK_MAJOR_VERSION < 2
-  GtkAccelGroup *accel_group;
-#endif
-
   GtkWidget     *main_win;
   GtkWidget     *main_vb;
 
   GtkWidget     *printer_fr, *printer_vb, *export_format_lb;
-  GtkWidget     *text_rb, *ps_rb, *pdml_rb, *psml_rb, *csv_rb;
+  GtkWidget     *text_rb, *ps_rb, *pdml_rb, *psml_rb, *csv_rb, *carrays_rb;
   GtkWidget     *printer_tb, *dest_cb;
 #ifndef _WIN32
   GtkWidget     *cmd_lb, *cmd_te;
@@ -463,17 +508,9 @@ open_print_dialog(const char *title, output_action_e action, print_args_t *args)
   /* Enable tooltips */
   tooltips = gtk_tooltips_new();
 
-#if GTK_MAJOR_VERSION < 2
-  /* Accelerator group for the accelerators (or, as they're called in
-     Windows and, I think, in Motif, "mnemonics"; Alt+<key> is a mnemonic,
-     Ctrl+<key> is an accelerator). */
-  accel_group = gtk_accel_group_new();
-  gtk_window_add_accel_group(GTK_WINDOW(main_win), accel_group);
-#endif
-
   /* Vertical enclosing container for each row of widgets */
   main_vb = gtk_vbox_new(FALSE, 5);
-  gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
+  gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
   gtk_container_add(GTK_CONTAINER(main_win), main_vb);
   gtk_widget_show(main_vb);
 
@@ -484,30 +521,30 @@ open_print_dialog(const char *title, output_action_e action, print_args_t *args)
   gtk_box_pack_start(GTK_BOX(main_vb), printer_fr, FALSE, FALSE, 0);
   gtk_widget_show(printer_fr);
   printer_vb = gtk_vbox_new(FALSE, 5);
-  gtk_container_border_width(GTK_CONTAINER(printer_vb), 5);
+  gtk_container_set_border_width(GTK_CONTAINER(printer_vb), 5);
   gtk_container_add(GTK_CONTAINER(printer_fr), printer_vb);
   gtk_widget_show(printer_vb);
 
   /* "Plain text" / "Postscript" / "PDML", ... radio buttons */
-  text_rb = RADIO_BUTTON_NEW_WITH_MNEMONIC(NULL, "Plain _text", accel_group);
+  text_rb = gtk_radio_button_new_with_mnemonic_from_widget(NULL, "Plain _text");
   if (args->format == PR_FMT_TEXT)
-    gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(text_rb), TRUE);
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(text_rb), TRUE);
   gtk_tooltips_set_tip (tooltips, text_rb, "Print output in ascii \"plain text\" format. If you're unsure, use this format.", NULL);
   gtk_box_pack_start(GTK_BOX(printer_vb), text_rb, FALSE, FALSE, 0);
   if(action == output_action_print)
     gtk_widget_show(text_rb);
 
-  ps_rb = RADIO_BUTTON_NEW_WITH_MNEMONIC(text_rb, "_PostScript", accel_group);
+  ps_rb = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(text_rb), "_PostScript");
   if (args->format == PR_FMT_PS)
-    gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(ps_rb), TRUE);
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ps_rb), TRUE);
   gtk_tooltips_set_tip (tooltips, ps_rb, "Print output in \"postscript\" format, for postscript capable printers or print servers.", NULL);
   gtk_box_pack_start(GTK_BOX(printer_vb), ps_rb, FALSE, FALSE, 0);
   if(action == output_action_print)
     gtk_widget_show(ps_rb);
 
-  pdml_rb = RADIO_BUTTON_NEW_WITH_MNEMONIC(text_rb, "PDM_L (XML: Packet Details Markup Language)", accel_group);
+  pdml_rb = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(text_rb), "PDM_L (XML: Packet Details Markup Language)");
   if (action == output_action_export_pdml)
-    gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(pdml_rb), TRUE);
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pdml_rb), TRUE);
   gtk_tooltips_set_tip (tooltips, pdml_rb,
       "Print output in \"PDML\" (Packet Details Markup Language), "
       "an XML based packet data interchange format. "
@@ -515,9 +552,9 @@ open_print_dialog(const char *title, output_action_e action, print_args_t *args)
   gtk_box_pack_start(GTK_BOX(printer_vb), pdml_rb, FALSE, FALSE, 0);
   /* gtk_widget_show(pdml_rb); */
 
-  psml_rb = RADIO_BUTTON_NEW_WITH_MNEMONIC(text_rb, "PSML (XML: Packet Summary Markup Language)", accel_group);
+  psml_rb = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(text_rb), "PSML (XML: Packet Summary Markup Language)");
   if (action == output_action_export_psml)
-    gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(psml_rb), TRUE);
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(psml_rb), TRUE);
   gtk_tooltips_set_tip (tooltips, psml_rb,
       "Print output in \"PSML\" (Packet Summary Markup Language), "
       "an XML based packet summary interchange format. "
@@ -525,9 +562,9 @@ open_print_dialog(const char *title, output_action_e action, print_args_t *args)
   gtk_box_pack_start(GTK_BOX(printer_vb), psml_rb, FALSE, FALSE, 0);
   /* gtk_widget_show(psml_rb); */
 
-  csv_rb = RADIO_BUTTON_NEW_WITH_MNEMONIC(text_rb, "_CSV", accel_group);
+  csv_rb = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(text_rb), "_CSV");
   if (action == output_action_export_csv)
-    gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(csv_rb), TRUE);
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(csv_rb), TRUE);
   gtk_tooltips_set_tip (tooltips, csv_rb,
       "Print output in \"Comma Separated Values\" (CSV) format, "
       "a text format compatible with OpenOffice and Excel. "
@@ -535,6 +572,16 @@ open_print_dialog(const char *title, output_action_e action, print_args_t *args)
   gtk_box_pack_start(GTK_BOX(printer_vb), csv_rb, FALSE, FALSE, 0);
   /* gtk_widget_show(csv_rb); */
 
+  carrays_rb = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(text_rb), "C Arrays");
+  if (action == output_action_export_carrays)
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(carrays_rb), TRUE);
+  gtk_tooltips_set_tip (tooltips, carrays_rb,
+      "Print output in C Arrays format, "
+      "a text file suitable for use in C/C++ programs. "
+      "One char[] for each packet.", NULL);
+  gtk_box_pack_start(GTK_BOX(printer_vb), carrays_rb, FALSE, FALSE, 0);
+  /* gtk_widget_show(carrays_rb); */
+
   /* printer table */
 #ifndef _WIN32
   printer_tb = gtk_table_new(2, 3, FALSE);
@@ -548,9 +595,9 @@ open_print_dialog(const char *title, output_action_e action, print_args_t *args)
 
 
   /* Output to file button */
-  dest_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC("Output to _file:", accel_group);
+  dest_cb = gtk_check_button_new_with_mnemonic("Output to _file:");
   if (args->to_file)
-    gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(dest_cb), TRUE);
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dest_cb), TRUE);
   gtk_tooltips_set_tip (tooltips, dest_cb, "Output to file instead of printer", NULL);
   gtk_table_attach_defaults(GTK_TABLE(printer_tb), dest_cb, 0, 1, 0, 1);
   if(action == output_action_print)
@@ -558,7 +605,7 @@ open_print_dialog(const char *title, output_action_e action, print_args_t *args)
 
   /* File text entry */
   file_te = gtk_entry_new();
-  OBJECT_SET_DATA(dest_cb, PRINT_FILE_TE_KEY, file_te);
+  g_object_set_data(G_OBJECT(dest_cb), PRINT_FILE_TE_KEY, file_te);
   gtk_tooltips_set_tip (tooltips, file_te, "Enter Output filename", NULL);
   gtk_entry_set_text(GTK_ENTRY(file_te), args->file);
   gtk_table_attach_defaults(GTK_TABLE(printer_tb), file_te, 1, 2, 0, 1);
@@ -568,9 +615,9 @@ open_print_dialog(const char *title, output_action_e action, print_args_t *args)
     gtk_widget_grab_focus(file_te);
 
   /* "Browse" button */
-  file_bt = BUTTON_NEW_FROM_STOCK(ETHEREAL_STOCK_BROWSE);
-  OBJECT_SET_DATA(dest_cb, PRINT_FILE_BT_KEY, file_bt);
-  OBJECT_SET_DATA(file_bt, PRINT_TE_PTR_KEY, file_te);
+  file_bt = gtk_button_new_from_stock(WIRESHARK_STOCK_BROWSE);
+  g_object_set_data(G_OBJECT(dest_cb), PRINT_FILE_BT_KEY, file_bt);
+  g_object_set_data(G_OBJECT(file_bt), PRINT_TE_PTR_KEY, file_te);
   gtk_tooltips_set_tip (tooltips, file_bt, "Browse output filename in filesystem", NULL);
   gtk_table_attach_defaults(GTK_TABLE(printer_tb), file_bt, 2, 3, 0, 1);
   gtk_widget_set_sensitive(file_bt, args->to_file);
@@ -579,15 +626,15 @@ open_print_dialog(const char *title, output_action_e action, print_args_t *args)
   /* Command label and text entry */
 #ifndef _WIN32
   cmd_lb = gtk_label_new("Print command:");
-  OBJECT_SET_DATA(dest_cb, PRINT_CMD_LB_KEY, cmd_lb);
-  gtk_misc_set_alignment(GTK_MISC(cmd_lb), 1.0, 0.5);
+  g_object_set_data(G_OBJECT(dest_cb), PRINT_CMD_LB_KEY, cmd_lb);
+  gtk_misc_set_alignment(GTK_MISC(cmd_lb), 1.0f, 0.5f);
   gtk_table_attach_defaults(GTK_TABLE(printer_tb), cmd_lb, 0, 1, 1, 2);
   gtk_widget_set_sensitive(cmd_lb, !args->to_file);
   if(action == output_action_print)
     gtk_widget_show(cmd_lb);
 
   cmd_te = gtk_entry_new();
-  OBJECT_SET_DATA(dest_cb, PRINT_CMD_TE_KEY, cmd_te);
+  g_object_set_data(G_OBJECT(dest_cb), PRINT_CMD_TE_KEY, cmd_te);
   gtk_tooltips_set_tip (tooltips, cmd_te, "Enter print command", NULL);
   gtk_entry_set_text(GTK_ENTRY(cmd_te), args->cmd);
   gtk_table_attach_defaults(GTK_TABLE(printer_tb), cmd_te, 1, 2, 1, 2);
@@ -596,8 +643,8 @@ open_print_dialog(const char *title, output_action_e action, print_args_t *args)
     gtk_widget_show(cmd_te);
 #endif
 
-  SIGNAL_CONNECT(dest_cb, "toggled", print_cmd_toggle_dest, NULL);
-  SIGNAL_CONNECT(file_bt, "clicked", print_browse_file_cb, file_te);
+  g_signal_connect(dest_cb, "toggled", G_CALLBACK(print_cmd_toggle_dest), NULL);
+  g_signal_connect(file_bt, "clicked", G_CALLBACK(print_browse_file_cb), file_te);
 
   if(action == output_action_export_ps) {
     export_format_lb = gtk_label_new("(PostScript files can be easily converted to PDF files using ghostscript's ps2pdf)");
@@ -617,11 +664,7 @@ open_print_dialog(const char *title, output_action_e action, print_args_t *args)
   gtk_box_pack_start(GTK_BOX(packet_hb), range_fr, FALSE, FALSE, 0);
   gtk_widget_show(range_fr);
 
-  range_tb = range_new(&args->range
-#if GTK_MAJOR_VERSION < 2
-  , accel_group
-#endif
-  );
+  range_tb = range_new(&args->range);
   gtk_container_add(GTK_CONTAINER(range_fr), range_tb);
   gtk_widget_show(range_tb);
 
@@ -635,66 +678,66 @@ open_print_dialog(const char *title, output_action_e action, print_args_t *args)
         action == output_action_export_ps)
     gtk_widget_show(format_fr);
   format_vb = gtk_vbox_new(FALSE, 5);
-  gtk_container_border_width(GTK_CONTAINER(format_vb), 5);
+  gtk_container_set_border_width(GTK_CONTAINER(format_vb), 5);
   gtk_container_add(GTK_CONTAINER(format_fr), format_vb);
   gtk_widget_show(format_vb);
 
   /* "Print summary line" check button */
-  summary_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC("Packet summary line", accel_group);
-  gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(summary_cb), args->print_summary);
-  SIGNAL_CONNECT(summary_cb, "clicked", print_cmd_toggle_detail, main_win);
+  summary_cb = gtk_check_button_new_with_mnemonic("Packet summary line");
+  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(summary_cb), args->print_summary);
+  g_signal_connect(summary_cb, "clicked", G_CALLBACK(print_cmd_toggle_detail), main_win);
   gtk_tooltips_set_tip (tooltips, summary_cb, "Output of a packet summary line, like in the packet list", NULL);
   gtk_container_add(GTK_CONTAINER(format_vb), summary_cb);
   gtk_widget_show(summary_cb);
 
 
   /* "Details" check button */
-  details_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC("Packet details:", accel_group);
-  gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(details_cb), args->print_dissections != print_dissections_none);
-  SIGNAL_CONNECT(details_cb, "clicked", print_cmd_toggle_detail, main_win);
+  details_cb = gtk_check_button_new_with_mnemonic("Packet details:");
+  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(details_cb), args->print_dissections != print_dissections_none);
+  g_signal_connect(details_cb, "clicked", G_CALLBACK(print_cmd_toggle_detail), main_win);
   gtk_tooltips_set_tip (tooltips, details_cb, "Output format of the selected packet details (protocol tree).", NULL);
   gtk_container_add(GTK_CONTAINER(format_vb), details_cb);
   gtk_widget_show(details_cb);
 
   /*** packet details ***/
   details_hb = gtk_hbox_new(FALSE, 6);
-  gtk_container_border_width(GTK_CONTAINER(details_hb), 0);
+  gtk_container_set_border_width(GTK_CONTAINER(details_hb), 0);
   gtk_container_add(GTK_CONTAINER(format_vb), details_hb);
   gtk_widget_show(details_hb);
 
   details_vb = gtk_vbox_new(FALSE, 6);
-  gtk_container_border_width(GTK_CONTAINER(details_vb), 0);
+  gtk_container_set_border_width(GTK_CONTAINER(details_vb), 0);
   gtk_container_add(GTK_CONTAINER(details_hb), details_vb);
   gtk_widget_show(details_vb);
 
   details_vb = gtk_vbox_new(FALSE, 6);
-  gtk_container_border_width(GTK_CONTAINER(details_vb), 0);
+  gtk_container_set_border_width(GTK_CONTAINER(details_vb), 0);
   gtk_container_add(GTK_CONTAINER(details_hb), details_vb);
   gtk_widget_show(details_vb);
 
   /* "All collapsed"/"As displayed"/"All Expanded" radio buttons */
-  collapse_all_rb = RADIO_BUTTON_NEW_WITH_MNEMONIC(NULL, "All co_llapsed", accel_group);
-  gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(collapse_all_rb), args->print_dissections == print_dissections_collapsed);
+  collapse_all_rb = gtk_radio_button_new_with_mnemonic_from_widget(NULL, "All co_llapsed");
+  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(collapse_all_rb), args->print_dissections == print_dissections_collapsed);
   gtk_tooltips_set_tip (tooltips, collapse_all_rb, "Output of the packet details tree \"collapsed\"", NULL);
   gtk_container_add(GTK_CONTAINER(details_vb), collapse_all_rb);
   gtk_widget_show(collapse_all_rb);
 
-  as_displayed_rb = RADIO_BUTTON_NEW_WITH_MNEMONIC(collapse_all_rb, "As displa_yed", accel_group);
-  gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(as_displayed_rb), args->print_dissections == print_dissections_as_displayed);
+  as_displayed_rb = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(collapse_all_rb), "As displa_yed");
+  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(as_displayed_rb), args->print_dissections == print_dissections_as_displayed);
   gtk_tooltips_set_tip (tooltips, as_displayed_rb, "Output of the packet details tree \"as displayed\"", NULL);
   gtk_container_add(GTK_CONTAINER(details_vb), as_displayed_rb);
   gtk_widget_show(as_displayed_rb);
 
-  expand_all_rb = RADIO_BUTTON_NEW_WITH_MNEMONIC(collapse_all_rb, "All e_xpanded", accel_group);
-  gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(expand_all_rb), args->print_dissections == print_dissections_expanded);
+  expand_all_rb = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(collapse_all_rb), "All e_xpanded");
+  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(expand_all_rb), args->print_dissections == print_dissections_expanded);
   gtk_tooltips_set_tip (tooltips, expand_all_rb, "Output of the packet details tree \"expanded\"", NULL);
   gtk_container_add(GTK_CONTAINER(details_vb), expand_all_rb);
   gtk_widget_show(expand_all_rb);
 
   /* "Print hex" check button. */
-  hex_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC("Packet bytes", accel_group);
-  gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(hex_cb), args->print_hex);
-  SIGNAL_CONNECT(hex_cb, "clicked", print_cmd_toggle_detail, main_win);
+  hex_cb = gtk_check_button_new_with_mnemonic("Packet bytes");
+  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hex_cb), args->print_hex);
+  g_signal_connect(hex_cb, "clicked", G_CALLBACK(print_cmd_toggle_detail), main_win);
   gtk_tooltips_set_tip (tooltips, hex_cb, "Add a hexdump of the packet data", NULL);
   gtk_container_add(GTK_CONTAINER(format_vb), hex_cb);
   gtk_widget_show(hex_cb);
@@ -705,66 +748,71 @@ open_print_dialog(const char *title, output_action_e action, print_args_t *args)
   gtk_widget_show(sep);
 
   /* "Each packet on a new page" check button. */
-  formfeed_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC("Each packet on a new page", accel_group);
-  gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(formfeed_cb), args->print_formfeed);
+  formfeed_cb = gtk_check_button_new_with_mnemonic("Each packet on a new page");
+  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(formfeed_cb), args->print_formfeed);
   gtk_tooltips_set_tip (tooltips, formfeed_cb, "When checked, a new page will be used for each packet. "
       "This is done by adding a formfeed (or similar) between the packet outputs.", NULL);
   gtk_container_add(GTK_CONTAINER(format_vb), formfeed_cb);
   gtk_widget_show(formfeed_cb);
 
 
-  OBJECT_SET_DATA(main_win, PRINT_ARGS_KEY, args);
-  OBJECT_SET_DATA(main_win, PRINT_SUMMARY_CB_KEY, summary_cb);
-  OBJECT_SET_DATA(main_win, PRINT_DETAILS_CB_KEY, details_cb);
-  OBJECT_SET_DATA(main_win, PRINT_COLLAPSE_ALL_RB_KEY, collapse_all_rb);
-  OBJECT_SET_DATA(main_win, PRINT_AS_DISPLAYED_RB_KEY, as_displayed_rb);
-  OBJECT_SET_DATA(main_win, PRINT_EXPAND_ALL_RB_KEY, expand_all_rb);
-  OBJECT_SET_DATA(main_win, PRINT_HEX_CB_KEY, hex_cb);
+  g_object_set_data(G_OBJECT(main_win), PRINT_ARGS_KEY, args);
+  g_object_set_data(G_OBJECT(main_win), PRINT_SUMMARY_CB_KEY, summary_cb);
+  g_object_set_data(G_OBJECT(main_win), PRINT_DETAILS_CB_KEY, details_cb);
+  g_object_set_data(G_OBJECT(main_win), PRINT_COLLAPSE_ALL_RB_KEY, collapse_all_rb);
+  g_object_set_data(G_OBJECT(main_win), PRINT_AS_DISPLAYED_RB_KEY, as_displayed_rb);
+  g_object_set_data(G_OBJECT(main_win), PRINT_EXPAND_ALL_RB_KEY, expand_all_rb);
+  g_object_set_data(G_OBJECT(main_win), PRINT_HEX_CB_KEY, hex_cb);
 
 /*****************************************************/
 
 
   /* Button row */
-  if(topic_available(HELP_PRINT_DIALOG)) {
-    bbox = dlg_button_row_new(action == output_action_print ? GTK_STOCK_PRINT : GTK_STOCK_OK, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
-  } else {
-    bbox = dlg_button_row_new(action == output_action_print ? GTK_STOCK_PRINT : GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL);
-  }
+  bbox = dlg_button_row_new(action == output_action_print ? GTK_STOCK_PRINT : GTK_STOCK_OK, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
   gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
   gtk_widget_show(bbox);
 
-  ok_bt = OBJECT_GET_DATA(bbox, action == output_action_print ? GTK_STOCK_PRINT : GTK_STOCK_OK);
+  ok_bt = g_object_get_data(G_OBJECT(bbox), action == output_action_print ? GTK_STOCK_PRINT : GTK_STOCK_OK);
 
-  OBJECT_SET_DATA(main_win, PRINT_BT_KEY, ok_bt);
+  g_object_set_data(G_OBJECT(main_win), PRINT_BT_KEY, ok_bt);
 
-  OBJECT_SET_DATA(ok_bt, PRINT_PS_RB_KEY, ps_rb);
-  OBJECT_SET_DATA(ok_bt, PRINT_PDML_RB_KEY, pdml_rb);
-  OBJECT_SET_DATA(ok_bt, PRINT_PSML_RB_KEY, psml_rb);
-  OBJECT_SET_DATA(ok_bt, PRINT_CSV_RB_KEY, csv_rb);
-  OBJECT_SET_DATA(ok_bt, PRINT_DEST_CB_KEY, dest_cb);
+  g_object_set_data(G_OBJECT(ok_bt), PRINT_PS_RB_KEY, ps_rb);
+  g_object_set_data(G_OBJECT(ok_bt), PRINT_PDML_RB_KEY, pdml_rb);
+  g_object_set_data(G_OBJECT(ok_bt), PRINT_PSML_RB_KEY, psml_rb);
+  g_object_set_data(G_OBJECT(ok_bt), PRINT_CSV_RB_KEY, csv_rb);
+  g_object_set_data(G_OBJECT(ok_bt), PRINT_CARRAYS_RB_KEY, carrays_rb);
+  g_object_set_data(G_OBJECT(ok_bt), PRINT_DEST_CB_KEY, dest_cb);
 #ifndef _WIN32
-  OBJECT_SET_DATA(ok_bt, PRINT_CMD_TE_KEY, cmd_te);
+  g_object_set_data(G_OBJECT(ok_bt), PRINT_CMD_TE_KEY, cmd_te);
 #endif
 
-  OBJECT_SET_DATA(ok_bt, PRINT_ARGS_KEY, args);
-  OBJECT_SET_DATA(ok_bt, PRINT_FILE_TE_KEY, file_te);
-  OBJECT_SET_DATA(ok_bt, PRINT_SUMMARY_CB_KEY, summary_cb);
-  OBJECT_SET_DATA(ok_bt, PRINT_DETAILS_CB_KEY, details_cb);
-  OBJECT_SET_DATA(ok_bt, PRINT_COLLAPSE_ALL_RB_KEY, collapse_all_rb);
-  OBJECT_SET_DATA(ok_bt, PRINT_AS_DISPLAYED_RB_KEY, as_displayed_rb);
-  OBJECT_SET_DATA(ok_bt, PRINT_EXPAND_ALL_RB_KEY, expand_all_rb);
-  OBJECT_SET_DATA(ok_bt, PRINT_HEX_CB_KEY, hex_cb);
-  OBJECT_SET_DATA(ok_bt, PRINT_FORMFEED_CB_KEY, formfeed_cb);
-  SIGNAL_CONNECT(ok_bt, "clicked", print_ok_cb, main_win);
+  g_object_set_data(G_OBJECT(ok_bt), PRINT_ARGS_KEY, args);
+  g_object_set_data(G_OBJECT(ok_bt), PRINT_FILE_TE_KEY, file_te);
+  g_object_set_data(G_OBJECT(ok_bt), PRINT_SUMMARY_CB_KEY, summary_cb);
+  g_object_set_data(G_OBJECT(ok_bt), PRINT_DETAILS_CB_KEY, details_cb);
+  g_object_set_data(G_OBJECT(ok_bt), PRINT_COLLAPSE_ALL_RB_KEY, collapse_all_rb);
+  g_object_set_data(G_OBJECT(ok_bt), PRINT_AS_DISPLAYED_RB_KEY, as_displayed_rb);
+  g_object_set_data(G_OBJECT(ok_bt), PRINT_EXPAND_ALL_RB_KEY, expand_all_rb);
+  g_object_set_data(G_OBJECT(ok_bt), PRINT_HEX_CB_KEY, hex_cb);
+  g_object_set_data(G_OBJECT(ok_bt), PRINT_FORMFEED_CB_KEY, formfeed_cb);
+  g_signal_connect(ok_bt, "clicked", G_CALLBACK(print_ok_cb), main_win);
   gtk_tooltips_set_tip (tooltips, ok_bt, "Start output", NULL);
 
-  cancel_bt  = OBJECT_GET_DATA(bbox, GTK_STOCK_CANCEL);
+  cancel_bt  = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
   window_set_cancel_button(main_win, cancel_bt, window_cancel_button_cb);
   gtk_tooltips_set_tip (tooltips, cancel_bt, "Cancel and exit dialog", NULL);
 
-  if(topic_available(HELP_PRINT_DIALOG)) {
-    help_bt  = OBJECT_GET_DATA(bbox, GTK_STOCK_HELP);
-    SIGNAL_CONNECT(help_bt, "clicked", topic_cb, HELP_PRINT_DIALOG);
+  if(action == output_action_print) {
+    help_bt  = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
+    g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb), (gpointer)HELP_PRINT_DIALOG);
+  } else {
+#if _WIN32
+    help_bt  = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
+    g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb), (gpointer)HELP_EXPORT_FILE_WIN32_DIALOG);
+#else
+    help_bt  = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
+    g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb), (gpointer)HELP_EXPORT_FILE_DIALOG);
+#endif
   }
 
   gtk_widget_grab_default(ok_bt);
@@ -779,7 +827,7 @@ open_print_dialog(const char *title, output_action_e action, print_args_t *args)
   if(action != output_action_print)
     dlg_set_activate(file_te, ok_bt);
 
-  SIGNAL_CONNECT(main_win, "delete_event", window_delete_event_cb, NULL);
+  g_signal_connect(main_win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
 
   gtk_widget_show(main_win);
   window_present(main_win);
@@ -799,11 +847,11 @@ print_cmd_toggle_dest(GtkWidget *widget, gpointer data _U_)
   int            to_file;
 
 #ifndef _WIN32
-  cmd_lb = GTK_WIDGET(OBJECT_GET_DATA(widget, PRINT_CMD_LB_KEY));
-  cmd_te = GTK_WIDGET(OBJECT_GET_DATA(widget, PRINT_CMD_TE_KEY));
+  cmd_lb = GTK_WIDGET(g_object_get_data(G_OBJECT(widget), PRINT_CMD_LB_KEY));
+  cmd_te = GTK_WIDGET(g_object_get_data(G_OBJECT(widget), PRINT_CMD_TE_KEY));
 #endif
-  file_bt = GTK_WIDGET(OBJECT_GET_DATA(widget, PRINT_FILE_BT_KEY));
-  file_te = GTK_WIDGET(OBJECT_GET_DATA(widget, PRINT_FILE_TE_KEY));
+  file_bt = GTK_WIDGET(g_object_get_data(G_OBJECT(widget), PRINT_FILE_BT_KEY));
+  file_te = GTK_WIDGET(g_object_get_data(G_OBJECT(widget), PRINT_FILE_TE_KEY));
 
   to_file = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (widget));
 #ifndef _WIN32
@@ -823,13 +871,13 @@ print_cmd_toggle_detail(GtkWidget *widget _U_, gpointer data)
   gboolean      print_detail;
 
 
-  print_bt = GTK_WIDGET(OBJECT_GET_DATA(data, PRINT_BT_KEY));
-  summary_cb = GTK_WIDGET(OBJECT_GET_DATA(data, PRINT_SUMMARY_CB_KEY));
-  details_cb = GTK_WIDGET(OBJECT_GET_DATA(data, PRINT_DETAILS_CB_KEY));
-  collapse_all_rb = GTK_WIDGET(OBJECT_GET_DATA(data, PRINT_COLLAPSE_ALL_RB_KEY));
-  as_displayed_rb = GTK_WIDGET(OBJECT_GET_DATA(data, PRINT_AS_DISPLAYED_RB_KEY));
-  expand_all_rb = GTK_WIDGET(OBJECT_GET_DATA(data, PRINT_EXPAND_ALL_RB_KEY));
-  hex_cb = GTK_WIDGET(OBJECT_GET_DATA(data, PRINT_HEX_CB_KEY));
+  print_bt = GTK_WIDGET(g_object_get_data(G_OBJECT(data), PRINT_BT_KEY));
+  summary_cb = GTK_WIDGET(g_object_get_data(G_OBJECT(data), PRINT_SUMMARY_CB_KEY));
+  details_cb = GTK_WIDGET(g_object_get_data(G_OBJECT(data), PRINT_DETAILS_CB_KEY));
+  collapse_all_rb = GTK_WIDGET(g_object_get_data(G_OBJECT(data), PRINT_COLLAPSE_ALL_RB_KEY));
+  as_displayed_rb = GTK_WIDGET(g_object_get_data(G_OBJECT(data), PRINT_AS_DISPLAYED_RB_KEY));
+  expand_all_rb = GTK_WIDGET(g_object_get_data(G_OBJECT(data), PRINT_EXPAND_ALL_RB_KEY));
+  hex_cb = GTK_WIDGET(g_object_get_data(G_OBJECT(data), PRINT_HEX_CB_KEY));
 
   /* is user disabled details, disable the corresponding buttons */
   print_detail = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (details_cb));
@@ -855,14 +903,16 @@ print_ok_cb(GtkWidget *ok_bt, gpointer parent_w)
   gchar             *dirname;
   gboolean          export_as_pdml = FALSE, export_as_psml = FALSE;
   gboolean          export_as_csv = FALSE;
+  gboolean          export_as_carrays = FALSE;
 #ifdef _WIN32
   gboolean          win_printer = FALSE;
   int               tmp_fd;
-  char              tmp_namebuf[128+1];    /* XXX - length was used elsewhere too, why? */
+  char              *tmp_namebuf;
+  char              *tmp_oldfile;
 #endif
   cf_print_status_t status;
 
-  args = (print_args_t *)OBJECT_GET_DATA(ok_bt, PRINT_ARGS_KEY);
+  args = (print_args_t *)g_object_get_data(G_OBJECT(ok_bt), PRINT_ARGS_KEY);
 
   /* Check whether the range is valid. */
   if (!range_check_validity(&args->range)) {
@@ -872,11 +922,11 @@ print_ok_cb(GtkWidget *ok_bt, gpointer parent_w)
     return;
   }
 
-  button = (GtkWidget *)OBJECT_GET_DATA(ok_bt, PRINT_DEST_CB_KEY);
+  button = (GtkWidget *)g_object_get_data(G_OBJECT(ok_bt), PRINT_DEST_CB_KEY);
   args->to_file = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button));
 
   if (args->to_file) {
-    g_dest = gtk_entry_get_text(GTK_ENTRY(OBJECT_GET_DATA(ok_bt,
+      g_dest = gtk_entry_get_text(GTK_ENTRY(g_object_get_data(G_OBJECT(ok_bt),
                                                           PRINT_FILE_TE_KEY)));
     if (!g_dest[0]) {
       simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
@@ -894,69 +944,73 @@ print_ok_cb(GtkWidget *ok_bt, gpointer parent_w)
 #ifdef _WIN32
     win_printer = TRUE;
     /* 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. */
+    /* 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.ethereal.com/bugzilla/show_bug.cgi?id=358 */
-
-    tmp_fd = create_tempfile(tmp_namebuf, sizeof(tmp_namebuf), "ethprint");
+    /* 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 a temporary file for printing.");
+            "Couldn't create a temporary file for printing:\n%s", tmp_namebuf);
         return;
     }
-    g_free(args->file);
+    /* remember to restore these values later! */
+    tmp_oldfile = args->file;
     args->file = g_strdup(tmp_namebuf);
-    eth_unlink(args->file);
+    ws_unlink(args->file);
     args->to_file = TRUE;
 #else
     g_free(args->cmd);
-    args->cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(OBJECT_GET_DATA(ok_bt,
+    args->cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(g_object_get_data(G_OBJECT(ok_bt),
       PRINT_CMD_TE_KEY))));
 #endif
   }
 
   args->format = PR_FMT_TEXT;
-  button = (GtkWidget *)OBJECT_GET_DATA(ok_bt, PRINT_PS_RB_KEY);
+  button = (GtkWidget *)g_object_get_data(G_OBJECT(ok_bt), PRINT_PS_RB_KEY);
   if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button)))
     args->format = PR_FMT_PS;
-  button = (GtkWidget *)OBJECT_GET_DATA(ok_bt, PRINT_PDML_RB_KEY);
+  button = (GtkWidget *)g_object_get_data(G_OBJECT(ok_bt), PRINT_PDML_RB_KEY);
   if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button)))
     export_as_pdml = TRUE;
-  button = (GtkWidget *)OBJECT_GET_DATA(ok_bt, PRINT_PSML_RB_KEY);
+  button = (GtkWidget *)g_object_get_data(G_OBJECT(ok_bt), PRINT_PSML_RB_KEY);
   if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button)))
     export_as_psml = TRUE;
-  button = (GtkWidget *)OBJECT_GET_DATA(ok_bt, PRINT_CSV_RB_KEY);
+  button = (GtkWidget *)g_object_get_data(G_OBJECT(ok_bt), PRINT_CSV_RB_KEY);
   if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button)))
     export_as_csv = TRUE;
+  button = (GtkWidget *)g_object_get_data(G_OBJECT(ok_bt), PRINT_CARRAYS_RB_KEY);
+  if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button)))
+    export_as_carrays = TRUE;
 
-  button = (GtkWidget *)OBJECT_GET_DATA(ok_bt, PRINT_SUMMARY_CB_KEY);
+  button = (GtkWidget *)g_object_get_data(G_OBJECT(ok_bt), PRINT_SUMMARY_CB_KEY);
   args->print_summary = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button));
 
-  button = (GtkWidget *)OBJECT_GET_DATA(ok_bt, PRINT_COLLAPSE_ALL_RB_KEY);
+  button = (GtkWidget *)g_object_get_data(G_OBJECT(ok_bt), PRINT_COLLAPSE_ALL_RB_KEY);
   if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button))) {
     args->print_dissections = print_dissections_collapsed;
   }
-  button = (GtkWidget *)OBJECT_GET_DATA(ok_bt, PRINT_AS_DISPLAYED_RB_KEY);
+  button = (GtkWidget *)g_object_get_data(G_OBJECT(ok_bt), PRINT_AS_DISPLAYED_RB_KEY);
   if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button))) {
     args->print_dissections = print_dissections_as_displayed;
   }
-  button = (GtkWidget *)OBJECT_GET_DATA(ok_bt, PRINT_EXPAND_ALL_RB_KEY);
+  button = (GtkWidget *)g_object_get_data(G_OBJECT(ok_bt), PRINT_EXPAND_ALL_RB_KEY);
   if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button))) {
     args->print_dissections = print_dissections_expanded;
   }
 
   /* the details setting has priority over the radio buttons */
-  button = (GtkWidget *)OBJECT_GET_DATA(ok_bt, PRINT_DETAILS_CB_KEY);
+  button = (GtkWidget *)g_object_get_data(G_OBJECT(ok_bt), PRINT_DETAILS_CB_KEY);
   if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button))) {
     args->print_dissections = print_dissections_none;
   }
 
-  button = (GtkWidget *)OBJECT_GET_DATA(ok_bt, PRINT_HEX_CB_KEY);
+  button = (GtkWidget *)g_object_get_data(G_OBJECT(ok_bt), PRINT_HEX_CB_KEY);
   args->print_hex = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button));
 
-  button = (GtkWidget *)OBJECT_GET_DATA(ok_bt, PRINT_FORMFEED_CB_KEY);
+  button = (GtkWidget *)g_object_get_data(G_OBJECT(ok_bt), PRINT_FORMFEED_CB_KEY);
   args->print_formfeed = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button));
 
 
@@ -969,6 +1023,8 @@ print_ok_cb(GtkWidget *ok_bt, gpointer parent_w)
     status = cf_write_psml_packets(&cfile, args);
   else if (export_as_csv)
     status = cf_write_csv_packets(&cfile, args);
+  else if (export_as_carrays)
+    status = cf_write_carrays_packets(&cfile, args);
   else {
     switch (args->format) {
 
@@ -1037,7 +1093,12 @@ print_ok_cb(GtkWidget *ok_bt, gpointer parent_w)
     print_mswin(args->file);
 
     /* trash temp file */
-    eth_remove(args->file);
+    ws_remove(args->file);
+    g_free(args->file);
+
+    /* restore old settings */
+    args->to_file = FALSE;
+    args->file = tmp_oldfile;
   }
 #endif
 }
@@ -1049,7 +1110,7 @@ print_destroy_cb(GtkWidget *win, gpointer user_data)
 
   /* Is there a file selection dialog associated with this
      Print File dialog? */
-  fs = OBJECT_GET_DATA(win, E_FILE_SEL_DIALOG_PTR_KEY);
+  fs = g_object_get_data(G_OBJECT(win), E_FILE_SEL_DIALOG_PTR_KEY);
 
   if (fs != NULL) {
     /* Yes.  Destroy it. */