summaryrefslogtreecommitdiff
path: root/gtk/dfilter_expr_dlg.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2003-08-25 00:15:02 +0000
committerGuy Harris <guy@alum.mit.edu>2003-08-25 00:15:02 +0000
commite4e0150ffacc90c811ba19293e65b33431bdafec (patch)
tree046726b5056ce40d792b79ace335dacd96fbc252 /gtk/dfilter_expr_dlg.c
parent6c1c67f70291d5a38efeb5dde891eb4e024b33c0 (diff)
downloadwireshark-e4e0150ffacc90c811ba19293e65b33431bdafec.tar.gz
From Matthijs Melchior:
support for registering fields after all the protocol registration routines are called (i.e., adding fields to the named field tree as they're registered); fix the GTK 2.x version of the field list dialog to show the correct name. svn path=/trunk/; revision=8248
Diffstat (limited to 'gtk/dfilter_expr_dlg.c')
-rw-r--r--gtk/dfilter_expr_dlg.c55
1 files changed, 31 insertions, 24 deletions
diff --git a/gtk/dfilter_expr_dlg.c b/gtk/dfilter_expr_dlg.c
index 0179c3e80e..a91c8c68e3 100644
--- a/gtk/dfilter_expr_dlg.c
+++ b/gtk/dfilter_expr_dlg.c
@@ -7,7 +7,7 @@
* Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com> and
* Guy Harris <guy@alum.mit.edu>
*
- * $Id: dfilter_expr_dlg.c,v 1.34 2003/07/25 03:44:04 gram Exp $
+ * $Id: dfilter_expr_dlg.c,v 1.35 2003/08/25 00:15:02 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -1287,33 +1287,18 @@ dfilter_expr_dlg_new(GtkWidget *filter_te)
hfinfo);
g_hash_table_insert(proto_array, (gpointer)i, protocol_node);
}
-#endif
len = proto_registrar_n();
for (i = 0; i < len; i++) {
-#if GTK_MAJOR_VERSION < 2
/*
* If this field is a protocol, skip it - we already put
* it in above.
*/
if (proto_registrar_is_protocol(i))
continue;
-#else
- GtkTreeIter child_iter;
-#endif
hfinfo = proto_registrar_get_nth(i);
-#if GTK_MAJOR_VERSION >= 2
- if (hfinfo->type == FT_PROTOCOL)
- {
- /* Create a node for the protocol */
- gtk_tree_store_append(store, &iter, NULL);
- gtk_tree_store_set(store, &iter, 0, hfinfo->abbrev, 1, hfinfo, -1);
- continue;
- }
-#endif
-
/*
* If this field isn't at the head of the list of
* fields with this name, skip this field - all
@@ -1331,7 +1316,6 @@ dfilter_expr_dlg_new(GtkWidget *filter_te)
/* Create a node for the item, and put it
under its parent protocol. */
-#if GTK_MAJOR_VERSION < 2
protocol_node = g_hash_table_lookup(proto_array,
GINT_TO_POINTER(proto_registrar_get_parent(i)));
item_node = gtk_ctree_insert_node(GTK_CTREE(tree),
@@ -1341,16 +1325,39 @@ dfilter_expr_dlg_new(GtkWidget *filter_te)
FALSE, FALSE);
gtk_ctree_node_set_row_data(GTK_CTREE(tree),
item_node, hfinfo);
-#else
- gtk_tree_store_append(store, &child_iter, &iter);
- gtk_tree_store_set(store, &child_iter, 0, hfinfo->name, 1, hfinfo, -1);
-#endif
}
-#if GTK_MAJOR_VERSION < 2
g_hash_table_destroy(proto_array);
-#else
+
+#else /* GTK_MAJOR_VERSION < 2 */
+{
+ /* GTK2 code using two levels iterator to enumerate all protocol fields */
+
+ GtkTreeIter iter, child_iter;
+ void *cookie, *cookie2;
+ gchar *name;
+
+ for (i = proto_get_first_protocol(&cookie); i != -1;
+ i = proto_get_next_protocol(&cookie)) {
+
+ hfinfo = proto_registrar_get_nth(i);
+ name = proto_get_protocol_short_name(i); /* name, short_name or filter name ? */
+
+ gtk_tree_store_append(store, &iter, NULL);
+ gtk_tree_store_set(store, &iter, 0, name, 1, hfinfo, -1);
+
+ for (hfinfo = proto_get_first_protocol_field(i, &cookie2); hfinfo != NULL;
+ hfinfo = proto_get_next_protocol_field(&cookie2)) {
+
+ if (hfinfo->same_name_prev != NULL) /* ignore duplicate names */
+ continue;
+
+ gtk_tree_store_append(store, &child_iter, &iter);
+ gtk_tree_store_set(store, &child_iter, 0, hfinfo->name, 1, hfinfo, -1);
+ }
+ }
g_object_unref(G_OBJECT(store));
-#endif
+}
+#endif /* GTK_MAJOR_VERSION < 2 */
gtk_widget_show_all(tree);