The rest of the Follow UDP Stream check-in
[obnox/wireshark/wip.git] / gtk / gui_prefs.c
index 93bdef8fa081a0decead0ef0ef018db9ac6b2066..4ef8687c6366648633c3b72add1f886715b39500 100644 (file)
@@ -1,10 +1,10 @@
 /* gui_prefs.c
  * Dialog box for GUI preferences
  *
- * $Id: gui_prefs.c,v 1.64 2004/02/12 22:24:28 guy Exp $
+ * $Id$
  *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
  * Copyright 1998 Gerald Combs
  *
  * This program is free software; you can redistribute it and/or
 #include "gtkglobals.h"
 #include "help_dlg.h"
 #include "supported_protos_dlg.h"
-#include "prefs.h"
+#include <epan/prefs.h>
 #include "prefs_dlg.h"
-#include "ui_util.h"
+#include "gui_utils.h"
 #include "simple_dialog.h"
 #include "dlg_utils.h"
 #include "proto_draw.h"
 #include "main.h"
-#include "packet_list.h"
 #include "compat_macros.h"
+#include "font_utils.h"
+#include "packet_list.h"
 #include "toolbar.h"
 #include "recent.h"
+#include "webbrowser.h"
+
 
 static gint fetch_enum_value(gpointer control, const enum_val_t *enumvals);
 static gint fileopen_dir_changed_cb(GtkWidget *myentry _U_, GdkEvent *event, gpointer parent_w);
+static gint fileopen_preview_changed_cb(GtkWidget *myentry _U_, GdkEvent *event, gpointer parent_w);
 static void fileopen_selected_cb(GtkWidget *mybutton_rb _U_, gpointer parent_w);
 static gint recent_files_count_changed_cb(GtkWidget *recent_files_entry _U_, 
                                          GdkEvent *event _U_, gpointer parent_w);
-
-#define SCROLLBAR_PLACEMENT_KEY                "scrollbar_placement"
 #define PLIST_SEL_BROWSE_KEY           "plist_sel_browse"
 #define PTREE_SEL_BROWSE_KEY           "ptree_sel_browse"
-#if GTK_MAJOR_VERSION < 2
-#define PTREE_LINE_STYLE_KEY           "ptree_line_style"
-#define PTREE_EXPANDER_STYLE_KEY       "ptree_expander_style"
-#else
-#define ALTERN_COLORS_KEY               "altern_colors"
-#endif
-#define HEX_DUMP_HIGHLIGHT_STYLE_KEY   "hex_dump_highlight_style"
 #define GEOMETRY_POSITION_KEY          "geometry_position"
 #define GEOMETRY_SIZE_KEY              "geometry_size"
 #define GEOMETRY_MAXIMIZED_KEY         "geometry_maximized"
 
+#define GUI_CONSOLE_OPEN_KEY "console_open"
 #define GUI_FILEOPEN_KEY       "fileopen_behavior"
+#define GUI_FILEOPEN_PREVIEW_KEY "fileopen_preview_timeout"
 #define GUI_RECENT_FILES_COUNT_KEY "recent_files_count"
 #define GUI_FILEOPEN_DIR_KEY   "fileopen_directory"
-
-#define GUI_TOOLBAR_STYLE_KEY  "toolbar_style"
-
-static const enum_val_t scrollbar_placement_vals[] = {
-       { "Left",  FALSE },
-       { "Right", TRUE },
-       { NULL,    0 }
+#define GUI_ASK_UNSAVED_KEY     "ask_unsaved"
+#define GUI_WEBBROWSER_KEY         "webbrowser"
+#define GUI_FIND_WRAP_KEY       "find_wrap"
+#define GUI_USE_PREF_SAVE_KEY   "use_pref_save"
+
+static const enum_val_t scrollbar_placement_vals[] _U_ = {
+       { "FALSE", "Left", FALSE },
+       { "TRUE",  "Right", TRUE },
+       { NULL,    NULL,    0 }
 };
 
 static const enum_val_t selection_mode_vals[] = {
-       { "Selects", FALSE },
-       { "Browses", TRUE },
-       { NULL,      0 }
+       { "FALSE", "Selects", FALSE },
+       { "TRUE",  "Browses", TRUE },
+       { NULL,    NULL,      0 }
 };
 
 #if GTK_MAJOR_VERSION < 2
 static const enum_val_t line_style_vals[] = {
-       { "None",   0 },
-       { "Solid",  1 },
-       { "Dotted", 2 },
-       { "Tabbed", 3 },
-       { NULL,     0 }
+       { "NONE",   "None",   0 },
+       { "SOLID",  "Solid",  1 },
+       { "DOTTED", "Dotted", 2 },
+       { "TABBED", "Tabbed", 3 },
+       { NULL,     NULL,     0 }
 };
 
 static const enum_val_t expander_style_vals[] = {
-       { "None",     0 },
-       { "Square",   1 },
-       { "Triangle", 2 },
-       { "Circular", 3 },
-       { NULL,       0 }
+       { "NONE",     "None",     0 },
+       { "SQUARE",   "Square",   1 },
+       { "TRIANGLE", "Triangle", 2 },
+       { "CIRCULAR", "Circular", 3 },
+       { NULL,       NULL,       0 }
 };
 #else
-static const enum_val_t altern_colors_vals[] = {
-       { "No",  FALSE },
-       { "Yes",  TRUE },
-       { NULL,      0 }
+static const enum_val_t altern_colors_vals[] _U_ = {
+       { "FALSE", "No",  FALSE },
+       { "TRUE",  "Yes", TRUE },
+       { NULL,    NULL,  0 }
 };
 #endif
 
-static const enum_val_t highlight_style_vals[] = {
-       { "Bold",     FALSE },
-       { "Inverse",  TRUE },
-       { NULL,       0 }
+static const enum_val_t filter_toolbar_placement_vals[] _U_ = {
+       { "FALSE", "Below the main toolbar", FALSE },
+       { "TRUE",  "Insert into statusbar",  TRUE },
+       { NULL,    NULL,                     0 }
 };
 
-static const enum_val_t toolbar_style_vals[] = {
-       { "Icons only",     TB_STYLE_ICONS },
-       { "Text only",      TB_STYLE_TEXT },
-       { "Icons & Text",   TB_STYLE_BOTH },
-       { NULL,             0 }
+static const enum_val_t highlight_style_vals[] _U_ = {
+       { "FALSE", "Bold",     FALSE },
+       { "TRUE",  "Inverse",  TRUE },
+       { NULL,    NULL,       0 }
 };
 
+
+static const enum_val_t toolbar_style_vals[] _U_ = {
+       { "ICONS", "Icons only",     TB_STYLE_ICONS },
+       { "TEXT",  "Text only",      TB_STYLE_TEXT },
+       { "BOTH",  "Icons & Text",   TB_STYLE_BOTH },
+       { NULL,    NULL,             0 }
+};
+
+#ifdef _WIN32
+static const enum_val_t gui_console_open_vals[] = {
+       { "NEVER",     "Never",                      console_open_never },
+       { "AUTOMATIC", "Automatic (advanced user)",  console_open_auto },
+       { "ALWAYS",    "Always (debugging)",         console_open_always },
+       { NULL,        NULL,                         0 }
+};
+#endif
+
 static const enum_val_t gui_fileopen_vals[] = {
-       { "Remember last directory", FO_STYLE_LAST_OPENED },
-       { "Always start in directory:", FO_STYLE_SPECIFIED },
-       { NULL,    0 }
+       { "LAST_OPENED", "Remember last directory", FO_STYLE_LAST_OPENED },
+       { "SPECIFIED",   "Always start in:",        FO_STYLE_SPECIFIED },
+       { NULL,          NULL,                      0 }
 };
 
 /* Set to FALSE initially; set to TRUE if the user ever hits "OK" on
@@ -143,137 +158,167 @@ static GtkWidget *font_browse_w;
 /* Used to contain the string from the Recent Files Count Max pref item */
 static char recent_files_count_max_str[128] = "";
 
