Automatically adjust the time column width when time format changes.

svn path=/trunk/; revision=29758
This commit is contained in:
Anders Broman 2009-09-07 10:03:55 +00:00
parent 99fba22209
commit 7473e1e04c
3 changed files with 30 additions and 1 deletions

16
file.c
View File

@ -189,6 +189,9 @@ cf_callback_remove(cf_callback_t func)
void
cf_timestamp_auto_precision(capture_file *cf)
{
#ifdef NEW_PACKET_LIST
int i;
#endif
int prec = timestamp_get_precision();
@ -229,6 +232,15 @@ cf_timestamp_auto_precision(capture_file *cf)
g_assert_not_reached();
}
}
#ifdef NEW_PACKET_LIST
/* Set the column widths of those columns that show the time in
"command-line-specified" format. */
for (i = 0; i < cf->cinfo.num_cols; i++) {
if (col_has_time_fmt(&cf->cinfo, i)) {
new_packet_list_set_time_width(cf->cinfo.col_fmt[i], i);
}
}
#endif
}
@ -2976,7 +2988,9 @@ cf_change_time_formats(capture_file *cf)
"command-line-specified" format. */
for (i = 0; i < cf->cinfo.num_cols; i++) {
if (col_has_time_fmt(&cf->cinfo, i)) {
#ifndef NEW_PACKET_LIST
#ifdef NEW_PACKET_LIST
new_packet_list_set_time_width(cf->cinfo.col_fmt[i], i);
#else
packet_list_set_time_width(cf->cinfo.col_fmt[i], i);
#endif
}

View File

@ -829,5 +829,19 @@ void new_packet_list_colorize_packets(void)
packet_list_reset_colorized(packetlist);
gtk_widget_queue_draw (packetlist->view);
}
void new_packet_list_set_time_width(gint col_fmt, gint col)
{
PangoLayout *layout;
GtkTreeViewColumn *column;
gint col_width;
column = gtk_tree_view_get_column (GTK_TREE_VIEW(packetlist->view), col);
layout = gtk_widget_create_pango_layout(packetlist->view, get_column_width_string(get_column_format(col), col));
pango_layout_get_pixel_size(layout, &col_width, NULL);
gtk_tree_view_column_set_fixed_width(column, col_width);
g_object_unref(G_OBJECT(layout));
}
#endif /* NEW_PACKET_LIST */

View File

@ -77,6 +77,7 @@ void new_packet_list_select_last_row(void);
void new_packet_list_moveto_end(void);
gboolean new_packet_list_check_end(void);
gint new_packet_list_find_row_from_data(gpointer data, gboolean select);
void new_packet_list_set_time_width(gint, gint);
#else
/* packet list related functions */
void packet_list_clear(void);