Added an option to display hidden protocol items.

svn path=/trunk/; revision=25108
This commit is contained in:
Stig Bjørlykke 2008-04-17 23:14:01 +00:00
parent b11501c457
commit a4f76f95a0
7 changed files with 184 additions and 10 deletions

View File

@ -1192,6 +1192,8 @@ init_prefs(void) {
/* set the default values for the rtp player dialog box */
prefs.rtp_player_max_visible = RTP_PLAYER_DEFAULT_VISIBLE;
prefs.display_hidden_proto_items = FALSE;
prefs_initialized = TRUE;
}
@ -1672,6 +1674,8 @@ prefs_is_capture_device_hidden(const char *name)
/* values for the rtp player preferences dialog box */
#define PRS_RTP_PLAYER_MAX_VISIBLE "rtp_player.max_visible"
#define PRS_DISPLAY_HIDDEN_PROTO_ITEMS "packet_list.display_hidden_proto_items"
static const gchar *pr_formats[] = { "text", "postscript" };
static const gchar *pr_dests[] = { "command", "file" };
@ -2078,6 +2082,8 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_)
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 if (strcmp(pref_name, PRS_DISPLAY_HIDDEN_PROTO_ITEMS) == 0) {
prefs.display_hidden_proto_items = ((g_ascii_strcasecmp(value, "true") == 0)?TRUE:FALSE);
} else {
/* To which module does this preference belong? */
module = NULL;
@ -2855,6 +2861,11 @@ write_prefs(char **pf_path_return)
fprintf(pf, "\n####### Protocols ########\n");
fprintf(pf, "\n# Display hidden items in packet details pane?\n");
fprintf(pf, "# TRUE or FALSE (case-insensitive).\n");
fprintf(pf, PRS_DISPLAY_HIDDEN_PROTO_ITEMS ": %s\n",
prefs.display_hidden_proto_items == TRUE ? "TRUE" : "FALSE");
pe_tree_foreach(prefs_modules, write_module_prefs, pf);
fclose(pf);
@ -2935,6 +2946,7 @@ copy_prefs(e_prefs *dest, e_prefs *src)
dest->capture_show_info = src->capture_show_info;
dest->name_resolve = src->name_resolve;
dest->name_resolve_concurrency = src->name_resolve_concurrency;
dest->display_hidden_proto_items = src->display_hidden_proto_items;
}

View File

@ -148,6 +148,7 @@ typedef struct _e_prefs {
gboolean capture_auto_scroll;
gboolean capture_show_info;
guint rtp_player_max_visible;
gboolean display_hidden_proto_items;
} e_prefs;
WS_VAR_IMPORT e_prefs prefs;

View File

@ -95,6 +95,7 @@ WIRESHARK_GTK_SRC = \
prefs_layout.c \
prefs_nameres.c \
prefs_print.c \
prefs_protocols.c \
prefs_rtp_player.c \
prefs_stream.c \
print_dlg.c \
@ -264,6 +265,7 @@ noinst_HEADERS = \
prefs_layout.h \
prefs_nameres.h \
prefs_print.h \
prefs_protocols.h \
prefs_rtp_player.h \
prefs_stream.h \
profile_dlg.h \

View File