+/* Used to contain the string from the Open File preview timeout pref item */
+static char open_file_preview_str[128] = "";
+
 #if GTK_MAJOR_VERSION < 2
-#define GUI_TABLE_ROWS 10
+#define GUI_TABLE_ROWS 5
 #else
-#define GUI_TABLE_ROWS 9
+#define GUI_TABLE_ROWS 4
 #endif
 
 GtkWidget*
 gui_prefs_show(void)
 {
-       GtkWidget *main_tb, *main_vb, *hbox;
-       GtkWidget *scrollbar_om, *plist_browse_om;
-       GtkWidget *ptree_browse_om, *highlight_style_om;
-       GtkWidget *fileopen_rb, *fileopen_dir_te, *toolbar_style_om;
-       GtkWidget *recent_files_count_max_te;
-       GtkWidget *save_position_cb, *save_size_cb, *save_maximized_cb;
-#if GTK_MAJOR_VERSION < 2
-       GtkWidget *expander_style_om, *line_style_om;
-#else
-       GtkWidget *altern_colors_om;
+       GtkWidget *main_tb, *main_vb;
+       GtkWidget *plist_browse_om;
+       GtkWidget *ptree_browse_om;
+#ifdef _WIN32
+       GtkWidget *console_open_om;
 #endif
+       GtkWidget *fileopen_rb, *fileopen_dir_te, *fileopen_preview_te;
+       GtkWidget *recent_files_count_max_te, *ask_unsaved_cb, *find_wrap_cb;
+       GtkWidget *use_pref_save_cb;
+       GtkWidget *webbrowser_te;
+       GtkWidget *save_position_cb, *save_size_cb, *save_maximized_cb;
+
+       GtkTooltips *tooltips = gtk_tooltips_new();
+
        int        pos = 0;
        char       current_val_str[128];
 
        /* The font haven't been changed yet. */
        font_changed = FALSE;
 
+       /* The columns haven't been changed yet */
+       cfile.cinfo.columns_changed = FALSE;
+
        /* Main vertical box */
        main_vb = gtk_vbox_new(FALSE, 7);
        gtk_container_border_width( GTK_CONTAINER(main_vb), 5 );
 
-       /* Main horizontal box  */
-       /* XXX - Is there a better way to center the table? */
-       hbox = gtk_hbox_new(FALSE, 7);
-       gtk_box_pack_start (GTK_BOX(main_vb), hbox, TRUE, FALSE, 0);
-
-       /* Main table */
-       main_tb = gtk_table_new(GUI_TABLE_ROWS, 2, FALSE);
-       gtk_box_pack_start( GTK_BOX(hbox), main_tb, TRUE, FALSE, 0 );
-       gtk_table_set_row_spacings( GTK_TABLE(main_tb), 10 );
-       gtk_table_set_col_spacings( GTK_TABLE(main_tb), 15 );
-       gtk_table_set_col_spacing( GTK_TABLE(main_tb), 0, 50 );
-
-       /* Scrollbar placement */
-       scrollbar_om = create_preference_option_menu(main_tb, pos++,
-           "Vertical scrollbar placement:", NULL, scrollbar_placement_vals,
-           prefs.gui_scrollbar_on_right);
-       OBJECT_SET_DATA(main_vb, SCROLLBAR_PLACEMENT_KEY, scrollbar_om);
+        /* Main table */
+        main_tb = gtk_table_new(GUI_TABLE_ROWS, 2, FALSE);
+        gtk_box_pack_start(GTK_BOX(main_vb), main_tb, FALSE, FALSE, 0);
+        gtk_table_set_row_spacings(GTK_TABLE(main_tb), 10);
+        gtk_table_set_col_spacings(GTK_TABLE(main_tb), 15);
 
        /* Packet list selection browseable */
        plist_browse_om = create_preference_option_menu(main_tb, pos++,
            "Packet list selection mode:", NULL, selection_mode_vals,
            prefs.gui_plist_sel_browse);
+       gtk_tooltips_set_tip(tooltips, plist_browse_om, "Choose to browse "
+               "or select a packet for detailed dissection.", NULL);
        OBJECT_SET_DATA(main_vb, PLIST_SEL_BROWSE_KEY, plist_browse_om);
 
        /* Proto tree selection browseable */
        ptree_browse_om = create_preference_option_menu(main_tb, pos++,
            "Protocol tree selection mode:", NULL, selection_mode_vals,
            prefs.gui_ptree_sel_browse);
+       gtk_tooltips_set_tip(tooltips, ptree_browse_om, "Choose to browse "
+               "or select.", NULL);
        OBJECT_SET_DATA(main_vb, PTREE_SEL_BROWSE_KEY, ptree_browse_om);
 
-#if GTK_MAJOR_VERSION < 2
-       /* Tree line style */
-       line_style_om = create_preference_option_menu(main_tb, pos++,
-           "Tree line style:", NULL, line_style_vals,
-           prefs.gui_ptree_line_style);
-       OBJECT_SET_DATA(main_vb, PTREE_LINE_STYLE_KEY, line_style_om);
-
-       /* Tree expander style */
-       expander_style_om = create_preference_option_menu(main_tb, pos++,
-           "Tree expander style:", NULL, expander_style_vals,
-           prefs.gui_ptree_expander_style);
-       OBJECT_SET_DATA(main_vb, PTREE_EXPANDER_STYLE_KEY, expander_style_om);
-#else
-       /* Alternating row colors in list and tree views */
-       altern_colors_om = create_preference_option_menu(main_tb, pos++,
-           "Alternating row colors in lists and trees:", NULL,
-           altern_colors_vals, prefs.gui_altern_colors);
-       OBJECT_SET_DATA(main_vb, ALTERN_COLORS_KEY, altern_colors_om);
-#endif
-
-       /* Hex Dump highlight style */
-       highlight_style_om = create_preference_option_menu(main_tb, pos++,
-           "Hex display highlight style:", NULL, highlight_style_vals,
-           prefs.gui_hex_dump_highlight_style);
-       OBJECT_SET_DATA(main_vb, HEX_DUMP_HIGHLIGHT_STYLE_KEY,
-           highlight_style_om);
-
-       /* Toolbar prefs */
-       toolbar_style_om = create_preference_option_menu(main_tb, pos++,
-           "Toolbar style:", NULL, toolbar_style_vals,
-           prefs.gui_toolbar_main_style);
-       OBJECT_SET_DATA(main_vb, GUI_TOOLBAR_STYLE_KEY,
-           toolbar_style_om);
-
        /* Geometry prefs */
        save_position_cb = create_preference_check_button(main_tb, pos++,
            "Save window position:", NULL, prefs.gui_geometry_save_position);
+       gtk_tooltips_set_tip(tooltips, save_position_cb, "Whether to save the "
+               "position of the main window.", NULL);
        OBJECT_SET_DATA(main_vb, GEOMETRY_POSITION_KEY, save_position_cb);
 
        save_size_cb = create_preference_check_button(main_tb, pos++,
            "Save window size:", NULL, prefs.gui_geometry_save_size);
+       gtk_tooltips_set_tip(tooltips, save_size_cb, "Whether to save the "
+               "size of the main window.", NULL);
        OBJECT_SET_DATA(main_vb, GEOMETRY_SIZE_KEY, save_size_cb);
 
        save_maximized_cb = create_preference_check_button(main_tb, pos++,
            "Save maximized state:", NULL, prefs.gui_geometry_save_maximized);
+       gtk_tooltips_set_tip(tooltips, save_maximized_cb, "Whether to save the "
+               "maximed state of the main window.", NULL);
        OBJECT_SET_DATA(main_vb, GEOMETRY_MAXIMIZED_KEY, save_maximized_cb);
 
+#ifdef _WIN32
+       /* How the console window should be opened */
+       console_open_om = create_preference_option_menu(main_tb, pos++,
+               "Open a console window", NULL, gui_console_open_vals, 
+               prefs.gui_console_open);
+       gtk_tooltips_set_tip(tooltips, console_open_om, "Whether to open a console window "
+               "(Automatic will open a console if messages appear).", NULL);
+       OBJECT_SET_DATA(main_vb, GUI_CONSOLE_OPEN_KEY, console_open_om);
+#endif
+
        /* Allow user to select where they want the File Open dialog to open to
         * by default */
        fileopen_rb = create_preference_radio_buttons(main_tb, pos++,
-           "File Open dialog behavior:", NULL, gui_fileopen_vals,
+           "\"File Open\" dialog behavior:", 
+        "Which directory the \"File Open\" dialog should start with.", gui_fileopen_vals,
            prefs.gui_fileopen_style);
 
        /* Directory to default File Open dialog to */
-       fileopen_dir_te = create_preference_entry(main_tb, pos++, "Directory:",
-           NULL, prefs.gui_fileopen_dir);
+       fileopen_dir_te = create_preference_entry(main_tb, pos++, 
+        "Directory:", NULL, prefs.gui_fileopen_dir);
+       gtk_tooltips_set_tip(tooltips, fileopen_dir_te,
+               "The \"File Open\" dialog defaults always to this directory.", NULL);
        OBJECT_SET_DATA(main_vb, GUI_FILEOPEN_KEY, fileopen_rb);
        OBJECT_SET_DATA(main_vb, GUI_FILEOPEN_DIR_KEY, fileopen_dir_te);
        SIGNAL_CONNECT(fileopen_rb, "clicked", fileopen_selected_cb, main_vb);
        SIGNAL_CONNECT(fileopen_dir_te, "focus-out-event",
            fileopen_dir_changed_cb, main_vb);
 
+       /* File Open dialog preview timeout */
+       fileopen_preview_te = create_preference_entry(main_tb, pos++,
+           "\"File Open\" preview timeout:", "Timeout, until preview gives up scanning the capture file content.", open_file_preview_str);
+       g_snprintf(current_val_str, 128, "%d", prefs.gui_fileopen_preview);
+       gtk_entry_set_text(GTK_ENTRY(fileopen_preview_te), current_val_str);
+       gtk_tooltips_set_tip(tooltips, fileopen_preview_te, 
+        "Reading preview data in the \"File Open\" dialog will be stopped after given seconds.", NULL);
+       OBJECT_SET_DATA(main_vb, GUI_FILEOPEN_PREVIEW_KEY, fileopen_preview_te);
+       SIGNAL_CONNECT(fileopen_preview_te, "focus_out_event", fileopen_preview_changed_cb, main_vb);
+
        /* Number of entries in the recent_files list ... */
        recent_files_count_max_te = create_preference_entry(main_tb, pos++,
-           "Recent Files Count Max:", "Maximum number of recent files", recent_files_count_max_str);
-       sprintf(current_val_str, "%d", prefs.gui_recent_files_count_max);
+           "\"Open Recent\" max. list entries:", "Maximum number of recent files", recent_files_count_max_str);
+       g_snprintf(current_val_str, 128, "%d", prefs.gui_recent_files_count_max);
        gtk_entry_set_text(GTK_ENTRY(recent_files_count_max_te), current_val_str);
