COL_INFO columns resize automatically even during a live
	capture;

	columns showing network addresses never resize automatically;

	other columns resize only when a capture is done;

and make all columns resizeable by hand (once they've resized, for
auto-resizeable columns).

svn path=/trunk/; revision=394
This commit is contained in:
Guy Harris 1999-07-28 03:29:02 +00:00
parent f04819106b
commit b70d733f50
5 changed files with 147 additions and 29 deletions

View File

@ -1,7 +1,7 @@
/* column.c
* Routines for handling column preferences
*
* $Id: column.c,v 1.19 1999/07/23 08:29:23 guy Exp $
* $Id: column.c,v 1.20 1999/07/28 03:29:00 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -233,6 +233,60 @@ get_column_width(gint format, GdkFont *font) {
}
}
enum col_resize_type
get_column_resize_type(gint format) {
switch (format) {
case COL_NUMBER:
case COL_CLS_TIME:
case COL_ABS_TIME:
case COL_REL_TIME:
case COL_DELTA_TIME:
case COL_DEF_SRC_PORT:
case COL_RES_SRC_PORT:
case COL_UNRES_SRC_PORT:
case COL_DEF_DST_PORT:
case COL_RES_DST_PORT:
case COL_UNRES_DST_PORT:
case COL_PROTOCOL:
case COL_PACKET_LENGTH:
/* We don't want these to resize during a live capture, as that
gets in the way of trying to look at the data while it's being
captured. */
return (RESIZE_AUTO);
break;
case COL_DEF_SRC:
case COL_RES_SRC:
case COL_UNRES_SRC:
case COL_DEF_DL_SRC:
case COL_RES_DL_SRC:
case COL_UNRES_DL_SRC:
case COL_DEF_NET_SRC:
case COL_RES_NET_SRC:
case COL_UNRES_NET_SRC:
case COL_DEF_DST:
case COL_RES_DST:
case COL_UNRES_DST:
case COL_DEF_DL_DST:
case COL_RES_DL_DST:
case COL_UNRES_DL_DST:
case COL_DEF_NET_DST:
case COL_RES_NET_DST:
case COL_UNRES_NET_DST:
/* We don't want these to resize dynamically; if they get resolved
to names, those names could be very long, and auto-resizing
columns showing those names may leave too little room for
other columns such as the "Info" column. */
return (RESIZE_MANUAL);
break;
default: /* COL_INFO */
/* We want this to resize dynamically, even during a live capture,
because otherewise you won't be able to see all that's in
it. */
return (RESIZE_LIVE);
break;
}
}
#define TIME_DEF 0
#define TIME_REL 1
#define TIME_ABS 2

View File

@ -1,7 +1,7 @@
/* column.h
* Definitions for column handling routines
*
* $Id: column.h,v 1.3 1999/07/22 21:14:13 guy Exp $
* $Id: column.h,v 1.4 1999/07/28 03:29:00 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -31,14 +31,21 @@ typedef struct _fmt_data {
gchar *fmt;
} fmt_data;
gint get_column_format(gint);
gchar *get_column_title(gint);
gchar *col_format_to_pref_str();
void get_column_format_matches(gboolean *, gint);
gint get_column_width(gint format, GdkFont *font);
GtkWidget *column_prefs_show();
void column_prefs_ok(GtkWidget *);
void column_prefs_save(GtkWidget *);
void column_prefs_cancel(GtkWidget *);
enum col_resize_type {
RESIZE_AUTO, /* Automatically resize */
RESIZE_LIVE, /* Automatically resize even during live capture */
RESIZE_MANUAL /* Don't automatically resize */
};
gint get_column_format(gint);
enum col_resize_type get_column_resize_type(gint);
gchar *get_column_title(gint);
gchar *col_format_to_pref_str(void);
void get_column_format_matches(gboolean *, gint);
gint get_column_width(gint format, GdkFont *font);
GtkWidget *column_prefs_show(void);
void column_prefs_ok(GtkWidget *);
void column_prefs_save(GtkWidget *);
void column_prefs_cancel(GtkWidget *);
#endif /* column.h */

View File