@ -1416,6 +1416,7 @@ GdkColor expert_color_chat = { 0, 0xcc00, 0xcc00, 0xe000 }; /* a pale bluegrey *
GdkColor expert_color_note = { 0, 0xa000, 0xff00, 0xff00 }; /* a bright turquoise */
GdkColor expert_color_warn = { 0, 0xff00, 0xff00, 0 }; /* yellow */
GdkColor expert_color_error = { 0, 0xff00, 0x5c00, 0x5c00 }; /* pale red */
GdkColor hidden_proto_item = { 0, 0x4400, 0x4400, 0x4400 }; /* gray */
void proto_draw_colors_init(void)
{
@ -1427,6 +1428,7 @@ void proto_draw_colors_init(void)
get_color(&expert_color_note);
get_color(&expert_color_warn);
get_color(&expert_color_error);
get_color(&hidden_proto_item);
colors_ok = TRUE;
}
@ -1481,6 +1483,9 @@ static void tree_cell_renderer(GtkTreeViewColumn *tree_column _U_,
*/
/*g_object_set (cell, "weight", PANGO_WEIGHT_BOLD, NULL);
g_object_set (cell, "weight-set", TRUE, NULL);*/
} else if(FI_GET_FLAG(fi, FI_HIDDEN)) {
g_object_set (cell, "foreground-gdk", &hidden_proto_item, NULL);
g_object_set (cell, "foreground-set", TRUE, NULL);
}
if(fi->hfinfo->type == FT_PROTOCOL) {
@ -1686,7 +1691,7 @@ proto_tree_draw_node(proto_node *node, gpointer data)
GtkTreeIter iter;
GtkTreePath *path;
if (PROTO_ITEM_IS_HIDDEN(node))
if (PROTO_ITEM_IS_HIDDEN(node) && !prefs.display_hidden_proto_items)
return;
/* was a free format label produced? */
@ -1713,8 +1718,10 @@ proto_tree_draw_node(proto_node *node, gpointer data)
is_expanded = FALSE;
}
if(PROTO_ITEM_IS_GENERATED(node)) {
if (PROTO_ITEM_IS_GENERATED(node)) {
label_ptr = g_strdup_printf("[%s]", label_ptr);
} else if (PROTO_ITEM_IS_HIDDEN(node)) {
label_ptr = g_strdup_printf("<%s>", label_ptr);
}
info.tree_view = parent_info->tree_view;
@ -1722,7 +1729,7 @@ proto_tree_draw_node(proto_node *node, gpointer data)
gtk_tree_store_append(store, &iter, parent_info->iter);
gtk_tree_store_set(store, &iter, 0, label_ptr, 1, fi, -1);
if(PROTO_ITEM_IS_GENERATED(node)) {
if (PROTO_ITEM_IS_GENERATED(node) || PROTO_ITEM_IS_HIDDEN(node)) {
g_free(label_ptr);
}

View File

@ -50,6 +50,7 @@
#include "gtk/prefs_capture.h"
#include "gtk/prefs_nameres.h"
#include "gtk/prefs_rtp_player.h"
#include "gtk/prefs_protocols.h"
#include "gtk/gui_utils.h"
#include "gtk/dlg_utils.h"
#include "gtk/stock_icons.h"
@ -96,6 +97,7 @@ static void prefs_tree_select_cb(GtkTreeSelection *, gpointer);
#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"
#define E_PROTOCOLS_PAGE_KEY "protocols_options_page"
/*
* Keep a static pointer to the current "Preferences" window, if any, so that
@ -122,7 +124,7 @@ struct ct_struct {
gboolean is_protocol;
};
static gint blank_page = 0;
static gint protocols_page = 0;
static guint
pref_exists(pref_t *pref _U_, gpointer user_data _U_)
@ -365,9 +367,9 @@ module_prefs_show(module_t *module, gpointer user_data)
/* Show 'em what we got */
gtk_widget_show_all(main_sw);
} else {
/* show the blank page */
/* show the protocols page */
gtk_tree_store_set(model, &iter, 0, label_str, 1, blank_page, -1);
gtk_tree_store_set(model, &iter, 0, label_str, 1, protocols_page, -1);
}
@ -497,10 +499,10 @@ prefs_cb(GtkWidget *w _U_, gpointer dummy _U_)
cts.page = 0;
/* Blank Page */
g_strlcpy(label_str, "(No Specific Preferences)", MAX_TREE_NODE_NAME_LEN);
prefs_nb_page_add(prefs_nb, label_str, NULL, NULL);
blank_page = cts.page++;
/* Preferences common for all protocols */
g_strlcpy(label_str, "Protocols", MAX_TREE_NODE_NAME_LEN);
prefs_nb_page_add(prefs_nb, label_str, protocols_prefs_show(), E_PROTOCOLS_PAGE_KEY);
protocols_page = cts.page++;
/* GUI prefs */
g_strlcpy(label_str, "User Interface", MAX_TREE_NODE_NAME_LEN);
@ -1265,6 +1267,7 @@ prefs_main_fetch_all(GtkWidget *dlg, gboolean *must_redissect)
#ifdef HAVE_LIBPORTAUDIO
rtp_player_prefs_fetch(g_object_get_data(G_OBJECT(dlg), E_RTP_PLAYER_PAGE_KEY));
#endif
protocols_prefs_fetch(g_object_get_data(G_OBJECT(dlg), E_PROTOCOLS_PAGE_KEY));
prefs_modules_foreach(module_prefs_fetch, must_redissect);
return TRUE;
@ -1303,6 +1306,7 @@ prefs_main_apply_all(GtkWidget *dlg, gboolean redissect)
#ifdef HAVE_LIBPORTAUDIO
rtp_player_prefs_apply(g_object_get_data(G_OBJECT(dlg), E_RTP_PLAYER_PAGE_KEY));
#endif
protocols_prefs_apply(g_object_get_data(G_OBJECT(dlg), E_PROTOCOLS_PAGE_KEY));
/* show/hide the Save button - depending on setting */
save_bt = g_object_get_data(G_OBJECT(prefs_w), E_PREFSW_SAVE_BT_KEY);
@ -1353,6 +1357,7 @@ prefs_main_destroy_all(GtkWidget *dlg)
preferences). */
free_prefs(&saved_prefs);
prefs_modules_foreach(module_prefs_clean, NULL);
protocols_prefs_destroy(g_object_get_data(G_OBJECT(dlg), E_PROTOCOLS_PAGE_KEY));
}