+       gtk_tooltips_set_tip(tooltips, recent_files_count_max_te, 
+        "Maximum number of entries in the \"File/Open Recent\" list.", NULL);
        OBJECT_SET_DATA(main_vb, GUI_RECENT_FILES_COUNT_KEY, recent_files_count_max_te);
        SIGNAL_CONNECT(recent_files_count_max_te, "focus_out_event", recent_files_count_changed_cb, main_vb);
 
-       fileopen_selected_cb(NULL, main_vb);        
+       fileopen_selected_cb(NULL, main_vb);
+
+       /* ask for unsaved capture files? */
+       ask_unsaved_cb = create_preference_check_button(main_tb, pos++,
+           "Ask for unsaved capture files:", NULL, prefs.gui_ask_unsaved);
+       gtk_tooltips_set_tip(tooltips, ask_unsaved_cb, "Whether a dialog should "
+               "pop up in case of an unsaved capture file.", NULL);
+       OBJECT_SET_DATA(main_vb, GUI_ASK_UNSAVED_KEY, ask_unsaved_cb);
+
+       /* do we want to wrap when searching for data? */
+       find_wrap_cb = create_preference_check_button(main_tb, pos++,
+           "Wrap to end/beginning of file during a find:", NULL, prefs.gui_find_wrap);
+       gtk_tooltips_set_tip(tooltips, find_wrap_cb, "Whether a search should "
+               "wrap in a capture file.", NULL);
+       OBJECT_SET_DATA(main_vb, GUI_FIND_WRAP_KEY, find_wrap_cb);
+
+       /* show an explicit Save button for settings dialogs (preferences and alike)? */
+       use_pref_save_cb = create_preference_check_button(main_tb, pos++,
+           "Settings dialogs show a save button:", NULL, prefs.gui_use_pref_save);
+       gtk_tooltips_set_tip(tooltips, use_pref_save_cb, 
+                "Whether the various settings dialogs (e.g. Preferences) should "
+               "use an explicit save button - for advanced users.", NULL);
+       OBJECT_SET_DATA(main_vb, GUI_USE_PREF_SAVE_KEY, use_pref_save_cb);
+
+       /* Webbrowser */
+       if (browser_needs_pref()) {
+           webbrowser_te = create_preference_entry(main_tb, pos++, 
+            "Web browser command:", NULL, prefs.gui_webbrowser);
+           gtk_entry_set_text(GTK_ENTRY(webbrowser_te), prefs.gui_webbrowser);
+           gtk_tooltips_set_tip(tooltips, webbrowser_te, "Command line to "
+               "desired browser.", NULL);
+           OBJECT_SET_DATA(main_vb, GUI_WEBBROWSER_KEY, webbrowser_te);
+       }
 
        /* Show 'em what we got */
        gtk_widget_show_all(main_vb);
