the text in all "Follow TCP Stream" windows;

	the text in the help window if we have one up;

	all hex dump windows;

when GUI preference changes are to be applied, so that font changes and
"Follow TCP Stream" color changes show up.

Update both the Roman and bold font when the font is changed.

Don't decrement the reference counts on the old Roman and bold fonts
until that's all done.

svn path=/trunk/; revision=2401
This commit is contained in:
Guy Harris 2000-09-08 10:59:21 +00:00
parent 0caf526d01
commit e91341e3c3
12 changed files with 169 additions and 63 deletions

5
file.c
View File

@ -1,7 +1,7 @@
/* file.c
* File I/O routines
*
* $Id: file.c,v 1.214 2000/09/08 09:49:17 guy Exp $
* $Id: file.c,v 1.215 2000/09/08 10:58:51 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -1557,8 +1557,7 @@ select_packet(capture_file *cf, int row)
clear_tree_and_hex_views();
proto_tree_draw(cf->protocol_tree, tree_view);
packet_hex_print(GTK_TEXT(byte_view), cf->pd, cf->current_frame->cap_len,
-1, -1, cf->current_frame->flags.encoding,
prefs.gui_hex_dump_highlight_style);
-1, -1, cf->current_frame->flags.encoding);
/* A packet is selected. */
set_menus_for_selected_packet(TRUE);

View File

@ -1,6 +1,6 @@
/* follow_dlg.c
*
* $Id: follow_dlg.c,v 1.8 2000/08/21 13:04:05 deniel Exp $
* $Id: follow_dlg.c,v 1.9 2000/09/08 10:59:09 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -108,6 +108,37 @@ FILE *data_out_file = NULL;
#define E_FOLLOW_INFO_KEY "follow_info_key"
/* List of "follow_info_t" structures for all "Follow TCP Stream" windows,
so we can redraw them all if the colors or font changes. */
static GList *follow_infos;
/* Add a "follow_info_t" structure to the list. */
static void
remember_follow_info(follow_info_t *follow_info)
{
follow_infos = g_list_append(follow_infos, follow_info);
}
/* Remove a "follow_info_t" structure from the list. */
static void
forget_follow_info(follow_info_t *follow_info)
{
follow_infos = g_list_remove(follow_infos, follow_info);
}
static void
follow_redraw(gpointer data, gpointer user_data)
{
follow_load_text((follow_info_t *)data);
}
/* Redraw the text in all "Follow TCP Stream" windows. */
void
follow_redraw_all(void)
{
g_list_foreach(follow_infos, follow_redraw, NULL);
}
/* Follow the TCP stream, if any, to which the last packet that we called
a dissection routine on belongs (this might be the most recently
selected packet, or it might be the last packet in the file). */
@ -347,6 +378,7 @@ follow_stream_cb(GtkWidget * w, gpointer data)
follow_info);
follow_load_text(follow_info);
remember_follow_info(follow_info);
data_out_file = NULL;
@ -367,6 +399,7 @@ follow_destroy_cb(GtkWidget *w, gpointer data)
follow_info = gtk_object_get_data(GTK_OBJECT(w), E_FOLLOW_INFO_KEY);
unlink(follow_info->data_out_filename);
gtk_widget_destroy(w);
forget_follow_info(follow_info);
g_free(follow_info);
}

View File

@ -1,6 +1,6 @@
/* follow_dlg.c
*
* $Id: follow_dlg.h,v 1.2 2000/08/11 13:32:57 deniel Exp $
* $Id: follow_dlg.h,v 1.3 2000/09/08 10:59:12 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -27,4 +27,7 @@
void follow_stream_cb( GtkWidget *, gpointer);
/* Redraw the text in all "Follow TCP Stream" windows. */
void follow_redraw_all(void);
#endif

View File

