Add a new function to build column widths based not only on the max

width that is hard-coded in get_column_longest_string(), but also on the
width of the user specified title of the column (in case it is wider.)


svn path=/trunk/; revision=20117
This commit is contained in:
Stephen Fisher 2006-12-11 20:09:04 +00:00
parent fdfd0be5bd
commit 41c5011f5b
3 changed files with 15 additions and 2 deletions

View File

@ -415,6 +415,18 @@ get_timestamp_column_longest_string(gint type, gint precision)
return "";
}
/* Returns the longer string of the column title or the hard-coded width of
* its contents for building the packet list layout. */
const gchar *
get_column_width_string(gint format, gint col)
{
if(strlen(get_column_longest_string(format)) >
strlen(get_column_title(col)))
return get_column_longest_string(format);
else
return get_column_title(col);
}
/* Returns a string representing the longest possible value for a
particular column type.

View File

@ -36,6 +36,7 @@ gint get_column_format(gint);
void get_column_format_matches(gboolean *, gint);
gint get_column_format_from_str(gchar *);
gchar *get_column_title(gint);
const gchar *get_column_width_string(gint, gint);
const char *get_column_longest_string(gint);
gint get_column_char_width(gint format);

View File

@ -481,10 +481,10 @@ packet_list_set_font(FONT_TYPE *font)
for (i = 0; i < cfile.cinfo.num_cols; i++) {
#if GTK_MAJOR_VERSION < 2
col_width = gdk_string_width(font,
get_column_longest_string(get_column_format(i)));
get_column_width_string(get_column_format(i), i));
#else
layout = gtk_widget_create_pango_layout(packet_list,
get_column_longest_string(get_column_format(i)));
get_column_width_string(get_column_format(i), i));
pango_layout_get_pixel_size(layout, &col_width, NULL);
g_object_unref(G_OBJECT(layout));
#endif