diff options
author | Guy Harris <guy@alum.mit.edu> | 2012-06-25 18:37:52 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2012-06-25 18:37:52 +0000 |
commit | f272aaeb803e7c8e7dd9039cd680e114afbe0319 (patch) | |
tree | a120a6fa318d81394118fe232a658a70d045a551 | |
parent | c96179ed1e6feafbed0f4fbbbc93628aa849692e (diff) | |
download | wireshark-f272aaeb803e7c8e7dd9039cd680e114afbe0319.tar.gz |
Only allow "Save" if
the file has unsaved changes, and we can save it in some format
through Wiretap
or
the file is a temporary file and has no unsaved changes (so that
"saving" it just means copying it).
Only allow "Save As" if
we can save it in some format through Wiretap
or
the file is a temporary file and has no unsaved changes (so that
"saving" it just means copying it).
This means that we don't support using "Save As" for just copying the
file unless we can do that with Wiretap; copying the file byte-for-byte
only works as "saving" if there are no unsaved changes *and* we're
saving it in the same format that it's in *and* we're saving it with the
same form of compression (if any) that it has.
Rename cf_can_save_as() to cf_can_write_with_wiretap() to better reflect
what it really does.
svn path=/trunk/; revision=43477
-rw-r--r-- | file.c | 5 | ||||
-rw-r--r-- | file.h | 4 | ||||
-rw-r--r-- | ui/gtk/main_menubar.c | 32 | ||||
-rw-r--r-- | ui/gtk/main_toolbar.c | 15 |
4 files changed, 42 insertions, 14 deletions
@@ -3833,10 +3833,11 @@ save_packet(capture_file *cf _U_, frame_data *fdata, } /* - * Can this capture file be saved in any format except by copying the raw data? + * Can this capture file be written out in any format using Wiretap + * rather than by copying the raw data? */ gboolean -cf_can_save_as(capture_file *cf) +cf_can_write_with_wiretap(capture_file *cf) { int ft; @@ -203,12 +203,12 @@ cf_read_status_t cf_finish_tail(capture_file *cf, int *err); /** * Determine whether this capture file (or a range of it) can be saved - * (except by copying the raw file data). + * in any format using Wiretap rather than by copying the raw data. * * @param cf the capture file to check * @return TRUE if it can be saved, FALSE if it can't */ -gboolean cf_can_save_as(capture_file *cf); +gboolean cf_can_write_with_wiretap(capture_file *cf); /** * Save all packets in a capture file to a new file, and, if that succeeds, diff --git a/ui/gtk/main_menubar.c b/ui/gtk/main_menubar.c index ab62ec925a..a768078128 100644 --- a/ui/gtk/main_menubar.c +++ b/ui/gtk/main_menubar.c @@ -4581,27 +4581,41 @@ set_menus_for_capture_file(capture_file *cf) set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/ExportObjects", FALSE); set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/Reload", FALSE); } else { - set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Merge", cf_can_save_as(cf)); + set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Merge", cf_can_write_with_wiretap(cf)); set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Close", TRUE); /* - * "Save" should be available only if the file is a temporary file - * or has unsaved changes. + * "Save" should be available only if: + * + * the file has unsaved changes, and we can save it in some + * format through Wiretap + * + * or + * + * the file is a temporary file and has no unsaved changes (so + * that "saving" it just means copying it). */ set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Save", - (cf->is_tempfile || cf->unsaved_changes)); + (cf->unsaved_changes && cf_can_write_with_wiretap(cf)) || + (cf->is_tempfile && !cf->unsaved_changes)); /* - * "Save As..." should be available only if we have no unsaved - * changes (so saving just involves copying the raw file) or if - * we can write the file out in at least one format. + * "Save As..." should be available only if: + * + * we can save it in some format through Wiretap + * + * or + * + * the file is a temporary file and has no unsaved changes (so + * that "saving" it just means copying it). */ set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/SaveAs", - (!cf->unsaved_changes || cf_can_save_as(cf))); + cf_can_write_with_wiretap(cf) || + (cf->is_tempfile && !cf->unsaved_changes)); /* * "Export Specified Packets..." should be available only if * we can write the file out in at least one format. */ set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/ExportSpecifiedPackets", - cf_can_save_as(cf)); + cf_can_write_with_wiretap(cf)); set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/ExportPacketDissections", TRUE); set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/ExportSelectedPacketBytes", TRUE); set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/ExportSSLSessionKeys", TRUE); diff --git a/ui/gtk/main_toolbar.c b/ui/gtk/main_toolbar.c index 19c7c15d62..a33fd37e50 100644 --- a/ui/gtk/main_toolbar.c +++ b/ui/gtk/main_toolbar.c @@ -138,8 +138,21 @@ void set_toolbar_for_capture_file(capture_file *cf) { g_object_set_data(G_OBJECT(save_button), "save", GINT_TO_POINTER(0)); } } + + /* + * "Save" should be available only if: + * + * the file has unsaved changes, and we can save it in some + * format through Wiretap + * + * or + * + * the file is a temporary file and has no unsaved changes (so + * that "saving" it just means copying it). + */ gtk_widget_set_sensitive(GTK_WIDGET(save_button), - (cf->is_tempfile || cf->unsaved_changes) && cf_can_save_as(cf)); + (cf->unsaved_changes && cf_can_write_with_wiretap(cf)) || + (cf->is_tempfile && !cf->unsaved_changes)); gtk_widget_set_sensitive(GTK_WIDGET(close_button), TRUE); gtk_widget_set_sensitive(GTK_WIDGET(reload_button), TRUE); } |