In the gtk2 port, make double click in the tree view expand or collapse
authoroabad <oabad@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 11 Nov 2002 18:46:16 +0000 (18:46 +0000)
committeroabad <oabad@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 11 Nov 2002 18:46:16 +0000 (18:46 +0000)
a row.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@6615 f5534014-38df-0310-8fa8-9805f1628bb7

gtk/STATUS.gtk2
gtk/menu.c

index 8bc40b417b425603e945721dc0d7ff9922a4f4e1..b780500eb5935384455d6e291b79677b014021fe 100644 (file)
@@ -66,6 +66,7 @@ Remaining problems :
 
 - double click on item in protocol tree doesn't expand or collapse its
   subtree ;
+  ==> Done
 
 - the spacing between lines in the tree view is too big ;
 
index 6ceeb21623ce23406c029cc415c56607c4fdd157..6072ef671bc083dd2d9c0dc3c45bfbc27e8b9350 100644 (file)
@@ -1,7 +1,7 @@
 /* menu.c
  * Menu routines
  *
- * $Id: menu.c,v 1.73 2002/11/11 15:39:05 oabad Exp $
+ * $Id: menu.c,v 1.74 2002/11/11 18:46:16 oabad Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -62,6 +62,7 @@
 #include "../packet-dcerpc.h"
 #include "dcerpc_stat.h"
 #include "compat_macros.h"
+#include "gtkglobals.h"
 
 GtkWidget *popup_menu_object;
 
@@ -555,47 +556,65 @@ set_menu_object_data (gchar *path, gchar *key, gpointer data) {
 gint
 popup_menu_handler(GtkWidget *widget, GdkEvent *event, gpointer data)
 {
-       GtkWidget *menu = NULL;
-       GdkEventButton *event_button = NULL;
-       GtkCList *packet_list = NULL;
-       gint row, column;
+    GtkWidget *menu = NULL;
+    GdkEventButton *event_button = NULL;
+    GtkCList *packet_list = NULL;
+    gint row, column;
 
-       if(widget == NULL || event == NULL || data == NULL) {
-               return FALSE;
-       }
+    if(widget == NULL || event == NULL || data == NULL) {
+        return FALSE;
+    }
 
-       /*
-        * If we ever want to make the menu differ based on what row
-        * and/or column we're above, we'd use "gtk_clist_get_selection_info()"
-        * to find the row and column number for the coordinates; a CTree is,
-        * I guess, like a CList with one column(?) and the expander widget
-        * as a pixmap.
-        */
-       /* Check if we are on packet_list object */
-       if (widget == OBJECT_GET_DATA(popup_menu_object, E_MPACKET_LIST_KEY)) {
-         packet_list=GTK_CLIST(widget);
-         if (gtk_clist_get_selection_info(GTK_CLIST(packet_list),
-             ((GdkEventButton *)event)->x,
-             ((GdkEventButton *)event)->y,&row,&column)) {
-           OBJECT_SET_DATA(popup_menu_object, E_MPACKET_LIST_ROW_KEY,
+    /*
+     * If we ever want to make the menu differ based on what row
+     * and/or column we're above, we'd use "gtk_clist_get_selection_info()"
+     * to find the row and column number for the coordinates; a CTree is,
+     * I guess, like a CList with one column(?) and the expander widget
+     * as a pixmap.
+     */
+    /* Check if we are on packet_list object */
+    if (widget == OBJECT_GET_DATA(popup_menu_object, E_MPACKET_LIST_KEY)) {
+        packet_list=GTK_CLIST(widget);
+        if (gtk_clist_get_selection_info(GTK_CLIST(packet_list),
+                                         ((GdkEventButton *)event)->x,
+                                         ((GdkEventButton *)event)->y,&row,&column)) {
+            OBJECT_SET_DATA(popup_menu_object, E_MPACKET_LIST_ROW_KEY,
                             GINT_TO_POINTER(row));
-           OBJECT_SET_DATA(popup_menu_object, E_MPACKET_LIST_COL_KEY,
+            OBJECT_SET_DATA(popup_menu_object, E_MPACKET_LIST_COL_KEY,
                             GINT_TO_POINTER(column));
-         }
-       }
-       menu = (GtkWidget *)data;
-       if(event->type == GDK_BUTTON_PRESS) {
-               event_button = (GdkEventButton *) event;
-
-               if(event_button->button == 3) {
-                       gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
-                                       event_button->button,
-                                       event_button->time);
-                       SIGNAL_EMIT_STOP_BY_NAME(widget, "button_press_event");
-                       return TRUE;
-               }
-       }
-       return FALSE;
+        }
+    }
+    menu = (GtkWidget *)data;
+    if(event->type == GDK_BUTTON_PRESS) {
+        event_button = (GdkEventButton *) event;
+
+        if(event_button->button == 3) {
+            gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
+                           event_button->button,
+                           event_button->time);
+            SIGNAL_EMIT_STOP_BY_NAME(widget, "button_press_event");
+            return TRUE;
+        }
+    }
+#if GTK_MAJOR_VERSION >= 2
+    if (widget == tree_view && event->type == GDK_2BUTTON_PRESS) {
+        GtkTreePath      *path;
+
+        if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget),
+                                          ((GdkEventButton *)event)->x,
+                                          ((GdkEventButton *)event)->y,
+                                          &path, NULL, NULL, NULL))
+        {
+            if (gtk_tree_view_row_expanded(GTK_TREE_VIEW(widget), path))
+                gtk_tree_view_collapse_row(GTK_TREE_VIEW(widget), path);
+            else
+                gtk_tree_view_expand_row(GTK_TREE_VIEW(widget), path,
+                                         FALSE);
+            gtk_tree_path_free(path);
+        }
+    }
+#endif
+    return FALSE;
 }
 
 /* Enable or disable menu items based on whether you have a capture file