Ethereal-dev: Re: [Ethereal-dev] Cannot compile Ethereal from CVS with GTK2.0

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

From: Olivier Abad <oabad@xxxxxxx>
Date: Mon, 3 Nov 2003 20:50:37 +0100
On lun, nov 03, 2003 at 12:51:36 +0100, Peter Kjellerstedt wrote:
> This is mostly a "Me too" as the problem has already 
> been noted by Ulf Lamping in this mail:
> http://www.ethereal.com/lists/ethereal-dev/200310/msg00532.html
> So as it currently stands, it is not possible to build Ethereal 
> from CVS (nor would I suspect 0.9.16 to build) with GTK 2.0 
> (which is the latest one provide by Redhat for RH7.3).
> Anyone looking at a solution to this?

Can you try the following patch ? I don't have a gtk+ v2.0 system to
check if it works.

Olivier
-- 
Doing gets it done.
Index: gtk/proto_draw.c
===================================================================
RCS file: /usr/local/cvsroot/ethereal/gtk/proto_draw.c,v
retrieving revision 1.63
diff -u -r1.63 proto_draw.c
--- gtk/proto_draw.c	17 Oct 2003 17:20:32 -0000	1.63
+++ gtk/proto_draw.c	3 Nov 2003 19:47:47 -0000
@@ -61,6 +61,46 @@
 #define E_BYTE_VIEW_END_KEY       "byte_view_end"
 #define E_BYTE_VIEW_ENCODE_KEY    "byte_view_encode"
 
+/* gtk_tree_view_expand_to_path doesn't exist in gtk+ v2.0 so we must include it
+ * when building with this version (taken from gtk+ v2.2.4) */
+#if GTK_MAJOR_VERSION >= 2 && GTK_MINOR_VERSION == 0
+/**
+ * gtk_tree_view_expand_to_path:
+ * @tree_view: A #GtkTreeView.
+ * @path: path to a row.
+ *
+ * Expands the row at @path. This will also expand all parent rows of
+ * @path as necessary.
+ *
+ * Since: 2.2
+ **/
+void
+gtk_tree_view_expand_to_path (GtkTreeView *tree_view,
+                              GtkTreePath *path)
+{
+  gint i, depth;
+  gint *indices;
+  GtkTreePath *tmp;
+
+  g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));
+  g_return_if_fail (path != NULL);
+
+  depth = gtk_tree_path_get_depth (path);
+  indices = gtk_tree_path_get_indices (path);
+
+  tmp = gtk_tree_path_new ();
+  g_return_if_fail (tmp != NULL);
+
+  for (i = 0; i < depth; i++)
+    {
+      gtk_tree_path_append_index (tmp, indices[i]);
+      gtk_tree_view_expand_row (tree_view, tmp, FALSE);
+    }
+
+  gtk_tree_path_free (tmp);
+}
+#endif
+
 static GtkWidget *
 add_byte_tab(GtkWidget *byte_nb, const char *name, tvbuff_t *tvb,
     proto_tree *tree, GtkWidget *tree_view);
@@ -1389,6 +1429,7 @@
 
     g_node_children_foreach((GNode*) protocol_tree, G_TRAVERSE_ALL,
                             proto_tree_draw_node, &info);
+
 #if GTK_MAJOR_VERSION < 2
     gtk_clist_thaw(GTK_CLIST(tree_view));
 #endif
@@ -1409,6 +1450,7 @@
 #else
     GtkTreeStore *store;
     GtkTreeIter   iter;
+    GtkTreePath  *path;
 #endif
 
     if (!fi->visible)
@@ -1460,16 +1502,19 @@
 #endif
         g_node_children_foreach(node, G_TRAVERSE_ALL,
                                 proto_tree_draw_node, &info);
-    }
 #if GTK_MAJOR_VERSION >= 2
-    if (is_expanded == TRUE)
-    {
-        GtkTreePath *path;
         path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
-        gtk_tree_view_expand_to_path(info.tree_view, path);
+        if (is_expanded)
+/* #if GTK_MINOR_VERSION >= 2 */
+            gtk_tree_view_expand_to_path(info.tree_view, path);
+/*#else
+            gtk_tree_view_expand_row(info.tree_view, path, FALSE);
+#endif*/
+        else
+            gtk_tree_view_collapse_row(info.tree_view, path);
         gtk_tree_path_free(path);
-    }
 #endif
+    }
 }
 
 /*