2 * Dialog box for tap/statistics preferences
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 #include <epan/prefs.h>
34 #include "gtk/prefs_taps.h"
35 #include "gtk/prefs_dlg.h"
38 #define TAP_UPDATE_INTERVAL_KEY "update_interval"
40 #define RTP_PLAYER_MAX_VISIBLE_KEY "rtp_player_max_visible"
41 #define RTP_PLAYER_TABLE_ROWS 6
43 static char update_interval_str[128] = "";
44 static char max_visible_str[128] = "";
48 stats_prefs_show(void)
50 GtkWidget *main_tb, *main_vb;
51 GtkWidget *tap_update_interval_te;
52 #ifdef HAVE_LIBPORTAUDIO
53 GtkWidget *rtp_player_max_visible_te;
56 GtkTooltips *tooltips = gtk_tooltips_new();
59 /* Main vertical box */
60 main_vb = gtk_vbox_new(FALSE, 7);
61 gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
64 main_tb = gtk_table_new(RTP_PLAYER_TABLE_ROWS, 2, FALSE);
65 gtk_box_pack_start(GTK_BOX(main_vb), main_tb, FALSE, FALSE, 0);
66 gtk_table_set_row_spacings(GTK_TABLE(main_tb), 10);
67 gtk_table_set_col_spacings(GTK_TABLE(main_tb), 15);
68 gtk_widget_show(main_tb);
69 g_object_set_data(G_OBJECT(main_tb), E_TOOLTIPS_KEY, tooltips);
71 /* Tap update gap in ms */
72 tap_update_interval_te = create_preference_entry(main_tb, pos++,
73 "Tap update interval in ms:",
74 "Determines time between tap updates.", max_visible_str);
75 g_snprintf(update_interval_str, sizeof(update_interval_str), "%d", prefs.tap_update_interval);
76 gtk_entry_set_text(GTK_ENTRY(tap_update_interval_te), update_interval_str);
77 gtk_tooltips_set_tip(tooltips, tap_update_interval_te,
78 "Gap in milliseconds between updates to taps is defined here", NULL);
79 g_object_set_data(G_OBJECT(main_vb), TAP_UPDATE_INTERVAL_KEY, tap_update_interval_te);
81 #ifdef HAVE_LIBPORTAUDIO
82 /* Max visible channels in RTP Player */
83 rtp_player_max_visible_te = create_preference_entry(main_tb, pos++,
84 "Max visible channels in RTP Player:",
85 "Determines maximum height of RTP Player window.", max_visible_str);
86 g_snprintf(max_visible_str, sizeof(max_visible_str), "%d", prefs.rtp_player_max_visible);
87 gtk_entry_set_text(GTK_ENTRY(rtp_player_max_visible_te), max_visible_str);
88 gtk_tooltips_set_tip(tooltips, rtp_player_max_visible_te,
89 "Maximum height of RTP Player window is defined here.", NULL);
90 g_object_set_data(G_OBJECT(main_vb), RTP_PLAYER_MAX_VISIBLE_KEY, rtp_player_max_visible_te);
93 /* Show 'em what we got */
94 gtk_widget_show_all(main_vb);
100 stats_prefs_fetch(GtkWidget *w _U_)
102 GtkWidget *tap_update_interval_te;
103 #ifdef HAVE_LIBPORTAUDIO
104 GtkWidget *rtp_player_max_visible_te;
107 /* Tap update interval */
108 tap_update_interval_te = (GtkWidget *)g_object_get_data(G_OBJECT(w), TAP_UPDATE_INTERVAL_KEY);
109 prefs.tap_update_interval = strtol(gtk_entry_get_text(
110 GTK_ENTRY(tap_update_interval_te)), NULL, 10);
112 /* Test for a sane tap update interval */
113 if (prefs.tap_update_interval < 100 || prefs.tap_update_interval > 10000) {
114 prefs.tap_update_interval = 3000;
117 #ifdef HAVE_LIBPORTAUDIO
118 /* Max RTP channels */
119 rtp_player_max_visible_te = (GtkWidget *)g_object_get_data(G_OBJECT(w), RTP_PLAYER_MAX_VISIBLE_KEY);
120 prefs.rtp_player_max_visible = strtol(gtk_entry_get_text(
121 GTK_ENTRY(rtp_player_max_visible_te)), NULL, 10);
123 /* Test for a sane max channels entry */
124 if (prefs.rtp_player_max_visible < 1 || prefs.rtp_player_max_visible > 10)
125 prefs.rtp_player_max_visible = RTP_PLAYER_DEFAULT_VISIBLE;
130 stats_prefs_apply(GtkWidget *w _U_)
132 reset_tap_update_timer();
136 stats_prefs_destroy(GtkWidget *w _U_)