diff options
author | Guy Harris <guy@alum.mit.edu> | 2012-06-04 02:24:42 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2012-06-04 02:24:42 +0000 |
commit | 9c44d87610cf97fbfc7d4ba9628676ab043547c9 (patch) | |
tree | b827248f96aff727b5aced96c5c97b4958b1c6d6 /ui/gtk | |
parent | bcfbbd6f1e0e34dfe8c12f231a0e69ed717248f3 (diff) |
Have a main_update_for_unsaved_changes() routine that, if changes are
made to the capture file (adding/removing/editing comments, for now) or
if a capture file with unsaved changes are unsaved, updates the menu
bar, the toolbar, *and* the titlebar, which now has a GNOME-style "*" to
indicate unsaved changes.
Make set_menus_for_capture_file() a private interface between main.c and
main_menubar.c, and have its callers, such as
main_update_for_unsaved_changes(), be responsible for updating the
toolbar as well.
svn path=/trunk/; revision=43051
Diffstat (limited to 'ui/gtk')
-rw-r--r-- | ui/gtk/Makefile.common | 1 | ||||
-rw-r--r-- | ui/gtk/capture_file_dlg.c | 1 | ||||
-rw-r--r-- | ui/gtk/capture_if_dlg.c | 1 | ||||
-rw-r--r-- | ui/gtk/drag_and_drop.c | 1 | ||||
-rw-r--r-- | ui/gtk/edit_packet_comment_dlg.c | 5 | ||||
-rw-r--r-- | ui/gtk/export_sslkeys.c | 1 | ||||
-rw-r--r-- | ui/gtk/main.c | 31 | ||||
-rw-r--r-- | ui/gtk/main.h | 7 | ||||
-rw-r--r-- | ui/gtk/main_menubar.c | 2 | ||||
-rw-r--r-- | ui/gtk/main_menubar_private.h | 34 | ||||
-rw-r--r-- | ui/gtk/menus.h | 6 | ||||
-rw-r--r-- | ui/gtk/new_packet_list.c | 2 | ||||
-rw-r--r-- | ui/gtk/summary_dlg.c | 5 |
13 files changed, 69 insertions, 28 deletions
diff --git a/ui/gtk/Makefile.common b/ui/gtk/Makefile.common index 113a945e8c..f836c60a21 100644 --- a/ui/gtk/Makefile.common +++ b/ui/gtk/Makefile.common @@ -292,6 +292,7 @@ noinst_HEADERS = \ main.h \ main_airpcap_toolbar.h \ main_filter_toolbar.h \ + main_menubar_private.h \ menus.h \ main_proto_draw.h \ main_statusbar_private.h \ diff --git a/ui/gtk/capture_file_dlg.c b/ui/gtk/capture_file_dlg.c index 8419dac1ff..381aaff836 100644 --- a/ui/gtk/capture_file_dlg.c +++ b/ui/gtk/capture_file_dlg.c @@ -61,7 +61,6 @@ #include "ui/gtk/capture_file_dlg.h" #include "ui/gtk/drag_and_drop.h" #include "ui/gtk/main.h" -#include "ui/gtk/menus.h" #include "ui/gtk/color_dlg.h" #include "ui/gtk/new_packet_list.h" #ifdef HAVE_LIBPCAP diff --git a/ui/gtk/capture_if_dlg.c b/ui/gtk/capture_if_dlg.c index dcde6983cf..15a12ead8d 100644 --- a/ui/gtk/capture_if_dlg.c +++ b/ui/gtk/capture_if_dlg.c @@ -68,7 +68,6 @@ #include "ui/gtk/network_icons.h" #include "ui/gtk/pipe_icon.h" #include "ui/gtk/main_welcome.h" -#include "ui/gtk/menus.h" #include "ui/gtk/old-gtk-compat.h" diff --git a/ui/gtk/drag_and_drop.c b/ui/gtk/drag_and_drop.c index 203ab62c3f..9d7c153643 100644 --- a/ui/gtk/drag_and_drop.c +++ b/ui/gtk/drag_and_drop.c @@ -46,7 +46,6 @@ #include "ui/gtk/capture_file_dlg.h" #include "ui/gtk/drag_and_drop.h" #include "ui/gtk/main.h" -#include "ui/gtk/menus.h" #ifdef HAVE_LIBPCAP #include "ui/gtk/capture_globals.h" #endif diff --git a/ui/gtk/edit_packet_comment_dlg.c b/ui/gtk/edit_packet_comment_dlg.c index c2f4bfec55..3c847bc0a6 100644 --- a/ui/gtk/edit_packet_comment_dlg.c +++ b/ui/gtk/edit_packet_comment_dlg.c @@ -43,7 +43,6 @@ #include "ui/gtk/gui_utils.h" #include "ui/gtk/help_dlg.h" #include "ui/gtk/main.h" -#include "ui/gtk/menus.h" #include "ui/gtk/new_packet_list.h" #include "ui/gtk/edit_packet_comment_dlg.h" #include "ui/gtk/old-gtk-compat.h" @@ -91,8 +90,8 @@ capture_comment_text_buff_ok_cb(GtkWidget *w _U_, GtkWidget *view) /*g_warning("The new comment is '%s'",new_capture_comment);*/ cf_update_capture_comment(&cfile, new_capture_comment); - /* Update the menus in case the file might need to be saved */ - set_menus_for_capture_file(&cfile); + /* Update the main window as appropriate */ + main_update_for_unsaved_changes(&cfile); window_destroy(edit_or_add_capture_comment_dlg); diff --git a/ui/gtk/export_sslkeys.c b/ui/gtk/export_sslkeys.c index 9bf220bb05..0838711120 100644 --- a/ui/gtk/export_sslkeys.c +++ b/ui/gtk/export_sslkeys.c @@ -73,7 +73,6 @@ #include "ui/gtk/font_utils.h" #include "ui/gtk/webbrowser.h" #include "ui/gtk/main.h" -#include "ui/gtk/menus.h" #include "ui/gtk/export_sslkeys.h" #ifdef _WIN32 diff --git a/ui/gtk/main.c b/ui/gtk/main.c index 311314df96..a7ff3d2360 100644 --- a/ui/gtk/main.c +++ b/ui/gtk/main.c @@ -143,6 +143,7 @@ extern gint if_list_comparator_alph (const void *first_arg, const void *second_a #include "ui/gtk/main_filter_toolbar.h" #include "ui/gtk/main_titlebar.h" #include "ui/gtk/menus.h" +#include "ui/gtk/main_menubar_private.h" #include "ui/gtk/macros_dlg.h" #include "ui/gtk/main_statusbar_private.h" #include "ui/gtk/main_toolbar.h" @@ -1339,7 +1340,8 @@ set_display_filename(capture_file *cf) if (cf->filename) { display_name = cf_get_display_name(cf); - window_name = g_strdup_printf("%s", display_name); + window_name = g_strdup_printf("%s%s", cf->unsaved_changes ? "*" : "", + display_name); g_free(display_name); main_set_window_name(window_name); g_free(window_name); @@ -1348,6 +1350,18 @@ set_display_filename(capture_file *cf) } } +/* Update various parts of the main window for a capture file "unsaved + changes" change - update the title to reflect whether there are + unsaved changes or not, and update the menus and toolbar to + enable or disable the "Save" operation. */ +void +main_update_for_unsaved_changes(capture_file *cf) +{ + set_display_filename(cf); + set_menus_for_capture_file(cf); + set_toolbar_for_capture_file(cf); +} + static GtkWidget *close_dlg = NULL; static void @@ -1390,6 +1404,7 @@ main_cf_cb_file_closing(capture_file *cf) /* Disable all menu items that make sense only if you have a capture. */ set_menus_for_capture_file(NULL); + set_toolbar_for_capture_file(NULL); set_menus_for_captured_packets(FALSE); set_menus_for_selected_packet(cf); set_menus_for_capture_in_progress(FALSE); @@ -1435,11 +1450,9 @@ main_cf_cb_file_read_finished(capture_file *cf) set_last_open_dir(dir_path); g_free(dir_path); } - set_display_filename(cf); - /* Enable menu items that make sense if you have a capture file you've - finished reading. */ - set_menus_for_capture_file(cf); + /* Update the appropriate parts of the main window. */ + main_update_for_unsaved_changes(cf); /* Enable menu items that make sense if you have some captured packets. */ set_menus_for_captured_packets(TRUE); @@ -1546,17 +1559,15 @@ main_capture_cb_capture_update_finished(capture_options *capture_opts) /* Add this filename to the list of recent files in the "Recent Files" submenu */ add_menu_recent_capture_file(cf->filename); } - set_display_filename(cf); + + /* Update the main window as appropriate */ + main_update_for_unsaved_changes(cf); /* Enable menu items that make sense if you're not currently running a capture. */ set_menus_for_capture_in_progress(FALSE); set_capture_if_dialog_for_capture_in_progress(FALSE); - /* Enable menu items that make sense if you have a capture file - you've finished reading. */ - set_menus_for_capture_file(cf); - /* Set up main window for a capture file. */ main_set_for_capture_file(TRUE); diff --git a/ui/gtk/main.h b/ui/gtk/main.h index 31f3fd8a9f..cee1b77099 100644 --- a/ui/gtk/main.h +++ b/ui/gtk/main.h @@ -307,6 +307,13 @@ extern void find_prev_mark_cb(GtkWidget *widget, gpointer data, int action); extern void dfilter_combo_add_empty(void); #endif +/** Update various parts of the main window for a capture file "unsaved + * changes" change. + * + * @param cf capture_file structure for the capture file. + */ +extern void main_update_for_unsaved_changes(capture_file *cf); + /** Quit the program. * * @return TRUE, if a file read is in progress diff --git a/ui/gtk/main_menubar.c b/ui/gtk/main_menubar.c index 8532a7fb77..6b49207dba 100644 --- a/ui/gtk/main_menubar.c +++ b/ui/gtk/main_menubar.c @@ -97,6 +97,7 @@ #include "ui/gtk/gui_stat_menu.h" #include "ui/gtk/main.h" #include "ui/gtk/menus.h" +#include "ui/gtk/main_menubar_private.h" #include "ui/gtk/main_toolbar.h" #include "ui/gtk/main_welcome.h" #include "ui/gtk/uat_gui.h" @@ -4650,7 +4651,6 @@ set_menus_for_capture_file(capture_file *cf) set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/ExportObjects", TRUE); set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/Reload", TRUE); } - set_toolbar_for_capture_file(cf); } /* Enable or disable menu items based on whether there's a capture in diff --git a/ui/gtk/main_menubar_private.h b/ui/gtk/main_menubar_private.h new file mode 100644 index 0000000000..a72ae66efb --- /dev/null +++ b/ui/gtk/main_menubar_private.h @@ -0,0 +1,34 @@ +/* main_menubar_private.h + * + * $Id$ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __MAIN_MENUBAR_PRIVATE_H__ +#define __MAIN_MENUBAR_PRIVATE_H__ + +/*** PRIVATE INTERFACE BETWEEN main.c AND main_menubar.c DON'T USE OR TOUCH :-)*/ + +/* Enable or disable menu items based on whether you have a capture file + you've finished reading and, if you have one, whether it's been saved + and whether it could be saved except by copying the raw packet data. */ +void set_menus_for_capture_file(capture_file *); + +#endif /* __MAIN_MENUBAR_PRIVATE_H__ */ diff --git a/ui/gtk/menus.h b/ui/gtk/menus.h index 27940cbc06..cf1ec47243 100644 --- a/ui/gtk/menus.h +++ b/ui/gtk/menus.h @@ -125,12 +125,6 @@ extern GtkWidget *menus_get_profiles_change_menu (void); void set_menus_for_selected_tree_row(capture_file *cf); -/* Enable or disable menu items based on whether you have a capture file - you've finished reading and, if you have one, whether it's been saved - and whether it could be saved except by copying the raw packet data. */ -void set_menus_for_capture_file(capture_file *); - - /* Enable or disable menu items based on whether there's a capture in progress. */ void set_menus_for_capture_in_progress(gboolean); diff --git a/ui/gtk/new_packet_list.c b/ui/gtk/new_packet_list.c index f6eebdc370..7dd8f9587e 100644 --- a/ui/gtk/new_packet_list.c +++ b/ui/gtk/new_packet_list.c @@ -1754,7 +1754,7 @@ new_packet_list_update_packet_comment(gchar *new_packet_comment) /* Mark the file as having unsaved changes */ cfile.unsaved_changes = TRUE; - set_menus_for_capture_file(&cfile); + main_update_for_unsaved_changes(&cfile); new_packet_list_queue_draw(); diff --git a/ui/gtk/summary_dlg.c b/ui/gtk/summary_dlg.c index 02febe2253..c51ee527b7 100644 --- a/ui/gtk/summary_dlg.c +++ b/ui/gtk/summary_dlg.c @@ -49,7 +49,6 @@ #include "ui/gtk/dlg_utils.h" #include "ui/gtk/gui_utils.h" #include "ui/gtk/help_dlg.h" -#include "ui/gtk/menus.h" #define SUM_STR_MAX 1024 #define FILTER_SNIP_LEN 50 @@ -144,8 +143,8 @@ summary_ok_cb(GtkWidget *w _U_, GtkWidget *view) cf_update_capture_comment(&cfile, new_comment); - /* Update the menus in case the file might need to be saved */ - set_menus_for_capture_file(&cfile); + /* Update the main window */ + main_update_for_unsaved_changes(&cfile); window_destroy(summary_dlg); } |