@ -1,6 +1,6 @@
/* ethereal.c
*
* $Id: ethereal.c,v 1.65 1999/07/28 01:35:25 gerald Exp $
* $Id: ethereal.c,v 1.66 1999/07/28 03:29:01 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -983,7 +983,6 @@ main(int argc, char *argv[])
gint pl_size = 280, tv_size = 95, bv_size = 75;
gchar *rc_file, *cf_name = NULL;
e_prefs *prefs;
gint *col_fmt;
gchar **col_title;
ethereal_path = argv[0];
@ -1015,8 +1014,10 @@ main(int argc, char *argv[])
cf.snap = MAX_PACKET_SIZE;
cf.count = 0;
cf.cinfo.num_cols = prefs->num_cols;
cf.cinfo.col_fmt = (gint *) g_malloc(sizeof(gint) * cf.cinfo.num_cols);
cf.cinfo.fmt_matx = (gboolean **) g_malloc(sizeof(gboolean *) * cf.cinfo.num_cols);
cf.cinfo.col_data = (gchar **) g_malloc(sizeof(gchar *) * cf.cinfo.num_cols);
cf.cinfo.col_width = (gint *) g_malloc(sizeof(gint) * cf.cinfo.num_cols);
/* Assemble the compile-time options */
snprintf(comp_info_str, 256,
@ -1146,15 +1147,14 @@ main(int argc, char *argv[])
#endif
/* Build the column format array */
col_fmt = (gint *) g_malloc(sizeof(gint) * cf.cinfo.num_cols);
col_title = (gchar **) g_malloc(sizeof(gchar *) * cf.cinfo.num_cols);
for (i = 0; i < cf.cinfo.num_cols; i++) {
col_fmt[i] = get_column_format(i);
cf.cinfo.col_fmt[i] = get_column_format(i);
col_title[i] = g_strdup(get_column_title(i));
cf.cinfo.fmt_matx[i] = (gboolean *) g_malloc0(sizeof(gboolean) *
NUM_COL_FMTS);
get_column_format_matches(cf.cinfo.fmt_matx[i], col_fmt[i]);
get_column_format_matches(cf.cinfo.fmt_matx[i], cf.cinfo.col_fmt[i]);
cf.cinfo.col_data[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
}
@ -1228,11 +1228,18 @@ main(int argc, char *argv[])
gtk_signal_connect(GTK_OBJECT(packet_list), "unselect_row",
GTK_SIGNAL_FUNC(packet_list_unselect_cb), NULL);
for (i = 0; i < cf.cinfo.num_cols; i++) {
gtk_clist_set_column_width(GTK_CLIST(packet_list), i,
get_column_width(get_column_format(i), pl_style->font));
if (col_fmt[i] == COL_NUMBER)
if (get_column_resize_type(cf.cinfo.col_fmt[i]) != RESIZE_MANUAL)
gtk_clist_set_column_auto_resize(GTK_CLIST(packet_list), i, TRUE);
/* Right-justify the packet number column. */
if (cf.cinfo.col_fmt[i] == COL_NUMBER)
gtk_clist_set_column_justification(GTK_CLIST(packet_list), i,
GTK_JUSTIFY_RIGHT);
/* Save static column sizes to use during a "-S" capture, so that
the columns don't resize during a live capture. */
cf.cinfo.col_width[i] = get_column_width(get_column_format(i),
pl_style->font);
}
gtk_widget_set_usize(packet_list, -1, pl_size);
gtk_paned_add1(GTK_PANED(u_pane), packet_sw);

60
file.c
View File

@ -1,7 +1,7 @@
/* file.c
* File I/O routines
*
* $Id: file.c,v 1.46 1999/07/27 02:04:37 guy Exp $
* $Id: file.c,v 1.47 1999/07/28 03:29:02 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -96,6 +96,9 @@ static void wtap_dispatch_cb(u_char *, const struct wtap_pkthdr *, int,
static gint tail_timeout_cb(gpointer);
#endif
static void freeze_clist(capture_file *cf);
static void thaw_clist(capture_file *cf);
int
open_cap_file(char *fname, capture_file *cf) {
struct stat cf_stat;
@ -210,12 +213,12 @@ load_cap_file(char *fname, capture_file *cf) {
err = open_cap_file(fname, cf);
if ((err == 0) && (cf->cd_t != WTAP_FILE_UNKNOWN)) {
gtk_clist_freeze(GTK_CLIST(packet_list));
freeze_clist(cf);
wtap_loop(cf->wth, 0, wtap_dispatch_cb, (u_char *) cf);
wtap_close(cf->wth);
cf->wth = NULL;
cf->fh = fopen(fname, "r");
gtk_clist_thaw(GTK_CLIST(packet_list));
thaw_clist(cf);
}
gtk_timeout_remove(timeout);
@ -289,7 +292,7 @@ cap_file_input_cb (gpointer data, gint source, GdkInputCondition condition) {
wtap_loop(cf->wth, 0, wtap_dispatch_cb, (u_char *) cf);
gtk_clist_thaw(GTK_CLIST(packet_list));
thaw_clist(cf);
wtap_close(cf->wth);
cf->wth = NULL;
@ -350,6 +353,7 @@ tail_timeout_cb(gpointer data) {
int
tail_cap_file(char *fname, capture_file *cf) {
int err;
int i;
close_cap_file(cf, info_bar, file_ctx);
@ -363,6 +367,17 @@ tail_cap_file(char *fname, capture_file *cf) {
set_menu_sensitivity("/Capture/Start...", FALSE);
set_menu_sensitivity("/Tools/Capture...", FALSE);
for (i = 0; i < cf->cinfo.num_cols; i++) {
if (get_column_resize_type(cf->cinfo.col_fmt[i]) == RESIZE_LIVE)
gtk_clist_set_column_auto_resize(GTK_CLIST(packet_list), i, TRUE);
else {
gtk_clist_set_column_auto_resize(GTK_CLIST(packet_list), i, FALSE);
gtk_clist_set_column_width(GTK_CLIST(packet_list), i,
cf->cinfo.col_width[i]);
gtk_clist_set_column_resizeable(GTK_CLIST(packet_list), i, TRUE);
}
}
cf->fh = fopen(fname, "r");
tail_timeout_id = -1;
cap_input_id = gtk_input_add_full (sync_pipe[0],
@ -648,7 +663,7 @@ change_time_formats(capture_file *cf)
/* Freeze the packet list while we redo it, so we don't get any
screen updates while it happens. */
gtk_clist_freeze(GTK_CLIST(packet_list));
freeze_clist(cf);
/*
* Iterate through the list of packets, calling a routine
@ -673,7 +688,7 @@ change_time_formats(capture_file *cf)
}
/* Unfreeze the packet list. */
gtk_clist_thaw(GTK_CLIST(packet_list));
thaw_clist(cf);
}
/* Select the packet on a given row. */
@ -739,6 +754,39 @@ unselect_packet(capture_file *cf)
set_menu_sensitivity("/File/Print Packet", FALSE);
}
static void
freeze_clist(capture_file *cf)
{
int i;
/* Make the column sizes static, so they don't adjust while
we're reading the capture file (freezing the clist doesn't
seem to suffice). */
for (i = 0; i < cf->cinfo.num_cols; i++)
gtk_clist_set_column_auto_resize(GTK_CLIST(packet_list), i, FALSE);
gtk_clist_freeze(GTK_CLIST(packet_list));
}
static void
thaw_clist(capture_file *cf)
{
int i;
/* Make the column sizes dynamic, so that they adjust to the
appropriate sizes. */
for (i = 0; i < cf->cinfo.num_cols; i++) {
if (get_column_resize_type(cf->cinfo.col_fmt[i]) != RESIZE_MANUAL)
gtk_clist_set_column_auto_resize(GTK_CLIST(packet_list), i, TRUE);
}
gtk_clist_thaw(GTK_CLIST(packet_list));
/* Hopefully, the columns have now gotten their appropriate sizes;
make them resizeable - a column that auto-resizes cannot be
resized by the user, and *vice versa*. */
for (i = 0; i < cf->cinfo.num_cols; i++)
gtk_clist_set_column_resizeable(GTK_CLIST(packet_list), i, TRUE);
}
/* Tries to mv a file. If unsuccessful, tries to cp the file.
* Returns 0 on failure to do either, 1 on success of either
*/

View File

@ -1,7 +1,7 @@
/* packet.h
* Definitions for packet disassembly structures and routines
*
* $Id: packet.h,v 1.73 1999/07/22 21:14:12 guy Exp $
* $Id: packet.h,v 1.74 1999/07/28 03:29:00 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -83,9 +83,11 @@
#define plurality(d,s,p) ((d) == 1 ? (s) : (p))
typedef struct _column_info {
gint num_cols; /* Number of columns */
gboolean **fmt_matx; /* Specifies which formats apply to a column */
gchar **col_data; /* Column data */
gint num_cols; /* Number of columns */
gint *col_fmt; /* Format of column */
gboolean **fmt_matx; /* Specifies which formats apply to a column */
gint *col_width; /* Column widths to use during a "-S" capture */
gchar **col_data; /* Column data */
} column_info;
#define COL_MAX_LEN 256