@ -1,7 +1,7 @@
/* gui_prefs.c
* Dialog box for GUI preferences
*
* $Id: gui_prefs.c,v 1.17 2000/09/08 09:50:01 guy Exp $
* $Id: gui_prefs.c,v 1.18 2000/09/08 10:59:12 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -33,6 +33,8 @@
#include "gui_prefs.h"
#include "gtkglobals.h"
#include "prefs_dlg.h"
#include "follow_dlg.h"
#include "help_dlg.h"
#include "prefs.h"
#include "prefs-int.h"
#include "ui_util.h"
@ -385,34 +387,61 @@ gui_prefs_fetch(GtkWidget *w)
void
gui_prefs_apply(GtkWidget *w)
{
GdkFont *font = NULL;
GdkFont *new_r_font, *new_b_font;
char *bold_font_name;
GdkFont *old_r_font = NULL, *old_b_font = NULL;
if (font_changed) {
font = gdk_font_load(prefs.gui_font_name);
if (font == NULL) {
new_r_font = gdk_font_load(prefs.gui_font_name);
if (new_r_font == NULL) {
/* XXX - make this a dialog box, and don't let them
continue! */
continue! */
fprintf(stderr, "Can't open font %s\n", prefs.gui_font_name);
} else {
bold_font_name = boldify(prefs.gui_font_name);
new_b_font = gdk_font_load(bold_font_name);
if (new_b_font == NULL) {
/* XXX - make this a dialog box, and don't
let them continue! */
fprintf(stderr, "Can't open font %s\n",
bold_font_name);
gdk_font_unref(new_r_font);
} else {
set_plist_font(new_r_font);
set_ptree_font_all(new_r_font);
old_r_font = m_r_font;
old_b_font = m_b_font;
m_r_font = new_r_font;
m_b_font = new_b_font;
}
g_free(bold_font_name);
}
}
/* Redraw the hex dump windows, in case either the font or the
highlight style changed. */
redraw_hex_dump_all();
/* Redraw the help window. */
help_redraw();
/* Redraw the "Follow TCP Stream" windows, in case either the font
or the colors to use changed. */
follow_redraw_all();
set_scrollbar_placement_all(prefs.gui_scrollbar_on_right);
set_plist_sel_browse(prefs.gui_plist_sel_browse);
set_ptree_sel_browse_all(prefs.gui_ptree_sel_browse);
set_ptree_line_style_all(prefs.gui_ptree_line_style);
set_ptree_expander_style_all(prefs.gui_ptree_expander_style);
set_hex_dump_highlight_style_all(prefs.gui_hex_dump_highlight_style);
if (colors_changed)
update_marked_frames();
if (font != NULL) {
set_plist_font(font);
set_ptree_font_all(font);
#if 0
gdk_font_unref(m_r_font);
m_r_font = font;
/* Do the windows that directly use m_r_font here. */
#endif
}
/* We're no longer using the old fonts; unreference them. */
if (old_r_font != NULL)
gdk_font_unref(old_r_font);
if (old_b_font != NULL)
gdk_font_unref(old_b_font);
}
void

View File

