Ethereal-dev: [Ethereal-dev] Patch: Hiding disabled protocols

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Stas Grabois <sagig@xxxxxxxxxxx>
Date: Thu, 10 Jun 2004 07:22:32 +0200

A patch to hide disabled protocols in "Filter" and "Decode" dialogs.


diff -Nru --exclude-from=exclude ethereal-0.10.4/gtk/decode_as_dlg.c ethereal-0.10.4.dp/gtk/decode_as_dlg.c --- ethereal-0.10.4/gtk/decode_as_dlg.c 2004-03-18 06:05:34.000000000 +0200 +++ ethereal-0.10.4.dp/gtk/decode_as_dlg.c 2004-06-08 10:00:33.000000000 +0300
@@ -1076,6 +1076,7 @@
   GtkTreeIter   iter;
   struct handle_lookup_info hli;
#endif
+    gint i;

   g_assert(user_data);
   g_assert(value);
@@ -1084,6 +1085,12 @@
   handle = value;
   proto_name = dissector_handle_get_short_name(handle);

+    i = dissector_handle_get_protocol_index(handle);
+
+    if (i >= 0 && !proto_is_protocol_enabled(find_protocol_by_id(i))) {
+        return;
+    }
+ #if GTK_MAJOR_VERSION < 2
   row = gtk_clist_find_row_from_data(list, handle);
   /* We already have an entry for this handle.
diff -Nru --exclude-from=exclude ethereal-0.10.4/gtk/dfilter_expr_dlg.c ethereal-0.10.4.dp/gtk/dfilter_expr_dlg.c --- ethereal-0.10.4/gtk/dfilter_expr_dlg.c 2004-03-18 06:05:34.000000000 +0200 +++ ethereal-0.10.4.dp/gtk/dfilter_expr_dlg.c 2004-06-08 10:00:11.000000000 +0300
@@ -1304,10 +1304,16 @@
   proto_array = g_hash_table_new(g_direct_hash, g_direct_equal);
   for (i = proto_get_first_protocol(&cookie); i != -1;
        i = proto_get_next_protocol(&cookie)) {
+ hfinfo = proto_registrar_get_nth(i);
       /* Create a node for the protocol, and remember it for
          later use. */
       protocol = find_protocol_by_id(i);
+
+        if (!proto_is_protocol_enabled(protocol)) {
+            continue;
+        }
+ name = proto_get_protocol_short_name(protocol); /* name, short_name or filter name ? */
       protocol_node = gtk_ctree_insert_node(GTK_CTREE(field_tree),
                                             NULL, NULL,
@@ -1347,6 +1353,11 @@
       if (hfinfo->same_name_prev != NULL)
           continue;

+        if (!proto_is_protocol_enabled(find_protocol_by_id(
+                        proto_registrar_get_parent(i)))) {
+            continue;
+        }
+ /* Create a node for the item, and put it
          under its parent protocol. */
       protocol_node = g_hash_table_lookup(proto_array,