Update the column widths if we change the time stamp format from the

"Display/Options" dialog box.

"get_column_width()" should check "timestamp_type" against ABSOLUTE, not
against COL_ABS_TIME.

Clean up the code to check the state of the time stamp radio buttons in
the "Display/Options" dialog box.

Check in "timestamp.h", which we failed to check in on the previous
commit.

svn path=/trunk/; revision=318
This commit is contained in:
Guy Harris 1999-06-19 01:47:43 +00:00
parent 88e94a0186
commit fe725bec8c
3 changed files with 72 additions and 13 deletions

View File

@ -1,7 +1,7 @@
/* column.c
* Routines for handling column preferences
*
* $Id: column.c,v 1.11 1999/06/19 01:14:49 guy Exp $
* $Id: column.c,v 1.12 1999/06/19 01:47:43 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -178,7 +178,7 @@ get_column_width(gint format, GdkFont *font) {
return (gdk_string_width(font, "0") * 7);
break;
case COL_CLS_TIME:
if (timestamp_type == COL_ABS_TIME)
if (timestamp_type == ABSOLUTE)
return (gdk_string_width(font, "00:00:00.000000"));
else
return (gdk_string_width(font, "0000.000000"));

View File

@ -1,7 +1,7 @@
/* display.c
* Routines for packet display windows
*
* $Id: display.c,v 1.1 1999/06/19 01:14:47 guy Exp $
* $Id: display.c,v 1.2 1999/06/19 01:47:43 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -60,11 +60,13 @@
#endif
#include "timestamp.h"
#include "column.h"
#include "packet.h"
#include "file.h"
#include "display.h"
extern capture_file cf;
extern GtkWidget *packet_list;
/* Display callback data keys */
#define E_DISPLAY_TIME_ABS_KEY "display_time_abs"
@ -142,27 +144,44 @@ display_opt_cb(GtkWidget *w, gpointer d) {
static void
display_opt_ok_cb(GtkWidget *w, gpointer data) {
GtkWidget *abs_rb, *rel_rb, *delta_rb;
GtkWidget *button;
GtkStyle *pl_style;
int i;
gint col_fmt;
#ifdef GTK_HAVE_FEATURES_1_1_0
data = w;
#endif
abs_rb = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(data),
E_DISPLAY_TIME_ABS_KEY);
rel_rb = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(data),
E_DISPLAY_TIME_REL_KEY);
delta_rb = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(data),
E_DISPLAY_TIME_DELTA_KEY);
if (GTK_TOGGLE_BUTTON (abs_rb)->active)
button = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(data),
E_DISPLAY_TIME_ABS_KEY);
if (GTK_TOGGLE_BUTTON (button)->active)
timestamp_type = ABSOLUTE;
if (GTK_TOGGLE_BUTTON (rel_rb)->active)
button = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(data),
E_DISPLAY_TIME_REL_KEY);
if (GTK_TOGGLE_BUTTON (button)->active)
timestamp_type = RELATIVE;
if (GTK_TOGGLE_BUTTON (delta_rb)->active)
button = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(data),
E_DISPLAY_TIME_DELTA_KEY);
if (GTK_TOGGLE_BUTTON (button)->active)
timestamp_type = DELTA;
gtk_widget_destroy(GTK_WIDGET(data));
/* Recompute the column widths; we may have changed the format of the
time stamp column. */
pl_style = gtk_widget_get_style(packet_list);
for (i = 0; i < cf.cinfo.num_cols; i++) {
col_fmt = get_column_format(i);
gtk_clist_set_column_width(GTK_CLIST(packet_list), i,
get_column_width(col_fmt, pl_style->font));
if (col_fmt == COL_NUMBER)
gtk_clist_set_column_justification(GTK_CLIST(packet_list), i,
GTK_JUSTIFY_RIGHT);
}
redisplay_packets(&cf);
}

40
timestamp.h Normal file
View File

@ -0,0 +1,40 @@
/* timestamp.h
* Defines for packet timestamps
*
* $Id: timestamp.h,v 1.1 1999/06/19 01:47:43 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
* 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 __TIMESTAMP_H__
#define __TIMESTAMP_H__
/*
* Type of time-stamp shown in the summary display.
*/
typedef enum {
RELATIVE,
ABSOLUTE,
DELTA
} ts_type;
extern ts_type timestamp_type;
#endif /* timestamp.h */