Enable "Match Selected" only if there's a field selected *and* we can do
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 5 Jun 2001 07:39:31 +0000 (07:39 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 5 Jun 2001 07:39:31 +0000 (07:39 +0000)
a "Match Selected" on it - we can't do a "Match Selected" if the field
has no value (e.g., FT_NULL) and has a length of 0.

If we unselect the current packet, we don't have a protocol tree, so we
don't have a currently selected field - clear the "Match Selected" menu
item and the display in the status line of information about the
currently selected field.

Move the low-level statusbar manipulation into "gtk/main.c", in routines
whose API doesn't expose anything GTK+-ish.

"close_cap_file()" calls one of those routines to clear out the status
bar, so it doesn't need to take a pointer to the statusbar widget as an
argument.

"clear_tree_and_hex_views()" is purely a display-manipulating routine;
move it to "gtk/proto_draw.c".

Extract from "tree_view_unselect_row_cb()" an "unselect_field()" routine
to do all the work that needs to be done if the currently selected
protocol tree row is unselected, and call it if the currently selected
packet list row is unselected (if it's unselected, there *is* no
protocol tree, so no row can be selected), as well as from
"tree_view_unselect_row_cb()".

Before pushing a new field-description message onto the statusbar, pop
the old one off.

Get rid of an unused variable (set, but not used).

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

16 files changed:
Makefile.am
capture.c
epan/proto.c
epan/proto.h
file.c
file.h
globals.h
gtk/file_dlg.c
gtk/gtkglobals.h
gtk/main.c
gtk/menu.c
gtk/proto_draw.c
gtk/proto_draw.h
menu.h
statusbar.h [new file with mode: 0644]
tethereal.c

index 56d3dcc217039689a6c62d21558ce7bf94c25fd9..f2b3de054f3bdb66525b7f8a472f2966f0cfae06 100644 (file)
@@ -1,7 +1,7 @@
 # Makefile.am
 # Automake file for Ethereal
 #
-# $Id: Makefile.am,v 1.330 2001/06/02 06:21:12 guy Exp $
+# $Id: Makefile.am,v 1.331 2001/06/05 07:39:31 guy Exp $
 #
 # Ethereal - Network traffic analyzer
 # By Gerald Combs <gerald@ethereal.com>
@@ -400,6 +400,7 @@ ethereal_SOURCES = \
        proto_hier_stats.h      \
        proto_hier_stats.c      \
        simple_dialog.h \
+       statusbar.h    \
        summary.c      \
        summary.h      \
        ui_util.h
index 0e2768d93cadb2cb636d665d783c60b56b119875..9453fbbc575126d7310779925336dd936fab5373 100644 (file)
--- a/capture.c
+++ b/capture.c
@@ -1,7 +1,7 @@
 /* capture.c
  * Routines for packet capture windows
  *
- * $Id: capture.c,v 1.150 2001/06/02 06:26:52 guy Exp $
+ * $Id: capture.c,v 1.151 2001/06/05 07:38:33 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -299,7 +299,7 @@ do_capture(char *capfile_name)
     }
     return;
   }
-  close_cap_file(&cfile, info_bar);
+  close_cap_file(&cfile);
   g_assert(cfile.save_file == NULL);
   cfile.save_file = capfile_name;
 
index 2c6915d6bc04c94cef260345cf25e0c42207c712..f6d5f1464ca5c6d4a3c63dc2672d5519c9f5f0ed 100644 (file)
@@ -1,12 +1,11 @@
 /* proto.c
  * Routines for protocol tree
  *
- * $Id: proto.c,v 1.28 2001/05/31 07:15:23 guy Exp $
+ * $Id: proto.c,v 1.29 2001/06/05 07:38:35 guy Exp $
  *
  * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
  * Copyright 1998 Gerald Combs
- *
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -2832,6 +2831,54 @@ hfinfo_numeric_format(header_field_info *hfinfo)
        return format;
 }
 
+/*
+ * Returns TRUE if we can do a "match selected" on the field, FALSE
+ * otherwise.
+ */
+gboolean
+proto_can_match_selected(field_info *finfo)
+{
+       header_field_info       *hfinfo;
+
+       hfinfo = finfo->hfinfo;
+       g_assert(hfinfo);
+
+       switch(hfinfo->type) {
+
+               case FT_BOOLEAN:
+               case FT_UINT8:
+               case FT_UINT16:
+               case FT_UINT24:
+               case FT_UINT32:
+               case FT_INT8:
+               case FT_INT16:
+               case FT_INT24:
+               case FT_INT32:
+               case FT_IPv4:
+               case FT_IPXNET:
+               case FT_IPv6:
+               case FT_DOUBLE:
+               case FT_ETHER:
+               case FT_ABSOLUTE_TIME:
+               case FT_RELATIVE_TIME:
+               case FT_STRING:
+               case FT_BYTES:
+                       /*
+                        * These all have values, so we can match.
+                        */
+                       return TRUE;
+
+               default:
+                       /*
+                        * This doesn't have a value, so we'd match
+                        * on the raw bytes at this address;
+                        * however, if the length is 0, there's nothing
+                        * to match, so we can't match.
+                        */
+                       return (finfo->length != 0);
+       }
+}
+
 char*
 proto_alloc_dfilter_string(field_info *finfo, guint8 *pd)
 {
index 5bf1b2c5d9c4a01c4f98304355ca016863b6ff26..e3be5efb61aeb6d85ce9d658fa1c74521a90b781 100644 (file)
@@ -1,12 +1,11 @@
 /* proto.h
  * Definitions for protocol display
  *
- * $Id: proto.h,v 1.11 2001/04/02 00:38:34 hagbard Exp $
+ * $Id: proto.h,v 1.12 2001/06/05 07:38:35 guy Exp $
  *
  * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
  * Copyright 1998 Gerald Combs
- *
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -559,6 +558,13 @@ extern int           num_tree_types;
 int
 hfinfo_bitwidth(header_field_info *hfinfo);
 
+/*
+ * Returns TRUE if we can do a "match selected" on the field, FALSE
+ * otherwise.
+ */
+gboolean
+proto_can_match_selected(field_info *finfo);
+
 char*
 proto_alloc_dfilter_string(field_info *finfo, guint8 *pd);
 
diff --git a/file.c b/file.c
index 9e506d8d5ee60b1bc35aaadef33b5202fe5c7ec1..83397b236fd2446ca85572903891fef25ca923d9 100644 (file)
--- a/file.c
+++ b/file.c
@@ -1,12 +1,11 @@
 /* file.c
  * File I/O routines
  *
- * $Id: file.c,v 1.237 2001/05/27 21:33:16 guy Exp $
+ * $Id: file.c,v 1.238 2001/06/05 07:38:33 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
  * Copyright 1998 Gerald Combs
- *
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -83,6 +82,7 @@
 #include "simple_dialog.h"
 #include "progress_dlg.h"
 #include "ui_util.h"
+#include "statusbar.h"
 #include "prefs.h"
 #include "gtk/proto_draw.h"
 #include "gtk/packet_win.h"
@@ -91,8 +91,7 @@
 #include "globals.h"
 #include "gtk/colors.h"
 
-extern GtkWidget *packet_list, *info_bar, *byte_nb_ptr, *tree_view;
-extern guint      file_ctx;
+extern GtkWidget *packet_list, *byte_nb_ptr, *tree_view;
 
 static guint32 firstsec, firstusec;
 static guint32 prevsec, prevusec;
@@ -142,7 +141,7 @@ open_cap_file(char *fname, gboolean is_tempfile, capture_file *cf)
 
   /* The open succeeded.  Close whatever capture file we had open,
      and fill in the information for this file. */
-  close_cap_file(cf, info_bar);
+  close_cap_file(cf);
 
   /* Initialize the table of conversations. */
   epan_conversation_init();
@@ -196,7 +195,7 @@ fail:
 
 /* Reset everything to a pristine state */
 void
-close_cap_file(capture_file *cf, void *w)
+close_cap_file(capture_file *cf)
 {
   /* Die if we're in the middle of reading a file. */
   g_assert(cf->state != FILE_READ_IN_PROGRESS);
@@ -242,7 +241,7 @@ close_cap_file(capture_file *cf, void *w)
   /* Clear any file-related status bar messages.
      XXX - should be "clear *ALL* file-related status bar messages;
      will there ever be more than one on the stack? */
-  gtk_statusbar_pop(GTK_STATUSBAR(w), file_ctx);
+  statusbar_pop_file_msg();
 
   /* Restore the standard title bar message. */
   set_main_window_name("The Ethereal Network Analyzer");
@@ -291,7 +290,7 @@ set_display_filename(capture_file *cf)
     done_msg = g_malloc(msg_len);
     snprintf(done_msg, msg_len, done_fmt_nodrops, name_ptr);
   }
-  gtk_statusbar_push(GTK_STATUSBAR(info_bar), file_ctx, done_msg);
+  statusbar_push_file_msg(done_msg);
   g_free(done_msg);
 
   msg_len = strlen(name_ptr) + strlen(win_name_fmt) + 1;
@@ -320,7 +319,7 @@ read_cap_file(capture_file *cf, int *err)
   msg_len = strlen(name_ptr) + strlen(load_fmt) + 2;
   load_msg = g_malloc(msg_len);
   snprintf(load_msg, msg_len, load_fmt, name_ptr);
-  gtk_statusbar_push(GTK_STATUSBAR(info_bar), file_ctx, load_msg);
+  statusbar_push_file_msg(load_msg);
 
   /* Update the progress bar when it gets to this value. */
   cf->progbar_nextstep = 0;
@@ -358,7 +357,7 @@ read_cap_file(capture_file *cf, int *err)
       destroy_progress_dlg(progbar);
       cf->state = FILE_READ_ABORTED;   /* so that we're allowed to close it */
       gtk_clist_thaw(GTK_CLIST(packet_list));  /* undo our freeze */
-      close_cap_file(cf, info_bar);
+      close_cap_file(cf);
       return (READ_ABORTED);
     }
     read_packet(cf, data_offset);
@@ -382,7 +381,7 @@ read_cap_file(capture_file *cf, int *err)
   cf->current_frame = cf->first_displayed;
   thaw_clist(cf);
 
-  gtk_statusbar_pop(GTK_STATUSBAR(info_bar), file_ctx);
+  statusbar_pop_file_msg();
   set_display_filename(cf);
 
   /* Enable menu items that make sense if you have a capture file you've
@@ -464,8 +463,7 @@ start_tail_cap_file(char *fname, gboolean is_tempfile, capture_file *cf)
       }
     }
 
-    gtk_statusbar_push(GTK_STATUSBAR(info_bar), file_ctx, 
-                      " <live capture in progress>");
+    statusbar_push_file_msg(" <live capture in progress>");
   }
   return err;
 }
@@ -534,7 +532,7 @@ finish_tail_cap_file(capture_file *cf, int *err)
        it's probably exited), so we can just close the capture
        file; we return READ_ABORTED so our caller can do whatever
        is appropriate when that happens. */
-    close_cap_file(cf, info_bar);
+    close_cap_file(cf);
     return READ_ABORTED;
   }
 
