aboutsummaryrefslogtreecommitdiffstats
path: root/ui/gtk/prefs_taps.c
blob: 22c60ed89b871f04129233d13814d3621882dbd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/* prefs_taps.c
 * Dialog box for tap/statistics preferences
 *
 * $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.
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>

#include <gtk/gtk.h>

#include <epan/prefs.h>

#include "ui/gtk/gui_utils.h"
#include "ui/gtk/prefs_taps.h"
#include "ui/gtk/prefs_dlg.h"
#include "ui/gtk/main.h"

#define TAP_UPDATE_INTERVAL_KEY   "update_interval"

#define RTP_PLAYER_MAX_VISIBLE_KEY   "rtp_player_max_visible"
#define RTP_PLAYER_TABLE_ROWS 6

static char update_interval_str[128] = "";
static char max_visible_str[128] = "";


GtkWidget*
stats_prefs_show(void)
{
        GtkWidget   *main_tb, *main_vb;
        GtkWidget   *tap_update_interval_te;
#ifdef HAVE_LIBPORTAUDIO
        GtkWidget   *rtp_player_max_visible_te;
#endif
        int pos = 0;

        /* Main vertical box */
        main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 7, FALSE);
        gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);

        /* Main table */
        main_tb = gtk_table_new(RTP_PLAYER_TABLE_ROWS, 2, FALSE);
        gtk_box_pack_start(GTK_BOX(main_vb), main_tb, FALSE, FALSE, 0);
        gtk_table_set_row_spacings(GTK_TABLE(main_tb), 10);
        gtk_table_set_col_spacings(GTK_TABLE(main_tb), 15);
        gtk_widget_show(main_tb);

        /* Tap update gap in ms */
        tap_update_interval_te = create_preference_entry(main_tb, pos++,
            "Tap update interval in ms:",
            "Determines time between tap updates.", max_visible_str);
        g_snprintf(update_interval_str, sizeof(update_interval_str), "%d", prefs.tap_update_interval);
        gtk_entry_set_text(GTK_ENTRY(tap_update_interval_te), update_interval_str);
        gtk_widget_set_tooltip_text(tap_update_interval_te, "Gap in milliseconds between updates to taps is defined here");
        g_object_set_data(G_OBJECT(main_vb), TAP_UPDATE_INTERVAL_KEY, tap_update_interval_te);

#ifdef HAVE_LIBPORTAUDIO
        /* Max visible channels in RTP Player */
        rtp_player_max_visible_te = create_preference_entry(main_tb, pos++,
            "Max visible channels in RTP Player:",
            "Determines maximum height of RTP Player window.", max_visible_str);
        g_snprintf(max_visible_str, sizeof(max_visible_str), "%d", prefs.rtp_player_max_visible);
        gtk_entry_set_text(GTK_ENTRY(rtp_player_max_visible_te), max_visible_str);
        gtk_widget_set_tooltip_text(rtp_player_max_visible_te, "Maximum height of RTP Player window is defined here.");
        g_object_set_data(G_OBJECT(main_vb), RTP_PLAYER_MAX_VISIBLE_KEY, rtp_player_max_visible_te);
#endif

        /* Show 'em what we got */
        gtk_widget_show_all(main_vb);

        return main_vb;
}

void
stats_prefs_fetch(GtkWidget *w _U_)
{
        GtkWidget *tap_update_interval_te;
#ifdef HAVE_LIBPORTAUDIO
        GtkWidget *rtp_player_max_visible_te;
#endif

        /* Tap update interval */
        tap_update_interval_te = (GtkWidget *)g_object_get_data(G_OBJECT(w), TAP_UPDATE_INTERVAL_KEY);
        prefs.tap_update_interval = strtol(gtk_entry_get_text(
                GTK_ENTRY(tap_update_interval_te)), NULL, 10);

        /* Test for a sane tap update interval */
        if (prefs.tap_update_interval < 100 || prefs.tap_update_interval > 10000) {
                prefs.tap_update_interval = TAP_UPDATE_DEFAULT_INTERVAL;
        }

#ifdef HAVE_LIBPORTAUDIO
        /* Max RTP channels */
        rtp_player_max_visible_te = (GtkWidget *)g_object_get_data(G_OBJECT(w), RTP_PLAYER_MAX_VISIBLE_KEY);
        prefs.rtp_player_max_visible = strtol(gtk_entry_get_text(
                GTK_ENTRY(rtp_player_max_visible_te)), NULL, 10);

        /* Test for a sane max channels entry */
        if (prefs.rtp_player_max_visible < 1 || prefs.rtp_player_max_visible > 10)
                prefs.rtp_player_max_visible = RTP_PLAYER_DEFAULT_VISIBLE;
#endif
}

void
stats_prefs_apply(GtkWidget *w _U_)
{
#if defined(_WIN32)
        reset_tap_update_timer();
#endif
}

void
stats_prefs_destroy(GtkWidget *w _U_)
{
}