aboutsummaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authorJaap Keuter <jaap.keuter@xs4all.nl>2008-01-16 07:36:34 +0000
committerJaap Keuter <jaap.keuter@xs4all.nl>2008-01-16 07:36:34 +0000
commit2e0f8088c381e1af5555268fae6beda35d730ac0 (patch)
treeac47560c23c630f5cfc4b4f91620092b7366ae70 /gtk
parentfa83e20a08de8d6cc62855d02459f2f25050e7f3 (diff)
From Jim Young:
This patch provides a new RTP Player preferences dialog. It allows one to select the maximum number of visable channels in the RTP Player window. The default is four (4) channels which is the maximum number of usable channels that the RTP Player can display and still have access to the bottom row buttons on a 1024*768 resolution display. Specifying a value less than 1 or greater than 10 will be result in the RTP Player displaying the default 4 channels. svn path=/trunk/; revision=24112
Diffstat (limited to 'gtk')
-rw-r--r--gtk/Makefile.am1
-rw-r--r--gtk/Makefile.common1
-rw-r--r--gtk/prefs_dlg.c28
-rw-r--r--gtk/rtp_player.c9
-rw-r--r--gtk/rtp_player_prefs.c102
-rw-r--r--gtk/rtp_player_prefs.h57
6 files changed, 195 insertions, 3 deletions
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 8d997dc255..f5aac05e87 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -106,6 +106,7 @@ noinst_HEADERS = \
recent.h \
rtp_analysis.h \
rtp_player.h \
+ rtp_player_prefs.h \
rtp_stream.h \
rtp_stream_dlg.h \
mcast_stream.h \
diff --git a/gtk/Makefile.common b/gtk/Makefile.common
index 7f3aeb19ac..03415e7b69 100644
--- a/gtk/Makefile.common
+++ b/gtk/Makefile.common
@@ -104,6 +104,7 @@ WIRESHARK_GTK_SRC = \
range_utils.c \
recent.c \
rtp_player.c \
+ rtp_player_prefs.c \
rtp_stream.c \
mcast_stream.c \
sctp_stat.c \
diff --git a/gtk/prefs_dlg.c b/gtk/prefs_dlg.c
index 465be9e966..cfaab16bf7 100644
--- a/gtk/prefs_dlg.c
+++ b/gtk/prefs_dlg.c
@@ -45,6 +45,7 @@
#include "layout_prefs.h"
#include "capture_prefs.h"
#include "nameres_prefs.h"
+#include "rtp_player_prefs.h"
#include "gui_utils.h"
#include "dlg_utils.h"
#include "simple_dialog.h"
@@ -101,6 +102,7 @@ static GtkWidget* create_preference_uat(GtkWidget*, int, const gchar*, const gch
#define E_CAPTURE_PAGE_KEY "capture_options_page"
#define E_PRINT_PAGE_KEY "printer_options_page"
#define E_NAMERES_PAGE_KEY "nameres_options_page"
+#define E_RTP_PLAYER_PAGE_KEY "rtp_player_options_page"
/*
* Keep a static pointer to the current "Preferences" window, if any, so that
@@ -674,6 +676,16 @@ prefs_cb(GtkWidget *w _U_, gpointer dummy _U_)
prefs_tree_page_add(label_str, cts.page, store, NULL, FALSE);
cts.page++;
+#ifdef HAVE_LIBPORTAUDIO
+#if GTK_MAJOR_VERSION >= 2
+ /* RTP player prefs */
+ strcpy(label_str, "RTP Player");
+ prefs_nb_page_add(prefs_nb, label_str, rtp_player_prefs_show(), E_RTP_PLAYER_PAGE_KEY);
+ prefs_tree_page_add(label_str, cts.page, store, NULL, FALSE);
+ cts.page++;
+#endif
+#endif
+
/* Registered prefs */
cts.notebook = prefs_nb;
cts.is_protocol = FALSE;
@@ -1349,7 +1361,11 @@ prefs_main_fetch_all(GtkWidget *dlg, gboolean *must_redissect)
#endif /* HAVE_LIBPCAP */
printer_prefs_fetch(OBJECT_GET_DATA(dlg, E_PRINT_PAGE_KEY));
nameres_prefs_fetch(OBJECT_GET_DATA(dlg, E_NAMERES_PAGE_KEY));
-
+#ifdef HAVE_LIBPORTAUDIO
+#if GTK_MAJOR_VERSION >= 2
+ rtp_player_prefs_fetch(OBJECT_GET_DATA(dlg, E_RTP_PLAYER_PAGE_KEY));
+#endif
+#endif
prefs_modules_foreach(module_prefs_fetch, must_redissect);
return TRUE;
@@ -1385,6 +1401,11 @@ prefs_main_apply_all(GtkWidget *dlg, gboolean redissect)
#endif /* HAVE_LIBPCAP */
printer_prefs_apply(OBJECT_GET_DATA(dlg, E_PRINT_PAGE_KEY));
nameres_prefs_apply(OBJECT_GET_DATA(dlg, E_NAMERES_PAGE_KEY));
+#ifdef HAVE_LIBPORTAUDIO
+#if GTK_MAJOR_VERSION >= 2
+ rtp_player_prefs_apply(OBJECT_GET_DATA(dlg, E_RTP_PLAYER_PAGE_KEY));
+#endif
+#endif
/* show/hide the Save button - depending on setting */
save_bt = OBJECT_GET_DATA(prefs_w, E_PREFSW_SAVE_BT_KEY);
@@ -1429,6 +1450,11 @@ prefs_main_destroy_all(GtkWidget *dlg)
#endif /* HAVE_LIBPCAP */
printer_prefs_destroy(OBJECT_GET_DATA(dlg, E_PRINT_PAGE_KEY));
nameres_prefs_destroy(OBJECT_GET_DATA(dlg, E_NAMERES_PAGE_KEY));
+#ifdef HAVE_LIBPORTAUDIO
+#if GTK_MAJOR_VERSION >= 2
+ rtp_player_prefs_destroy(OBJECT_GET_DATA(dlg, E_RTP_PLAYER_PAGE_KEY));
+#endif
+#endif
/* Free up the saved preferences (both for "prefs" and for registered
preferences). */
diff --git a/gtk/rtp_player.c b/gtk/rtp_player.c
index 4c690c8c85..96a1cbe264 100644
--- a/gtk/rtp_player.c
+++ b/gtk/rtp_player.c
@@ -85,6 +85,7 @@
#include "codecs/G711a/G711adecode.h"
#include "codecs/G711u/G711udecode.h"
#include <math.h>
+#include <epan/prefs.h> /* For prefs.rtp_player_max_visible and RTP_PLAYER_DEFAULT_VISIBLE */
#ifndef min
#define min(a,b) (((a)<(b))?(a):(b))
@@ -1759,9 +1760,13 @@ decode_streams(void)
if (rtp_channels_hash)
g_hash_table_foreach( rtp_channels_hash, (GHFunc)add_channel_to_window, &counter);
- /* Resize the main scroll window to display no more than 5 channels, otherwise the scroll bar need to be used */
+ /* Resize the main scroll window to display no more than preferred (or default) max channels, scroll bar will be used if needed */
+
+ if (prefs.rtp_player_max_visible < 1 || prefs.rtp_player_max_visible > 10)
+ prefs.rtp_player_max_visible = RTP_PLAYER_DEFAULT_VISIBLE;
+
WIDGET_SET_SIZE(main_scrolled_window, CHANNEL_WIDTH,
- min(counter, 5) * (CHANNEL_HEIGHT+60));
+ min(counter, prefs.rtp_player_max_visible) * (CHANNEL_HEIGHT+60));
gtk_widget_show_all(main_scrolled_window);
diff --git a/gtk/rtp_player_prefs.c b/gtk/rtp_player_prefs.c
new file mode 100644
index 0000000000..ec40c8d8a0
--- /dev/null
+++ b/gtk/rtp_player_prefs.c
@@ -0,0 +1,102 @@
+/* rtp_player_prefs.c
+ * Dialog box for RTP player 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 <gtk/gtk.h>
+#include <stdlib.h>
+#include "rtp_player_prefs.h"
+#include <epan/prefs.h>
+#include "prefs_dlg.h"
+#include "compat_macros.h"
+
+#define RTP_PLAYER_MAX_VISIBLE_KEY "max_visible"
+#define RTP_PLAYER_TABLE_ROWS 6
+
+static char max_visible_str[128] = "";
+
+GtkWidget*
+rtp_player_prefs_show(void)
+{
+ GtkWidget *main_tb, *main_vb;
+ GtkWidget *rtp_player_max_visible_te;
+ GtkTooltips *tooltips = gtk_tooltips_new();
+ int pos = 0;
+
+ /* Main vertical box */
+ main_vb = gtk_vbox_new(FALSE, 7);
+ gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
+
+ /* Main table */
+ main_tb = gtk_table_new(RTP_PLAYER_TABLE_ROWS, 1, 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);
+ OBJECT_SET_DATA(main_tb, E_TOOLTIPS_KEY, tooltips);
+
+ /* Max visable 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, 128, "%d", prefs.rtp_player_max_visible);
+ gtk_entry_set_text(GTK_ENTRY(rtp_player_max_visible_te), max_visible_str);
+ gtk_tooltips_set_tip(tooltips, rtp_player_max_visible_te,
+ "Maximum height of RTP Player window is defined here.", NULL);
+ OBJECT_SET_DATA(main_vb, RTP_PLAYER_MAX_VISIBLE_KEY, rtp_player_max_visible_te);
+
+ /* Show 'em what we got */
+ gtk_widget_show_all(main_vb);
+
+ return main_vb;
+}
+
+void
+rtp_player_prefs_fetch(GtkWidget *w _U_)
+{
+ GtkWidget *rtp_player_max_visible_te;
+
+ rtp_player_max_visible_te = (GtkWidget *)OBJECT_GET_DATA(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 minimum sane max channels */
+
+ if (prefs.rtp_player_max_visible < 1 || prefs.rtp_player_max_visible > 10)
+ prefs.rtp_player_max_visible = RTP_PLAYER_DEFAULT_VISIBLE;
+}
+
+void
+rtp_player_prefs_apply(GtkWidget *w _U_)
+{
+}
+
+void
+rtp_player_prefs_destroy(GtkWidget *w _U_)
+{
+}
+
diff --git a/gtk/rtp_player_prefs.h b/gtk/rtp_player_prefs.h
new file mode 100644
index 0000000000..2b0e4be110
--- /dev/null
+++ b/gtk/rtp_player_prefs.h
@@ -0,0 +1,57 @@
+/* rtp_player_prefs.h
+ * Definitions for RTP player preferences window
+ *
+ * $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 __RTP_PLAYER_PREFS_H__
+#define __RTP_PLAYER_PREFS_H__
+
+/** @file
+ * "RTP player" preferences page.
+ * @ingroup prefs_group
+ */
+
+/** Build a RTP player preferences page.
+ *
+ * @return the new preferences page
+ */
+GtkWidget *rtp_player_prefs_show(void);
+
+/** Fetch preference values from page.
+ *
+ * @param widget widget from rtp_player_prefs_show()
+ */
+void rtp_player_prefs_fetch(GtkWidget *widget);
+
+/** Apply preference values from page.
+ *
+ * @param widget widget from rtp_player_prefs_show()
+ */
+void rtp_player_prefs_apply(GtkWidget *widget);
+
+/** Destroy preference values from page.
+ *
+ * @param widget widget from rtp_player_prefs_show()
+ */
+void rtp_player_prefs_destroy(GtkWidget *widget);
+
+#endif