@@ -559,7 +557,7 @@ finish_tail_cap_file(capture_file *cf, int *err)
   cf->lnk_t = wtap_file_encap(cf->wth);
 
   /* Pop the "<live capture in progress>" message off the status bar. */
-  gtk_statusbar_pop(GTK_STATUSBAR(info_bar), file_ctx);
+  statusbar_pop_file_msg();
 
   set_display_filename(cf);
 
@@ -1368,34 +1366,6 @@ change_time_formats(capture_file *cf)
   thaw_clist(cf);
 }
 
-static void
-clear_tree_and_hex_views(void)
-{
-  /* Clear the hex dump. */
-
-  GtkWidget *byte_view;
-  int i;
-
-/* Get the current tab scroll window, then get the text widget  */
-/* from the E_BYTE_VIEW_TEXT_INFO_KEY data field               */
-
-  i = gtk_notebook_get_current_page( GTK_NOTEBOOK(byte_nb_ptr));
-
-  if ( i >= 0){
-    byte_view = gtk_notebook_get_nth_page( GTK_NOTEBOOK(byte_nb_ptr), i);
-    byte_view = gtk_object_get_data(GTK_OBJECT(byte_view), E_BYTE_VIEW_TEXT_INFO_KEY);
-
-    gtk_text_freeze(GTK_TEXT(byte_view));
-    gtk_text_set_point(GTK_TEXT(byte_view), 0);
-    gtk_text_forward_delete(GTK_TEXT(byte_view),
-      gtk_text_get_length(GTK_TEXT(byte_view)));
-    gtk_text_thaw(GTK_TEXT(byte_view));
-  }
-  /* Remove all nodes in ctree. This is how it's done in testgtk.c in GTK+ */
-  gtk_clist_clear ( GTK_CLIST(tree_view) );
-
-}
-
 gboolean
 find_packet(capture_file *cf, dfilter_t *sfcode)
 {
@@ -1624,13 +1594,14 @@ unselect_packet(capture_file *cf)
     cf->edt = NULL;
   }
 
