summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--file.c5
-rw-r--r--file.h4
-rw-r--r--ui/gtk/main_menubar.c32
-rw-r--r--ui/gtk/main_toolbar.c15
4 files changed, 42 insertions, 14 deletions
diff --git a/file.c b/file.c
index e5c75f556e..60720aa64d 100644
--- a/file.c
+++ b/file.c
@@ -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;
diff --git a/file.h b/file.h
index a86e85fd85..b713c7e3bc 100644
--- a/file.h
+++ b/file.h
@@ -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);
}