aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gtk/main.h6
-rw-r--r--gtk/menu.c13
-rw-r--r--gtk/print_dlg.c402
3 files changed, 335 insertions, 86 deletions
diff --git a/gtk/main.h b/gtk/main.h
index e8f52abc69..c125ef13ab 100644
--- a/gtk/main.h
+++ b/gtk/main.h
@@ -1,7 +1,7 @@
/* main.h
* Global defines, etc.
*
- * $Id: main.h,v 1.44 2004/03/19 06:23:38 guy Exp $
+ * $Id: main.h,v 1.45 2004/04/25 16:04:12 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -95,6 +95,10 @@ void prepare_selected_cb_and_plist_not( GtkWidget *, gpointer);
void prepare_selected_cb_or_plist_not( GtkWidget *, gpointer);
void file_quit_cmd_cb(GtkWidget *, gpointer);
void file_print_cmd_cb(GtkWidget *, gpointer);
+void export_text_cmd_cb(GtkWidget *, gpointer);
+void export_ps_cmd_cb(GtkWidget *, gpointer);
+void export_psml_cmd_cb(GtkWidget *, gpointer);
+void export_pdml_cmd_cb(GtkWidget *, gpointer);
void tools_plugins_cmd_cb(GtkWidget *, gpointer);
void expand_tree_cb(GtkWidget *, gpointer);
void expand_all_cb(GtkWidget *, gpointer);
diff --git a/gtk/menu.c b/gtk/menu.c
index cf06c435e1..7719629d62 100644
--- a/gtk/menu.c
+++ b/gtk/menu.c
@@ -1,7 +1,7 @@
/* menu.c
* Menu routines
*
- * $Id: menu.c,v 1.181 2004/03/23 07:57:48 guy Exp $
+ * $Id: menu.c,v 1.182 2004/04/25 16:04:12 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -157,7 +157,16 @@ static GtkItemFactoryEntry menu_items[] =
0, GTK_STOCK_SAVE_AS),
ITEM_FACTORY_ENTRY("/File/<separator>", NULL, NULL, 0, "<Separator>", NULL),
ITEM_FACTORY_ENTRY("/File/_Export", NULL, NULL, 0, "<Branch>", NULL),
- ITEM_FACTORY_ENTRY("/File/_Export/_Selected Packet Bytes...", "<control>H", savehex_cb,
+ ITEM_FACTORY_ENTRY("/File/Export/as \"Plain _Text\" file...", NULL, export_text_cmd_cb,
+ 0, NULL, NULL),
+ ITEM_FACTORY_ENTRY("/File/Export/as \"_PostScript\" file...", NULL, export_ps_cmd_cb,
+ 0, NULL, NULL),
+ ITEM_FACTORY_ENTRY("/File/Export/as \"P_SML\" file...", NULL, export_psml_cmd_cb,
+ 0, NULL, NULL),
+ ITEM_FACTORY_ENTRY("/File/Export/as \"P_DML\" file...", NULL, export_pdml_cmd_cb,
+ 0, NULL, NULL),
+ ITEM_FACTORY_ENTRY("/File/Export/<separator>", NULL, NULL, 0, "<Separator>", NULL),
+ ITEM_FACTORY_ENTRY("/File/Export/_Selected Packet Bytes...", "<control>H", savehex_cb,
0, NULL, NULL),
ITEM_FACTORY_ENTRY("/File/<separator>", NULL, NULL, 0, "<Separator>", NULL),
ITEM_FACTORY_STOCK_ENTRY("/File/_Print...", "<control>P", file_print_cmd_cb,
diff --git a/gtk/print_dlg.c b/gtk/print_dlg.c
index 9ffa135641..20ecc9b9a7 100644
--- a/gtk/print_dlg.c
+++ b/gtk/print_dlg.c
@@ -1,7 +1,7 @@
/* print_dlg.c
* Dialog boxes for printing
*
- * $Id: print_dlg.c,v 1.73 2004/04/25 12:04:08 ulfl Exp $
+ * $Id: print_dlg.c,v 1.74 2004/04/25 16:04:13 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -50,6 +50,16 @@
#include "range_utils.h"
+/* dialog output action */
+typedef enum {
+ output_action_print, /* print text to printer */
+ output_action_export_text, /* export to plain text */
+ 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_e;
+
+
/* On Win32, a GUI application apparently can't use "popen()" (it
"returns an invalid file handle, if used in a Windows program,
that will cause the program to hang indefinitely"), so we can't
@@ -59,6 +69,8 @@
for this (and also use various UNIX printing APIs, when present?).
*/
+static GtkWidget *
+open_print_dialog(char *title, output_action_e action, print_args_t *args);
static void print_cmd_toggle_dest(GtkWidget *widget, gpointer data);
static void print_cmd_toggle_detail(GtkWidget *widget, gpointer data);
static void print_ok_cb(GtkWidget *ok_bt, gpointer parent_w);
@@ -84,29 +96,241 @@ static void print_destroy_cb(GtkWidget *win, gpointer user_data);
#define PRINT_BT_KEY "printer_button"
+
+
/*
* Keep a static pointer to the current "Print" window, if any, so that if
* somebody tries to do "File:Print" while there's already a "Print" window
* up, we just pop up the existing one, rather than creating a new one.
*/
-static GtkWidget *print_w = NULL;
+static GtkWidget *print_win = NULL;
static print_args_t print_args;
static gboolean print_prefs_init = FALSE;
-/* Open the print dialog */
void
file_print_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
{
+ print_args_t *args = &print_args;
+
+ if (print_win != NULL) {
+ /* There's already a "Print" dialog box; reactivate it. */
+ reactivate_window(print_win);
+ return;
+ }
+
+ /* get settings from preferences (and other initial values) only once */
+ if(print_prefs_init == FALSE) {
+ print_prefs_init = TRUE;
+ args->format = prefs.pr_format;
+ args->to_file = prefs.pr_dest;
+ args->file = g_strdup(prefs.pr_file);
+ args->cmd = g_strdup(prefs.pr_cmd);
+ args->print_summary = TRUE;
+ args->print_dissections = print_dissections_as_displayed;
+ args->print_hex = FALSE;
+ args->print_formfeed = FALSE;
+
+ /* init the printing range */
+ packet_range_init(&args->range);
+ }
+
+ print_win = open_print_dialog("Ethereal: Print", output_action_print, args);
+ SIGNAL_CONNECT(print_win, "destroy", print_destroy_cb, &print_win);
+}
+
+
+/*
+ * Keep a static pointer to the current "Export text" window, if any, so that if
+ * somebody tries to do "File:Export to text" while there's already a "Export text" window
+ * up, we just pop up the existing one, rather than creating a new one.
+ */
+static GtkWidget *export_text_win = NULL;
+
+static print_args_t export_text_args;
+
+static gboolean export_text_prefs_init = FALSE;
+
+
+void
+export_text_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
+{
+ print_args_t *args = &export_text_args;
+
+ if (export_text_win != NULL) {
+ /* There's already a "Export text" dialog box; reactivate it. */
+ reactivate_window(export_text_win);
+ return;
+ }
+
+ /* get settings from preferences (and other initial values) only once */
+ if(export_text_prefs_init == FALSE) {
+ export_text_prefs_init = TRUE;
+ args->format = PR_FMT_TEXT;
+ args->to_file = TRUE;
+ args->file = g_strdup("");
+ args->cmd = g_strdup("");
+ args->print_summary = TRUE;
+ args->print_dissections = print_dissections_as_displayed;
+ args->print_hex = FALSE;
+ args->print_formfeed = FALSE;
+
+ /* 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);
+}
+
+
+/*
+ * Keep a static pointer to the current "Export ps" window, if any, so that if
+ * somebody tries to do "File:Export to ps" while there's already a "Export ps" window
+ * up, we just pop up the existing one, rather than creating a new one.
+ */
+static GtkWidget *export_ps_win = NULL;
+
+static print_args_t export_ps_args;
+
+static gboolean export_ps_prefs_init = FALSE;
+
+
+void
+export_ps_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
+{
+ print_args_t *args = &export_ps_args;
+
+ if (export_ps_win != NULL) {
+ /* There's already a "Export ps" dialog box; reactivate it. */
+ reactivate_window(export_ps_win);
+ return;
+ }
+
+ /* get settings from preferences (and other initial values) only once */
+ if(export_ps_prefs_init == FALSE) {
+ export_ps_prefs_init = TRUE;
+ args->format = PR_FMT_PS;
+ args->to_file = TRUE;
+ args->file = g_strdup("");
+ args->cmd = g_strdup("");
+ args->print_summary = TRUE;
+ args->print_dissections = print_dissections_as_displayed;
+ args->print_hex = FALSE;
+ args->print_formfeed = FALSE;
+
+ /* 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);
+}
+
+
+/*
+ * Keep a static pointer to the current "Export psml" window, if any, so that if
+ * somebody tries to do "File:Export to psml" while there's already a "Export psml" window
+ * up, we just pop up the existing one, rather than creating a new one.
+ */
+static GtkWidget *export_psml_win = NULL;
+
+static print_args_t export_psml_args;
+
+static gboolean export_psml_prefs_init = FALSE;
+
+
+void
+export_psml_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
+{
+ print_args_t *args = &export_psml_args;
+
+ if (export_psml_win != NULL) {
+ /* There's already a "Export psml" dialog box; reactivate it. */
+ reactivate_window(export_psml_win);
+ return;
+ }
+
+ /* get settings from preferences (and other initial values) only once */
+ if(export_psml_prefs_init == FALSE) {
+ export_psml_prefs_init = TRUE;
+ args->format = PR_FMT_PSML;
+ args->to_file = TRUE;
+ args->file = g_strdup("");
+ args->cmd = g_strdup("");
+ args->print_summary = TRUE;
+ args->print_dissections = print_dissections_as_displayed;
+ args->print_hex = FALSE;
+ args->print_formfeed = FALSE;
+
+ /* 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);
+}
+
+
+/*
+ * Keep a static pointer to the current "Export pdml" window, if any, so that if
+ * somebody tries to do "File:Export to pdml" while there's already a "Export pdml" window
+ * up, we just pop up the existing one, rather than creating a new one.
+ */
+static GtkWidget *export_pdml_win = NULL;
+
+static print_args_t export_pdml_args;
+
+static gboolean export_pdml_prefs_init = FALSE;
+
+
+void
+export_pdml_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
+{
+ print_args_t *args = &export_pdml_args;
+
+ if (export_pdml_win != NULL) {
+ /* There's already a "Export pdml" dialog box; reactivate it. */
+ reactivate_window(export_pdml_win);
+ return;
+ }
+
+ /* get settings from preferences (and other initial values) only once */
+ if(export_pdml_prefs_init == FALSE) {
+ export_pdml_prefs_init = TRUE;
+ args->format = PR_FMT_PDML;
+ args->to_file = TRUE;
+ args->file = g_strdup("");
+ args->cmd = g_strdup("");
+ args->print_summary = TRUE;
+ args->print_dissections = print_dissections_as_displayed;
+ args->print_hex = FALSE;
+ args->print_formfeed = FALSE;
+
+ /* 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);
+}
+
+
+
+/* Open the print dialog */
+static GtkWidget *
+open_print_dialog(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;
+ GtkWidget *printer_fr, *printer_vb, *printer_lb;
GtkWidget *text_rb, *ps_rb, *pdml_rb, *psml_rb;
GtkWidget *printer_tb, *dest_cb;
#ifndef _WIN32
@@ -131,55 +355,31 @@ file_print_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
GtkTooltips *tooltips;
- print_args_t *args = &print_args;
- if (print_w != NULL) {
- /* There's already a "Print" dialog box; reactivate it. */
- reactivate_window(print_w);
- return;
- }
-
- /* get settings from preferences (and other initial values) only once */
- if(print_prefs_init == FALSE) {
- print_prefs_init = TRUE;
- args->format = prefs.pr_format;
- args->to_file = prefs.pr_dest;
- args->file = g_strdup(prefs.pr_file);
- args->cmd = g_strdup(prefs.pr_cmd);
- args->print_summary = TRUE;
- args->print_dissections = print_dissections_as_displayed;
- args->print_hex = FALSE;
- args->print_formfeed = FALSE;
-
- /* init the printing range */
- packet_range_init(&args->range);
- }
+ /* dialog window */
+ main_win = dlg_window_new(title);
/* Enable tooltips */
tooltips = gtk_tooltips_new();
- /* dialog window */
- print_w = dlg_window_new("Ethereal: Print");
- SIGNAL_CONNECT(print_w, "destroy", print_destroy_cb, NULL);
-
#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(print_w), accel_group);
+ 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_add(GTK_CONTAINER(print_w), main_vb);
+ gtk_container_add(GTK_CONTAINER(main_win), main_vb);
gtk_widget_show(main_vb);
/*****************************************************/
/*** printer frame ***/
- printer_fr = gtk_frame_new("Printer");
+ printer_fr = gtk_frame_new(action == output_action_print ? "Printer" : "Export to file:");
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);
@@ -191,36 +391,38 @@ file_print_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
text_rb = RADIO_BUTTON_NEW_WITH_MNEMONIC(NULL, "Plain _text", accel_group);
if (args->format == PR_FMT_TEXT)
gtk_toggle_button_set_state(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_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);
- gtk_widget_show(text_rb);
+ if(action == output_action_print)
+ gtk_widget_show(text_rb);
ps_rb = RADIO_BUTTON_NEW_WITH_MNEMONIC(text_rb, "_PostScript", accel_group);
if (args->format == PR_FMT_PS)
gtk_toggle_button_set_state(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_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);
- gtk_widget_show(ps_rb);
+ 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);
if (args->format == PR_FMT_PDML)
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(pdml_rb), TRUE);
- gtk_tooltips_set_tip (tooltips, pdml_rb, (
+ gtk_tooltips_set_tip (tooltips, pdml_rb,
"Print output in \"PDML\" (Packet Details Markup Language), "
"an XML based packet data interchange format. "
- "Usually used in combination with the \"Output to file\" option to export packet data into an XML file."), NULL);
+ "Usually used in combination with the \"Output to file\" option to export packet data into an XML file.", NULL);
gtk_box_pack_start(GTK_BOX(printer_vb), pdml_rb, FALSE, FALSE, 0);
- gtk_widget_show(pdml_rb);
+ /* gtk_widget_show(pdml_rb); */
psml_rb = RADIO_BUTTON_NEW_WITH_MNEMONIC(text_rb, "PSML (XML: Packet Summary Markup Language)", accel_group);
if (args->format == PR_FMT_PSML)
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(psml_rb), TRUE);
- gtk_tooltips_set_tip (tooltips, psml_rb, (
+ gtk_tooltips_set_tip (tooltips, psml_rb,
"Print output in \"PSML\" (Packet Summary Markup Language), "
"an XML based packet summary interchange format. "
- "Usually used in combination with the \"Output to file\" option to export packet data into an XML file."), NULL);
+ "Usually used in combination with the \"Output to file\" option to export packet data into an XML file.", NULL);
gtk_box_pack_start(GTK_BOX(printer_vb), psml_rb, FALSE, FALSE, 0);
- gtk_widget_show(psml_rb);
+ /* gtk_widget_show(psml_rb); */
/* printer table */
#ifndef _WIN32
@@ -238,14 +440,15 @@ file_print_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
dest_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC("Output to _file:", accel_group);
if (args->to_file)
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(dest_cb), TRUE);
- gtk_tooltips_set_tip (tooltips, dest_cb, ("Output to file instead of printer"), NULL);
+ 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);
- gtk_widget_show(dest_cb);
+ if(action == output_action_print)
+ gtk_widget_show(dest_cb);
- /* File text entry and "Browse" button */
+ /* File text entry */
file_te = gtk_entry_new();
OBJECT_SET_DATA(dest_cb, PRINT_FILE_TE_KEY, file_te);
- gtk_tooltips_set_tip (tooltips, file_te, ("Enter Output filename"), NULL);
+ 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);
gtk_widget_set_sensitive(file_te, args->to_file);
@@ -253,10 +456,11 @@ file_print_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
if (args->to_file)
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, E_FILE_TE_PTR_KEY, file_te);
- gtk_tooltips_set_tip (tooltips, file_bt, ("Browse output filename in filesystem"), NULL);
+ 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);
gtk_widget_show(file_bt);
@@ -268,21 +472,47 @@ file_print_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
gtk_misc_set_alignment(GTK_MISC(cmd_lb), 1.0, 0.5);
gtk_table_attach_defaults(GTK_TABLE(printer_tb), cmd_lb, 0, 1, 1, 2);
gtk_widget_set_sensitive(cmd_lb, !args->to_file);
- gtk_widget_show(cmd_lb);
+ 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);
- gtk_tooltips_set_tip (tooltips, cmd_te, ("Enter print command"), NULL);
+ 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);
gtk_widget_set_sensitive(cmd_te, !args->to_file);
- gtk_widget_show(cmd_te);
+ if(action == output_action_print)
+ gtk_widget_show(cmd_te);
#endif
SIGNAL_CONNECT(dest_cb, "toggled", print_cmd_toggle_dest, NULL);
SIGNAL_CONNECT(file_bt, "clicked", select_file_cb, "Ethereal: Print to File");
+ switch(action) {
+ case(output_action_print):
+ printer_lb = NULL;
+ break;
+ case(output_action_export_text):
+ printer_lb = gtk_label_new("... export as ASCII plain text file.");
+ break;
+ case(output_action_export_ps):
+ printer_lb = gtk_label_new("... export as PostScript file (can be easily converted to a PDF file using ghostscript's ps2pdf).");
+ break;
+ case(output_action_export_psml):
+ printer_lb = gtk_label_new("... export as Packet Summary Markup Language (XML) file.");
+ break;
+ case(output_action_export_pdml):
+ printer_lb = gtk_label_new("... export as Packet Details Markup Language (XML) file.");
+ break;
+ default:
+ g_assert_not_reached();
+ }
+ if(printer_lb) {
+ gtk_box_pack_start(GTK_BOX(printer_vb), printer_lb, FALSE, FALSE, 0);
+ gtk_widget_show(printer_lb);
+ }
+
/*****************************************************/
/*** hor box for range and format frames ***/
@@ -308,7 +538,10 @@ file_print_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
/*** packet format frame ***/
format_fr = gtk_frame_new("Packet Format");
gtk_box_pack_start(GTK_BOX(packet_hb), format_fr, TRUE, TRUE, 0);
- gtk_widget_show(format_fr);
+ if( action == output_action_print ||
+ action == output_action_export_text ||
+ 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_add(GTK_CONTAINER(format_fr), format_vb);
@@ -317,8 +550,8 @@ file_print_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
/* "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, print_w);
- gtk_tooltips_set_tip (tooltips, summary_cb, ("Output of a packet summary line, like in the packet list"), NULL);
+ SIGNAL_CONNECT(summary_cb, "clicked", 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);
@@ -326,8 +559,8 @@ file_print_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
/* "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, print_w);
- gtk_tooltips_set_tip (tooltips, details_cb, ("Output format of the selected packet details (protocol tree)."), NULL);
+ SIGNAL_CONNECT(details_cb, "clicked", 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);
@@ -350,27 +583,27 @@ file_print_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
/* "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);
- gtk_tooltips_set_tip (tooltips, collapse_all_rb, ("Output of the packet details tree \"collapsed\""), NULL);
+ 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);
- gtk_tooltips_set_tip (tooltips, as_displayed_rb, ("Output of the packet details tree \"as displayed\""), NULL);
+ 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);
- gtk_tooltips_set_tip (tooltips, expand_all_rb, ("Output of the packet details tree \"expanded\""), NULL);
+ 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, print_w);
- gtk_tooltips_set_tip (tooltips, hex_cb, ("Add a hexdump of the packet data"), NULL);
+ SIGNAL_CONNECT(hex_cb, "clicked", 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);
@@ -382,31 +615,31 @@ file_print_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
/* "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);
- 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_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(print_w, PRINT_ARGS_KEY, args);
- OBJECT_SET_DATA(print_w, PRINT_SUMMARY_CB_KEY, summary_cb);
- OBJECT_SET_DATA(print_w, PRINT_DETAILS_CB_KEY, details_cb);
- OBJECT_SET_DATA(print_w, PRINT_COLLAPSE_ALL_RB_KEY, collapse_all_rb);
- OBJECT_SET_DATA(print_w, PRINT_AS_DISPLAYED_RB_KEY, as_displayed_rb);
- OBJECT_SET_DATA(print_w, PRINT_EXPAND_ALL_RB_KEY, expand_all_rb);
- OBJECT_SET_DATA(print_w, PRINT_HEX_CB_KEY, hex_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);
/*****************************************************/
/* Button row */
- bbox = dlg_button_row_new(GTK_STOCK_PRINT, GTK_STOCK_CANCEL, NULL);
+ bbox = dlg_button_row_new(action == output_action_print ? GTK_STOCK_PRINT : GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL);
gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
gtk_widget_show(bbox);
- ok_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_PRINT);
+ ok_bt = OBJECT_GET_DATA(bbox, action == output_action_print ? GTK_STOCK_PRINT : GTK_STOCK_OK);
- OBJECT_SET_DATA(print_w, PRINT_BT_KEY, ok_bt);
+ OBJECT_SET_DATA(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);
@@ -425,13 +658,13 @@ file_print_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
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, print_w);
- gtk_tooltips_set_tip (tooltips, ok_bt, ("Start printing"), NULL);
+ SIGNAL_CONNECT(ok_bt, "clicked", print_ok_cb, main_win);
+ gtk_tooltips_set_tip (tooltips, ok_bt, "Start output", NULL);
gtk_widget_grab_default(ok_bt);
cancel_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CANCEL);
- SIGNAL_CONNECT(cancel_bt, "clicked", print_close_cb, print_w);
- gtk_tooltips_set_tip (tooltips, cancel_bt, ("Cancel print and exit dialog"), NULL);
+ SIGNAL_CONNECT(cancel_bt, "clicked", print_close_cb, main_win);
+ gtk_tooltips_set_tip (tooltips, cancel_bt, "Cancel and exit dialog", NULL);
/* Catch the "activate" signal on the "Command" and "File" text entries,
so that if the user types Return there, we act as if the "OK" button
@@ -441,14 +674,17 @@ file_print_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
#ifndef _WIN32
dlg_set_activate(cmd_te, ok_bt);
#endif
- dlg_set_activate(file_te, ok_bt);
+ if(action != output_action_print)
+ dlg_set_activate(file_te, ok_bt);
/* Catch the "key_press_event" signal in the window, so that we can catch
the ESC key being pressed and act as if the "Cancel" button had
been selected. */
- dlg_set_cancel(print_w, cancel_bt);
+ dlg_set_cancel(main_win, cancel_bt);
+
+ gtk_widget_show(main_win);
- gtk_widget_show(print_w);
+ return main_win;
}
@@ -531,7 +767,7 @@ print_ok_cb(GtkWidget *ok_bt, gpointer parent_w)
PRINT_FILE_TE_KEY)));
if (!g_dest[0]) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- "Printing to file, but no file specified.");
+ "Output to file, but no file specified.");
return;
}
g_free(args->file);
@@ -638,7 +874,7 @@ print_close_cb(GtkWidget *close_bt _U_, gpointer parent_w)
}
static void
-print_destroy_cb(GtkWidget *win, gpointer user_data _U_)
+print_destroy_cb(GtkWidget *win, gpointer user_data)
{
GtkWidget *fs;
@@ -652,7 +888,7 @@ print_destroy_cb(GtkWidget *win, gpointer user_data _U_)
}
/* Note that we no longer have a "Print" dialog box. */
- print_w = NULL;
+ *((gpointer *) user_data) = NULL;
}