ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
July 17th, 2024 | 10:00am-11:55am SGT (UTC+8) | Online

Ethereal-dev: Re: [Ethereal-dev] Packet list columns are not resizeable with GTK+2.x

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: Sat, 20 Sep 2003 11:01:38 +0200
Le jeu 18/09/2003 à 21:56, Guy Harris a écrit :
> Was it compensating for a bug or a misfeature in the GtkClist code in 
> older versions of GTK+ 2.x?  (I'm primarily asking Olivier that 
> question - it was in there since the GTK+ 1.2[.x] and 2.x code was 
> merged in, and it might have been there since the 2.x code was first 
> put in.)

I don't remember exactly why I did it for the GTK2 port, but it isn't
necessary anymore (see below).

However, the right patch for the column resize problem should be to
check if the GdkWindow associated with the event is the one used to draw
the GtkCList (and not the colum titles), i.e. :

event_button->window == GTK_CLIST(w)->clist_window

My only problem is that it doesn't work on my Debian sid system (which
uses gtk+ v2.2.4), because GTK_CLIST(w)->clist_window has a bad value
(0x3ee) so the test always fails. BTW, with this failing test, selecting
packets works which proves we can remove the "else if
(event_button->button == 1)" statement. However, marking packets doesn't
work anymore.

If we just remove the "else if (event_button->button == 1)" statement
(and don't add the GdkWindow test), resizing columns and marking packets
work, but you can also (un)mark the first packet with a middle mouse
button click on the column resize handles !

I tried to build gtkclist.c (from gtk+ 2.2.4) in ethereal to be able to
debug the bad pointer value in GTK_CLIST(w)->clist_window, but it worked
fine !

Can someone who doesn't use Debian unstable try the patch ? I'd like to
see if it is Debian specific. I'm attaching it (with a printf which
displays event_button->window and GTK_CLIST(w)->clist_window).

Olivier

P.S. : the event_button->window == GTK_CLIST(w)->clist_window test was
in the gtk2 code but I removed it a few times ago when someone reported
that marking packets didn't work in GTK2. I should have tried resizing
columns...
-- 
Always try to do things in chronological order; it's less confusing that
way.
Index: gtk/main.c
===================================================================
RCS file: /usr/local/cvsroot/ethereal/gtk/main.c,v
retrieving revision 1.315
diff -u -r1.315 main.c
--- gtk/main.c	15 Sep 2003 23:20:34 -0000	1.315
+++ gtk/main.c	20 Sep 2003 08:36:51 -0000
@@ -784,17 +784,16 @@
     if (w == NULL || event == NULL)
         return FALSE;
 
+    printf("event_button->window : 0x%x, packet_list->clist_window : 0x%x\n",
+            event_button->window, GTK_CLIST(w)->clist_window);
     if (event->type == GDK_BUTTON_PRESS &&
+        event_button->window == GTK_CLIST(w)->clist_window &&
         gtk_clist_get_selection_info(GTK_CLIST(w), event_button->x,
                                      event_button->y, &row, &column)) {
         if (event_button->button == 2)
         {
             frame_data *fdata = (frame_data *)gtk_clist_get_row_data(GTK_CLIST(w), row);
             set_frame_mark(!fdata->flags.marked, fdata, row);
-            return TRUE;
-        }
-        else if (event_button->button == 1) {
-            gtk_clist_select_row(GTK_CLIST(w), row, column);
             return TRUE;
         }
     }