diff options
author | Guy Harris <guy@alum.mit.edu> | 2006-02-11 11:21:38 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2006-02-11 11:21:38 +0000 |
commit | ca970e37571a3a39d6fc257c899ffacc25222269 (patch) | |
tree | ff956e880115576e487829bce6a27e383a9fe274 /gtk/file_dlg.c | |
parent | 83aad499b42aaf5b004206f6b29989182716d5cb (diff) |
In "Save As", support only file types we can write to; that simplifies
the logic, making it easier to get it right (fewer interactions between
components of the dialog - the file type doesn't affect whether we can
save some but not all packets). It also means we don't offer a file
type for saving, only to take it away if you choose anything other than
saving all packets.
If the capture file is a temporary file from a capture done in the
current Ethereal session, it's libpcap format, which we can write to, so
you would be able to save it.
If it's a saved file we read in, saving the file in its entirety in its
own format is just copying the file, and it's not clear supporting that
adds enough useful functionality to justify the extra complication.
Fix "range_update_dynamics()" to update all the rows of the range
button/count table properly (make the button active iff there's
a non-zero count in the currently-selected column, make a count active
iff the column is selected), to select the "Captured" column if the
count of displayed packets goes to zero, and to select the "Save all
packets" row if the count of packets in the currently-selected row and
column goes to zero. (XXX - we should perhaps do that with the
"user-defined range" counts as well, which would involve updating the
counts on every change to the range field.)
svn path=/trunk/; revision=17251
Diffstat (limited to 'gtk/file_dlg.c')
-rw-r--r-- | gtk/file_dlg.c | 85 |
1 files changed, 20 insertions, 65 deletions
diff --git a/gtk/file_dlg.c b/gtk/file_dlg.c index a2a6dd0da8..5943bcb00c 100644 --- a/gtk/file_dlg.c +++ b/gtk/file_dlg.c @@ -1161,20 +1161,8 @@ can_save_with_wiretap(int ft) } -/* Generate a list of the file types we can save this file as. - - "filetype" is the type it has now. - - "encap" is the encapsulation for its packets (which could be - "unknown" or "per-packet"). - - "filtered" is TRUE if we're to save only the packets that passed - the display filter (in which case we have to save it using Wiretap) - and FALSE if we're to save the entire file (in which case, if we're - saving it in the type it has already, we can just copy it). - - The same applies for sel_curr, sel_all, sel_m_only, sel_m_range and sel_man_range -*/ +/* Generate a list of the file types we can save this file as, by + checking what Wiretap supports. */ static void set_file_type_list(GtkWidget *option_menu) { @@ -1192,23 +1180,19 @@ set_file_type_list(GtkWidget *option_menu) /* Check all file types. */ index = 0; for (ft = 0; ft < WTAP_NUM_FILE_TYPES; ft++) { - if (!packet_range_process_all(&range) || ft != cfile.cd_t) { - /* not all unfiltered packets or a different file type. We have to use Wiretap. */ - if (!can_save_with_wiretap(ft)) - continue; /* We can't. */ - } - - /* OK, we can write it out in this type. */ - ft_menu_item = gtk_menu_item_new_with_label(wtap_file_type_string(ft)); - if (ft == filetype) { - /* Default to the same format as the file, if it's supported. */ - item_to_select = index; + if (can_save_with_wiretap(ft)) { + /* OK, we can write it out in this type. */ + ft_menu_item = gtk_menu_item_new_with_label(wtap_file_type_string(ft)); + if (ft == filetype) { + /* Default to the same format as the file, if it's supported. */ + item_to_select = index; + } + SIGNAL_CONNECT(ft_menu_item, "activate", select_file_type_cb, + GINT_TO_POINTER(ft)); + gtk_menu_append(GTK_MENU(ft_menu), ft_menu_item); + gtk_widget_show(ft_menu_item); + index++; } - SIGNAL_CONNECT(ft_menu_item, "activate", select_file_type_cb, - GINT_TO_POINTER(ft)); - gtk_menu_append(GTK_MENU(ft_menu), ft_menu_item); - gtk_widget_show(ft_menu_item); - index++; } gtk_option_menu_set_menu(GTK_OPTION_MENU(option_menu), ft_menu); @@ -1222,46 +1206,26 @@ select_file_type_cb(GtkWidget *w _U_, gpointer data) GtkWidget *compressed_cb; if (filetype != new_filetype) { - /* We can select only the filtered or marked packets to be saved if we can - use Wiretap to save the file. */ - if (range_tb != NULL) - range_set_displayed_sensitive(range_tb, can_save_with_wiretap(new_filetype)); filetype = new_filetype; - file_set_save_marked_sensitive(); - compressed_cb = OBJECT_GET_DATA(file_save_as_w, "compressed"); - gtk_widget_set_sensitive(compressed_cb, wtap_dump_can_compress(new_filetype)); + compressed_cb = OBJECT_GET_DATA(file_save_as_w, "compressed"); + gtk_widget_set_sensitive(compressed_cb, wtap_dump_can_compress(new_filetype)); } } /* - * 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. + * Update various dynamic parts of the range controls; called from outside + * the file dialog code whenever the packet counts change. */ void -file_set_save_marked_sensitive(void) +file_save_update_dynamics(void) { if (file_save_as_w == NULL) { /* We don't currently have a "Save As..." dialog box up. */ return; } - /* 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) { - range_set_marked_sensitive(range_tb, 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. */ - range.process = range_process_all; - set_file_type_list(ft_om); - range_set_marked_sensitive(range_tb, FALSE); - } + range_update_dynamics(range_tb); } @@ -1345,15 +1309,6 @@ file_save_as_cmd(action_after_save_e action_after_save, gpointer action_after_sa gtk_box_pack_start(GTK_BOX(ft_hb), ft_om, FALSE, FALSE, 0); gtk_widget_show(ft_om); - /* - * Set the sensitivity of the "Save only marked packets" toggle - * button - * - * This has to be done after we create the file type menu option, - * as the routine that sets it also sets that menu. - */ - file_set_save_marked_sensitive(); - /* dynamic values in the range frame */ range_update_dynamics(range_tb); |