90
gtk/prefs_protocols.c Normal file
View File

@ -0,0 +1,90 @@
/* prefs_protocols.c
* Dialog box for preferences common for all protocols
*
* $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 <epan/prefs.h>
#include "gtk/prefs_protocols.h"
#include "gtk/prefs_dlg.h"
#define PROTOCOLS_SHOW_HIDDEN_KEY "display_hidden_items"
#define PROTOCOLS_TABLE_ROWS 1
GtkWidget*
protocols_prefs_show(void)
{
GtkWidget *main_tb, *main_vb;
GtkWidget *display_hidden_cb;
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(PROTOCOLS_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);
g_object_set_data(G_OBJECT(main_tb), E_TOOLTIPS_KEY, tooltips);
/* Show hidden protocol items in packet list */
display_hidden_cb = create_preference_check_button(main_tb, pos++,
"Display hidden protocol items:",
"Display all hidden protocol items in the packet list.",
prefs.display_hidden_proto_items);
g_object_set_data(G_OBJECT(main_vb), PROTOCOLS_SHOW_HIDDEN_KEY, display_hidden_cb);
/* Show 'em what we got */
gtk_widget_show_all(main_vb);
return main_vb;
}
void
protocols_prefs_fetch(GtkWidget *w _U_)
{
GtkWidget *display_hidden_cb;
display_hidden_cb = (GtkWidget *)g_object_get_data(G_OBJECT(w), PROTOCOLS_SHOW_HIDDEN_KEY);
prefs.display_hidden_proto_items = (GTK_TOGGLE_BUTTON (display_hidden_cb)->active ? TRUE : FALSE);
}
void
protocols_prefs_apply(GtkWidget *w _U_)
{
}
void
protocols_prefs_destroy(GtkWidget *w _U_)
{
}

57
gtk/prefs_protocols.h Normal file
View File

@ -0,0 +1,57 @@
/* prefs_protocols.h
* Definitions for preferences common for all protocols
*
* $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 __PREFS_PROTOCOLS_H__
#define __PREFS_PROTOCOLS_H__
/** @file
* "Protocols" preferences page.
* @ingroup prefs_group
*/
/** Build a page for preferences common for all protocols
*
* @return the new preferences page
*/
GtkWidget *protocols_prefs_show(void);
/** Fetch preference values from page.
*
* @param widget widget from protocols_prefs_show()
*/
void protocols_prefs_fetch(GtkWidget *widget);
/** Apply preference values from page.
*
* @param widget widget from protocols_prefs_show()
*/
void protocols_prefs_apply(GtkWidget *widget);
/** Destroy preference values from page.
*
* @param widget widget from protocols_prefs_show()
*/
void protocols_prefs_destroy(GtkWidget *widget);
#endif