aboutsummaryrefslogtreecommitdiffstats
path: root/gtk/file_dlg.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2001-12-06 02:21:26 +0000
committerGuy Harris <guy@alum.mit.edu>2001-12-06 02:21:26 +0000
commita936b559df71128d0d40de3647248464aa60b534 (patch)
treeaa6e4bbf6f48a2c8e17b6ddb772bf9b1b925fe85 /gtk/file_dlg.c
parentfcdb3784172eb64a6a7c6a79793b6541f54c7189 (diff)
Make the "Save only marked frames" button in the "Save As..." dialog box
sensitive only if there *are* marked frames. svn path=/trunk/; revision=4341
Diffstat (limited to 'gtk/file_dlg.c')
-rw-r--r--gtk/file_dlg.c46
1 files changed, 39 insertions, 7 deletions
diff --git a/gtk/file_dlg.c b/gtk/file_dlg.c
index 8a769f1da6..dfefc25025 100644
--- a/gtk/file_dlg.c
+++ b/gtk/file_dlg.c
@@ -1,7 +1,7 @@
/* file_dlg.c
* Dialog boxes for handling files
*
- * $Id: file_dlg.c,v 1.44 2001/11/09 00:08:30 guy Exp $
+ * $Id: file_dlg.c,v 1.45 2001/12/06 02:21:26 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -378,8 +378,8 @@ select_file_type_cb(GtkWidget *w, gpointer data)
/* We can select only the filtered or marked packets to be saved if we can
use Wiretap to save the file. */
gtk_widget_set_sensitive(filter_cb, can_save_with_wiretap(new_filetype));
- gtk_widget_set_sensitive(mark_cb, can_save_with_wiretap(new_filetype));
filetype = new_filetype;
+ file_set_save_marked_sensitive();
}
}
@@ -472,17 +472,15 @@ file_save_as_cmd_cb(GtkWidget *w, gpointer data)
gtk_widget_show(filter_cb);
/*
- * XXX - should this be sensitive only if at least one packet is
- * marked, so that there are marked packets to save, and if not
- * all packets are marked, so that "only marked packets" is different
- * from "all packets"?
+ * XXX - if the number of marked frames changes to or from 0, we
+ * should change whether this is sensitive or not.
*/
mark_cb = gtk_check_button_new_with_label("Save only marked packets");
gtk_container_add(GTK_CONTAINER(main_vb), mark_cb);
+ marked = FALSE;
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(mark_cb), FALSE);
gtk_signal_connect(GTK_OBJECT(mark_cb), "toggled",
GTK_SIGNAL_FUNC(toggle_marked_cb), NULL);
- gtk_widget_set_sensitive(mark_cb, can_save_with_wiretap(filetype));
gtk_widget_show(mark_cb);
/* File type row */
@@ -501,6 +499,15 @@ file_save_as_cmd_cb(GtkWidget *w, gpointer data)
gtk_box_pack_start(GTK_BOX(ft_hb), ft_om, FALSE, FALSE, 0);
gtk_widget_show(ft_om);
+ /*
+ * Make the "Save only marked packets" toggle sensitive if there are
+ * marked frames; make it insensitive, turn it off, and set the
+ * file type option menu appropriately, if there aren't.
+ *
+ * This has to be done after we create the file type menu option.
+ */
+ file_set_save_marked_sensitive();
+
/* Connect the cancel_button to destroy the widget */
gtk_signal_connect_object(GTK_OBJECT (GTK_FILE_SELECTION
(file_save_as_w)->cancel_button), "clicked", (GtkSignalFunc)
@@ -512,9 +519,34 @@ file_save_as_cmd_cb(GtkWidget *w, gpointer data)
dlg_set_cancel(file_save_as_w, GTK_FILE_SELECTION(file_save_as_w)->cancel_button);
gtk_file_selection_set_filename(GTK_FILE_SELECTION(file_save_as_w), "");
+
gtk_widget_show(file_save_as_w);
}
+/*
+ * Set the "Save only marked packets" toggle button as appropriate for
+ * the current output file type and count of marked packets.
+ * Called when the "Save As..." dialog box is created and when either
+ * the file type or the marked count changes.
+ */
+void
+file_set_save_marked_sensitive(void)
+{
+ /* We can request that only the marked packets be saved only if we
+ can use Wiretap to save the file and if there *are* marked packets. */
+ if (can_save_with_wiretap(filetype) && cfile.marked_count != 0)
+ gtk_widget_set_sensitive(mark_cb, TRUE);
+ else {
+ /* Force the "Save only marked packets" toggle to "false", turn
+ off the flag it controls, and update the list of types we can
+ save the file as. */
+ marked = FALSE;
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(mark_cb), FALSE);
+ set_file_type_list(ft_om);
+ gtk_widget_set_sensitive(mark_cb, FALSE);
+ }
+}
+
static void
file_save_as_ok_cb(GtkWidget *w, GtkFileSelection *fs) {
gchar *cf_name;