-  finfo_selected = NULL;
-
   /* Clear out the display of that packet. */
   clear_tree_and_hex_views();
 
   /* No packet is selected. */
   set_menus_for_selected_packet(FALSE);
+
+  /* No protocol tree means no selected field. */
+  unselect_field();
 }
 
 /* Set the selected row and the focus row of the packet list to the specified
@@ -1654,6 +1625,15 @@ set_selected_row(int row)
   gtk_clist_select_row(GTK_CLIST(packet_list), row, -1);
 }
 
+/* Unset the selected protocol tree field, if any. */
+void
+unselect_field(void)
+{
+  statusbar_pop_field_msg();
+  finfo_selected = NULL;
+  set_menus_for_selected_tree_row(FALSE);
+}
+
 static void
 freeze_clist(capture_file *cf)
 {
@@ -1711,7 +1691,7 @@ save_cap_file(char *fname, capture_file *cf, gboolean save_filtered, gboolean sa
   msg_len = strlen(name_ptr) + strlen(save_fmt) + 2;
   save_msg = g_malloc(msg_len);
   snprintf(save_msg, msg_len, save_fmt, name_ptr);
-  gtk_statusbar_push(GTK_STATUSBAR(info_bar), file_ctx, save_msg);
+  statusbar_push_file_msg(save_msg);
   g_free(save_msg);
 
   if (!save_filtered && !save_marked && save_format == cf->cd_t) {
@@ -1823,7 +1803,7 @@ save_cap_file(char *fname, capture_file *cf, gboolean save_filtered, gboolean sa
 done:
 
   /* Pop the "Saving:" message off the status bar. */
-  gtk_statusbar_pop(GTK_STATUSBAR(info_bar), file_ctx);
+  statusbar_pop_file_msg();
   if (err == 0) {
     if (!save_filtered && !save_marked) {
       /* We saved the entire capture, not just some packets from it.
diff --git a/file.h b/file.h
index 3429dfae836c005a7f2722cd77a21b02b95669a2..ea3e1bd0f1a9788dca5eed009792f109055eddcf 100644 (file)
--- a/file.h
+++ b/file.h
@@ -1,12 +1,11 @@
 /* file.h
  * Definitions for file structures and routines
  *
- * $Id: file.h,v 1.82 2001/04/18 05:45:57 guy Exp $
+ * $Id: file.h,v 1.83 2001/06/05 07:38:33 guy Exp $
  *
  * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
  * Copyright 1998 Gerald Combs
- *
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -111,7 +110,7 @@ typedef enum {
 } read_status_t;
 
 int  open_cap_file(char *, gboolean, capture_file *);
-void close_cap_file(capture_file *, void *);
+void close_cap_file(capture_file *);
 read_status_t read_cap_file(capture_file *, int *);
 int  start_tail_cap_file(char *, gboolean, capture_file *);
 read_status_t continue_tail_cap_file(capture_file *, int, int *);
@@ -136,6 +135,8 @@ goto_result_t goto_frame(capture_file *cf, guint fnumber);
 void select_packet(capture_file *, int);
 void unselect_packet(capture_file *);
 
+void unselect_field(void);
+
 /* Moves or copies a file. Returns 0 on failure, 1 on success */
 int file_mv(char *from, char *to);
 
index b9fd5be6559c23d006775872d6fb22a98549e014..5bb3dd4ba94a74692279b2a1ee90db81ab84e841 100644 (file)
--- a/globals.h
+++ b/globals.h
@@ -1,12 +1,11 @@
 /* globals.h
  * Global defines, etc.
  *
- * $Id: globals.h,v 1.25 2001/05/01 00:18:46 guy Exp $
+ * $Id: globals.h,v 1.26 2001/06/05 07:38:33 guy Exp $
  *
  * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
  * Copyright 1998 Gerald Combs
- *
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -33,7 +32,6 @@
 #define MIN_PACKET_SIZE 68     /* minimum amount of packet data we can read */
 
 extern capture_file cfile;
-extern guint        main_ctx, file_ctx;
 extern gchar       *ethereal_path;
 extern gchar       *last_open_dir;
 extern field_info  *finfo_selected;
index d2d3906480a5c95490f1131fe57f9059b80538ec..8f89941b0a493bb5c32203d5c513b54a70fdabb9 100644 (file)
@@ -1,12 +1,11 @@
 /* file_dlg.c
  * Dialog boxes for handling files
  *
- * $Id: file_dlg.c,v 1.39 2001/05/31 08:36:46 guy Exp $
+ * $Id: file_dlg.c,v 1.40 2001/06/05 07:38:37 guy Exp $
  *
  * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
  * Copyright 1998 Gerald Combs
- *
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -282,7 +281,7 @@ file_open_destroy_cb(GtkWidget *win, gpointer user_data)
 /* Close a file */
 void
 file_close_cmd_cb(GtkWidget *widget, gpointer data) {
-  close_cap_file(&cfile, info_bar);
+  close_cap_file(&cfile);
 }
 
 void
index f9d4bed5fae5ac75e9bbe1320dd4438cca644121..947be5e19bcb666a8eaea033d7e9042054fbb0ce 100644 (file)
@@ -1,12 +1,11 @@
 /* gtkglobals.h
  * GTK-related Global defines, etc.
  *
- * $Id: gtkglobals.h,v 1.15 2001/04/25 06:33:41 guy Exp $
+ * $Id: gtkglobals.h,v 1.16 2001/06/05 07:38:37 guy Exp $
  *
  * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
  * Copyright 1998 Gerald Combs
- *
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -30,8 +29,7 @@
 #include <gtk/gtk.h>
 #endif
 
-extern GtkWidget   *top_level, *packet_list, *tree_view,
-            *byte_nb_ptr, *info_bar;
+extern GtkWidget   *top_level, *packet_list, *tree_view, *byte_nb_ptr;
 extern GdkFont     *m_r_font, *m_b_font;
 extern guint m_font_height, m_font_width;
 
index 774ad399bb5453a6fdd680ecaa6afa3a03997021..230f4b441fcdca8ceba4386a46f2264636a21861 100644 (file)
@@ -1,6 +1,6 @@
 /* main.c
  *
- * $Id: main.c,v 1.199 2001/05/31 08:36:46 guy Exp $
+ * $Id: main.c,v 1.200 2001/06/05 07:38:37 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
 #include "print.h"
 #include "resolv.h"
 #include "util.h"
+#include "statusbar.h"
 #include "simple_dialog.h"
 #include "proto_draw.h"
 #include "dfilter/dfilter.h"
 packet_info  pi;
 capture_file cfile;
 GtkWidget   *top_level, *packet_list, *tree_view, *byte_nb_ptr,
-            *info_bar, *tv_scrollw, *pkt_scrollw;
-static GtkWidget       *bv_scrollw;
+            *tv_scrollw, *pkt_scrollw;
+static GtkWidget       *info_bar, *bv_scrollw;
 GdkFont     *m_r_font, *m_b_font;
 guint          m_font_height, m_font_width;
-guint        main_ctx, file_ctx, help_ctx;
+static guint    main_ctx, file_ctx, help_ctx;
 static GString *comp_info_str;
 gchar       *ethereal_path = NULL;
 gchar       *last_open_dir = NULL;
@@ -211,14 +212,6 @@ match_selected_cb(GtkWidget *w, gpointer data)
 
     filter_te = gtk_object_get_data(GTK_OBJECT(w), E_DFILTER_TE_KEY);
 
-    if (!finfo_selected) {
-       simple_dialog(ESD_TYPE_CRIT, NULL,
-                     "Error determining selected bytes.  Please make\n"
-                     "sure you have selected a field within the tree\n"
-                     "view to be matched.");
-       return;
-    }
-
     buf = proto_alloc_dfilter_string(finfo_selected, cfile.pd);
 
     /* create a new one and set the display filter entry accordingly */
@@ -463,7 +456,6 @@ tree_view_select_row_cb(GtkCTree *ctree, GList *node, gint column, gpointer user
        g_assert(byte_data);
 
        finfo_selected = finfo;
-
        set_menus_for_selected_tree_row(TRUE);
 
        if (finfo->hfinfo) {
@@ -474,13 +466,14 @@ tree_view_select_row_cb(GtkCTree *ctree, GList *node, gint column, gpointer user
          } else {
            length = strlen(finfo->hfinfo->name);
          }
+         statusbar_pop_field_msg();    /* get rid of current help msg */
           if (length) {
            length += strlen(finfo->hfinfo->abbrev) + 10;
            help_str = g_malloc(sizeof(gchar) * length);
            sprintf(help_str, "%s (%s)", 
               (has_blurb) ? finfo->hfinfo->blurb : finfo->hfinfo->name,
               finfo->hfinfo->abbrev);
-           gtk_statusbar_push(GTK_STATUSBAR(info_bar), help_ctx, help_str);
+           statusbar_push_field_msg(help_str);
            g_free(help_str);
           } else {
             /*
@@ -489,6 +482,9 @@ tree_view_select_row_cb(GtkCTree *ctree, GList *node, gint column, gpointer user
             * a field, and we don't want "Text (text)" showing up
             * on the status line if you've selected such a field.
             *
+            * XXX - there are zero-length fields for which we *do*
+            * want to show the field name.
+            *
             * XXX - perhaps the name and abbrev field should be null
             * pointers rather than null strings for that pseudo-field,
             * but we'd have to add checks for null pointers in some
@@ -499,7 +495,7 @@ tree_view_select_row_cb(GtkCTree *ctree, GList *node, gint column, gpointer user
             * with no pseudo-field being used, but that might also
             * require special checks for -1 to be added.
             */
-           gtk_statusbar_push(GTK_STATUSBAR(info_bar), help_ctx, "");
+           statusbar_push_field_msg("");
           }
        }
 
@@ -513,16 +509,16 @@ tree_view_unselect_row_cb(GtkCTree *ctree, GList *node, gint column, gpointer us
        GtkWidget       *byte_view;
        guint8  *data;
        gint    len;    
-       field_info* fi;
-
-       fi = (field_info*)user_data;
 
+       /*
+        * Which byte view is displaying the current protocol tree
+        * row's data?
+        */
        len = get_byte_view_and_data( byte_nb_ptr, &byte_view, &data);
+       if ( len < 0)
+               return; /* none */
 
-       if ( len < 0) return;
-       gtk_statusbar_pop(GTK_STATUSBAR(info_bar), help_ctx);
-       finfo_selected = NULL;
-       set_menus_for_selected_tree_row(FALSE);
+       unselect_field();
        packet_hex_print(GTK_TEXT(byte_view), data, cfile.current_frame,
                NULL, len);
 }
@@ -663,6 +659,46 @@ set_plist_font(GdkFont *font)
        }
 }
 
+/*
+ * Push a message referring to file access onto the statusbar.
+ */
+void
+statusbar_push_file_msg(gchar *msg)
+{
+       gtk_statusbar_push(GTK_STATUSBAR(info_bar), file_ctx, msg);
+}
+
+/*
+ * Pop a message referring to file access off the statusbar.
+ */
+void
+statusbar_pop_file_msg(void)
+{
+       gtk_statusbar_pop(GTK_STATUSBAR(info_bar), file_ctx);
+}
+
+/*
+ * XXX - do we need multiple statusbar contexts?
+ */
+
+/*
+ * Push a message referring to the currently-selected field onto the statusbar.
+ */
+void
+statusbar_push_field_msg(gchar *msg)
+{
+       gtk_statusbar_push(GTK_STATUSBAR(info_bar), help_ctx, msg);
+}
+
+/*
+ * Pop a message referring to the currently-selected field off the statusbar.
+ */
+void
+statusbar_pop_field_msg(void)
+{
+       gtk_statusbar_pop(GTK_STATUSBAR(info_bar), help_ctx);
+}
+
 static gboolean
 main_window_delete_event_cb(GtkWidget *widget, GdkEvent *event, gpointer data)
 {
@@ -716,7 +752,7 @@ file_quit_cmd_cb (GtkWidget *widget, gpointer data)
                   which we'd call here, and another routine that
                   calls that routine and also cleans up the UI, which
                   we'd call elsewhere? */
-               close_cap_file(&cfile, info_bar);
+               close_cap_file(&cfile);
 
                /* Exit by leaving the main loop, so that any quit functions
                   we registered get called. */
index 183a84496c9daadada0de9aba0f68a1b005464d8..793abf184eacfc8d299f9dd157d8c45606e3ce2e 100644 (file)
@@ -1,12 +1,11 @@
 /* menu.c
  * Menu routines
  *
- * $Id: menu.c,v 1.52 2001/04/15 03:37:16 guy Exp $
+ * $Id: menu.c,v 1.53 2001/06/05 07:38:37 guy Exp $
  *
  * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
  * Copyright 1998 Gerald Combs
- *
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -378,7 +377,6 @@ set_menus_for_captured_packets(gboolean have_captured_packets)
   set_menu_sensitivity("/File/Print...", have_captured_packets);
   set_menu_sensitivity("/Edit/Find Frame...", have_captured_packets);
   set_menu_sensitivity("/Edit/Go To Frame...", have_captured_packets);
-  set_menu_sensitivity("/Display/Match Selected", have_captured_packets);
   set_menu_sensitivity("/Display/Colorize Display...", have_captured_packets);
   set_menu_sensitivity("/Tools/Summary", have_captured_packets);
   set_menu_sensitivity("/Tools/Protocol Hierarchy Statistics", have_captured_packets);
@@ -403,11 +401,13 @@ set_menus_for_selected_packet(gboolean have_selected_packet)
       have_selected_packet && !prefs.name_resolve);  
 }
 
-/* Enable or disable menu items based on whether a tree row is selected. */
+/* Enable or disable menu items based on whether a tree row is selected
+   and and on whether a "Match Selected" can be done. */
 void
 set_menus_for_selected_tree_row(gboolean have_selected_tree)
 {
   gboolean properties = FALSE;
+
   if (finfo_selected) {
        header_field_info *hfinfo = finfo_selected->hfinfo;
        if (hfinfo->parent == -1) {
@@ -415,6 +415,10 @@ set_menus_for_selected_tree_row(gboolean have_selected_tree)
        } else {
          properties = prefs_is_registered_protocol(proto_registrar_get_abbrev(hfinfo->parent));
        }
-  }
+       set_menu_sensitivity("/Display/Match Selected",
+         proto_can_match_selected(finfo_selected));
+  } else
+       set_menu_sensitivity("/Display/Match Selected", FALSE);
+
   set_menu_sensitivity("/Protocol Properties...", have_selected_tree && properties);
 }
index d5637dbeb06dcc9e053b74083adcbd9e316d4481..5c153d6b8829352e0369cba90610c386ce6330de 100644 (file)
@@ -1,10 +1,10 @@
 /* proto_draw.c
  * Routines for GTK+ packet display
  *
- * $Id: proto_draw.c,v 1.34 2001/05/27 07:50:28 guy Exp $
+ * $Id: proto_draw.c,v 1.35 2001/06/05 07:38:37 guy Exp $
  *
  * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
  * Copyright 1998 Gerald Combs
  *
  * Jeff Foster,    2001/03/12,  added support for displaying named
@@ -937,3 +937,34 @@ proto_tree_draw_node(GNode *node, gpointer data)
                        proto_tree_draw_node, &info);
        }
 }
+
+/*
+ * Clear the hex dump and protocol tree panes.
+ */
+void
+clear_tree_and_hex_views(void)
+{
+  /* Clear the hex dump. */
+
+  GtkWidget *byte_view;
+  int i;
+
+/* Get the current tab scroll window, then get the text widget  */
+/* from the E_BYTE_VIEW_TEXT_INFO_KEY data field               */
+
+  i = gtk_notebook_get_current_page( GTK_NOTEBOOK(byte_nb_ptr));
+
+  if ( i >= 0){
+    byte_view = gtk_notebook_get_nth_page( GTK_NOTEBOOK(byte_nb_ptr), i);
+    byte_view = gtk_object_get_data(GTK_OBJECT(byte_view), E_BYTE_VIEW_TEXT_INFO_KEY);
+
+    gtk_text_freeze(GTK_TEXT(byte_view));
+    gtk_text_set_point(GTK_TEXT(byte_view), 0);
+    gtk_text_forward_delete(GTK_TEXT(byte_view),
+      gtk_text_get_length(GTK_TEXT(byte_view)));
+    gtk_text_thaw(GTK_TEXT(byte_view));
+  }
+  /* Remove all nodes in ctree. This is how it's done in testgtk.c in GTK+ */
+  gtk_clist_clear ( GTK_CLIST(tree_view) );
+
+}
index 371ca75627c6ae5bf9f11198cc8e4c1ba87affba..efd3fd1696f4bcc15303db3d68788a5cf2626bfe 100644 (file)
@@ -1,12 +1,11 @@
-/* gtkpacket.h
+/* proto_draw.h
  * Definitions for GTK+ packet display structures and routines
  *
- * $Id: proto_draw.h,v 1.11 2001/03/23 14:44:04 jfoster Exp $
+ * $Id: proto_draw.h,v 1.12 2001/06/05 07:38:37 guy Exp $
  *
  * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
  * Copyright 1998 Gerald Combs
- *
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -64,4 +63,6 @@ void set_ptree_line_style_all(gint style);
 void set_ptree_expander_style_all(gint style);
 void set_ptree_font_all(GdkFont *font);
 
+void clear_tree_and_hex_views(void);
+
 #endif
diff --git a/menu.h b/menu.h
index b55454a7d67bb4b861ecd46098b76f15b4c38539..83b756c25b4a85c63d2a776e3205dea337cb2ae1 100644 (file)
--- a/menu.h
+++ b/menu.h
@@ -2,12 +2,11 @@
  * Definitions for menu routines with toolkit-independent APIs but
  * toolkit-dependent implementations.
  *
- * $Id: menu.h,v 1.8 2000/08/15 20:42:09 deniel Exp $
+ * $Id: menu.h,v 1.9 2001/06/05 07:38:33 guy Exp $
  *
  * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
  * Copyright 1998 Gerald Combs
- *
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -52,7 +51,8 @@ void set_menus_for_captured_packets(gboolean);
 /* Enable or disable menu items based on whether a packet is selected. */
 void set_menus_for_selected_packet(gboolean);
 
-/* Enable or disable menu items based on whether a tree row is selected. */
+/* Enable or disable menu items based on whether a tree row is selected
+   and and on whether a "Match Selected" can be done. */
 void set_menus_for_selected_tree_row(gboolean);
 
 #ifdef __cplusplus
diff --git a/statusbar.h b/statusbar.h
new file mode 100644 (file)
index 0000000..a7b3b49
--- /dev/null
@@ -0,0 +1,56 @@
+/* statusbar.h
+ * Definitions for status bar UI routines
+ *
+ * $Id: statusbar.h,v 1.1 2001/06/05 07:39:31 guy Exp $
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@ethereal.com>
+ * Copyright 1998 Gerald Combs
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#ifndef __STATUSBAR_H__
+#define __STATUSBAR_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/*
+ * Push a message referring to file access onto the statusbar.
+ */
+void statusbar_push_file_msg(gchar *msg);
+
+/*
+ * Pop a message referring to file access off the statusbar.
+ */
+void statusbar_pop_file_msg(void);
+
+/*
+ * Push a message referring to the currently-selected field onto the statusbar.
+ */
+void statusbar_push_field_msg(gchar *msg);
+
+/*
+ * Pop a message referring to the currently-selected field off the statusbar.
+ */
+void statusbar_pop_field_msg(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __STATUSBAR_H__ */
index 6a6fc71b7c059ae21b2c56d136c05c8a9cde1b9b..e4f9df5ba69fc57130cde2adc90d48baccae4c05 100644 (file)
@@ -1,9 +1,9 @@
 /* tethereal.c
  *
- * $Id: tethereal.c,v 1.83 2001/05/31 08:36:41 guy Exp $
+ * $Id: tethereal.c,v 1.84 2001/06/05 07:38:33 guy Exp $
  *
  * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
  * Copyright 1998 Gerald Combs
  *
  * Text-mode variant, by Gilbert Ramirez <gram@xiexie.org>.
@@ -137,7 +137,6 @@ static void wtap_dispatch_cb_print(u_char *, const struct wtap_pkthdr *, int,
 packet_info  pi;
 capture_file cfile;
 FILE        *data_out_file = NULL;
-guint        main_ctx, file_ctx;
 ts_type timestamp_type = RELATIVE;
 #ifdef HAVE_LIBPCAP
 static int promisc_mode = TRUE;