add support to link from specially marked fields to related packets,

a doubleclick will follow the link

svn path=/trunk/; revision=10892
This commit is contained in:
Ulf Lamping 2004-05-14 15:55:37 +00:00
parent 161d88c50a
commit 1314808bd5
3 changed files with 89 additions and 3 deletions

View File

@ -1,7 +1,7 @@
/* proto.h
* Definitions for protocol display
*
* $Id: proto.h,v 1.66 2004/05/10 23:13:55 ulfl Exp $
* $Id: proto.h,v 1.67 2004/05/14 15:55:37 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -163,6 +163,9 @@ typedef struct field_info {
/** The protocol field should be displayed as "generated by Ethereal",
* used in field_info.flags. */
#define FI_GENERATED 0x0002
/** The protocol field should be displayed as a link to another packet,
* used in field_info.flags. */
#define FI_LINK 0x0004
/** convenience macro to get field_info.flags */
#define FI_GET_FLAG(fi, flag) (fi->flags & flag)
@ -206,6 +209,12 @@ typedef proto_node proto_item;
/** mark this protocol field as generated by Ethereal (and not read from the packet data) */
#define PROTO_ITEM_SET_GENERATED(proto_item) \
((proto_item) ? FI_SET_FLAG(proto_item->finfo, FI_GENERATED) : 0)
/** is this protocol field a link to another packet? */
#define PROTO_ITEM_IS_LINK(proto_item) \
((proto_item) ? FI_GET_FLAG(proto_item->finfo, FI_LINK) : 0)
/** mark this protocol field as a link to another packet */
#define PROTO_ITEM_SET_LINK(proto_item) \
((proto_item) ? FI_SET_FLAG(proto_item->finfo, FI_LINK) : 0)
typedef void (*proto_tree_foreach_func)(proto_node *, gpointer);

View File

@ -1,7 +1,7 @@
/* proto_draw.c
* Routines for GTK+ packet display
*
* $Id: proto_draw.c,v 1.94 2004/05/09 07:01:07 ulfl Exp $
* $Id: proto_draw.c,v 1.95 2004/05/14 15:55:37 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -1593,6 +1593,50 @@ set_ptree_font_all(PangoFontDescription *font)
#endif
}
#if GTK_MAJOR_VERSION >= 2
void tree_cell_renderer(GtkTreeViewColumn *tree_column,
GtkCellRenderer *cell,
GtkTreeModel *tree_model,
GtkTreeIter *iter,
gpointer data)
{
field_info *fi;
gtk_tree_model_get(tree_model, iter, 1, &fi, -1);
/* for each field, we have to reset the renderer attributes */
g_object_set (cell, "foreground-set", FALSE, NULL);
g_object_set (cell, "underline", PANGO_UNDERLINE_NONE, NULL);
g_object_set (cell, "underline-set", FALSE, NULL);
/*g_object_set (cell, "style", PANGO_STYLE_NORMAL, NULL);
g_object_set (cell, "style-set", FALSE, NULL);*/
/*g_object_set (cell, "weight", PANGO_WEIGHT_NORMAL, NULL);
g_object_set (cell, "weight-set", FALSE, NULL);*/
if(FI_GET_FLAG(fi, FI_GENERATED)) {
/* as some fonts don't support italic, don't use this */
/*g_object_set (cell, "style", PANGO_STYLE_ITALIC, NULL);
g_object_set (cell, "style-set", TRUE, NULL);
*/
/*g_object_set (cell, "weight", PANGO_WEIGHT_BOLD, NULL);
g_object_set (cell, "weight-set", TRUE, NULL);*/
}
if(FI_GET_FLAG(fi, FI_LINK)) {
g_object_set (cell, "foreground", "blue", NULL);
g_object_set (cell, "foreground-set", TRUE, NULL);
g_object_set (cell, "underline", PANGO_UNDERLINE_SINGLE, NULL);
g_object_set (cell, "underline-set", TRUE, NULL);
}
}
#endif
GtkWidget *
main_tree_view_new(e_prefs *prefs, GtkWidget **tree_view_p)
{
@ -1625,11 +1669,18 @@ main_tree_view_new(e_prefs *prefs, GtkWidget **tree_view_p)
g_object_unref(G_OBJECT(store));
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree_view), FALSE);
renderer = gtk_cell_renderer_text_new();
g_object_set (renderer, "ypad", 0, NULL);
col_offset = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(tree_view),
-1, "Name", renderer,
"text", 0, NULL);
column = gtk_tree_view_get_column(GTK_TREE_VIEW(tree_view),
col_offset - 1);
gtk_tree_view_column_set_cell_data_func(column,
renderer,
tree_cell_renderer,
NULL,
NULL);
gtk_tree_view_column_set_sizing(GTK_TREE_VIEW_COLUMN(column),
GTK_TREE_VIEW_COLUMN_AUTOSIZE);
SIGNAL_CONNECT(tree_view, "row-expanded", expand_tree, NULL);
@ -1701,6 +1752,26 @@ main_proto_tree_draw(proto_tree *protocol_tree)
proto_tree_draw(protocol_tree, tree_view);
}
#if GTK_MAJOR_VERSION >= 2
void
tree_view_follow_link(GtkTreeSelection *sel)
{
GtkTreeModel *model;
GtkTreeIter iter;
field_info *fi;
if(gtk_tree_selection_get_selected (sel, &model, &iter)) {
gtk_tree_model_get(model, &iter, 1, &fi, -1);
if(FI_GET_FLAG(fi, FI_LINK)) {
g_assert(fi->hfinfo->type == FT_FRAMENUM);
goto_frame(&cfile, fi->value.value.integer);
}
}
}
#endif
/* If the user selected a position in the tree view, try to find
* the item in the GUI proto_tree that corresponds to that byte, and
* select it. */
@ -1739,6 +1810,11 @@ tree_view_select(GtkWidget *widget, GdkEventButton *event)
{
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
gtk_tree_selection_select_path(sel, path);
/* if that's a doubleclick, try to follow the link */
if(event->type == GDK_2BUTTON_PRESS) {
tree_view_follow_link(sel);
}
} else {
return FALSE;
}

View File

@ -1,7 +1,7 @@
/* packet-tcp.c
* Routines for TCP packet disassembly
*
* $Id: packet-tcp.c,v 1.232 2004/05/14 09:00:06 ulfl Exp $
* $Id: packet-tcp.c,v 1.233 2004/05/14 15:55:36 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -1159,6 +1159,7 @@ tcp_print_sequence_number_analysis(packet_info *pinfo, tvbuff_t *tvb, proto_tree
item = proto_tree_add_uint(tree, hf_tcp_analysis_acks_frame,
tvb, 0, 0, ta->frame_acked);
PROTO_ITEM_SET_GENERATED(item);
PROTO_ITEM_SET_LINK(item);
}
if( ta->ts.secs || ta->ts.nsecs ){
item = proto_tree_add_time(tree, hf_tcp_analysis_ack_rtt,