Patch from Ronnie Sahlberg to cause the field description section of the

status bar to display nothing, rather than "Text (text)", when a
"proto_tree_add_text()" field is selected.

While we're at it, use a similar test to eliminate the text pseudo-field
from the output of "{ethereal,tethereal} -G", as well.

svn path=/trunk/; revision=3335
This commit is contained in:
Guy Harris 2001-04-19 23:06:23 +00:00
parent 0fa45bb541
commit 4caa331d21
2 changed files with 51 additions and 12 deletions

View File

@ -1,7 +1,7 @@
/* proto.c
* Routines for protocol tree
*
* $Id: proto.c,v 1.21 2001/04/10 19:10:10 guy Exp $
* $Id: proto.c,v 1.22 2001/04/19 23:06:22 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -168,8 +168,8 @@ proto_init(const char *plugin_dir,void (register_all_protocols)(void),
{
static hf_register_info hf[] = {
{ &hf_text_only,
{ "Text", "text", FT_NONE, BASE_NONE, NULL, 0x0,
"" }},
{ "", "", FT_NONE, BASE_NONE, NULL, 0x0,
NULL }},
};
if (gmc_hfinfo)
@ -2708,6 +2708,26 @@ proto_registrar_dump(void)
for (i = 0; i < len ; i++) {
hfinfo = proto_registrar_get_nth(i);
/*
* Skip fields with zero-length names or abbreviations;
* the pseudo-field for "proto_tree_add_text()" is such
* a field, and we don't want it in the list of filterable
* fields.
*
*
* XXX - perhaps the name and abbrev field should be null
* pointers rather than null strings for that pseudo-field,
* but we'd have to add checks for null pointers in some
* places if we did that.
*
* Or perhaps protocol tree items added with
* "proto_tree_add_text()" should have -1 as the field index,
* with no pseudo-field being used, but that might also
* require special checks for -1 to be added.
*/
if (strlen(hfinfo->name) == 0 || strlen(hfinfo->abbrev) == 0)
continue;
/* format for protocols */
if (proto_registrar_is_protocol(i)) {
printf("P\t%s\t%s\n", hfinfo->name, hfinfo->abbrev);

View File

@ -1,6 +1,6 @@
/* main.c
*
* $Id: main.c,v 1.194 2001/04/18 05:45:58 guy Exp $
* $Id: main.c,v 1.195 2001/04/19 23:06:23 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -466,7 +466,6 @@ tree_view_select_row_cb(GtkCTree *ctree, GList *node, gint column, gpointer user
set_menus_for_selected_tree_row(TRUE);
/*if (finfo->hfinfo && finfo->hfinfo->type != FT_TEXT_ONLY) {*/
if (finfo->hfinfo) {
if (finfo->hfinfo->blurb != NULL &&
finfo->hfinfo->blurb[0] != '\0') {
@ -475,13 +474,33 @@ tree_view_select_row_cb(GtkCTree *ctree, GList *node, gint column, gpointer user
} else {
length = strlen(finfo->hfinfo->name);
}
length += strlen(finfo->hfinfo->abbrev) + 10;
help_str = g_malloc(sizeof(gchar) * length);
sprintf(help_str, "%s (%s)",
(has_blurb) ? finfo->hfinfo->blurb : finfo->hfinfo->name,
finfo->hfinfo->abbrev);
gtk_statusbar_push(GTK_STATUSBAR(info_bar), help_ctx, help_str);
g_free(help_str);
if (length) {
length += strlen(finfo->hfinfo->abbrev) + 10;
help_str = g_malloc(sizeof(gchar) * length);
sprintf(help_str, "%s (%s)",
(has_blurb) ? finfo->hfinfo->blurb : finfo->hfinfo->name,
finfo->hfinfo->abbrev);
gtk_statusbar_push(GTK_STATUSBAR(info_bar), help_ctx, help_str);
g_free(help_str);
} else {
/*
* Don't show anything if the field name is zero-length;
* the pseudo-field for "proto_tree_add_text()" is such
* a field, and we don't want "Text (text)" showing up
* on the status line if you've selected such a field.
*
* XXX - perhaps the name and abbrev field should be null
* pointers rather than null strings for that pseudo-field,
* but we'd have to add checks for null pointers in some
* places if we did that.
*
* Or perhaps protocol tree items added with
* "proto_tree_add_text()" should have -1 as the field index,
* with no pseudo-field being used, but that might also
* require special checks for -1 to be added.
*/
gtk_statusbar_push(GTK_STATUSBAR(info_bar), help_ctx, "");
}
}
packet_hex_print(GTK_TEXT(byte_view), byte_data, cfile.current_frame,