summaryrefslogtreecommitdiff
path: root/ui/gtk
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2012-06-04 03:15:05 +0000
committerGuy Harris <guy@alum.mit.edu>2012-06-04 03:15:05 +0000
commiteb03bb0290d7facf2baa411e80c7fa34e58437df (patch)
treef84f279cf8f4dbbf2cd298a8f03468be418b2ce6 /ui/gtk
parent2d4bd31654a2bb5669a2cf01e91b88723540fbbb (diff)
downloadwireshark-eb03bb0290d7facf2baa411e80c7fa34e58437df.tar.gz
Add some more routines to main.c that handle updates to "auto scroll in
live capture" and colorization, so that the ones in main_menubar.c don't have to know about anything other than the main menubar. Move some toolbar routines that should only be used by routines in main.c into a main_toolbar_private.h header. svn path=/trunk/; revision=43053
Diffstat (limited to 'ui/gtk')
-rw-r--r--ui/gtk/Makefile.common1
-rw-r--r--ui/gtk/capture_dlg.c3
-rw-r--r--ui/gtk/main.c31
-rw-r--r--ui/gtk/main.h12
-rw-r--r--ui/gtk/main_menubar.c28
-rw-r--r--ui/gtk/main_menubar_private.h8
-rw-r--r--ui/gtk/main_toolbar.c6
-rw-r--r--ui/gtk/main_toolbar.h17
-rw-r--r--ui/gtk/main_toolbar_private.h46
-rw-r--r--ui/gtk/menus.h8
-rw-r--r--ui/gtk/new_packet_list.c2
11 files changed, 107 insertions, 55 deletions
diff --git a/ui/gtk/Makefile.common b/ui/gtk/Makefile.common
index f836c60a21..eaff1da4c3 100644
--- a/ui/gtk/Makefile.common
+++ b/ui/gtk/Makefile.common
@@ -298,6 +298,7 @@ noinst_HEADERS = \
main_statusbar_private.h \
main_titlebar.h \
main_toolbar.h \
+ main_toolbar_private.h \
main_welcome.h \
manual_addr_resolv.h \
mcast_stream.h \
diff --git a/ui/gtk/capture_dlg.c b/ui/gtk/capture_dlg.c
index 32e76ebc24..e4818fa326 100644
--- a/ui/gtk/capture_dlg.c
+++ b/ui/gtk/capture_dlg.c
@@ -50,7 +50,6 @@
#include "ui/simple_dialog.h"
#include "ui/gtk/main.h"
-#include "ui/gtk/menus.h"
#include "ui/gtk/gui_utils.h"
#include "ui/gtk/capture_dlg.h"
#include "ui/gtk/filter_dlg.h"
@@ -4169,7 +4168,7 @@ capture_start_confirmed(void)
}
/* XXX - we might need to init other pref data as well... */
- menu_auto_scroll_live_changed(auto_scroll_live);
+ main_auto_scroll_live_changed(auto_scroll_live);
/* XXX - can this ever happen? */
if (global_capture_opts.state != CAPTURE_STOPPED)
diff --git a/ui/gtk/main.c b/ui/gtk/main.c
index a7ff3d2360..a89520abd4 100644
--- a/ui/gtk/main.c
+++ b/ui/gtk/main.c
@@ -147,6 +147,7 @@ extern gint if_list_comparator_alph (const void *first_arg, const void *second_a
#include "ui/gtk/macros_dlg.h"
#include "ui/gtk/main_statusbar_private.h"
#include "ui/gtk/main_toolbar.h"
+#include "ui/gtk/main_toolbar_private.h"
#include "ui/gtk/main_welcome.h"
#include "ui/gtk/drag_and_drop.h"
#include "ui/gtk/capture_file_dlg.h"
@@ -1362,6 +1363,34 @@ main_update_for_unsaved_changes(capture_file *cf)
set_toolbar_for_capture_file(cf);
}
+#ifdef HAVE_LIBPCAP
+void
+main_auto_scroll_live_changed(gboolean auto_scroll_live_in)
+{
+ /* Update menubar and toolbar */
+ menu_auto_scroll_live_changed(auto_scroll_live_in);
+ toolbar_auto_scroll_live_changed(auto_scroll_live_in);
+
+ /* change auto scroll state */
+ auto_scroll_live = auto_scroll_live_in;
+}
+#endif
+
+void
+main_colorize_changed(gboolean packet_list_colorize)
+{
+ /* Update menubar and toolbar */
+ menu_colorize_changed(packet_list_colorize);
+ toolbar_colorize_changed(packet_list_colorize);
+
+ /* change colorization */
+ if(packet_list_colorize != recent.packet_list_colorize) {
+ recent.packet_list_colorize = packet_list_colorize;
+ color_filters_enable(packet_list_colorize);
+ new_packet_list_colorize_packets();
+ }
+}
+
static GtkWidget *close_dlg = NULL;
static void
@@ -2874,7 +2903,7 @@ main(int argc, char *argv[])
menu_recent_read_finished();
#ifdef HAVE_LIBPCAP
- menu_auto_scroll_live_changed(auto_scroll_live);
+ main_auto_scroll_live_changed(auto_scroll_live);
#endif
switch (user_font_apply()) {
diff --git a/ui/gtk/main.h b/ui/gtk/main.h
index cee1b77099..8028a7f75d 100644
--- a/ui/gtk/main.h
+++ b/ui/gtk/main.h
@@ -314,6 +314,18 @@ extern void dfilter_combo_add_empty(void);
*/
extern void main_update_for_unsaved_changes(capture_file *cf);
+#ifdef HAVE_LIBPCAP
+/** Update various parts of the main window for a change in whether
+ * "auto scroll in live capture" is on or off.
+ *
+ * @param auto_scroll_live_in new state of "auto scroll in live capture"
+ */
+void main_auto_scroll_live_changed(gboolean auto_scroll_live_in);
+#endif
+
+/** Update parts of the main window for a change in colorization. */
+extern void main_colorize_changed(gboolean packet_list_colorize);
+
/** 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 6b49207dba..aa93a03a4a 100644
--- a/ui/gtk/main_menubar.c
+++ b/ui/gtk/main_menubar.c
@@ -783,7 +783,7 @@ view_menu_auto_scroll_live_cb(GtkAction *action _U_, gpointer user_data _U_)
if (!widget){
g_warning("view_menu_auto_scroll_live_cb: No widget found");
}else{
- menu_auto_scroll_live_changed(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)));
+ main_auto_scroll_live_changed(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)));
}
#endif
}
@@ -4344,6 +4344,7 @@ name_resolution_cb(GtkWidget *w, gpointer d _U_, gint action)
}
}
+#ifdef HAVE_LIBPCAP
void
menu_auto_scroll_live_changed(gboolean auto_scroll_live_in) {
GtkWidget *menu;
@@ -4357,17 +4358,8 @@ menu_auto_scroll_live_changed(gboolean auto_scroll_live_in) {
if( ((gboolean) gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu)) != auto_scroll_live_in) ) {
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), auto_scroll_live_in);
}
-
-#ifdef HAVE_LIBPCAP
- /* tell toolbar about it */
- toolbar_auto_scroll_live_changed(auto_scroll_live_in);
-
- /* change auto scroll */
- if(auto_scroll_live_in != auto_scroll_live) {
- auto_scroll_live = auto_scroll_live_in;
- }
-#endif /*HAVE_LIBPCAP */
}
+#endif /*HAVE_LIBPCAP */
@@ -4385,22 +4377,12 @@ menu_colorize_changed(gboolean packet_list_colorize) {
if( (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu)) != packet_list_colorize) ) {
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), packet_list_colorize);
}
-
- /* tell toolbar about it */
- toolbar_colorize_changed(packet_list_colorize);
-
- /* change colorization */
- if(packet_list_colorize != recent.packet_list_colorize) {
- recent.packet_list_colorize = packet_list_colorize;
- color_filters_enable(packet_list_colorize);
- new_packet_list_colorize_packets();
- }
}
static void
colorize_cb(GtkWidget *w, gpointer d _U_)
{
- menu_colorize_changed(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)));
+ main_colorize_changed(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)));
}
@@ -4524,7 +4506,7 @@ menu_recent_read_finished(void) {
g_assert_not_reached();
}
- menu_colorize_changed(recent.packet_list_colorize);
+ main_colorize_changed(recent.packet_list_colorize);
}
diff --git a/ui/gtk/main_menubar_private.h b/ui/gtk/main_menubar_private.h
index a72ae66efb..231406947c 100644
--- a/ui/gtk/main_menubar_private.h
+++ b/ui/gtk/main_menubar_private.h
@@ -31,4 +31,12 @@
and whether it could be saved except by copying the raw packet data. */
void set_menus_for_capture_file(capture_file *);
+#ifdef HAVE_LIBPCAP
+/** The "Auto Scroll Packet List in Live Capture" option changed. */
+extern void menu_auto_scroll_live_changed(gboolean auto_scroll_in);
+#endif
+
+/** The "Colorize Packet List" option changed. */
+extern void menu_colorize_changed(gboolean packet_list_colorize);
+
#endif /* __MAIN_MENUBAR_PRIVATE_H__ */
diff --git a/ui/gtk/main_toolbar.c b/ui/gtk/main_toolbar.c
index f98ffc3d82..d4714fea23 100644
--- a/ui/gtk/main_toolbar.c
+++ b/ui/gtk/main_toolbar.c
@@ -52,8 +52,8 @@
#include "ui/gtk/color_dlg.h"
#include "ui/gtk/prefs_dlg.h"
#include "ui/gtk/main.h"
-#include "ui/gtk/menus.h"
#include "ui/gtk/main_toolbar.h"
+#include "ui/gtk/main_toolbar_private.h"
#include "ui/gtk/help_dlg.h"
#include "ui/gtk/gtkglobals.h"
#include "ui/gtk/stock_icons.h"
@@ -257,7 +257,7 @@ static void toolbar_append_separator(GtkWidget *toolbar) {
static void
colorize_toggle_cb(GtkWidget *toggle_button, gpointer user_data _U_) {
- menu_colorize_changed(TOGGLE_BUTTON_GET_ACTIVE(TOGGLE_BUTTON(toggle_button)));
+ main_colorize_changed(TOGGLE_BUTTON_GET_ACTIVE(TOGGLE_BUTTON(toggle_button)));
}
void
@@ -270,7 +270,7 @@ toolbar_colorize_changed(gboolean packet_list_colorize) {
#ifdef HAVE_LIBPCAP
static void
auto_scroll_live_toggle_cb(GtkWidget *autoscroll_button_lcl, gpointer user_data _U_) {
- menu_auto_scroll_live_changed(TOGGLE_BUTTON_GET_ACTIVE(TOGGLE_BUTTON(autoscroll_button_lcl)));
+ main_auto_scroll_live_changed(TOGGLE_BUTTON_GET_ACTIVE(TOGGLE_BUTTON(autoscroll_button_lcl)));
}
void
diff --git a/ui/gtk/main_toolbar.h b/ui/gtk/main_toolbar.h
index 701798340b..bb797d8ddd 100644
--- a/ui/gtk/main_toolbar.h
+++ b/ui/gtk/main_toolbar.h
@@ -40,23 +40,6 @@ GtkWidget *toolbar_new(void);
/** Redraw the main toolbar. Used, when user changes preferences. */
void toolbar_redraw_all(void);
-/** The "Colorize Packet List" option has changed.
- */
-void toolbar_colorize_changed(gboolean packet_list_colorize);
-
-#ifdef HAVE_LIBPCAP
-/** The "Auto Scroll in Live Capture" option has changed.
- */
-void toolbar_auto_scroll_live_changed(gboolean auto_scroll_live);
-#endif
-
-/* Enable or disable toolbar items based on whether you have a capture file
- * and, if so, whether you've finished reading it and whether there's stuff
- * in it that hasn't yet been saved to a permanent file.
- * @param cf cfile_t for the capture file in question
- */
-void set_toolbar_for_capture_file(capture_file *cf);
-
/** We have (or don't have) a capture in progress now.
*
* @param have_capture_file TRUE, if we have a capture in progress file
diff --git a/ui/gtk/main_toolbar_private.h b/ui/gtk/main_toolbar_private.h
new file mode 100644
index 0000000000..ceba1c6ee0
--- /dev/null
+++ b/ui/gtk/main_toolbar_private.h
@@ -0,0 +1,46 @@
+/* main_toolbar_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_TOLBAR_PRIVATE_H__
+#define __MAIN_TOLBAR_PRIVATE_H__
+
+/*** PRIVATE INTERFACE BETWEEN main.c AND main_toolbar.c DON'T USE OR TOUCH :-)*/
+
+/** The "Colorize Packet List" option has changed.
+ */
+void toolbar_colorize_changed(gboolean packet_list_colorize);
+
+#ifdef HAVE_LIBPCAP
+/** The "Auto Scroll in Live Capture" option has changed.
+ */
+void toolbar_auto_scroll_live_changed(gboolean auto_scroll_live);
+#endif
+
+/* Enable or disable toolbar items based on whether you have a capture file
+ * and, if so, whether you've finished reading it and whether there's stuff
+ * in it that hasn't yet been saved to a permanent file.
+ * @param cf cfile_t for the capture file in question
+ */
+void set_toolbar_for_capture_file(capture_file *cf);
+
+#endif /* __MAIN_TOOLBAR_PRIVATE_H__ */
diff --git a/ui/gtk/menus.h b/ui/gtk/menus.h
index cf1ec47243..282c030e33 100644
--- a/ui/gtk/menus.h
+++ b/ui/gtk/menus.h
@@ -50,19 +50,11 @@ extern void menu_recent_read_finished(void);
/** One of the name resolution menu items changed. */
extern void menu_name_resolution_changed(void);
-/** The "Colorize Packet List" option changed. */
-extern void menu_colorize_changed(gboolean packet_list_colorize);
-
/* Reset preferences menu on profile or preference change. */
extern void menu_prefs_reset(void);
extern void rebuild_visible_columns_menu (void);
-#ifdef HAVE_LIBPCAP
-/** The "Auto Scroll Packet List in Live Capture" option changed. */
-extern void menu_auto_scroll_live_changed(gboolean auto_scroll_in);
-#endif
-
/** Create a new menu.
*
* @param accel the created accelerator group
diff --git a/ui/gtk/new_packet_list.c b/ui/gtk/new_packet_list.c
index 7dd8f9587e..35dc1ce0ac 100644
--- a/ui/gtk/new_packet_list.c
+++ b/ui/gtk/new_packet_list.c
@@ -1118,7 +1118,7 @@ new_packet_list_check_end(void)
}
#ifdef HAVE_LIBPCAP
if (gtk_adjustment_get_value(adj) > 0 && at_end != last_at_end && at_end != auto_scroll_live) {
- menu_auto_scroll_live_changed(at_end);
+ main_auto_scroll_live_changed(at_end);
}
#endif
last_at_end = at_end;