@ -1,6 +1,6 @@
/* help_dlg.c
*
* $Id: help_dlg.c,v 1.9 2000/09/07 05:08:19 gram Exp $
* $Id: help_dlg.c,v 1.10 2000/09/08 10:59:13 guy Exp $
*
* Laurent Deniel <deniel@worldnet.fr>
*
@ -70,14 +70,19 @@ static void set_help_text(GtkWidget *w, help_type_t type);
*/
static GtkWidget *help_w = NULL;
/*
* Keep static pointers to the text widgets as well.
*/
GtkWidget *overview_text, *proto_text, *dfilter_text, *cfilter_text;
void help_cb(GtkWidget *w, gpointer data)
{
GtkWidget *main_vb, *bbox, *help_nb, *close_bt, *label, *txt_scrollw,
*overview_vb, *overview_text,
*proto_vb, *proto_text,
*dfilter_vb, *dfilter_text,
*cfilter_vb, *cfilter_text;
*overview_vb,
*proto_vb,
*dfilter_vb,
*cfilter_vb;
if (help_w != NULL) {
/* There's already a "Help" dialog box; reactivate it. */
@ -398,3 +403,42 @@ static void set_help_text(GtkWidget *w, help_type_t type)
gtk_text_thaw(GTK_TEXT(w));
} /* set_help_text */
static void clear_help_text(GtkWidget *w)
{
GtkText *txt = GTK_TEXT(w);
gtk_text_set_point(txt, 0);
/* Keep GTK+ 1.2.3 through 1.2.6 from dumping core - see
http://ethereal.zing.org/lists/ethereal-dev/199912/msg00312.html and
http://www.gnome.org/mailing-lists/archives/gtk-devel-list/1999-October/0051.shtml
for more information */
gtk_adjustment_set_value(txt->vadj, 0.0);
gtk_text_forward_delete(txt, gtk_text_get_length(txt));
}
/* Redraw all the text widgets, to use a new font. */
void help_redraw(void)
{
if (help_w != NULL) {
gtk_text_freeze(GTK_TEXT(overview_text));
clear_help_text(overview_text);
set_help_text(overview_text, OVERVIEW_HELP);
gtk_text_thaw(GTK_TEXT(overview_text));
gtk_text_freeze(GTK_TEXT(proto_text));
clear_help_text(proto_text);
set_help_text(proto_text, PROTOCOL_HELP);
gtk_text_thaw(GTK_TEXT(proto_text));
gtk_text_freeze(GTK_TEXT(dfilter_text));
clear_help_text(dfilter_text);
set_help_text(dfilter_text, DFILTER_HELP);
gtk_text_thaw(GTK_TEXT(dfilter_text));
gtk_text_freeze(GTK_TEXT(cfilter_text));
clear_help_text(cfilter_text);
set_help_text(cfilter_text, CFILTER_HELP);
gtk_text_thaw(GTK_TEXT(cfilter_text));
}
}

View File

@ -1,6 +1,6 @@
/* help_dlg.h
*
* $Id: help_dlg.h,v 1.2 2000/08/11 13:32:57 deniel Exp $
* $Id: help_dlg.h,v 1.3 2000/09/08 10:59:14 guy Exp $
*
* Laurent Deniel <deniel@worldnet.fr>
*
@ -29,4 +29,7 @@
void help_cb(GtkWidget *, gpointer);
/* Redraw all the text widgets, to use a new font. */
void help_redraw(void);
#endif

View File

@ -1,6 +1,6 @@
/* main.c
*
* $Id: main.c,v 1.154 2000/09/08 09:50:03 guy Exp $
* $Id: main.c,v 1.155 2000/09/08 10:59:15 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -136,7 +136,6 @@ GtkStyle *item_style;
field_info *finfo_selected = NULL;
static char* hfinfo_numeric_format(header_field_info *hfinfo);
static char *boldify(const char *font_name);
static void create_main_window(gint, gint, gint, e_prefs*);
/* About Ethereal window */
@ -573,8 +572,7 @@ tree_view_select_row_cb(GtkCTree *ctree, GList *node, gint column, gpointer user
}
packet_hex_print(GTK_TEXT(byte_view), cfile.pd, cfile.current_frame->cap_len,
finfo->start, finfo->length, cfile.current_frame->flags.encoding,
prefs.gui_hex_dump_highlight_style);
finfo->start, finfo->length, cfile.current_frame->flags.encoding);
}
static void
@ -584,8 +582,7 @@ tree_view_unselect_row_cb(GtkCTree *ctree, GList *node, gint column, gpointer us
finfo_selected = NULL;
set_menus_for_selected_tree_row(FALSE);
packet_hex_print(GTK_TEXT(byte_view), cfile.pd, cfile.current_frame->cap_len,
-1, -1, cfile.current_frame->flags.encoding,
prefs.gui_hex_dump_highlight_style);
-1, -1, cfile.current_frame->flags.encoding);
}
void collapse_all_cb(GtkWidget *widget, gpointer data) {
@ -1406,7 +1403,7 @@ static const struct {
};
#define N_WEIGHTS (sizeof weight_map / sizeof weight_map[0])
static char *
char *
boldify(const char *font_name)
{
char *bold_font_name;

View File

@ -1,7 +1,7 @@
/* main.h
* Global defines, etc.
*
* $Id: main.h,v 1.19 2000/08/22 14:04:52 deniel Exp $
* $Id: main.h,v 1.20 2000/09/08 10:59:17 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -63,4 +63,6 @@ void mark_all_frames_cb(GtkWidget *w, gpointer);
void unmark_all_frames_cb(GtkWidget *w, gpointer);
void update_marked_frames(void);
char *boldify(const char *);
#endif /* __MAIN_H__ */

View File

@ -3,7 +3,7 @@
*
* Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com>
*
* $Id: packet_win.c,v 1.13 2000/09/08 09:50:06 guy Exp $
* $Id: packet_win.c,v 1.14 2000/09/08 10:59:18 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -196,8 +196,7 @@ create_new_window ( char *Title, gint tv_size, gint bv_size){
/* draw the protocol tree & print hex data */
proto_tree_draw(DataPtr->protocol_tree, tree_view);
packet_hex_print( GTK_TEXT(byte_view), DataPtr->pd,
DataPtr->cap_len, -1, -1, DataPtr->encoding,
prefs.gui_hex_dump_highlight_style);
DataPtr->cap_len, -1, -1, DataPtr->encoding);
DataPtr->finfo_selected = NULL;
gtk_widget_show(main_w);
@ -232,7 +231,7 @@ new_tree_view_select_row_cb(GtkCTree *ctree, GList *node, gint column,
packet_hex_print(GTK_TEXT(DataPtr->byte_view), DataPtr->pd,
DataPtr->cap_len, finfo->start, finfo->length,
DataPtr->encoding, prefs.gui_hex_dump_highlight_style);
DataPtr->encoding);
}
@ -248,8 +247,7 @@ new_tree_view_unselect_row_cb(GtkCTree *ctree, GList *node, gint column,
DataPtr->finfo_selected = NULL;
packet_hex_print(GTK_TEXT(DataPtr->byte_view), DataPtr->pd,
DataPtr->cap_len, -1, -1, DataPtr->encoding,
prefs.gui_hex_dump_highlight_style);
DataPtr->cap_len, -1, -1, DataPtr->encoding);
}
/* Functions called from elsewhere to act on all popup packet windows. */
@ -272,17 +270,16 @@ destroy_packet_wins(void)
}
static void
set_hex_dump_highlight_style_cb(gpointer data, gpointer user_data)
redraw_hex_dump_cb(gpointer data, gpointer user_data)
{
struct PacketWinData *DataPtr = (struct PacketWinData *)data;
set_hex_dump_highlight_style(DataPtr->byte_view,
DataPtr->finfo_selected, *(gint *)user_data);
redraw_hex_dump(DataPtr->byte_view, DataPtr->finfo_selected);
}
/* Set the hex dump highlight style of all the popup packet windows. */
/* Redraw the hex dump part of all the popup packet windows. */
void
set_hex_dump_highlight_style_packet_wins(gboolean style)
redraw_hex_dump_packet_wins(void)
{
g_list_foreach(detail_windows, set_hex_dump_highlight_style_cb, &style);
g_list_foreach(detail_windows, redraw_hex_dump_cb, NULL);
}

