diff options
author | Guy Harris <guy@alum.mit.edu> | 2012-05-25 21:25:55 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2012-05-25 21:25:55 +0000 |
commit | 601403570300c61921515bfc9e1a08a8d65cba5f (patch) | |
tree | 47a97b29a7ed76ebbcc7c7b7116ee1387c16fc1c | |
parent | ce9bd398931417602c5884019923f71b7dee4391 (diff) |
Use GTK+'s GtkMessageDialog for the questions we ask in the process of
saving files, and run it modal (which we're already doing with the
GtkFileChooserDialog); this means less callback-based state machine
stuff, simplifying the code paths a bit.
If we're saving a file before closing it, don't bother reloading it
after saving it.
svn path=/trunk/; revision=42855
-rw-r--r-- | file.c | 70 | ||||
-rw-r--r-- | file.h | 6 | ||||
-rw-r--r-- | ui/gtk/capture_dlg.c | 37 | ||||
-rw-r--r-- | ui/gtk/capture_file_dlg.c | 587 | ||||
-rw-r--r-- | ui/gtk/capture_file_dlg.h | 33 | ||||
-rw-r--r-- | ui/gtk/drag_and_drop.c | 39 | ||||
-rw-r--r-- | ui/gtk/export_sslkeys.c | 1 | ||||
-rw-r--r-- | ui/gtk/file_import_dlg.c | 41 | ||||
-rw-r--r-- | ui/gtk/main.c | 58 | ||||
-rw-r--r-- | ui/gtk/main_menubar.c | 40 | ||||
-rw-r--r-- | ui/gtk/main_proto_draw.c | 1 | ||||
-rw-r--r-- | ui/gtk/main_toolbar.c | 3 | ||||
-rw-r--r-- | ui/gtk/print_dlg.c | 1 | ||||
-rw-r--r-- | ui/win32/file_dlg_win32.c | 39 | ||||
-rw-r--r-- | ui/win32/file_dlg_win32.h | 4 |
15 files changed, 414 insertions, 546 deletions
@@ -3813,7 +3813,7 @@ cf_can_save_as(capture_file *cf) cf_status_t cf_save_packets(capture_file *cf, const char *fname, guint save_format, - gboolean compressed) + gboolean compressed, gboolean dont_reopen) { gchar *fname_new = NULL; int err; @@ -3966,42 +3966,44 @@ cf_save_packets(capture_file *cf, const char *fname, guint save_format, } cf_callback_invoke(cf_cb_file_save_finished, NULL); - - /* Open and read the file we saved to. - - XXX - this is somewhat of a waste; we already have the - packets, all this gets us is updated file type information - (which we could just stuff into "cf"), and having the new - file be the one we have opened and from which we're reading - the data, and it means we have to spend time opening and - reading the file, which could be a significant amount of - time if the file is large. - - If the capture-file-writing code were to return the - seek offset of each packet it writes, we could save that - in the frame_data structure for the frame, and just open - the file without reading it again. */ cf->unsaved_changes = FALSE; - if ((cf_open(cf, fname, FALSE, &err)) == CF_OK) { - /* XXX - report errors if this fails? - What should we return if it fails or is aborted? */ - - switch (cf_read(cf, TRUE)) { - - case CF_READ_OK: - case CF_READ_ERROR: - /* Just because we got an error, that doesn't mean we were unable - to read any of the file; we handle what we could get from the - file. */ - break; + if (!dont_reopen) { + /* Open and read the file we saved to. + + XXX - this is somewhat of a waste; we already have the + packets, all this gets us is updated file type information + (which we could just stuff into "cf"), and having the new + file be the one we have opened and from which we're reading + the data, and it means we have to spend time opening and + reading the file, which could be a significant amount of + time if the file is large. + + If the capture-file-writing code were to return the + seek offset of each packet it writes, we could save that + in the frame_data structure for the frame, and just open + the file without reading it again. */ + + if ((cf_open(cf, fname, FALSE, &err)) == CF_OK) { + /* XXX - report errors if this fails? + What should we return if it fails or is aborted? */ + + switch (cf_read(cf, TRUE)) { + + case CF_READ_OK: + case CF_READ_ERROR: + /* Just because we got an error, that doesn't mean we were unable + to read any of the file; we handle what we could get from the + file. */ + break; - case CF_READ_ABORTED: - /* The user bailed out of re-reading the capture file; the - capture file has been closed - just return (without - changing any menu settings; "cf_close()" set them - correctly for the "no capture file open" state). */ - break; + case CF_READ_ABORTED: + /* The user bailed out of re-reading the capture file; the + capture file has been closed - just return (without + changing any menu settings; "cf_close()" set them + correctly for the "no capture file open" state). */ + break; + } } } return CF_OK; @@ -206,9 +206,13 @@ gboolean cf_can_save_as(capture_file *cf); * @param fname the filename to save to * @param save_format the format of the file to save (libpcap, ...) * @param compressed whether to gzip compress the file + * @param dont_reopen TRUE if it shouldn't reopen and make that file the + * current capture file * @return one of cf_status_t */ -cf_status_t cf_save_packets(capture_file * cf, const char *fname, guint save_format, gboolean compressed); +cf_status_t cf_save_packets(capture_file * cf, const char *fname, + guint save_format, gboolean compressed, + gboolean dont_reopen); /** * Export some or all packets from a capture file to a new file. If there's diff --git a/ui/gtk/capture_dlg.c b/ui/gtk/capture_dlg.c index fbcf7f6a5d..74ca0ca940 100644 --- a/ui/gtk/capture_dlg.c +++ b/ui/gtk/capture_dlg.c @@ -4194,33 +4194,10 @@ capture_start_confirmed(void) } } -/* user confirmed the "Save capture file..." dialog */ -static void -capture_start_answered_cb(gpointer dialog _U_, gint btn, gpointer data) -{ - switch(btn) { - case(ESD_BTN_SAVE): - /* save file first */ - file_save_as_cmd(after_save_capture_dialog, data); - break; - case(ESD_BTN_DONT_SAVE): - /* XXX - unlink old file? */ - /* start the capture */ - capture_start_confirmed(); - break; - case(ESD_BTN_CANCEL): - break; - default: - g_assert_not_reached(); - } -} - /* user pressed the "Start" button (in dialog or toolbar) */ void capture_start_cb(GtkWidget *w _U_, gpointer d _U_) { - gpointer dialog; - #ifdef HAVE_AIRPCAP airpcap_if_active = airpcap_if_selected; if (airpcap_if_active) @@ -4251,19 +4228,9 @@ capture_start_cb(GtkWidget *w _U_, gpointer d _U_) return; } - if((cfile.state != FILE_CLOSED) && (cfile.is_tempfile || cfile.unsaved_changes) && - prefs.gui_ask_unsaved) { - /* This is a temporary capture file or has unsaved changes; ask the - user whether to save the capture. */ - dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_SAVE_DONTSAVE_CANCEL, - "%sSave capture file before starting a new capture?%s\n\n" - "If you start a new capture without saving, your current capture data will\nbe discarded.", - simple_dialog_primary_start(), simple_dialog_primary_end()); - simple_dialog_set_cb(dialog, capture_start_answered_cb, NULL); - } else { - /* unchanged file, just capture a new one */ + /* XXX - will closing this remove a temporary file? */ + if (do_file_close(&cfile, FALSE, " before starting a new capture")) capture_start_confirmed(); - } } diff --git a/ui/gtk/capture_file_dlg.c b/ui/gtk/capture_file_dlg.c index 83ea2738cd..b35322c3f1 100644 --- a/ui/gtk/capture_file_dlg.c +++ b/ui/gtk/capture_file_dlg.c @@ -82,8 +82,10 @@ static void file_open_ok_cb(GtkWidget *w, gpointer fs); static void file_open_destroy_cb(GtkWidget *win, gpointer user_data); static void file_merge_ok_cb(GtkWidget *w, gpointer fs); static void file_merge_destroy_cb(GtkWidget *win, gpointer user_data); +static void do_file_save(capture_file *cf, gboolean dont_reopen); +static void do_file_save_as(capture_file *cf); +static void file_save_as_cb(GtkWidget *fs); static void file_save_as_select_file_type_cb(GtkWidget *w, gpointer data); -static void file_save_as_ok_cb(GtkWidget *w, gpointer fs); static void file_save_as_destroy_cb(GtkWidget *win, gpointer user_data); static void file_export_specified_packets_cb(GtkWidget *w, gpointer fs); static void file_export_specified_packets_select_file_type_cb(GtkWidget *w, gpointer data); @@ -594,41 +596,12 @@ file_open_cmd(GtkWidget *w) #endif /* _WIN32 */ } -static void file_open_answered_cb(gpointer dialog _U_, gint btn, gpointer data) -{ - switch(btn) { - case(ESD_BTN_SAVE): - /* save file first */ - file_save_as_cmd(after_save_open_dialog, data); - break; - case(ESD_BTN_DONT_SAVE): - cf_close(&cfile); - file_open_cmd(data); - break; - case(ESD_BTN_CANCEL): - break; - default: - g_assert_not_reached(); - } -} - void file_open_cmd_cb(GtkWidget *widget, gpointer data _U_) { - gpointer dialog; - - if((cfile.state != FILE_CLOSED) && (cfile.is_tempfile || cfile.unsaved_changes) && - prefs.gui_ask_unsaved) { - /* This is a temporary capture file or has unsaved changes; ask the - user whether to save the capture. */ - dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_SAVE_DONTSAVE_CANCEL, - "%sSave capture file before opening a new one?%s\n\n" - "If you open a new capture file without saving, your capture data will be discarded.", - simple_dialog_primary_start(), simple_dialog_primary_end()); - simple_dialog_set_cb(dialog, file_open_answered_cb, widget); - } else { - /* unchanged file, just open a new one */ + /* If there's unsaved data, let the user save it first. + If they cancel out of it, don't quit. */ + if (do_file_close(&cfile, FALSE, " before opening a new capture file")) file_open_cmd(widget); - } } /* user pressed "open" button */ @@ -904,37 +877,87 @@ file_merge_cmd(GtkWidget *w) #endif /* _WIN32 */ } -static void file_merge_answered_cb(gpointer dialog _U_, gint btn, gpointer data _U_) -{ - switch(btn) { - case(ESD_BTN_OK): - /* save file first */ - file_save_as_cmd(after_save_merge_dialog, data); - break; - case(ESD_BTN_CANCEL): - break; - default: - g_assert_not_reached(); - } -} - void file_merge_cmd_cb(GtkWidget *widget, gpointer data _U_) { - gpointer dialog; + /* If there's unsaved data, let the user save it first. + If they cancel out of it, don't merge. */ + GtkWidget *msg_dialog; + gchar *vmessage, *message; + gint response; + + if (prefs.gui_ask_unsaved) { + if (cfile.is_tempfile || cfile.unsaved_changes) { + /* This is a temporary capture file or has unsaved changes; ask the + user whether to save the capture. */ + if (cfile.is_tempfile) { + msg_dialog = gtk_message_dialog_new(GTK_WINDOW(top_level), + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_NONE, + "Do you want to save the captured packets before merging another capture file into it?"); + + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(msg_dialog), + "A temporary capture file can't be merged."); + } else { + /* + * Format the message. + * + * XXX - is this because cf_name is in the locale, rather than being + * guaranteed to be in UTF-8? + */ + vmessage = g_strdup_printf("Do you want to save the changes you've made " + "to the capture file \"%s\" before merging another capture file into it?", + cfile.filename); + + /* convert character encoding from locale to UTF8 (using iconv) */ + message = g_locale_to_utf8(vmessage, -1, NULL, NULL, NULL); + g_free(vmessage); + + msg_dialog = gtk_message_dialog_new(GTK_WINDOW(top_level), + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_NONE, + "%s", message); + g_free(message); + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(msg_dialog), + "The changes must be saved before the files are merged."); + } - if((cfile.state != FILE_CLOSED) && (cfile.is_tempfile || cfile.unsaved_changes) && - prefs.gui_ask_unsaved) { - /* This is a temporary capture file or has unsaved changes; ask the - user whether to save the capture. */ - dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_OK_CANCEL, - "%sSave the capture file before merging to another one?%s\n\n" - "A temporary capture file can't be merged.", - simple_dialog_primary_start(), simple_dialog_primary_end()); - simple_dialog_set_cb(dialog, file_merge_answered_cb, widget); - } else { - /* unchanged file, just start to merge */ - file_merge_cmd(widget); +#ifndef _WIN32 + gtk_dialog_add_button(GTK_DIALOG(msg_dialog), + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); + gtk_dialog_add_button(GTK_DIALOG(msg_dialog), + GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT); +#else + gtk_dialog_add_button(GTK_DIALOG(msg_dialog), + GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT); + gtk_dialog_add_button(GTK_DIALOG(msg_dialog), + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); +#endif + gtk_dialog_set_default_response(GTK_DIALOG(msg_dialog), GTK_RESPONSE_ACCEPT); + + response = gtk_dialog_run(GTK_DIALOG(msg_dialog)); + gtk_widget_destroy(msg_dialog); + + switch (response) { + + case GTK_RESPONSE_ACCEPT: + /* Save the file but don't close it */ + do_file_save(&cfile, FALSE); + break; + + case GTK_RESPONSE_CANCEL: + case GTK_RESPONSE_NONE: + case GTK_RESPONSE_DELETE_EVENT: + default: + /* Don't do the merge. */ + return; + } + } } + + /* Do the merge. */ + file_merge_cmd(widget); } @@ -1071,63 +1094,159 @@ file_merge_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_) file_merge_w = NULL; } - -static void file_close_answered_cb(gpointer dialog _U_, gint btn, gpointer data _U_) +gboolean +do_file_close(capture_file *cf, gboolean from_quit, const char *before_what) { - switch(btn) { - case(ESD_BTN_SAVE): - /* save file first */ - file_save_as_cmd(after_save_close_file, NULL); + GtkWidget *msg_dialog; + gchar *vmessage, *message; + gint response; + + if (cf->state == FILE_CLOSED) + return TRUE; /* already closed, nothing to do */ + + if (prefs.gui_ask_unsaved) { + if (cf->is_tempfile || cf->unsaved_changes) { + /* This is a temporary capture file or has unsaved changes; ask the + user whether to save the capture. */ + if (cf->is_tempfile) { + msg_dialog = gtk_message_dialog_new(GTK_WINDOW(top_level), + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_NONE, + "Do you want to save the captured packets%s?", + before_what); + + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(msg_dialog), + "Your captured packets will be lost if you don't save them."); + } else { + /* + * Format the message. + * + * XXX - is this because cf_name is in the locale, rather than being + * guaranteed to be in UTF-8? + */ + vmessage = g_strdup_printf("Do you want to save the changes you've made " + "to the capture file \"%s\"%s?", + cf->filename, before_what); + + /* convert character encoding from locale to UTF8 (using iconv) */ + message = g_locale_to_utf8(vmessage, -1, NULL, NULL, NULL); + g_free(vmessage); + + msg_dialog = gtk_message_dialog_new(GTK_WINDOW(top_level), + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_NONE, + "%s", message); + g_free(message); + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(msg_dialog), + "Your changes will be lost if you don't save them."); + } + +#ifndef _WIN32 + /* If this is from a Quit operation, use "quit and don't save" + rather than just "don't save". */ + gtk_dialog_add_button(GTK_DIALOG(msg_dialog), + (from_quit ? WIRESHARK_STOCK_QUIT_DONT_SAVE : + WIRESHARK_STOCK_DONT_SAVE), + GTK_RESPONSE_REJECT); + gtk_dialog_add_button(GTK_DIALOG(msg_dialog), + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); + /* If there's a read in progress, we can't save. */ + if (cf->state != FILE_READ_IN_PROGRESS) + gtk_dialog_add_button(GTK_DIALOG(msg_dialog), + GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT); +#else + /* If there's a read in progress, we can't save. */ + if (cf->state != FILE_READ_IN_PROGRESS) + gtk_dialog_add_button(GTK_DIALOG(msg_dialog), + GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT); + gtk_dialog_add_button(GTK_DIALOG(msg_dialog), + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); + gtk_dialog_add_button(GTK_DIALOG(msg_dialog), + (from_quit ? WIRESHARK_STOCK_QUIT_DONT_SAVE : + WIRESHARK_STOCK_DONT_SAVE), + GTK_RESPONSE_REJECT); +#endif + gtk_dialog_set_default_response(GTK_DIALOG(msg_dialog), GTK_RESPONSE_ACCEPT); + + response = gtk_dialog_run(GTK_DIALOG(msg_dialog)); + gtk_widget_destroy(msg_dialog); + + switch (response) { + + case GTK_RESPONSE_ACCEPT: + /* Save the file and close it */ + do_file_save(cf, TRUE); break; - case(ESD_BTN_DONT_SAVE): - cf_close(&cfile); + + case GTK_RESPONSE_REJECT: + /* Just close the file, discarding changes */ + cf_close(cf); break; - case(ESD_BTN_CANCEL): + + case GTK_RESPONSE_CANCEL: + case GTK_RESPONSE_NONE: + case GTK_RESPONSE_DELETE_EVENT: + default: + /* Don't close the file. */ + return FALSE; /* file not closed */ break; - default: - g_assert_not_reached(); + } + } else { + /* User asked not to be bothered by those prompts, just close it. + XXX - should that apply only to saving temporary files? */ + cf_close(cf); } + } else { + /* unchanged file, just close it */ + cf_close(cf); + } + return TRUE; /* file closed */ } /* Close a file */ void file_close_cmd_cb(GtkWidget *widget _U_, gpointer data _U_) { - gpointer dialog; - - if((cfile.state != FILE_CLOSED) && (cfile.is_tempfile || cfile.unsaved_changes) && - prefs.gui_ask_unsaved) { - /* This is a temporary capture file or has unsaved changes; ask the - user whether to save the capture. */ - dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_SAVE_DONTSAVE_CANCEL, - "%sSave capture file before closing it?%s\n\n" - "If you close without saving, your capture data will be discarded.", - simple_dialog_primary_start(), simple_dialog_primary_end()); - - simple_dialog_set_cb(dialog, file_close_answered_cb, NULL); - } else { - /* unchanged file, just close it */ - cf_close(&cfile); - } + do_file_close(&cfile, FALSE, ""); } -void -file_save_cmd_cb(GtkWidget *w _U_, gpointer data _U_) { - if (cfile.is_tempfile) { +/* + * Save the capture file in question, prompting the user for a file + * name to save to if necessary. + */ +static void +do_file_save(capture_file *cf, gboolean dont_reopen) +{ + char *fname; + + if (cf->is_tempfile) { /* This is a temporary capture file, so saving it means saving - it to a permanent file. */ - file_save_as_cmd(after_save_no_action, NULL); + it to a permanent file. Prompt the user for a location + to which to save it. */ + do_file_save_as(cf); } else { - if (cfile.unsaved_changes) { + if (cf->unsaved_changes) { /* This is not a temporary capture file, but it has unsaved changes, so saving it means doing a "safe save" on top of the existing file, in the same format - no UI needed. */ - file_save_cmd(after_save_no_action, NULL); + /* XXX - cf->filename might get freed out from under us, because + the code path through which cf_save_packets() goes currently + closes the current file and then opens and reloads the saved file, + so make a copy and free it later. */ + fname = g_strdup(cf->filename); + cf_save_packets(cf, fname, cf->cd_t, cf->iscompressed, dont_reopen); + g_free(fname); } - /* Otherwise just do nothing (this shouldn't even be enabled if - it's not a temporary file and there are no unsaved changes). */ + /* Otherwise just do nothing. */ } } +void +file_save_cmd_cb(GtkWidget *w _U_, gpointer data _U_) { + do_file_save(&cfile, FALSE); +} + /* Attach a list of the valid 'save as' file types to a combo_box by checking what Wiretap supports. Make the default type the first in the list. @@ -1178,35 +1297,17 @@ file_save_as_select_file_type_cb(GtkWidget *w, gpointer data _U_) } -action_after_save_e action_after_save_g; -gpointer action_after_save_data_g; - - -void -file_save_cmd(action_after_save_e action_after_save, gpointer action_after_save_data) -{ - char *fname; - - action_after_save_g = action_after_save; - action_after_save_data_g = action_after_save_data; - - /* XXX - cfile.filename might get freed out from under us, because - the code path through which cf_save_packets() goes currently closes the - current file and then opens and reloads the saved file, so make - a copy and free it later. */ - fname = g_strdup(cfile.filename); - - cf_save_packets(&cfile, fname, cfile.cd_t, cfile.iscompressed); - g_free(fname); -} - -void -file_save_as_cmd(action_after_save_e action_after_save, gpointer action_after_save_data) +static void +do_file_save_as(capture_file *cf) { #if _WIN32 - win32_save_as_file(GDK_WINDOW_HWND(gtk_widget_get_window(top_level)), action_after_save, action_after_save_data); + win32_save_as_file(GDK_WINDOW_HWND(gtk_widget_get_window(top_level))); #else /* _WIN32 */ GtkWidget *main_vb, *ft_hb, *ft_lb, *ft_combo_box, *compressed_cb; + GtkWidget *msg_dialog; + gchar *vmessage, *message; + gint response; + char *cf_name; if (file_save_as_w != NULL) { /* There's already an "Save Capture File As" dialog box; reactivate it. */ @@ -1220,11 +1321,6 @@ file_save_as_cmd(action_after_save_e action_after_save, gpointer action_after_sa file_save_as_w = file_selection_new ("Wireshark: Save Capture File As", FILE_SELECTION_SAVE); - /* as the dialog might already be gone, when using this values, we cannot - * set data to the dialog object, but keep global values */ - action_after_save_g = action_after_save; - action_after_save_data_g = action_after_save_data; - /* Container for each row of widgets */ main_vb = gtk_vbox_new(FALSE, 5); @@ -1245,7 +1341,7 @@ file_save_as_cmd(action_after_save_e action_after_save, gpointer action_after_sa ft_combo_box = ws_combo_box_new_text_and_pointer(); /* Generate the list of file types we can save. */ - set_file_type_list(ft_combo_box, cfile.cd_t); + set_file_type_list(ft_combo_box, cf->cd_t); gtk_box_pack_start(GTK_BOX(ft_hb), ft_combo_box, FALSE, FALSE, 0); gtk_widget_show(ft_combo_box); g_object_set_data(G_OBJECT(file_save_as_w), E_FILE_TYPE_COMBO_BOX_KEY, ft_combo_box); @@ -1262,10 +1358,111 @@ file_save_as_cmd(action_after_save_e action_after_save, gpointer action_after_sa g_signal_connect(file_save_as_w, "destroy", G_CALLBACK(file_save_as_destroy_cb), NULL); - if (gtk_dialog_run(GTK_DIALOG(file_save_as_w)) == GTK_RESPONSE_ACCEPT) { - file_save_as_ok_cb(file_save_as_w, file_save_as_w); - } else { - window_destroy(file_save_as_w); + /* + * Loop until the user either selects a file or gives up. + */ + for (;;) { + if (gtk_dialog_run(GTK_DIALOG(file_save_as_w)) != GTK_RESPONSE_ACCEPT) { + /* They clicked "Cancel" or closed the dialog or.... */ + window_destroy(file_save_as_w); + return; + } + + cf_name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(file_save_as_w)); + + /* Perhaps the user specified a directory instead of a file. + Check whether they did. */ + if (test_for_directory(cf_name) == EISDIR) { + /* It's a directory - set the file selection box to display that + directory, and go back and re-run it. */ + set_last_open_dir(cf_name); + g_free(cf_name); + file_selection_set_current_folder(file_save_as_w, + get_last_open_dir()); + continue; + } + + /* + * Check that the from file is not the same as to file + * We do it here so we catch all cases ... + * Unfortunately, the file requester gives us an absolute file + * name and the read file name may be relative (if supplied on + * the command line). From Joerg Mayer. + */ + if (files_identical(cf->filename, cf_name)) { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + "%sCapture file: \"%s\" identical to loaded file!%s\n\n" + "Please choose a different filename.", + simple_dialog_primary_start(), cf_name, simple_dialog_primary_end()); + g_free(cf_name); + + /* XXX - as we cannot start a new event loop (using gtk_dialog_run()), + * as this will prevent the user from closing the now existing error + * message, simply close the dialog (this is the best we can do here). */ + if (file_save_as_w) + window_destroy(GTK_WIDGET(file_save_as_w)); + + return; + } + + /* it the file doesn't exist, simply try to save it */ + if (!file_exists(cf_name)) { + gtk_widget_hide(GTK_WIDGET(file_save_as_w)); + g_free(cf_name); + file_save_as_cb(file_save_as_w); + return; + } + + /* The file exists. Ask the user if they want to overwrite it. */ + + /* + * Format the message. + * + * XXX - is this because cf_name is in the locale, rather than being + * guaranteed to be in UTF-8? + */ + vmessage = g_strdup_printf("A file named \"%s\" already exists. Do you want to replace it?", + cf_name); + + /* convert character encoding from locale to UTF8 (using iconv) */ + message = g_locale_to_utf8(vmessage, -1, NULL, NULL, NULL); + g_free(vmessage); + + msg_dialog = gtk_message_dialog_new(GTK_WINDOW(file_save_as_w), + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_NONE, + "%s", message); + g_free(message); + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(msg_dialog), + "A file or folder with the same name already exists in that folder. " + "Replacing it will overwrite its current contents."); + + gtk_dialog_add_buttons(GTK_DIALOG(msg_dialog), +#ifndef _WIN32 + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + "Replace", GTK_RESPONSE_ACCEPT, +#else + "Replace", GTK_RESPONSE_ACCEPT, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, +#endif + NULL); + gtk_dialog_set_default_response(GTK_DIALOG(msg_dialog), GTK_RESPONSE_CANCEL); + + response = gtk_dialog_run(GTK_DIALOG(msg_dialog)); + gtk_widget_destroy(msg_dialog); + + if (response != GTK_RESPONSE_ACCEPT) { + /* The user doesn't want to overwrite this file; let them choose + another one */ + g_free(cf_name); + continue; + } + + /* save file */ + gtk_widget_hide(GTK_WIDGET(file_save_as_w)); + file_save_as_cb(file_save_as_w); + return; } #endif /* _WIN32 */ } @@ -1273,13 +1470,13 @@ file_save_as_cmd(action_after_save_e action_after_save, gpointer action_after_sa void file_save_as_cmd_cb(GtkWidget *w _U_, gpointer data _U_) { - file_save_as_cmd(after_save_no_action, NULL); + do_file_save_as(&cfile); } /* all tests ok, we only have to save the file */ /* (and probably continue with a pending operation) */ static void -file_save_as_cb(GtkWidget *w _U_, gpointer fs) { +file_save_as_cb(GtkWidget *fs) { GtkWidget *ft_combo_box; GtkWidget *compressed_cb; gchar *cf_name; @@ -1300,7 +1497,7 @@ file_save_as_cb(GtkWidget *w _U_, gpointer fs) { compressed = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(compressed_cb)); /* Write out all the packets to the file with the specified name. */ - if (cf_save_packets(&cfile, cf_name, file_type, compressed) != CF_OK) { + if (cf_save_packets(&cfile, cf_name, file_type, compressed, FALSE) != CF_OK) { /* The write failed; don't dismiss the open dialog box, just leave it around so that the user can, after they dismiss the alert box popped up for the error, try again. */ @@ -1322,131 +1519,9 @@ file_save_as_cb(GtkWidget *w _U_, gpointer fs) { dirname = get_dirname(cf_name); /* Overwrites cf_name */ set_last_open_dir(dirname); g_free(cf_name); - - /* we have finished saving, do we have pending things to do? */ - switch(action_after_save_g) { - case(after_save_no_action): - break; - case(after_save_open_dialog): - file_open_cmd(action_after_save_data_g); - break; - case(after_save_open_recent_file): - menu_open_recent_file_cmd(action_after_save_data_g); - break; - case(after_save_open_dnd_file): - dnd_open_file_cmd(action_after_save_data_g); - break; - case(after_save_merge_dialog): - file_merge_cmd(action_after_save_data_g); - break; -#ifdef HAVE_LIBPCAP - case(after_save_capture_dialog): - capture_start_confirmed(); - break; -#endif - case(after_save_close_file): - cf_close(&cfile); - break; - case(after_save_exit): - main_do_quit(); - break; - default: - g_assert_not_reached(); - } - - action_after_save_g = after_save_no_action; -} - - -static void file_save_as_exists_answered_cb(gpointer dialog _U_, gint btn, gpointer data) -{ - gchar *cf_name; - - cf_name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(data)); - - switch(btn) { - case(ESD_BTN_OK): - /* save file */ - file_save_as_cb(NULL, data); - break; - case(ESD_BTN_CANCEL): - /* XXX - as we cannot start a new event loop (using gtk_dialog_run()), - * as this will prevent the user from closing the now existing error - * message, simply close the dialog (this is the best we can do here). */ - if (file_save_as_w) - window_destroy(file_save_as_w); - break; - default: - g_assert_not_reached(); - } - g_free(cf_name); } -/* user pressed "Save As" dialog "Ok" button */ -static void -file_save_as_ok_cb(GtkWidget *w _U_, gpointer fs) { - gchar *cf_name; - gpointer dialog; - - cf_name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fs)); - - /* Perhaps the user specified a directory instead of a file. - Check whether they did. */ - if (test_for_directory(cf_name) == EISDIR) { - /* It's a directory - set the file selection box to display that - directory, and leave the selection box displayed. */ - set_last_open_dir(cf_name); - g_free(cf_name); - file_selection_set_current_folder(fs, get_last_open_dir()); - return; - } - - /* - * Check that the from file is not the same as to file - * We do it here so we catch all cases ... - * Unfortunately, the file requester gives us an absolute file - * name and the read file name may be relative (if supplied on - * the command line). From Joerg Mayer. - */ - if (files_identical(cfile.filename, cf_name)) { - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, - "%sCapture file: \"%s\" identical to loaded file!%s\n\n" - "Please choose a different filename.", - simple_dialog_primary_start(), cf_name, simple_dialog_primary_end()); - g_free(cf_name); - /* XXX - as we cannot start a new event loop (using gtk_dialog_run()), - * as this will prevent the user from closing the now existing error - * message, simply close the dialog (this is the best we can do here). */ - if (file_save_as_w) - window_destroy(GTK_WIDGET (fs)); - - return; - } - - /* don't show the dialog while saving (or asking) */ - gtk_widget_hide(GTK_WIDGET (fs)); - - /* it the file doesn't exist, simply try to save it */ - if (!file_exists(cf_name)) { - file_save_as_cb(NULL, fs); - g_free(cf_name); - return; - } - - /* The file exists. Ask the user if they want to overwrite it. */ - dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_OK_CANCEL, - "%s" - "A file named \"%s\" already exists. Do you want to replace it?" - "%s\n\n" - "A file or folder with the same name already exists in that folder. " - "Replacing it will overwrite its current contents.", - simple_dialog_primary_start(), cf_name, simple_dialog_primary_end()); - simple_dialog_set_cb(dialog, file_save_as_exists_answered_cb, fs); - - g_free(cf_name); -} - void file_save_as_destroy(void) { diff --git a/ui/gtk/capture_file_dlg.h b/ui/gtk/capture_file_dlg.h index e1473b7772..b0efd82819 100644 --- a/ui/gtk/capture_file_dlg.h +++ b/ui/gtk/capture_file_dlg.h @@ -30,31 +30,18 @@ * @ingroup dialog_group */ -/** the action to take, after save has been done */ -typedef enum { - after_save_no_action, /**< no action to take */ - after_save_close_file, /**< close the file */ - after_save_open_dialog, /**< open the file open dialog */ - after_save_open_recent_file, /**< open the specified recent file */ - after_save_open_dnd_file, /**< open the specified file from drag and drop */ - after_save_merge_dialog, /**< open the file merge dialog */ - after_save_capture_dialog, /**< open the capture dialog */ - after_save_exit /**< exit program */ -} action_after_save_e; - -/** Do a "Save", opening a dialog box if the current file is a temporary file. - * - * @param action_after_save the action to take, when save completed - * @param action_after_save_data data for action_after_save - */ -void file_save_cmd(action_after_save_e action_after_save, gpointer action_after_save_data); - -/** Open the "Save As" dialog box. +/** If there are unsaved changes, ask the user whether to save them, + * discard them, or cancel the operation that would cause the changes + * to be lost if not saved. + * + * @param cf the capture_file structure for the file to be closed + * @param from_quit TRUE if this is from a quit operation + * @param before_what description of the operation, or a null string + * for an explicit close operation * - * @param action_after_save the action to take, when save completed - * @param action_after_save_data data for action_after_save + * @return TRUE if the user didn't cancel the operation, FALSE if they did */ -void file_save_as_cmd(action_after_save_e action_after_save, gpointer action_after_save_data); +gboolean do_file_close(capture_file *cf, gboolean from_quit, const char *before_what); /** Destroy the "Save As" dialog. */ diff --git a/ui/gtk/drag_and_drop.c b/ui/gtk/drag_and_drop.c index ecbe5bf476..203ab62c3f 100644 --- a/ui/gtk/drag_and_drop.c +++ b/ui/gtk/drag_and_drop.c @@ -287,34 +287,12 @@ dnd_open_file_cmd(gchar *cf_names_freeme) g_free(cf_names_freeme); } -/* ask the user to save current unsaved file, before opening the dnd file */ -static void -dnd_save_file_answered_cb(gpointer dialog _U_, gint btn, gpointer data) -{ - switch(btn) { - case(ESD_BTN_SAVE): - /* save file first */ - file_save_as_cmd(after_save_open_dnd_file, data); - break; - case(ESD_BTN_DONT_SAVE): - cf_close(&cfile); - dnd_open_file_cmd(data); - break; - case(ESD_BTN_CANCEL): - break; - default: - g_assert_not_reached(); - } -} - - /* we have received some drag and drop data */ /* (as we only registered to "text/uri-list", we will only get a file list here) */ static void dnd_data_received(GtkWidget *widget _U_, GdkDragContext *dc _U_, gint x _U_, gint y _U_, GtkSelectionData *selection_data, guint info, guint t _U_, gpointer data _U_) { - gpointer dialog; gchar *cf_names_freeme; const guchar *sel_data_data; gint sel_data_len; @@ -355,21 +333,10 @@ dnd_data_received(GtkWidget *widget _U_, GdkDragContext *dc _U_, gint x _U_, gin memcpy(cf_names_freeme, sel_data_data, sel_data_len); cf_names_freeme[sel_data_len] = '\0'; - /* ask the user to save it's current capture file first */ - if((cfile.state != FILE_CLOSED) && (cfile.is_tempfile || cfile.unsaved_changes) && - prefs.gui_ask_unsaved) { - /* This is a temporary capture file or has unsaved changes; ask the - user whether to save the capture. */ - dialog = simple_dialog(ESD_TYPE_CONFIRMATION, - ESD_BTNS_SAVE_DONTSAVE_CANCEL, - "%sSave capture file before opening a new one?%s\n\n" - "If you open a new capture file without saving, your current capture data will be discarded.", - simple_dialog_primary_start(), simple_dialog_primary_end()); - simple_dialog_set_cb(dialog, dnd_save_file_answered_cb, cf_names_freeme ); - } else { - /* unchanged file */ + /* If there's unsaved data, let the user save it first. + If they cancel out of it, don't open the file. */ + if (do_file_close(&cfile, FALSE, " before opening a new capture file")) dnd_open_file_cmd( cf_names_freeme ); - } } } diff --git a/ui/gtk/export_sslkeys.c b/ui/gtk/export_sslkeys.c index 14c214cd16..9bf220bb05 100644 --- a/ui/gtk/export_sslkeys.c +++ b/ui/gtk/export_sslkeys.c @@ -66,7 +66,6 @@ #include "ui/gtk/keys.h" #include "ui/gtk/color_utils.h" -#include "ui/gtk/capture_file_dlg.h" #include "ui/gtk/packet_win.h" #include "ui/gtk/file_dlg.h" #include "ui/gtk/gui_utils.h" diff --git a/ui/gtk/file_import_dlg.c b/ui/gtk/file_import_dlg.c index c525c81809..cf68d77608 100644 --- a/ui/gtk/file_import_dlg.c +++ b/ui/gtk/file_import_dlg.c @@ -772,51 +772,18 @@ setup_file_import(GtkWidget *main_w) /*****************************************************************************/ static void -file_import_answered_cb(gpointer dialog _U_, gint btn, gpointer data) -{ - text_import_info_t *text_import_info; - - switch (btn) { - case ESD_BTN_SAVE: - /* save file first */ - file_save_as_cmd(after_save_no_action, NULL); - break; - case ESD_BTN_DONT_SAVE: - cf_close(&cfile); - break; - case ESD_BTN_CANCEL: - return; - default: - g_assert_not_reached(); - } - - text_import_info = setup_file_import(data); - if (text_import_info) - file_import_open(text_import_info); -} - -static void file_import_ok_cb(GtkWidget *widget _U_, gpointer data) { text_import_info_t *text_import_info; - if((cfile.state != FILE_CLOSED) && (cfile.is_tempfile || cfile.unsaved_changes) && - prefs.gui_ask_unsaved) { - /* This is a temporary capture file or has unsaved changes; ask the - user whether to save the capture. */ - gpointer dialog; - dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_SAVE_DONTSAVE_CANCEL, - "%sSave capture file before opening a new one?%s\n\n" - "If you open a new capture file without saving, your capture data will be discarded.", - simple_dialog_primary_start(), simple_dialog_primary_end()); - simple_dialog_set_cb(dialog, file_import_answered_cb, data); - } else { - /* unchanged file, just open a new one */ + /* If there's unsaved data, let the user save it first. + If they cancel out of it, don't open the file. */ + if (do_file_close(&cfile, FALSE, " before opening a new capture file")) { + /* open the new file */ text_import_info = setup_file_import(data); if (text_import_info) file_import_open(text_import_info); } - } /*****************************************************************************/ diff --git a/ui/gtk/main.c b/ui/gtk/main.c index 662b1fd70a..415b4970d5 100644 --- a/ui/gtk/main.c +++ b/ui/gtk/main.c @@ -239,7 +239,6 @@ capture_options global_capture_opts; static void create_main_window(gint, gint, gint, e_prefs*); static void show_main_window(gboolean); -static void file_quit_answered_cb(gpointer dialog, gint btn, gpointer data); static void main_save_window_geometry(GtkWidget *widget); @@ -1007,25 +1006,12 @@ main_do_quit(void) static gboolean main_window_delete_event_cb(GtkWidget *widget _U_, GdkEvent *event _U_, gpointer data _U_) { - gpointer dialog; - - if((cfile.state != FILE_CLOSED) && (cfile.is_tempfile || cfile.unsaved_changes) && - prefs.gui_ask_unsaved) { - /* This is a temporary capture file or has unsaved changes; ask the - user whether to save the capture. */ - gtk_window_present(GTK_WINDOW(top_level)); - dialog = simple_dialog(ESD_TYPE_CONFIRMATION, - ((cfile.state == FILE_READ_IN_PROGRESS) ? ESD_BTNS_QUIT_DONTSAVE_CANCEL : ESD_BTNS_SAVE_QUIT_DONTSAVE_CANCEL), - "%sSave capture file before program quit?%s\n\n" - "If you quit the program without saving, your capture data will be discarded.", - simple_dialog_primary_start(), simple_dialog_primary_end()); - simple_dialog_set_cb(dialog, file_quit_answered_cb, NULL); - return TRUE; - } else { - /* unchanged file, just exit */ - /* "main_do_quit()" indicates whether the main window should be deleted. */ + /* If there's unsaved data, let the user save it first. + If they cancel out of it, don't quit. */ + if (do_file_close(&cfile, TRUE, " before quitting")) return main_do_quit(); - } + else + return TRUE; /* will this keep the window from being deleted? */ } @@ -1097,42 +1083,12 @@ main_save_window_geometry(GtkWidget *widget) statusbar_save_window_geometry(); } -static void file_quit_answered_cb(gpointer dialog _U_, gint btn, gpointer data _U_) -{ - switch(btn) { - case(ESD_BTN_SAVE): - /* save file first */ - file_save_as_cmd(after_save_exit, NULL); - break; - case(ESD_BTN_QUIT_DONT_SAVE): - main_do_quit(); - break; - case(ESD_BTN_CANCEL): - break; - default: - g_assert_not_reached(); - } -} - void file_quit_cmd_cb(GtkWidget *widget _U_, gpointer data _U_) { - gpointer dialog; - - if((cfile.state != FILE_CLOSED) && (cfile.is_tempfile || cfile.unsaved_changes) && - prefs.gui_ask_unsaved) { - /* This is a temporary capture file or has unsaved changes; ask the - user whether to save the capture. */ - dialog = simple_dialog(ESD_TYPE_CONFIRMATION, - ((cfile.state == FILE_READ_IN_PROGRESS) ? ESD_BTNS_QUIT_DONTSAVE_CANCEL : ESD_BTNS_SAVE_QUIT_DONTSAVE_CANCEL), - "%sSave capture file before program quit?%s\n\n" - "If you quit the program without saving, your capture data will be discarded.", - simple_dialog_primary_start(), simple_dialog_primary_end()); - simple_dialog_set_cb(dialog, file_quit_answered_cb, NULL); - } else { - /* unchanged file, just exit */ + /* If there's unsaved data, let the user save it first. */ + if (do_file_close(&cfile, TRUE, " before quitting")) main_do_quit(); - } } static void diff --git a/ui/gtk/main_menubar.c b/ui/gtk/main_menubar.c index 113394f232..8532a7fb77 100644 --- a/ui/gtk/main_menubar.c +++ b/ui/gtk/main_menubar.c @@ -46,6 +46,8 @@ #include <epan/filesystem.h> +#include "../cfile.h" +#include "../globals.h" #include "../print.h" #include "../color_filters.h" #include "../stat_menu.h" @@ -4178,41 +4180,13 @@ menu_open_recent_file_cmd(gpointer action) } } -static void menu_open_recent_file_answered_cb(gpointer dialog _U_, gint btn, gpointer data) -{ - switch(btn) { - case(ESD_BTN_YES): - /* save file first */ - file_save_as_cmd(after_save_open_recent_file, data); - break; - case(ESD_BTN_NO): - cf_close(&cfile); - menu_open_recent_file_cmd(data); - break; - case(ESD_BTN_CANCEL): - break; - default: - g_assert_not_reached(); - } -} static void -menu_open_recent_file_cmd_cb(GtkAction *action, gpointer data _U_) { - gpointer dialog; - - - if((cfile.state != FILE_CLOSED) && (cfile.is_tempfile || cfile.unsaved_changes) && - prefs.gui_ask_unsaved) { - /* This is a temporary capture file or has unsaved changes; ask the - user whether to save the capture. */ - dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_YES_NO_CANCEL, - "%sSave capture file before opening a new one?%s\n\n" - "If you open a new capture file without saving, your current capture data will be discarded.", - simple_dialog_primary_start(), simple_dialog_primary_end()); - simple_dialog_set_cb(dialog, menu_open_recent_file_answered_cb, action); - } else { - /* unchanged file */ +menu_open_recent_file_cmd_cb(GtkAction *action, gpointer data _U_) +{ + /* If there's unsaved data, let the user save it first. + If they cancel out of it, don't open the file. */ + if (do_file_close(&cfile, FALSE, " before opening a new capture file")) menu_open_recent_file_cmd(action); - } } static void diff --git a/ui/gtk/main_proto_draw.c b/ui/gtk/main_proto_draw.c index 24860b2f9e..03d93a62bf 100644 --- a/ui/gtk/main_proto_draw.c +++ b/ui/gtk/main_proto_draw.c @@ -67,7 +67,6 @@ #include "ui/gtk/keys.h" #include "ui/gtk/color_utils.h" -#include "ui/gtk/capture_file_dlg.h" #include "ui/gtk/packet_win.h" #include "ui/gtk/file_dlg.h" #include "ui/gtk/gui_utils.h" diff --git a/ui/gtk/main_toolbar.c b/ui/gtk/main_toolbar.c index 488a6c2279..f98ffc3d82 100644 --- a/ui/gtk/main_toolbar.c +++ b/ui/gtk/main_toolbar.c @@ -1,4 +1,4 @@ -/* toolbar.c +/* main_toolbar.c * The main toolbar * Copyright 2003, Ulf Lamping <ulf.lamping@web.de> * @@ -36,6 +36,7 @@ #include <epan/prefs.h> #include <epan/dfilter/dfilter.h> +#include "../cfile.h" #include "../color_filters.h" #include "ui/recent.h" diff --git a/ui/gtk/print_dlg.c b/ui/gtk/print_dlg.c index c8fd0e70dc..f374dfab0f 100644 --- a/ui/gtk/print_dlg.c +++ b/ui/gtk/print_dlg.c @@ -42,7 +42,6 @@ #include "ui/gtk/gtkglobals.h" #include "ui/gtk/keys.h" -#include "ui/gtk/capture_file_dlg.h" #include "ui/gtk/gui_utils.h" #include "ui/gtk/dlg_utils.h" #include "ui/gtk/file_dlg.h" diff --git a/ui/win32/file_dlg_win32.c b/ui/win32/file_dlg_win32.c index da0a7ec804..094ea784ef 100644 --- a/ui/win32/file_dlg_win32.c +++ b/ui/win32/file_dlg_win32.c @@ -265,7 +265,9 @@ win32_open_file (HWND h_wnd) { void -win32_save_as_file(HWND h_wnd, action_after_save_e action_after_save, gpointer action_after_save_data) { +win32_save_as_file(HWND h_wnd) +{ + HWND h_wnd; GArray *savable_file_types; OPENFILENAME *ofn; TCHAR file_name16[MAX_PATH] = _T(""); @@ -279,6 +281,8 @@ win32_save_as_file(HWND h_wnd, action_after_save_e action_after_save, gpointer a OSVERSIONINFO osvi; #endif + hwnd = GDK_WINDOW_HWND(gtk_widget_get_window(top_level))); + savable_file_types = wtap_get_savable_file_types(cfile.cd_t, cfile.lnk_t); if (savable_file_types == NULL) return; /* shouldn't happen - the "Save As..." item should be disabled if we can't save the file */ @@ -383,7 +387,7 @@ win32_save_as_file(HWND h_wnd, action_after_save_e action_after_save, gpointer a g_string_free(file_name8, TRUE /* free_segment */); g_free( (void *) ofn->lpstrFilter); g_free( (void *) ofn); - win32_save_as_file(h_wnd, action_after_save, action_after_save_data); + win32_save_as_file(h_wnd); return; } @@ -392,37 +396,6 @@ win32_save_as_file(HWND h_wnd, action_after_save_e action_after_save, gpointer a set_last_open_dir(dirname); g_string_free(file_name8, TRUE /* free_segment */); - - /* we have finished saving, do we have pending things to do? */ - switch(action_after_save) { - case(after_save_no_action): - break; - case(after_save_open_dialog): - win32_open_file(h_wnd); - break; - case(after_save_open_recent_file): - menu_open_recent_file_cmd(action_after_save_data); - break; - case(after_save_open_dnd_file): - dnd_open_file_cmd(action_after_save_data); - break; - case(after_save_merge_dialog): - win32_merge_file(h_wnd); - break; -#ifdef HAVE_LIBPCAP - case(after_save_capture_dialog): - capture_start_confirmed(); - break; -#endif - case(after_save_close_file): - cf_close(&cfile); - break; - case(after_save_exit): - main_do_quit(); - break; - default: - g_assert_not_reached(); - } } g_sf_hwnd = NULL; g_array_free(savable_file_types, TRUE); diff --git a/ui/win32/file_dlg_win32.h b/ui/win32/file_dlg_win32.h index f34a2f5ecf..3df58d3d1f 100644 --- a/ui/win32/file_dlg_win32.h +++ b/ui/win32/file_dlg_win32.h @@ -43,10 +43,8 @@ gboolean win32_open_file (HWND h_wnd); /** Open the "Save As" dialog box. * * @param h_wnd HWND of the parent window. - * @param action_after_save The action to take, when save completed - * @param action_after_save_data Data for action_after_save */ -void win32_save_as_file(HWND h_wnd, action_after_save_e action_after_save, gpointer action_after_save_data); +void win32_save_as_file(HWND h_wnd); /** Open the "Export Specified Packets" dialog box. * |