@@ -286,38 +331,8 @@ gui_prefs_show(void)
 GtkWidget *
 gui_font_prefs_show(void)
 {
-#if 0
-#if GTK_MAJOR_VERSION < 2
-       static gchar *fixedwidths[] = { "c", "m", NULL };
-#endif
-#endif
-
-       /* Now create a new widget. */
+       /* Create the font selection widget. */
        font_browse_w = (GtkWidget *) gtk_font_selection_new();
-
-    /*gtk_font_selection_set_preview_text(GTK_FONT_SELECTION(font_browse_w), 
-        "WWWWWWWW llllllll (Tip: use a fixed width font)");*/
-
-#if 0
-    /* GTK (at least version 1.3) has an annoying bug: */
-    /* when using the font selection instead of the dialog, */
-    /* the widget seems to disconnected from the parent, */
-    /* if a filter is used! */
-#if GTK_MAJOR_VERSION < 2
-       /* Set its filter to show only fixed_width fonts. */
-       gtk_font_selection_set_filter(
-           GTK_FONT_SELECTION(font_browse_w),
-           GTK_FONT_FILTER_BASE, /* user can't change the filter */
-           GTK_FONT_ALL,         /* bitmap or scalable are fine */
-           NULL,                 /* all foundries are OK */
-           NULL,                 /* all weights are OK (XXX - normal only?) */
-           NULL,                 /* all slants are OK (XXX - Roman only?) */
-           NULL,                 /* all setwidths are OK */
-           fixedwidths,          /* ONLY fixed-width fonts */
-           NULL);      /* all charsets are OK (XXX - ISO 8859/1 only?) */
-#endif
-#endif
-
        gtk_widget_show(font_browse_w);
 
        return font_browse_w;
@@ -328,12 +343,6 @@ static gboolean
 font_fetch(void)
 {
        gchar   *font_name;
-#if GTK_MAJOR_VERSION < 2
-       gchar   *bold_font_name;
-       GdkFont *new_r_font, *new_b_font;
-#else
-       PangoFontDescription *new_r_font, *new_b_font;
-#endif
 
        font_name = g_strdup(gtk_font_selection_get_font_name(
              GTK_FONT_SELECTION(font_browse_w)));
@@ -346,52 +355,13 @@ font_fetch(void)
                return FALSE;
        }
 
-#if GTK_MAJOR_VERSION < 2
-       /* Get the name that the boldface version of that font would have. */
-       bold_font_name = font_boldify(font_name);
-
-       /* Now load those fonts, just to make sure we can. */
-       new_r_font = gdk_font_load(font_name);
-#else
-       new_r_font = pango_font_description_from_string(font_name);
-#endif
-       if (new_r_font == NULL) {
-               /* Oops, that font didn't work.
-                  Tell the user, but don't tear down the font selection
-                  dialog, so that they can try again. */
-               simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
-                  "The font you selected cannot be loaded.");
-
+       if (!user_font_test(font_name)) {
+               /* The font isn't usable; "user_font_test()" has already
+                  told the user why.  Don't tear down the font selection
+                  dialog. */
                g_free(font_name);
-#if GTK_MAJOR_VERSION < 2
-               g_free(bold_font_name);
-#endif
-               return FALSE;
-       }
-
-#if GTK_MAJOR_VERSION < 2
-       new_b_font = gdk_font_load(bold_font_name);
-#else
-       new_b_font = pango_font_description_copy(new_r_font);
-       pango_font_description_set_weight(new_b_font, PANGO_WEIGHT_BOLD);
-#endif
-       if (new_b_font == NULL) {
-               /* Oops, that font didn't work.
-                  Tell the user, but don't tear down the font selection
-                  dialog, so that they can try again. */
-               simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
-                  "The font you selected doesn't have a boldface version.");
-
-               g_free(font_name);
-#if GTK_MAJOR_VERSION < 2
-               g_free(bold_font_name);
-               gdk_font_unref(new_r_font);
-#else
-               pango_font_description_free(new_r_font);
-#endif
                return FALSE;
        }
