aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2000-09-08 10:59:21 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2000-09-08 10:59:21 +0000
commit0c888b68f1e40eee307400f73818d088a4481f58 (patch)
treea48d6d3526472e06b5aba914253cdab9560d9916
parent21dbba5f1caf062c4f965d49e2104cd3de9e8524 (diff)
Redraw:
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. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@2401 f5534014-38df-0310-8fa8-9805f1628bb7
-rw-r--r--file.c5
-rw-r--r--gtk/follow_dlg.c35
-rw-r--r--gtk/follow_dlg.h5
-rw-r--r--gtk/gui_prefs.c59
-rw-r--r--gtk/help_dlg.c54
-rw-r--r--gtk/help_dlg.h5
-rw-r--r--gtk/main.c11
-rw-r--r--gtk/main.h4
-rw-r--r--gtk/packet_win.c21
-rw-r--r--gtk/packet_win.h4
-rw-r--r--gtk/proto_draw.c20
-rw-r--r--gtk/proto_draw.h9
12 files changed, 169 insertions, 63 deletions
diff --git a/file.c b/file.c
index ff03a4c6c9..d453a062a0 100644
--- a/file.c
+++ b/file.c
@@ -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);
diff --git a/gtk/follow_dlg.c b/gtk/follow_dlg.c
index 8dddc1da9a..c122b79d9a 100644
--- a/gtk/follow_dlg.c
+++ b/gtk/follow_dlg.c
@@ -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);
}
diff --git a/gtk/follow_dlg.h b/gtk/follow_dlg.h
index 07fb180eea..7c203b2137 100644
--- a/gtk/follow_dlg.h
+++ b/gtk/follow_dlg.h
@@ -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
diff --git a/gtk/gui_prefs.c b/gtk/gui_prefs.c
index 2010dc5120..f9ef193c05 100644
--- a/gtk/gui_prefs.c
+++ b/gtk/gui_prefs.c
@@ -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
diff --git a/gtk/help_dlg.c b/gtk/help_dlg.c
index 00d0a2c5d5..8c7b2d4198 100644
--- a/gtk/help_dlg.c
+++ b/gtk/help_dlg.c
@@ -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));
+ }
+}
diff --git a/gtk/help_dlg.h b/gtk/help_dlg.h
index 99c1ed0cbe..88e6950b0f 100644
--- a/gtk/help_dlg.h
+++ b/gtk/help_dlg.h
@@ -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
diff --git a/gtk/main.c b/gtk/main.c
index 1e3591a089..cbda9e18c4 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -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;
diff --git a/gtk/main.h b/gtk/main.h
index e0f41284e5..6eee7b6a6b 100644
--- a/gtk/main.h
+++ b/gtk/main.h
@@ -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__ */
diff --git a/gtk/packet_win.c b/gtk/packet_win.c
index 8fd9fb5872..48084fe3cd 100644
--- a/gtk/packet_win.c
+++ b/gtk/packet_win.c
@@ -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);
}
diff --git a/gtk/packet_win.h b/gtk/packet_win.h
index 42391ec99b..6ca94550c1 100644
--- a/gtk/packet_win.h
+++ b/gtk/packet_win.h
@@ -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
diff --git a/gtk/proto_draw.c b/gtk/proto_draw.c
index 3e05ef43bf..c5d22cf06f 100644
--- a/gtk/proto_draw.c
+++ b/gtk/proto_draw.c
@@ -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;
diff --git a/gtk/proto_draw.h b/gtk/proto_draw.h
index 96fb55c89b..68d5126630 100644
--- a/gtk/proto_draw.h
+++ b/gtk/proto_draw.h
@@ -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"