diff options
author | Guy Harris <guy@alum.mit.edu> | 2012-06-17 00:00:25 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2012-06-17 00:00:25 +0000 |
commit | 480e2c351b63252fc8648cd26199900b1d5a6f88 (patch) | |
tree | f846768ad598f57b3c14b7c132a3c9f87a78f6ce | |
parent | 8bd9df6671b4ab8ba2be4c2bd8fdc88233c31636 (diff) | |
download | wireshark-480e2c351b63252fc8648cd26199900b1d5a6f88.tar.gz wireshark-480e2c351b63252fc8648cd26199900b1d5a6f88.tar.bz2 wireshark-480e2c351b63252fc8648cd26199900b1d5a6f88.zip |
Move some code to manipulate the toolbar and capture interface dialog
out of main_menubar.c into routines in main.c.
Move some routines that are only used by main.c into
main_menubar_private.h.
svn path=/trunk/; revision=43298
-rw-r--r-- | ui/gtk/main.c | 59 | ||||
-rw-r--r-- | ui/gtk/main.h | 3 | ||||
-rw-r--r-- | ui/gtk/main_menubar.c | 12 | ||||
-rw-r--r-- | ui/gtk/main_menubar_private.h | 23 | ||||
-rw-r--r-- | ui/gtk/menus.h | 30 | ||||
-rw-r--r-- | ui/gtk/packet_history.c | 6 |
6 files changed, 78 insertions, 55 deletions
diff --git a/ui/gtk/main.c b/ui/gtk/main.c index 7af86a3936..1e580bc3ae 100644 --- a/ui/gtk/main.c +++ b/ui/gtk/main.c @@ -923,6 +923,20 @@ void resolve_name_cb(GtkWidget *widget _U_, gpointer data _U_) { } } +/* Update main window items based on whether there's a capture in progress. */ +static void +main_set_for_capture_in_progress(gboolean capture_in_progress) +{ + set_menus_for_capture_in_progress(capture_in_progress); + +#ifdef HAVE_LIBPCAP + set_toolbar_for_capture_in_progress(capture_in_progress); + + set_capture_if_dialog_for_capture_in_progress(capture_in_progress); +#endif +} + +/* Update main window items based on whether we have a capture file. */ static void main_set_for_capture_file(gboolean have_capture_file_in) { @@ -931,6 +945,22 @@ main_set_for_capture_file(gboolean have_capture_file_in) main_widgets_show_or_hide(); } +/* Update main window items based on whether we have captured packets. */ +static void +main_set_for_captured_packets(gboolean have_captured_packets) +{ + set_menus_for_captured_packets(have_captured_packets); + set_toolbar_for_captured_packets(have_captured_packets); +} + +/* Update main window items based on whether we have a packet history. */ +void +main_set_for_packet_history(gboolean back_history, gboolean forward_history) +{ + set_menus_for_packet_history(back_history, forward_history); + set_toolbar_for_packet_history(back_history, forward_history); +} + gboolean main_do_quit(void) { @@ -1440,9 +1470,9 @@ 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); + main_set_for_captured_packets(FALSE); set_menus_for_selected_packet(cf); - set_menus_for_capture_in_progress(FALSE); + main_set_for_capture_in_progress(FALSE); set_capture_if_dialog_for_capture_in_progress(FALSE); set_menus_for_selected_tree_row(cf); @@ -1490,7 +1520,7 @@ main_cf_cb_file_read_finished(capture_file *cf) main_update_for_unsaved_changes(cf); /* Enable menu items that make sense if you have some captured packets. */ - set_menus_for_captured_packets(TRUE); + main_set_for_captured_packets(TRUE); } static void @@ -1578,7 +1608,7 @@ main_capture_cb_capture_prepared(capture_options *capture_opts) /* Disable menu items that make no sense if you're currently running a capture. */ - set_menus_for_capture_in_progress(TRUE); + main_set_for_capture_in_progress(TRUE); set_capture_if_dialog_for_capture_in_progress(TRUE); /* Don't set up main window for a capture file. */ @@ -1592,12 +1622,12 @@ main_capture_cb_capture_update_started(capture_options *capture_opts) switching to the next multiple file. */ main_capture_set_main_window_title(capture_opts); - set_menus_for_capture_in_progress(TRUE); + main_set_for_capture_in_progress(TRUE); set_capture_if_dialog_for_capture_in_progress(TRUE); /* Enable menu items that make sense if you have some captured packets (yes, I know, we don't have any *yet*). */ - set_menus_for_captured_packets(TRUE); + main_set_for_captured_packets(TRUE); /* Set up main window for a capture file. */ main_set_for_capture_file(TRUE); @@ -1622,7 +1652,7 @@ main_capture_cb_capture_update_finished(capture_options *capture_opts) /* Enable menu items that make sense if you're not currently running a capture. */ - set_menus_for_capture_in_progress(FALSE); + main_set_for_capture_in_progress(FALSE); set_capture_if_dialog_for_capture_in_progress(FALSE); /* Set up main window for a capture file. */ @@ -1662,7 +1692,7 @@ main_capture_cb_capture_fixed_finished(capture_options *capture_opts _U_) /* Enable menu items that make sense if you're not currently running a capture. */ - set_menus_for_capture_in_progress(FALSE); + main_set_for_capture_in_progress(FALSE); set_capture_if_dialog_for_capture_in_progress(FALSE); /* Restore the standard title bar message */ @@ -1689,6 +1719,11 @@ main_capture_cb_capture_stopping(capture_options *capture_opts _U_) { capture_stopping = TRUE; set_menus_for_capture_stopping(); +#ifdef HAVE_LIBPCAP + set_toolbar_for_capture_stopping(); + + set_capture_if_dialog_for_capture_stopping(); +#endif } static void @@ -1704,7 +1739,7 @@ main_capture_cb_capture_failed(capture_options *capture_opts _U_) main_set_window_name("The Wireshark Network Analyzer"); - set_menus_for_capture_in_progress(FALSE); + main_set_for_capture_in_progress(FALSE); set_capture_if_dialog_for_capture_in_progress(FALSE); main_set_for_capture_file(FALSE); @@ -3111,7 +3146,7 @@ main(int argc, char *argv[]) cfile.rfcode = NULL; show_main_window(FALSE); /* Don't call check_and_warn_user_startup(): we did it above */ - set_menus_for_capture_in_progress(FALSE); + main_set_for_capture_in_progress(FALSE); set_capture_if_dialog_for_capture_in_progress(FALSE); } } @@ -3146,7 +3181,7 @@ main(int argc, char *argv[]) } else { show_main_window(FALSE); check_and_warn_user_startup(cf_name); - set_menus_for_capture_in_progress(FALSE); + main_set_for_capture_in_progress(FALSE); set_capture_if_dialog_for_capture_in_progress(FALSE); } @@ -3157,7 +3192,7 @@ main(int argc, char *argv[]) #else /* HAVE_LIBPCAP */ show_main_window(FALSE); check_and_warn_user_startup(cf_name); - set_menus_for_capture_in_progress(FALSE); + main_set_for_capture_in_progress(FALSE); set_capture_if_dialog_for_capture_in_progress(FALSE); #endif /* HAVE_LIBPCAP */ } diff --git a/ui/gtk/main.h b/ui/gtk/main.h index 8028a7f75d..4e269fd5cc 100644 --- a/ui/gtk/main.h +++ b/ui/gtk/main.h @@ -338,6 +338,9 @@ extern void main_widgets_rearrange(void); /** Show or hide the main window widgets, user changed it's preferences. */ extern void main_widgets_show_or_hide(void); +/* Update main window items based on whether we have a packet history. */ +extern void main_set_for_packet_history(gboolean back_history, gboolean forward_history); + /** Apply a new filter string. * Call cf_filter_packets() and add this filter string to the recent filter list. * diff --git a/ui/gtk/main_menubar.c b/ui/gtk/main_menubar.c index 6fab9051db..379ba95bab 100644 --- a/ui/gtk/main_menubar.c +++ b/ui/gtk/main_menubar.c @@ -4151,8 +4151,8 @@ menu_open_filename(gchar *cf_name) } /* callback, if the user pushed a recent file submenu item */ -void -menu_open_recent_file_cmd(gpointer action) +static void +menu_open_recent_file_cmd(GtkAction *action) { GtkWidget *submenu_recent_files; GList *recent_files_list; @@ -4675,9 +4675,6 @@ set_menus_for_capture_in_progress(gboolean capture_in_progress) capture_in_progress); set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/CaptureMenu/Restart", capture_in_progress); - set_toolbar_for_capture_in_progress(capture_in_progress); - - set_capture_if_dialog_for_capture_in_progress(capture_in_progress); #endif /* HAVE_LIBPCAP */ } @@ -4695,9 +4692,6 @@ set_menus_for_capture_stopping(void) FALSE); set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/CaptureMenu/Restart", FALSE); - set_toolbar_for_capture_stopping(); - - set_capture_if_dialog_for_capture_stopping(); #endif /* HAVE_LIBPCAP */ } @@ -4740,7 +4734,6 @@ set_menus_for_captured_packets(gboolean have_captured_packets) have_captured_packets); set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/StatisticsMenu/ProtocolHierarchy", have_captured_packets); - set_toolbar_for_captured_packets(have_captured_packets); } @@ -5488,7 +5481,6 @@ set_menus_for_selected_tree_row(capture_file *cf) void set_menus_for_packet_history(gboolean back_history, gboolean forward_history) { set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/GoMenu/Back", back_history); set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/GoMenu/Forward", forward_history); - set_toolbar_for_packet_history(back_history, forward_history); } diff --git a/ui/gtk/main_menubar_private.h b/ui/gtk/main_menubar_private.h index 231406947c..30f47b44f4 100644 --- a/ui/gtk/main_menubar_private.h +++ b/ui/gtk/main_menubar_private.h @@ -26,11 +26,34 @@ /*** PRIVATE INTERFACE BETWEEN main.c AND main_menubar.c DON'T USE OR TOUCH :-)*/ +/** The recent file read has finished, update the menu corresponding. */ +extern void menu_recent_read_finished(void); + /* 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 *); +/** The packet history has changed, we need to update the menu. + * + * @param back_history some back history entries available + * @param forward_history some forward history entries available + */ +extern void set_menus_for_packet_history(gboolean back_history, gboolean forward_history); + +/* Enable or disable menu items based on whether there's a capture in + progress. */ +void set_menus_for_capture_in_progress(gboolean); + +/* Disable menu items while we're waiting for the capture child to + finish. We disallow quitting until it finishes, and also disallow + stopping or restarting the capture. */ +void set_menus_for_capture_stopping(void); + +/* Enable or disable menu items based on whether you have some captured + packets. */ +void set_menus_for_captured_packets(gboolean); + #ifdef HAVE_LIBPCAP /** The "Auto Scroll Packet List in Live Capture" option changed. */ extern void menu_auto_scroll_live_changed(gboolean auto_scroll_in); diff --git a/ui/gtk/menus.h b/ui/gtk/menus.h index ec574662ac..79ea7ceb85 100644 --- a/ui/gtk/menus.h +++ b/ui/gtk/menus.h @@ -38,15 +38,6 @@ extern void menu_open_filename(gchar *cf_name); * @ingroup main_window_group */ -/** User pushed a recent file submenu item. - * - * @param widget parent widget - */ -extern void menu_open_recent_file_cmd(gpointer action); - -/** The recent file read has finished, update the menu corresponding. */ -extern void menu_recent_read_finished(void); - /** One of the name resolution menu items changed. */ extern void menu_name_resolution_changed(void); @@ -78,13 +69,6 @@ extern void set_menu_object_data(const gchar *path, const gchar *key, gpointer d */ extern gboolean popup_menu_handler(GtkWidget *widget, GdkEvent *event, gpointer data); -/** The packet history has changed, we need to update the menu. - * - * @param back_history some back history entries available - * @param forward_history some forward history entries available - */ -extern void set_menus_for_packet_history(gboolean back_history, gboolean forward_history); - /** The current file has changed, we need to update the file set menu items. * * @param file_set the current file is part of a file set @@ -116,20 +100,6 @@ extern GtkWidget *menus_get_profiles_change_menu (void); and and on whether a "Match Selected" can be done. */ void set_menus_for_selected_tree_row(capture_file *cf); - -/* Enable or disable menu items based on whether there's a capture in - progress. */ -void set_menus_for_capture_in_progress(gboolean); - -/* Disable menu items while we're waiting for the capture child to - finish. We disallow quitting until it finishes, and also disallow - stopping or restarting the capture. */ -void set_menus_for_capture_stopping(void); - -/* Enable or disable menu items based on whether you have some captured - packets. */ -void set_menus_for_captured_packets(gboolean); - /* Enable or disable menu items based on whether a packet is selected. */ void set_menus_for_selected_packet(capture_file *cf); diff --git a/ui/gtk/packet_history.c b/ui/gtk/packet_history.c index 5951da3b02..7dea3d31d4 100644 --- a/ui/gtk/packet_history.c +++ b/ui/gtk/packet_history.c @@ -33,7 +33,7 @@ #include "../file.h" #include "../globals.h" -#include "ui/gtk/menus.h" +#include "ui/gtk/main.h" #include "ui/gtk/packet_history.h" @@ -65,12 +65,12 @@ static void history_print(void) { static void adjust_menus(void) { if(history_current) { - set_menus_for_packet_history( + main_set_for_packet_history( (g_list_previous(history_current) != NULL), (g_list_next(history_current) != NULL)); } else { /* we don't have any history */ - set_menus_for_packet_history(FALSE, FALSE); + main_set_for_packet_history(FALSE, FALSE); } /* history_print(); */ |