-
        new_font_name = font_name;
        return TRUE;
 }
@@ -406,43 +376,42 @@ fetch_enum_value(gpointer control, const enum_val_t *enumvals)
 void
 gui_prefs_fetch(GtkWidget *w)
 {
-       prefs.gui_scrollbar_on_right = fetch_enum_value(
-           OBJECT_GET_DATA(w, SCROLLBAR_PLACEMENT_KEY),
-           scrollbar_placement_vals);
        prefs.gui_plist_sel_browse = fetch_enum_value(
            OBJECT_GET_DATA(w, PLIST_SEL_BROWSE_KEY), selection_mode_vals);
        prefs.gui_ptree_sel_browse = fetch_enum_value(
            OBJECT_GET_DATA(w, PTREE_SEL_BROWSE_KEY), selection_mode_vals);
-#if GTK_MAJOR_VERSION < 2
-       prefs.gui_ptree_line_style = fetch_enum_value(
-           OBJECT_GET_DATA(w, PTREE_LINE_STYLE_KEY), line_style_vals);
-       prefs.gui_ptree_expander_style = fetch_enum_value(
-           OBJECT_GET_DATA(w, PTREE_EXPANDER_STYLE_KEY), expander_style_vals);
-#else
-       prefs.gui_altern_colors = fetch_enum_value(
-           OBJECT_GET_DATA(w, ALTERN_COLORS_KEY), altern_colors_vals);
-#endif
-       prefs.gui_hex_dump_highlight_style = fetch_enum_value(
-           OBJECT_GET_DATA(w, HEX_DUMP_HIGHLIGHT_STYLE_KEY),
-           highlight_style_vals);
-       prefs.gui_toolbar_main_style = fetch_enum_value(
-           OBJECT_GET_DATA(w, GUI_TOOLBAR_STYLE_KEY),
-           toolbar_style_vals);        
        prefs.gui_geometry_save_position =
-           gtk_toggle_button_get_active(OBJECT_GET_DATA(w,
-               GEOMETRY_POSITION_KEY));
+           gtk_toggle_button_get_active(OBJECT_GET_DATA(w, GEOMETRY_POSITION_KEY));
        prefs.gui_geometry_save_size =
            gtk_toggle_button_get_active(OBJECT_GET_DATA(w, GEOMETRY_SIZE_KEY));
        prefs.gui_geometry_save_maximized =
            gtk_toggle_button_get_active(OBJECT_GET_DATA(w, GEOMETRY_MAXIMIZED_KEY));
+#ifdef _WIN32
+       prefs.gui_console_open = fetch_enum_value(
+           OBJECT_GET_DATA(w, GUI_CONSOLE_OPEN_KEY), gui_console_open_vals);
+#endif
        prefs.gui_fileopen_style = fetch_preference_radio_buttons_val(
            OBJECT_GET_DATA(w, GUI_FILEOPEN_KEY), gui_fileopen_vals);
-           
+       
        if (prefs.gui_fileopen_dir != NULL)
                g_free(prefs.gui_fileopen_dir);
        prefs.gui_fileopen_dir = g_strdup(gtk_entry_get_text(
                GTK_ENTRY(OBJECT_GET_DATA(w, GUI_FILEOPEN_DIR_KEY))));
 
+    prefs.gui_ask_unsaved = 
+           gtk_toggle_button_get_active(OBJECT_GET_DATA(w, GUI_ASK_UNSAVED_KEY));
+
+    prefs.gui_find_wrap = 
+           gtk_toggle_button_get_active(OBJECT_GET_DATA(w, GUI_FIND_WRAP_KEY));
+
+    prefs.gui_use_pref_save = 
+           gtk_toggle_button_get_active(OBJECT_GET_DATA(w, GUI_USE_PREF_SAVE_KEY));
+
+    if (browser_needs_pref()) {
+               g_free(prefs.gui_webbrowser);
+           prefs.gui_webbrowser = g_strdup(gtk_entry_get_text(
+                   GTK_ENTRY(OBJECT_GET_DATA(w, GUI_WEBBROWSER_KEY))));
+    }
        /*
         * XXX - we need to have a way to fetch the preferences into
         * local storage and only set the permanent preferences if there
@@ -465,15 +434,22 @@ void
 gui_prefs_apply(GtkWidget *w _U_)
 {
 
+#ifdef _WIN32
+    /* user immediately wants to see a console */
+    if (prefs.gui_console_open == console_open_always) {
+        create_console();
+    }
+#endif
+
        if (font_changed) {
                /* This redraws the hex dump windows. */
-               switch (font_apply()) {
+               switch (user_font_apply()) {
 
                case FA_SUCCESS:
                        break;
 
                case FA_FONT_NOT_RESIZEABLE:
-                       /* "font_apply()" popped up an alert box. */
+                       /* "user_font_apply()" popped up an alert box. */
                        /* turn off zooming - font can't be resized */
                        recent.gui_zoom_level = 0;
                        break;
@@ -482,7 +458,7 @@ gui_prefs_apply(GtkWidget *w _U_)
                        /* We assume this means that the specified size
                           isn't available. */
                        simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
-                           "That font font isn't available at the specified zoom level;\n"
+                           "That font isn't available at the specified zoom level;\n"
                            "turning zooming off.");
                        recent.gui_zoom_level = 0;
                        break;
@@ -500,11 +476,12 @@ gui_prefs_apply(GtkWidget *w _U_)
 
        /* XXX: redraw the toolbar only, if style changed */
        toolbar_redraw_all();
-       
+
        set_scrollbar_placement_all();
-       set_plist_sel_browse(prefs.gui_plist_sel_browse);
+       packet_list_set_sel_browse(prefs.gui_plist_sel_browse, FALSE);
        set_ptree_sel_browse_all(prefs.gui_ptree_sel_browse);
        set_tree_styles_all();
+       main_widgets_rearrange();
 }
 
 void
@@ -540,7 +517,32 @@ recent_files_count_changed_cb(GtkWidget *recent_files_entry _U_,
 
     /* We really should pop up a nasty dialog box if newval <= 0 */
 
-    return TRUE;
+    return FALSE;
+}
+
+static gint
+fileopen_preview_changed_cb(GtkWidget *recent_files_entry _U_, 
+                             GdkEvent *event _U_, gpointer parent_w)
+{
+    GtkWidget  *fileopen_preview_te;
+    guint newval;
+    
+    fileopen_preview_te = (GtkWidget *)OBJECT_GET_DATA(parent_w, GUI_FILEOPEN_PREVIEW_KEY);
+
+    /*
+     * Now, just convert the string to a number and store it in the prefs
+     * filed ...
+     */
+
+    newval = strtol(gtk_entry_get_text (GTK_ENTRY(fileopen_preview_te)), NULL, 10);
+
+    if (newval > 0) {
+      prefs.gui_fileopen_preview = newval;
+    }
+
+    /* We really should pop up a nasty dialog box if newval <= 0 */
+
+    return FALSE;
 }
 
 static gint
@@ -578,3 +580,4 @@ fileopen_selected_cb(GtkWidget *mybutton_rb _U_, gpointer parent_w)
     }
     return;
 }
+