aboutsummaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2000-08-21 08:09:17 +0000
committerGuy Harris <guy@alum.mit.edu>2000-08-21 08:09:17 +0000
commit023bf363b5abf534228537a71acd1dc1bfb474de (patch)
tree06cb8393e5ca61235f98360aa58142be828252b1 /gtk
parent352f8f1603aa76143273d9f9130d8f149f508522 (diff)
Instead of each set of built-in preferences having "ok", "save",
"cancel", and "delete" methods, give them: "fetch" - fetch from the notebook tab any values not already stored in "prefs", and store them there, but doesn't apply them; "apply" - apply the settings in "prefs"; "destroy" - clean up any windows created from the tab. As we no longer have "cancel" methods, we don't have per-preference code to revert preference values; instead, we have the common preference dialog box code make a copy of all the current preferences, and, when the "Cancel" button is clicked, free the current preferences and copy the saved preferences to it, and apply the preferences. Add an "Apply" button to the preference dialog box, which applies the current preferences without closing the dialog box. Treat a request to delete the preferences dialog box as equivalent to clicking "Cancel". Have a "remember_ptree_widget()" routine to remember all protocol tree widgets, and use the list of those widgets when we set GUI preferences for the protocol tree widgets, rather than setting the main protocol tree widget and then using the list of packet windows. Move that code out of "main.c" to "proto_draw.c", as it's not used by anything in "main.c", but is used by stuff in "proto_draw.c". Make the font one of the preferences we can set on the fly for protocol tree widgets. Also make it something we can set on the fly for the packet list widget. svn path=/trunk/; revision=2316
Diffstat (limited to 'gtk')
-rw-r--r--gtk/column_prefs.c16
-rw-r--r--gtk/column_prefs.h9
-rw-r--r--gtk/gtkglobals.h11
-rw-r--r--gtk/gui_prefs.c102
-rw-r--r--gtk/gui_prefs.h9
-rw-r--r--gtk/main.c91
-rw-r--r--gtk/packet_win.c47
-rw-r--r--gtk/packet_win.h5
-rw-r--r--gtk/prefs_dlg.c147
-rw-r--r--gtk/print_prefs.c33
-rw-r--r--gtk/print_prefs.h9
-rw-r--r--gtk/proto_draw.c132
-rw-r--r--gtk/proto_draw.h8
-rw-r--r--gtk/stream_prefs.c17
-rw-r--r--gtk/stream_prefs.h9
15 files changed, 359 insertions, 286 deletions
diff --git a/gtk/column_prefs.c b/gtk/column_prefs.c
index 97b23082a7..cd9f9d1e21 100644
--- a/gtk/column_prefs.c
+++ b/gtk/column_prefs.c
@@ -1,7 +1,7 @@
/* column_prefs.c
* Dialog box for column preferences
*
- * $Id: column_prefs.c,v 1.2 2000/08/11 13:33:04 deniel Exp $
+ * $Id: column_prefs.c,v 1.3 2000/08/21 08:09:10 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -340,23 +340,15 @@ column_set_fmt_cb(GtkWidget *w, gpointer data) {
}
void
-column_prefs_ok(GtkWidget *w) {
-
- column_prefs_delete(w);
+column_prefs_fetch(GtkWidget *w) {
}
void
-column_prefs_save(GtkWidget *w) {
-}
-
-void
-column_prefs_cancel(GtkWidget *w) {
-
- column_prefs_delete(w);
+column_prefs_apply(GtkWidget *w) {
}
void
-column_prefs_delete(GtkWidget *w) {
+column_prefs_destroy(GtkWidget *w) {
/* Let the list cb know we're about to destroy the widget tree, so it */
/* doesn't operate on widgets that don't exist. */
diff --git a/gtk/column_prefs.h b/gtk/column_prefs.h
index 3a4f146267..9671f11e1f 100644
--- a/gtk/column_prefs.h
+++ b/gtk/column_prefs.h
@@ -1,7 +1,7 @@
/* gui_prefs.h
* Definitions for column preferences window
*
- * $Id: column_prefs.h,v 1.1 2000/01/10 01:43:58 guy Exp $
+ * $Id: column_prefs.h,v 1.2 2000/08/21 08:09:10 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -24,7 +24,6 @@
*/
GtkWidget *column_prefs_show(void);
-void column_prefs_ok(GtkWidget *);
-void column_prefs_save(GtkWidget *);
-void column_prefs_cancel(GtkWidget *);
-void column_prefs_delete(GtkWidget *);
+void column_prefs_fetch(GtkWidget *);
+void column_prefs_apply(GtkWidget *);
+void column_prefs_destroy(GtkWidget *);
diff --git a/gtk/gtkglobals.h b/gtk/gtkglobals.h
index d553bd2b91..35ceded245 100644
--- a/gtk/gtkglobals.h
+++ b/gtk/gtkglobals.h
@@ -1,7 +1,7 @@
/* gtkglobals.h
* GTK-related Global defines, etc.
*
- * $Id: gtkglobals.h,v 1.10 2000/08/17 07:56:34 guy Exp $
+ * $Id: gtkglobals.h,v 1.11 2000/08/21 08:09:11 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -39,12 +39,9 @@ extern GtkStyle *item_style;
void set_scrollbar_placement_scrollw(GtkWidget *, int); /* 0=left, 1=right */
void set_scrollbar_placement_all(int); /* 1=right, 0=left */
void remember_scrolled_window(GtkWidget *);
+
+
void set_plist_sel_browse(gboolean);
-void set_ptree_sel_browse(GtkWidget *, gboolean);
-void set_ptree_sel_browse_all(gboolean);
-void set_ptree_line_style(GtkWidget *, gint style);
-void set_ptree_line_style_all(gint style);
-void set_ptree_expander_style(GtkWidget *, gint style);
-void set_ptree_expander_style_all(gint style);
+void set_plist_font(GdkFont *font);
#endif
diff --git a/gtk/gui_prefs.c b/gtk/gui_prefs.c
index 3d8d4f53a8..504f16edfb 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.6 2000/08/20 07:53:43 guy Exp $
+ * $Id: gui_prefs.c,v 1.7 2000/08/21 08:09:11 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -35,6 +35,7 @@
#include "prefs_dlg.h"
#include "ui_util.h"
#include "dlg_utils.h"
+#include "proto_draw.h"
static void scrollbar_menu_item_cb(GtkWidget *w, gpointer data);
static void plist_sel_browse_cb(GtkWidget *w, gpointer data);
@@ -45,13 +46,6 @@ static void font_browse_cb(GtkWidget *w, gpointer data);
static void font_browse_ok_cb(GtkWidget *w, GtkFontSelectionDialog *fs);
static void font_browse_destroy(GtkWidget *win, gpointer data);
-static gboolean temp_gui_scrollbar_on_right;
-static gboolean temp_gui_plist_sel_browse;
-static gboolean temp_gui_ptree_sel_browse;
-static gint temp_gui_ptree_line_style;
-static gint temp_gui_ptree_expander_style;
-static gchar *temp_gui_font_name;
-
#define E_FONT_DIALOG_PTR_KEY "font_dialog_ptr"
#define E_FONT_CALLER_PTR_KEY "font_caller_ptr"
@@ -63,13 +57,6 @@ gui_prefs_show(void)
*menu_item_0, *menu_item_1, *menu_item_2, *menu_item_3,
*scrollbar_menu, *scrollbar_option_menu, *font_bt;
- temp_gui_scrollbar_on_right = prefs.gui_scrollbar_on_right;
- temp_gui_plist_sel_browse = prefs.gui_plist_sel_browse;
- temp_gui_ptree_sel_browse = prefs.gui_ptree_sel_browse;
- temp_gui_ptree_line_style = prefs.gui_ptree_line_style;
- temp_gui_ptree_expander_style = prefs.gui_ptree_expander_style;
- temp_gui_font_name = g_strdup(prefs.gui_font_name);
-
/* Main vertical box */
main_vb = gtk_vbox_new(FALSE, 5);
gtk_container_border_width( GTK_CONTAINER(main_vb), 5 );
@@ -104,7 +91,7 @@ gui_prefs_show(void)
gtk_option_menu_set_menu( GTK_OPTION_MENU(scrollbar_option_menu),
scrollbar_menu );
gtk_option_menu_set_history( GTK_OPTION_MENU(scrollbar_option_menu),
- temp_gui_scrollbar_on_right);
+ prefs.gui_scrollbar_on_right);
gtk_table_attach_defaults( GTK_TABLE(main_tb), scrollbar_option_menu,
1, 2, 0, 1 );
@@ -131,7 +118,7 @@ gui_prefs_show(void)
gtk_option_menu_set_menu( GTK_OPTION_MENU(scrollbar_option_menu),
scrollbar_menu );
gtk_option_menu_set_history( GTK_OPTION_MENU(scrollbar_option_menu),
- temp_gui_plist_sel_browse);
+ prefs.gui_plist_sel_browse);
gtk_table_attach_defaults( GTK_TABLE(main_tb), scrollbar_option_menu,
1, 2, 1, 2 );
@@ -158,7 +145,7 @@ gui_prefs_show(void)
gtk_option_menu_set_menu( GTK_OPTION_MENU(scrollbar_option_menu),
scrollbar_menu );
gtk_option_menu_set_history( GTK_OPTION_MENU(scrollbar_option_menu),
- temp_gui_ptree_sel_browse);
+ prefs.gui_ptree_sel_browse);
gtk_table_attach_defaults( GTK_TABLE(main_tb), scrollbar_option_menu,
1, 2, 2, 3 );
@@ -193,7 +180,7 @@ gui_prefs_show(void)
gtk_option_menu_set_menu( GTK_OPTION_MENU(scrollbar_option_menu),
scrollbar_menu );
gtk_option_menu_set_history( GTK_OPTION_MENU(scrollbar_option_menu),
- temp_gui_ptree_line_style);
+ prefs.gui_ptree_line_style);
gtk_table_attach_defaults( GTK_TABLE(main_tb), scrollbar_option_menu,
1, 2, 3, 4 );
@@ -228,7 +215,7 @@ gui_prefs_show(void)
gtk_option_menu_set_menu( GTK_OPTION_MENU(scrollbar_option_menu),
scrollbar_menu );
gtk_option_menu_set_history( GTK_OPTION_MENU(scrollbar_option_menu),
- temp_gui_ptree_expander_style);
+ prefs.gui_ptree_expander_style);
gtk_table_attach_defaults( GTK_TABLE(main_tb), scrollbar_option_menu,
1, 2, 4, 5 );
@@ -250,8 +237,7 @@ scrollbar_menu_item_cb(GtkWidget *w, gpointer data)
{
gboolean value = GPOINTER_TO_INT(data);
- temp_gui_scrollbar_on_right = value;
- set_scrollbar_placement_all(value);
+ prefs.gui_scrollbar_on_right = value;
}
static void
@@ -259,8 +245,7 @@ plist_sel_browse_cb(GtkWidget *w, gpointer data)
{
gboolean value = GPOINTER_TO_INT(data);
- temp_gui_plist_sel_browse = value;
- set_plist_sel_browse(value);
+ prefs.gui_plist_sel_browse = value;
}
static void
@@ -268,8 +253,7 @@ ptree_sel_browse_cb(GtkWidget *w, gpointer data)
{
gboolean value = GPOINTER_TO_INT(data);
- temp_gui_ptree_sel_browse = value;
- set_ptree_sel_browse_all(value);
+ prefs.gui_ptree_sel_browse = value;
}
static void
@@ -277,8 +261,7 @@ ptree_line_style_cb(GtkWidget *w, gpointer data)
{
gint value = GPOINTER_TO_INT(data);
- temp_gui_ptree_line_style = value;
- set_ptree_line_style_all(value);
+ prefs.gui_ptree_line_style = value;
}
static void
@@ -286,8 +269,7 @@ ptree_expander_style_cb(GtkWidget *w, gpointer data)
{
gint value = GPOINTER_TO_INT(data);
- temp_gui_ptree_expander_style = value;
- set_ptree_expander_style_all(value);
+ prefs.gui_ptree_expander_style = value;
}
/* XXX - need a way to set this on the fly, so that a font change takes
@@ -373,9 +355,9 @@ font_browse_cb(GtkWidget *w, gpointer data)
static void
font_browse_ok_cb(GtkWidget *w, GtkFontSelectionDialog *fs)
{
- if (temp_gui_font_name != NULL)
- g_free(temp_gui_font_name);
- temp_gui_font_name =
+ if (prefs.gui_font_name != NULL)
+ g_free(prefs.gui_font_name);
+ prefs.gui_font_name =
g_strdup(gtk_font_selection_dialog_get_font_name(
GTK_FONT_SELECTION_DIALOG(fs)));
@@ -405,51 +387,40 @@ font_browse_destroy(GtkWidget *win, gpointer data)
}
void
-gui_prefs_ok(GtkWidget *w)
+gui_prefs_fetch(GtkWidget *w)
{
- prefs.gui_scrollbar_on_right = temp_gui_scrollbar_on_right;
- prefs.gui_plist_sel_browse = temp_gui_plist_sel_browse;
- prefs.gui_ptree_sel_browse = temp_gui_ptree_sel_browse;
- prefs.gui_ptree_line_style = temp_gui_ptree_line_style;
- prefs.gui_ptree_expander_style = temp_gui_ptree_expander_style;
- if (prefs.gui_font_name != NULL)
- g_free(prefs.gui_font_name);
- prefs.gui_font_name = g_strdup(temp_gui_font_name);
-
- gui_prefs_delete(w);
}
void
-gui_prefs_save(GtkWidget *w)
+gui_prefs_apply(GtkWidget *w)
{
- gui_prefs_ok(w);
-}
+ GdkFont *font;
-void
-gui_prefs_cancel(GtkWidget *w)
-{
- /* Reset GUI preference values back to what the
- * current preferences says they should be */
- temp_gui_scrollbar_on_right = prefs.gui_scrollbar_on_right;
- temp_gui_plist_sel_browse = prefs.gui_plist_sel_browse;
- temp_gui_ptree_sel_browse = prefs.gui_ptree_sel_browse;
- temp_gui_ptree_line_style = prefs.gui_ptree_line_style;
- temp_gui_ptree_expander_style = prefs.gui_ptree_expander_style;
- if (temp_gui_font_name != NULL)
- g_free(temp_gui_font_name);
- temp_gui_font_name = g_strdup(prefs.gui_font_name);
+ font = gdk_font_load(prefs.gui_font_name);
+ if (font == NULL) {
+ /* XXX - make this a dialog box, and don't let them
+ continue! */
+ fprintf(stderr, "Can't open font %s\n", prefs.gui_font_name);
+ }
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);
-
- gui_prefs_delete(w);
+ 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
+ }
}
void
-gui_prefs_delete(GtkWidget *w)
+gui_prefs_destroy(GtkWidget *w)
{
GtkWidget *caller = gtk_widget_get_toplevel(w);
GtkWidget *fs;
@@ -462,9 +433,4 @@ gui_prefs_delete(GtkWidget *w)
/* Yes. Destroy it. */
gtk_widget_destroy(fs);
}
-
- if (temp_gui_font_name != NULL) {
- g_free(temp_gui_font_name);
- temp_gui_font_name = NULL;
- }
}
diff --git a/gtk/gui_prefs.h b/gtk/gui_prefs.h
index 3520fd24e3..3d8d70ce0d 100644
--- a/gtk/gui_prefs.h
+++ b/gtk/gui_prefs.h
@@ -1,7 +1,7 @@
/* gui_prefs.h
* Definitions for GUI preferences window
*
- * $Id: gui_prefs.h,v 1.2 2000/08/11 13:32:58 deniel Exp $
+ * $Id: gui_prefs.h,v 1.3 2000/08/21 08:09:12 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -27,9 +27,8 @@
#define __GUI_PREFS_H__
GtkWidget *gui_prefs_show(void);
-void gui_prefs_ok(GtkWidget *w);
-void gui_prefs_save(GtkWidget *w);
-void gui_prefs_cancel(GtkWidget *w);
-void gui_prefs_delete(GtkWidget *w);
+void gui_prefs_fetch(GtkWidget *w);
+void gui_prefs_apply(GtkWidget *w);
+void gui_prefs_destroy(GtkWidget *w);
#endif
diff --git a/gtk/main.c b/gtk/main.c
index e18436dc28..ec591bd7c5 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -1,6 +1,6 @@
/* main.c
*
- * $Id: main.c,v 1.142 2000/08/21 01:52:57 guy Exp $
+ * $Id: main.c,v 1.143 2000/08/21 08:09:12 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -610,66 +610,27 @@ set_plist_sel_browse(gboolean val)
gtk_clist_set_selection_mode(GTK_CLIST(packet_list), GTK_SELECTION_BROWSE);
}
}
-
-/* Set the selection mode of a given packet tree window. */
+
+/* Set the font of the packet list window. */
void
-set_ptree_sel_browse(GtkWidget *tv, gboolean val)
+set_plist_font(GdkFont *font)
{
- /* Yeah, GTK uses "browse" in the case where we do not, but oh well. I think
- * "browse" in Ethereal makes more sense than "SINGLE" in GTK+ */
- if (val) {
- gtk_clist_set_selection_mode(GTK_CLIST(tv), GTK_SELECTION_SINGLE);
- }
- else {
- gtk_clist_set_selection_mode(GTK_CLIST(tv), GTK_SELECTION_BROWSE);
- }
-}
+ GtkStyle *style;
+ int i;
-/* Set the selection mode of all packet tree windows. */
-void
-set_ptree_sel_browse_all(gboolean val)
-{
- set_ptree_sel_browse(tree_view, val);
- set_ptree_sel_browse_packet_wins(val);
-}
+ style = gtk_style_new();
+ gdk_font_unref(style->font);
+ style->font = font;
+ gdk_font_ref(font);
-/* Set the line style of a given packet tree window. */
-void
-set_ptree_line_style(GtkWidget *tv, gint style)
-{
- /* I'm using an assert here since the preferences code limits
- * the user input, both in the GUI and when reading the preferences file.
- * If the value is incorrect, it's a program error, not a user-initiated error.
- */
- g_assert(style >= GTK_CTREE_LINES_NONE && style <= GTK_CTREE_LINES_TABBED);
- gtk_ctree_set_line_style( GTK_CTREE(tv), style );
-}
+ gtk_widget_set_style(packet_list, style);
-/* Set the line style of all packet tree window. */
-void
-set_ptree_line_style_all(gint style)
-{
- set_ptree_line_style(tree_view, style);
- set_ptree_line_style_packet_wins(style);
-}
-
-/* Set the expander style of a given packet tree window. */
-void
-set_ptree_expander_style(GtkWidget *tv, gint style)
-{
- /* I'm using an assert here since the preferences code limits
- * the user input, both in the GUI and when reading the preferences file.
- * If the value is incorrect, it's a program error, not a user-initiated error.
- */
- g_assert(style >= GTK_CTREE_EXPANDER_NONE && style <= GTK_CTREE_EXPANDER_CIRCULAR);
- gtk_ctree_set_expander_style( GTK_CTREE(tv), style );
-}
-
-void
-set_ptree_expander_style_all(gint style)
-{
- set_ptree_expander_style(tree_view, style);
- set_ptree_expander_style_packet_wins(style);
+ /* Compute static column sizes to use during a "-S" capture, so that
+ the columns don't resize during a live capture. */
+ for (i = 0; i < cfile.cinfo.num_cols; i++) {
+ cfile.cinfo.col_width[i] = gdk_string_width(font,
+ get_column_longest_string(get_column_format(i)));
+ }
}
static gboolean
@@ -1391,7 +1352,6 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
*filter_bt, *filter_cm, *filter_te,
*filter_reset;
GList *filter_list = NULL;
- GtkStyle *pl_style;
GtkAccelGroup *accel;
int i;
@@ -1439,10 +1399,7 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
gtk_container_add(GTK_CONTAINER(pkt_scrollw), packet_list);
set_plist_sel_browse(prefs->gui_plist_sel_browse);
- pl_style = gtk_style_new();
- gdk_font_unref(pl_style->font);
- pl_style->font = m_r_font;
- gtk_widget_set_style(packet_list, pl_style);
+ set_plist_font(m_r_font);
gtk_widget_set_name(packet_list, "packet list");
gtk_signal_connect (GTK_OBJECT (packet_list), "click_column",
GTK_SIGNAL_FUNC(packet_list_click_column_cb), NULL);
@@ -1458,11 +1415,6 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
if (cfile.cinfo.col_fmt[i] == COL_NUMBER)
gtk_clist_set_column_justification(GTK_CLIST(packet_list), i,
GTK_JUSTIFY_RIGHT);
-
- /* Save static column sizes to use during a "-S" capture, so that
- the columns don't resize during a live capture. */
- cfile.cinfo.col_width[i] = gdk_string_width(pl_style->font,
- get_column_longest_string(get_column_format(i)));
}
gtk_widget_set_usize(packet_list, -1, pl_size);
gtk_signal_connect_object(GTK_OBJECT(packet_list), "button_press_event",
@@ -1471,6 +1423,9 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
gtk_widget_show(packet_list);
/* Tree view */
+ item_style = gtk_style_new();
+ gdk_font_unref(item_style->font);
+ item_style->font = m_r_font;
create_tree_view(tv_size, prefs, l_pane, &tv_scrollw, &tree_view,
prefs->gui_scrollbar_on_right);
gtk_signal_connect(GTK_OBJECT(tree_view), "tree-select-row",
@@ -1481,10 +1436,6 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
GTK_SIGNAL_FUNC(popup_menu_handler), gtk_object_get_data(GTK_OBJECT(popup_menu_object), PM_TREE_VIEW_KEY));
gtk_widget_show(tree_view);
- item_style = gtk_style_new();
- gdk_font_unref(item_style->font);
- item_style->font = m_r_font;
-
/* Byte view. */
create_byte_view(bv_size, l_pane, &byte_view, &bv_scrollw,
prefs->gui_scrollbar_on_right);
diff --git a/gtk/packet_win.c b/gtk/packet_win.c
index 658ab3127d..33bd71c090 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.11 2000/08/17 07:56:42 guy Exp $
+ * $Id: packet_win.c,v 1.12 2000/08/21 08:09:13 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -265,48 +265,3 @@ destroy_packet_wins(void)
gtk_widget_destroy(DataPtr->main);
}
}
-
-static void
-set_ptree_sel_browse_cb(gpointer data, gpointer user_data)
-{
- struct PacketWinData *DataPtr = (struct PacketWinData *)data;
-
- set_ptree_sel_browse(DataPtr->tree_view, *(gboolean *)user_data);
-}
-
-/* Set the selection mode of all the popup packet windows. */
-void
-set_ptree_sel_browse_packet_wins(gboolean val)
-{
- g_list_foreach(detail_windows, set_ptree_sel_browse_cb, &val);
-}
-
-static void
-set_ptree_line_style_cb(gpointer data, gpointer user_data)
-{
- struct PacketWinData *DataPtr = (struct PacketWinData *)data;
-
- set_ptree_line_style(DataPtr->tree_view, *(gint *)user_data);
-}
-
-/* Set the selection mode of all the popup packet windows. */
-void
-set_ptree_line_style_packet_wins(gint style)
-{
- g_list_foreach(detail_windows, set_ptree_line_style_cb, &style);
-}
-
-static void
-set_ptree_expander_style_cb(gpointer data, gpointer user_data)
-{
- struct PacketWinData *DataPtr = (struct PacketWinData *)data;
-
- set_ptree_expander_style(DataPtr->tree_view, *(gint *)user_data);
-}
-
-/* Set the selection mode of all the popup packet windows. */
-void
-set_ptree_expander_style_packet_wins(gint style)
-{
- g_list_foreach(detail_windows, set_ptree_expander_style_cb, &style);
-}
diff --git a/gtk/packet_win.h b/gtk/packet_win.h
index 6be5e7b530..0371d11c7a 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.3 2000/08/11 13:32:57 deniel Exp $
+ * $Id: packet_win.h,v 1.4 2000/08/21 08:09:14 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -28,8 +28,5 @@
#define __PACKET_WIN_H__
extern void new_window_cb(GtkWidget *w);
-void set_ptree_sel_browse_packet_wins(gboolean val);
-void set_ptree_line_style_packet_wins(gint style);
-void set_ptree_expander_style_packet_wins(gint style);
#endif
diff --git a/gtk/prefs_dlg.c b/gtk/prefs_dlg.c
index b18170a6d9..19a46b0e8c 100644
--- a/gtk/prefs_dlg.c
+++ b/gtk/prefs_dlg.c
@@ -1,7 +1,7 @@
/* prefs_dlg.c
* Routines for handling preferences
*
- * $Id: prefs_dlg.c,v 1.20 2000/08/17 07:56:42 guy Exp $
+ * $Id: prefs_dlg.c,v 1.21 2000/08/21 08:09:14 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -64,6 +64,7 @@
#include "prefs-int.h"
static void prefs_main_ok_cb(GtkWidget *, gpointer);
+static void prefs_main_apply_cb(GtkWidget *, gpointer);
static void prefs_main_save_cb(GtkWidget *, gpointer);
static void prefs_main_cancel_cb(GtkWidget *, gpointer);
static gboolean prefs_main_delete_cb(GtkWidget *, gpointer);
@@ -90,6 +91,13 @@ static GtkWidget *notebook;
*/
static GtkWidget *prefs_w;
+/*
+ * Save the value of the preferences as of when the preferences dialog
+ * box was first popped up, so we can revert to those values if the
+ * user selects "Cancel".
+ */
+static e_prefs saved_prefs;
+
static void
pref_show(pref_t *pref, gpointer user_data)
{
@@ -241,7 +249,7 @@ module_prefs_show(module_t *module, gpointer user_data)
void
prefs_cb(GtkWidget *w, gpointer dummy) {
GtkWidget *main_vb, *top_hb, *bbox, *prefs_nb,
- *ok_bt, *save_bt, *cancel_bt;
+ *ok_bt, *apply_bt, *save_bt, *cancel_bt;
GtkWidget *print_pg, *column_pg, *stream_pg, *gui_pg, *label;
if (prefs_w != NULL) {
@@ -250,6 +258,10 @@ prefs_cb(GtkWidget *w, gpointer dummy) {
return;
}
+ /* Save the current preferences, so we can revert to those values
+ if the user presses "Cancel". */
+ copy_prefs(&saved_prefs, &prefs);
+
prefs_w = dlg_window_new();
gtk_window_set_title(GTK_WINDOW(prefs_w), "Ethereal: Preferences");
gtk_signal_connect(GTK_OBJECT(prefs_w), "delete_event",
@@ -314,6 +326,13 @@ prefs_cb(GtkWidget *w, gpointer dummy) {
gtk_widget_grab_default(ok_bt);
gtk_widget_show(ok_bt);
+ apply_bt = gtk_button_new_with_label ("Apply");
+ gtk_signal_connect(GTK_OBJECT(apply_bt), "clicked",
+ GTK_SIGNAL_FUNC(prefs_main_apply_cb), GTK_OBJECT(prefs_w));
+ GTK_WIDGET_SET_FLAGS(apply_bt, GTK_CAN_DEFAULT);
+ gtk_box_pack_start(GTK_BOX (bbox), apply_bt, TRUE, TRUE, 0);
+ gtk_widget_show(apply_bt);
+
save_bt = gtk_button_new_with_label ("Save");
gtk_signal_connect(GTK_OBJECT(save_bt), "clicked",
GTK_SIGNAL_FUNC(prefs_main_save_cb), GTK_OBJECT(prefs_w));
@@ -470,13 +489,23 @@ prefs_main_ok_cb(GtkWidget *ok_bt, gpointer parent_w)
{
gboolean must_redissect = FALSE;
- printer_prefs_ok(gtk_object_get_data(GTK_OBJECT(parent_w), E_PRINT_PAGE_KEY));
- column_prefs_ok(gtk_object_get_data(GTK_OBJECT(parent_w), E_COLUMN_PAGE_KEY));
- stream_prefs_ok(gtk_object_get_data(GTK_OBJECT(parent_w), E_STREAM_PAGE_KEY));
- gui_prefs_ok(gtk_object_get_data(GTK_OBJECT(parent_w), E_GUI_PAGE_KEY));
+ /* Fetch the preferences (i.e., make sure all the values set in all of
+ the preferences panes have been copied to "prefs" and the registered
+ preferences). */
+ printer_prefs_fetch(gtk_object_get_data(GTK_OBJECT(parent_w), E_PRINT_PAGE_KEY));
+ column_prefs_fetch(gtk_object_get_data(GTK_OBJECT(parent_w), E_COLUMN_PAGE_KEY));
+ stream_prefs_fetch(gtk_object_get_data(GTK_OBJECT(parent_w), E_STREAM_PAGE_KEY));
+ gui_prefs_fetch(gtk_object_get_data(GTK_OBJECT(parent_w), E_GUI_PAGE_KEY));
prefs_module_foreach(module_prefs_fetch, &must_redissect);
+
+ /* Now apply those preferences. */
+ printer_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_PRINT_PAGE_KEY));
+ column_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_COLUMN_PAGE_KEY));
+ stream_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_STREAM_PAGE_KEY));
+ gui_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_GUI_PAGE_KEY));
prefs_apply_all();
- prefs_module_foreach(module_prefs_clean, NULL);
+
+ /* Now destroy the "Preferences" dialog. */
gtk_widget_destroy(GTK_WIDGET(parent_w));
if (must_redissect) {
@@ -486,20 +515,50 @@ prefs_main_ok_cb(GtkWidget *ok_bt, gpointer parent_w)
}
static void
-prefs_main_save_cb(GtkWidget *save_bt, gpointer parent_w)
+prefs_main_apply_cb(GtkWidget *apply_bt, gpointer parent_w)
{
gboolean must_redissect = FALSE;
+ /* Fetch the preferences (i.e., make sure all the values set in all of
+ the preferences panes have been copied to "prefs" and the registered
+ preferences). */
+ printer_prefs_fetch(gtk_object_get_data(GTK_OBJECT(parent_w), E_PRINT_PAGE_KEY));
+ column_prefs_fetch(gtk_object_get_data(GTK_OBJECT(parent_w), E_COLUMN_PAGE_KEY));
+ stream_prefs_fetch(gtk_object_get_data(GTK_OBJECT(parent_w), E_STREAM_PAGE_KEY));
+ gui_prefs_fetch(gtk_object_get_data(GTK_OBJECT(parent_w), E_GUI_PAGE_KEY));
+ prefs_module_foreach(module_prefs_fetch, &must_redissect);
+
+ /* Now apply those preferences. */
+ printer_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_PRINT_PAGE_KEY));
+ column_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_COLUMN_PAGE_KEY));
+ stream_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_STREAM_PAGE_KEY));
+ gui_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_GUI_PAGE_KEY));
+ prefs_module_foreach(module_prefs_fetch, &must_redissect);
+ prefs_apply_all();
+
+ if (must_redissect) {
+ /* Redissect all the packets, and re-evaluate the display filter. */
+ redissect_packets(&cfile);
+ }
+}
+
+static void
+prefs_main_save_cb(GtkWidget *save_bt, gpointer parent_w)
+{
+ gboolean must_redissect = FALSE;
int err;
char *pf_path;
- printer_prefs_save(gtk_object_get_data(GTK_OBJECT(parent_w), E_PRINT_PAGE_KEY));
- column_prefs_save(gtk_object_get_data(GTK_OBJECT(parent_w), E_COLUMN_PAGE_KEY));
- stream_prefs_save(gtk_object_get_data(GTK_OBJECT(parent_w), E_STREAM_PAGE_KEY));
- gui_prefs_save(gtk_object_get_data(GTK_OBJECT(parent_w), E_GUI_PAGE_KEY));
+ /* Fetch the preferences (i.e., make sure all the values set in all of
+ the preferences panes have been copied to "prefs" and the registered
+ preferences). */
+ printer_prefs_fetch(gtk_object_get_data(GTK_OBJECT(parent_w), E_PRINT_PAGE_KEY));
+ column_prefs_fetch(gtk_object_get_data(GTK_OBJECT(parent_w), E_COLUMN_PAGE_KEY));
+ stream_prefs_fetch(gtk_object_get_data(GTK_OBJECT(parent_w), E_STREAM_PAGE_KEY));
+ gui_prefs_fetch(gtk_object_get_data(GTK_OBJECT(parent_w), E_GUI_PAGE_KEY));
prefs_module_foreach(module_prefs_fetch, &must_redissect);
- prefs_apply_all();
- prefs_module_foreach(module_prefs_clean, NULL);
+
+ /* Write the preferencs out. */
err = write_prefs(&pf_path);
if (err != 0) {
simple_dialog(ESD_TYPE_WARN, NULL,
@@ -507,6 +566,27 @@ prefs_main_save_cb(GtkWidget *save_bt, gpointer parent_w)
strerror(err));
}
+ /* Now apply those preferences.
+ XXX - should we do this? The user didn't click "OK" or "Apply".
+ However:
+
+ 1) by saving the preferences they presumably indicate that they
+ like them;
+
+ 2) the next time they fire Ethereal up, those preferences will
+ apply;
+
+ 3) we'd have to buffer "must_redissect" so that if they do
+ "Apply" after this, we know we have to redissect;
+
+ 4) we did apply the protocol preferences, at least, in the past. */
+ printer_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_PRINT_PAGE_KEY));
+ column_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_COLUMN_PAGE_KEY));
+ stream_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_STREAM_PAGE_KEY));
+ gui_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_GUI_PAGE_KEY));
+ prefs_module_foreach(module_prefs_fetch, &must_redissect);
+ prefs_apply_all();
+
if (must_redissect) {
/* Redissect all the packets, and re-evaluate the display filter. */
redissect_packets(&cfile);
@@ -579,11 +659,21 @@ prefs_main_cancel_cb(GtkWidget *cancel_bt, gpointer parent_w)
{
gboolean must_redissect = FALSE;
- printer_prefs_cancel(gtk_object_get_data(GTK_OBJECT(parent_w), E_PRINT_PAGE_KEY));
- column_prefs_cancel(gtk_object_get_data(GTK_OBJECT(parent_w), E_COLUMN_PAGE_KEY));
- stream_prefs_cancel(gtk_object_get_data(GTK_OBJECT(parent_w), E_STREAM_PAGE_KEY));
- gui_prefs_cancel(gtk_object_get_data(GTK_OBJECT(parent_w), E_GUI_PAGE_KEY));
+ /* Free up the current preferences and copy the saved preferences to the
+ current preferences. */
+ free_prefs(&prefs);
+ copy_prefs(&prefs, &saved_prefs);
+
+ /* Now revert the registered preferences. */
prefs_module_foreach(module_prefs_revert, &must_redissect);
+
+ /* Now apply the reverted-to preferences. */
+ printer_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_PRINT_PAGE_KEY));
+ column_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_COLUMN_PAGE_KEY));
+ stream_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_STREAM_PAGE_KEY));
+ gui_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_GUI_PAGE_KEY));
+ prefs_apply_all();
+
gtk_widget_destroy(GTK_WIDGET(parent_w));
if (must_redissect) {
@@ -592,21 +682,30 @@ prefs_main_cancel_cb(GtkWidget *cancel_bt, gpointer parent_w)
}
}
+/* Treat this as a cancel, by calling "prefs_main_cancel_cb()".
+ XXX - that'll destroy the Preferences dialog; will that upset
+ a higher-level handler that says "OK, we've been asked to delete
+ this, so destroy it"? */
static gboolean
prefs_main_delete_cb(GtkWidget *prefs_w, gpointer dummy)
{
- printer_prefs_delete(gtk_object_get_data(GTK_OBJECT(prefs_w), E_PRINT_PAGE_KEY));
- column_prefs_delete(gtk_object_get_data(GTK_OBJECT(prefs_w), E_COLUMN_PAGE_KEY));
- stream_prefs_delete(gtk_object_get_data(GTK_OBJECT(prefs_w), E_STREAM_PAGE_KEY));
- gui_prefs_delete(gtk_object_get_data(GTK_OBJECT(prefs_w), E_GUI_PAGE_KEY));
+ prefs_main_cancel_cb(NULL, prefs_w);
return FALSE;
}
static void
prefs_main_destroy_cb(GtkWidget *win, gpointer user_data)
{
- /* XXX - call the delete callback? Or move its stuff here and
- get rid of it? */
+ /* Let the preference tabs clean up anything they've done. */
+ printer_prefs_destroy(gtk_object_get_data(GTK_OBJECT(prefs_w), E_PRINT_PAGE_KEY));
+ column_prefs_destroy(gtk_object_get_data(GTK_OBJECT(prefs_w), E_COLUMN_PAGE_KEY));
+ stream_prefs_destroy(gtk_object_get_data(GTK_OBJECT(prefs_w), E_STREAM_PAGE_KEY));
+ gui_prefs_destroy(gtk_object_get_data(GTK_OBJECT(prefs_w), E_GUI_PAGE_KEY));
+
+ /* Free up the saved preferences (both for "prefs" and for registered
+ preferences). */
+ free_prefs(&saved_prefs);
+ prefs_module_foreach(module_prefs_clean, NULL);
/* Note that we no longer have a "Preferences" dialog box. */
prefs_w = NULL;
diff --git a/gtk/print_prefs.c b/gtk/print_prefs.c
index 0e63995f21..8ae97d972d 100644
--- a/gtk/print_prefs.c
+++ b/gtk/print_prefs.c
@@ -1,7 +1,7 @@
/* print_prefs.c
* Dialog boxes for preferences for printing
*
- * $Id: print_prefs.c,v 1.6 2000/08/11 13:33:01 deniel Exp $
+ * $Id: print_prefs.c,v 1.7 2000/08/21 08:09:15 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -234,35 +234,30 @@ printer_opts_fs_destroy_cb(GtkWidget *win, gpointer data)
}
void
-printer_prefs_ok(GtkWidget *w)
+printer_prefs_fetch(GtkWidget *w)
{
- if(prefs.pr_cmd) g_free(prefs.pr_cmd);
+ if (prefs.pr_cmd)
+ g_free(prefs.pr_cmd);
prefs.pr_cmd =
- g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_object_get_data(GTK_OBJECT(w),
- PRINT_CMD_TE_KEY))));
+ g_strdup(gtk_entry_get_text(
+ GTK_ENTRY(gtk_object_get_data(GTK_OBJECT(w),
+ PRINT_CMD_TE_KEY))));
- if(prefs.pr_file) g_free(prefs.pr_file);
+ if (prefs.pr_file)
+ g_free(prefs.pr_file);
prefs.pr_file =
- g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_object_get_data(GTK_OBJECT(w),
- PRINT_FILE_TE_KEY))));
-
- printer_prefs_delete(w);
-}
-
-void
-printer_prefs_save(GtkWidget *w)
-{
- printer_prefs_ok(w);
+ g_strdup(gtk_entry_get_text(
+ GTK_ENTRY(gtk_object_get_data(GTK_OBJECT(w),
+ PRINT_FILE_TE_KEY))));
}
void
-printer_prefs_cancel(GtkWidget *w)
+printer_prefs_apply(GtkWidget *w)
{
- printer_prefs_delete(w);
}
void
-printer_prefs_delete(GtkWidget *w)
+printer_prefs_destroy(GtkWidget *w)
{
GtkWidget *caller = gtk_widget_get_toplevel(w);
GtkWidget *fs;
diff --git a/gtk/print_prefs.h b/gtk/print_prefs.h
index 8d0e213ce1..e09813866d 100644
--- a/gtk/print_prefs.h
+++ b/gtk/print_prefs.h
@@ -1,7 +1,7 @@
/* print_prefs.h
* Definitions for print preferences window
*
- * $Id: print_prefs.h,v 1.4 2000/08/11 13:32:56 deniel Exp $
+ * $Id: print_prefs.h,v 1.5 2000/08/21 08:09:15 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -27,9 +27,8 @@
#define __PRINT_PREFS_H__
GtkWidget *printer_prefs_show(void);
-void printer_prefs_ok(GtkWidget *w);
-void printer_prefs_save(GtkWidget *w);
-void printer_prefs_cancel(GtkWidget *w);
-void printer_prefs_delete(GtkWidget *w);
+void printer_prefs_fetch(GtkWidget *w);
+void printer_prefs_apply(GtkWidget *w);
+void printer_prefs_destroy(GtkWidget *w);
#endif
diff --git a/gtk/proto_draw.c b/gtk/proto_draw.c
index 630458fbff..67239304b5 100644
--- a/gtk/proto_draw.c
+++ b/gtk/proto_draw.c
@@ -1,7 +1,7 @@
/* gtkpacket.c
* Routines for GTK+ packet display
*
- * $Id: proto_draw.c,v 1.17 2000/04/27 20:39:21 guy Exp $
+ * $Id: proto_draw.c,v 1.18 2000/08/21 08:09:16 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -190,6 +190,133 @@ packet_hex_print(GtkText *bv, guint8 *pd, gint len, gint bstart, gint blen,
}
}
+/* List of all protocol tree widgets, so we can globally set the selection
+ mode, line style, expander style, and font of all of them. */
+static GList *ptree_widgets;
+
+/* Add a protocol tree widget to the list of protocol tree widgets. */
+static void forget_ptree_widget(GtkWidget *ptreew, gpointer data);
+
+void
+remember_ptree_widget(GtkWidget *ptreew)
+{
+ ptree_widgets = g_list_append(ptree_widgets, ptreew);
+
+ /* Catch the "destroy" event on the widget, so that we remove it from
+ the list when it's destroyed. */
+ gtk_signal_connect(GTK_OBJECT(ptreew), "destroy",
+ GTK_SIGNAL_FUNC(forget_ptree_widget), NULL);
+}
+
+/* Remove a scrolled window from the list of scrolled windows. */
+static void
+forget_ptree_widget(GtkWidget *ptreew, gpointer data)
+{
+ ptree_widgets = g_list_remove(ptree_widgets, ptreew);
+}
+
+/* Set the selection mode of a given packet tree window. */
+static void
+set_ptree_sel_browse(GtkWidget *ptreew, gboolean val)
+{
+ /* Yeah, GTK uses "browse" in the case where we do not, but oh well.
+ I think "browse" in Ethereal makes more sense than "SINGLE" in
+ GTK+ */
+ if (val) {
+ gtk_clist_set_selection_mode(GTK_CLIST(ptreew),
+ GTK_SELECTION_SINGLE);
+ }
+ else {
+ gtk_clist_set_selection_mode(GTK_CLIST(ptreew),
+ GTK_SELECTION_BROWSE);
+ }
+}
+
+static void
+set_ptree_sel_browse_cb(gpointer data, gpointer user_data)
+{
+ set_ptree_sel_browse((GtkWidget *)data, *(gboolean *)user_data);
+}
+
+/* Set the selection mode of all packet tree windows. */
+void
+set_ptree_sel_browse_all(gboolean val)
+{
+ g_list_foreach(ptree_widgets, set_ptree_sel_browse_cb, &val);
+}
+
+/* Set the line style of a given packet tree window. */
+static void
+set_ptree_line_style(GtkWidget *ptreew, gint style)
+{
+ /* I'm using an assert here since the preferences code limits
+ * the user input, both in the GUI and when reading the preferences file.
+ * If the value is incorrect, it's a program error, not a user-initiated error.
+ */
+ g_assert(style >= GTK_CTREE_LINES_NONE && style <= GTK_CTREE_LINES_TABBED);
+ gtk_ctree_set_line_style(GTK_CTREE(ptreew), style);
+}
+
+static void
+set_ptree_line_style_cb(gpointer data, gpointer user_data)
+{
+ set_ptree_line_style((GtkWidget *)data, *(gint *)user_data);
+}
+
+/* Set the line style of all packet tree window. */
+void
+set_ptree_line_style_all(gint style)
+{
+ g_list_foreach(ptree_widgets, set_ptree_line_style_cb, &style);
+}
+
+/* Set the expander style of a given packet tree window. */
+static void
+set_ptree_expander_style(GtkWidget *ptreew, gint style)
+{
+ /* I'm using an assert here since the preferences code limits
+ * the user input, both in the GUI and when reading the preferences file.
+ * If the value is incorrect, it's a program error, not a user-initiated error.
+ */
+ g_assert(style >= GTK_CTREE_EXPANDER_NONE && style <= GTK_CTREE_EXPANDER_CIRCULAR);
+ gtk_ctree_set_expander_style(GTK_CTREE(ptreew), style);
+}
+
+static void
+set_ptree_expander_style_cb(gpointer data, gpointer user_data)
+{
+ set_ptree_expander_style((GtkWidget *)data, *(gint *)user_data);
+}
+
+void
+set_ptree_expander_style_all(gint style)
+{
+ g_list_foreach(ptree_widgets, set_ptree_expander_style_cb, &style);
+}
+
+static void
+set_ptree_style_cb(gpointer data, gpointer user_data)
+{
+ gtk_widget_set_style((GtkWidget *)data, (GtkStyle *)user_data);
+}
+
+void
+set_ptree_font_all(GdkFont *font)
+{
+ GtkStyle *style;
+
+ style = gtk_style_new();
+ gdk_font_unref(style->font);
+ style->font = font;
+ gdk_font_ref(font);
+
+ g_list_foreach(ptree_widgets, set_ptree_style_cb, style);
+
+ /* Now nuke the old style and replace it with the new one. */
+ gtk_style_unref(item_style);
+ item_style = style;
+}
+
void
create_tree_view(gint tv_size, e_prefs *prefs, GtkWidget *pane,
GtkWidget **tv_scrollw_p, GtkWidget **tree_view_p, int pos)
@@ -214,6 +341,8 @@ create_tree_view(gint tv_size, e_prefs *prefs, GtkWidget *pane,
set_ptree_sel_browse(tree_view, prefs->gui_ptree_sel_browse);
set_ptree_line_style(tree_view, prefs->gui_ptree_line_style);
set_ptree_expander_style(tree_view, prefs->gui_ptree_expander_style);
+ gtk_widget_set_style(tree_view, item_style);
+ remember_ptree_widget(tree_view);
*tree_view_p = tree_view;
*tv_scrollw_p = tv_scrollw;
@@ -334,7 +463,6 @@ proto_tree_draw_node(GNode *node, gpointer data)
is_leaf, is_expanded );
gtk_ctree_node_set_row_data( GTK_CTREE(info.ctree), parent, fi );
- gtk_ctree_node_set_row_style( GTK_CTREE(info.ctree), parent, item_style);
if (!is_leaf) {
info.ctree_node = parent;
diff --git a/gtk/proto_draw.h b/gtk/proto_draw.h
index 4708b2dd7d..59c305efb7 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.6 2000/03/02 07:05:57 guy Exp $
+ * $Id: proto_draw.h,v 1.7 2000/08/21 08:09:16 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -39,4 +39,10 @@ void proto_tree_draw(proto_tree *protocol_tree, GtkWidget *tree_view);
void expand_all_tree(proto_tree *protocol_tree, GtkWidget *tree_view);
void collapse_all_tree(proto_tree *protocol_tree, GtkWidget *tree_view);
+void remember_ptree_widget(GtkWidget *);
+void set_ptree_sel_browse_all(gboolean);
+void set_ptree_line_style_all(gint style);
+void set_ptree_expander_style_all(gint style);
+void set_ptree_font_all(GdkFont *font);
+
#endif
diff --git a/gtk/stream_prefs.c b/gtk/stream_prefs.c
index 6bbd17680e..d11d7a12b0 100644
--- a/gtk/stream_prefs.c
+++ b/gtk/stream_prefs.c
@@ -1,7 +1,7 @@
/* stream_prefs.c
* Dialog boxes for preferences for the stream window
*
- * $Id: stream_prefs.c,v 1.2 2000/08/11 13:33:00 deniel Exp $
+ * $Id: stream_prefs.c,v 1.3 2000/08/21 08:09:16 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -183,29 +183,20 @@ copy_color_vals(GdkColor *target, GdkColor *source)
}
void
-stream_prefs_ok(GtkWidget *w)
+stream_prefs_fetch(GtkWidget *w)
{
copy_color_vals(&prefs.st_client_fg, &tcolors[CFG_IDX]);
copy_color_vals(&prefs.st_client_bg, &tcolors[CBG_IDX]);
copy_color_vals(&prefs.st_server_fg, &tcolors[SFG_IDX]);
copy_color_vals(&prefs.st_server_bg, &tcolors[SBG_IDX]);
-
- stream_prefs_delete(w);
-}
-
-void
-stream_prefs_save(GtkWidget *w)
-{
- stream_prefs_ok(w);
}
void
-stream_prefs_cancel(GtkWidget *w)
+stream_prefs_apply(GtkWidget *w)
{
- stream_prefs_delete(w);
}
void
-stream_prefs_delete(GtkWidget *w)
+stream_prefs_destroy(GtkWidget *w)
{
}
diff --git a/gtk/stream_prefs.h b/gtk/stream_prefs.h
index e648cc66f1..b9ea1f9156 100644
--- a/gtk/stream_prefs.h
+++ b/gtk/stream_prefs.h
@@ -1,7 +1,7 @@
/* stream_prefs.h
* Definitions for stream preferences window
*
- * $Id: stream_prefs.h,v 1.2 2000/08/11 13:32:56 deniel Exp $
+ * $Id: stream_prefs.h,v 1.3 2000/08/21 08:09:17 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -27,9 +27,8 @@
#define __STREAM_PREFS_H__
GtkWidget *stream_prefs_show(void);
-void stream_prefs_ok(GtkWidget *w);
-void stream_prefs_save(GtkWidget *w);
-void stream_prefs_cancel(GtkWidget *w);
-void stream_prefs_delete(GtkWidget *w);
+void stream_prefs_fetch(GtkWidget *w);
+void stream_prefs_apply(GtkWidget *w);
+void stream_prefs_destroy(GtkWidget *w);
#endif