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
This commit is contained in:
Jaap Keuter 2008-01-16 07:36:34 +00:00
parent fa83e20a08
commit 2e0f8088c3
8 changed files with 215 additions and 3 deletions

View File

@ -1215,9 +1215,14 @@ init_prefs(void) {
prefs.capture_real_time = TRUE;
prefs.capture_auto_scroll = TRUE;
prefs.capture_show_info = FALSE;
/* set the default values for the name resolution dialog box */
prefs.name_resolve = RESOLV_ALL ^ RESOLV_NETWORK;
prefs.name_resolve_concurrency = 500;
/* set the default values for the rtp player dialog box */
prefs.rtp_player_max_visible = RTP_PLAYER_DEFAULT_VISIBLE;
prefs_initialized = TRUE;
}
@ -1596,6 +1601,9 @@ prefs_set_pref(char *prefarg)
#define GREEN_COMPONENT(x) (guint16) (((((x) >> 8) & 0xff) * 65535 / 255))
#define BLUE_COMPONENT(x) (guint16) ( (((x) & 0xff) * 65535 / 255))
/* values for the rtp player preferences dialog box */
#define PRS_RTP_PLAYER_MAX_VISIBLE "rtp_player.max_visible"
static const gchar *pr_formats[] = { "text", "postscript" };
static const gchar *pr_dests[] = { "command", "file" };
@ -1983,6 +1991,8 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_)
}
} else if (strcmp(pref_name, PRS_NAME_RESOLVE_CONCURRENCY) == 0) {
prefs.name_resolve_concurrency = strtol(value, NULL, 10);
} else if (strcmp(pref_name, PRS_RTP_PLAYER_MAX_VISIBLE) == 0) {
prefs.rtp_player_max_visible = strtol(value, NULL, 10);
} else {
/* To which module does this preference belong? */
module = NULL;
@ -2737,6 +2747,13 @@ write_prefs(char **pf_path_return)
fprintf(pf, PRS_NAME_RESOLVE_CONCURRENCY ": %d\n",
prefs.name_resolve_concurrency);
fprintf(pf, "\n####### RTP Player ########\n");
fprintf(pf, "\n# Maximum visible channels in RTP Player window.\n");
fprintf(pf, "# An integer value greater than 0.\n");
fprintf(pf, PRS_RTP_PLAYER_MAX_VISIBLE ": %d\n",
prefs.rtp_player_max_visible);
fprintf(pf, "\n####### Protocols ########\n");
pe_tree_foreach(prefs_modules, write_module_prefs, pf);

View File

@ -39,6 +39,8 @@
#define MAX_VAL_LEN 1024
#define RTP_PLAYER_DEFAULT_VISIBLE 4
/* only GTK1 *or* GTK2 font_name should be used */
/* (we need to keep both in the preferences file but will only use the one suitable for the programs GTK version used) */
#if GTK_MAJOR_VERSION < 2
@ -153,6 +155,7 @@ typedef struct _e_prefs {
gboolean capture_real_time;
gboolean capture_auto_scroll;
gboolean capture_show_info;
guint rtp_player_max_visible;
} e_prefs;
WS_VAR_IMPORT e_prefs prefs;

View File

@ -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 \

View File

@ -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 \

View File

@ -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). */

View File

@ -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);

102
gtk/rtp_player_prefs.c Normal file
View File

@ -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_)
{
}

57
gtk/rtp_player_prefs.h Normal file
View File

@ -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