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 /ui/gtk/file_import_dlg.c | |
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
Diffstat (limited to 'ui/gtk/file_import_dlg.c')
-rw-r--r-- | ui/gtk/file_import_dlg.c | 41 |
1 files changed, 4 insertions, 37 deletions
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); } - } /*****************************************************************************/ |