View File

@ -3,7 +3,7 @@
*
* Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com>
*
* $Id: packet_win.h,v 1.5 2000/09/08 09:50:07 guy Exp $
* $Id: packet_win.h,v 1.6 2000/09/08 10:59:19 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -28,6 +28,6 @@
#define __PACKET_WIN_H__
extern void new_window_cb(GtkWidget *w);
void set_hex_dump_highlight_style_packet_wins(gboolean style);
void redraw_hex_dump_packet_wins(void);
#endif

View File

@ -1,7 +1,7 @@
/* proto_draw.c
* Routines for GTK+ packet display
*
* $Id: proto_draw.c,v 1.19 2000/09/08 09:50:07 guy Exp $
* $Id: proto_draw.c,v 1.20 2000/09/08 10:59:19 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -58,25 +58,25 @@ extern GdkFont *m_r_font, *m_b_font;
static void
proto_tree_draw_node(GNode *node, gpointer data);
/* Set the highlight style of a given byte view window. */
/* Redraw a given byte view window. */
void
set_hex_dump_highlight_style(GtkWidget *bv, field_info *finfo, gboolean style)
redraw_hex_dump(GtkWidget *bv, field_info *finfo)
{
if (finfo != NULL) {
packet_hex_print(GTK_TEXT(bv), cfile.pd, cfile.current_frame->cap_len,
finfo->start, finfo->length,
cfile.current_frame->flags.encoding, style);
cfile.current_frame->flags.encoding);
} else {
packet_hex_print(GTK_TEXT(bv), cfile.pd, cfile.current_frame->cap_len,
-1, -1, cfile.current_frame->flags.encoding, style);
-1, -1, cfile.current_frame->flags.encoding);
}
}
void
set_hex_dump_highlight_style_all(gboolean style)
redraw_hex_dump_all(void)
{
set_hex_dump_highlight_style(byte_view, finfo_selected, style);
set_hex_dump_highlight_style_packet_wins(style);
redraw_hex_dump(byte_view, finfo_selected);
redraw_hex_dump_packet_wins();
}
void
@ -108,7 +108,7 @@ create_byte_view(gint bv_size, GtkWidget *pane, GtkWidget **byte_view_p,
void
packet_hex_print(GtkText *bv, guint8 *pd, gint len, gint bstart, gint blen,
char_enc encoding, gboolean style) {
char_enc encoding) {
gint i = 0, j, k, cur;
guchar line[128], hexchars[] = "0123456789abcdef", c = '\0';
GdkFont *cur_font, *new_font;
@ -138,7 +138,7 @@ packet_hex_print(GtkText *bv, guint8 *pd, gint len, gint bstart, gint blen,
sprintf(line, "%04x ", i);
/* Display with inverse video ? */
if (style) {
if (prefs.gui_hex_dump_highlight_style) {
gtk_text_insert(bv, m_r_font, &BLACK, &WHITE, line, -1);
/* Do we start in reverse? */
reverse = i >= bstart && i < bend;

View File

@ -1,7 +1,7 @@
/* gtkpacket.h
* Definitions for GTK+ packet display structures and routines
*
* $Id: proto_draw.h,v 1.8 2000/09/08 09:50:08 guy Exp $
* $Id: proto_draw.h,v 1.9 2000/09/08 10:59:21 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -27,12 +27,11 @@
#ifndef __GTKPACKET_H__
#define __GTKPACKET_H__
void set_hex_dump_highlight_style(GtkWidget *bv, field_info *finfo,
gboolean style);
void set_hex_dump_highlight_style_all(gboolean);
void redraw_hex_dump(GtkWidget *bv, field_info *finfo);
void redraw_hex_dump_all(void);
void create_byte_view(gint bv_size, GtkWidget *pane, GtkWidget **byte_view_p,
GtkWidget **bv_scrollw_p, int pos);
void packet_hex_print(GtkText *, guint8 *, gint, gint, gint, char_enc, gboolean);
void packet_hex_print(GtkText *, guint8 *, gint, gint, gint, char_enc);
#define E_TREEINFO_FIELD_INFO_KEY "tree_info_finfo"