/* gui_prefs.c
* Dialog box for GUI preferences
*
- * $Id: gui_prefs.c,v 1.34 2002/03/05 11:55:59 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
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "config.h"
#endif
-#include <errno.h>
#include <gtk/gtk.h>
-#include "color.h"
-#include "color_utils.h"
+#include <string.h>
+
#include "globals.h"
#include "gui_prefs.h"
#include "gtkglobals.h"
-#include "follow_dlg.h"
#include "help_dlg.h"
-#include "prefs.h"
+#include "supported_protos_dlg.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 "compat_macros.h"
+#include "font_utils.h"
+#include "packet_list.h"
+#include "toolbar.h"
+#include "recent.h"
+#include "webbrowser.h"
+
-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 gint fetch_enum_value(gpointer control, const enum_val_t *enumvals);
-static void color_browse_cb(GtkWidget *w, gpointer data);
-static void update_text_color(GtkWidget *w, gpointer data);
-static void update_current_color(GtkWidget *w, gpointer data);
-static void color_ok_cb(GtkWidget *w, gpointer data);
-static void color_cancel_cb(GtkWidget *w, gpointer data);
-static gboolean color_delete_cb(GtkWidget *prefs_w, gpointer dummy);
-static void color_destroy_cb(GtkWidget *w, gpointer data);
-static void fetch_colors(void);
-
-#define SCROLLBAR_PLACEMENT_KEY "scrollbar_placement"
+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 PLIST_SEL_BROWSE_KEY "plist_sel_browse"
#define PTREE_SEL_BROWSE_KEY "ptree_sel_browse"
-#define PTREE_LINE_STYLE_KEY "ptree_line_style"
-#define PTREE_EXPANDER_STYLE_KEY "ptree_expander_style"
-#define HEX_DUMP_HIGHLIGHT_STYLE_KEY "hex_dump_highlight_style"
#define GEOMETRY_POSITION_KEY "geometry_position"
#define GEOMETRY_SIZE_KEY "geometry_size"
-
-#define FONT_DIALOG_PTR_KEY "font_dialog_ptr"
-#define FONT_CALLER_PTR_KEY "font_caller_ptr"
-#define COLOR_DIALOG_PTR_KEY "color_dialog_ptr"
-#define COLOR_CALLER_PTR_KEY "color_caller_ptr"
-#define COLOR_SAMPLE_PTR_KEY "color_sample_ptr"
-#define COLOR_SELECTION_PTR_KEY "color_selection_ptr"
-
-static const enum_val_t scrollbar_placement_vals[] = {
- { "Left", FALSE },
- { "Right", TRUE },
- { NULL, 0 }
+#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_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[] _U_ = {
+ { "FALSE", "No", FALSE },
+ { "TRUE", "Yes", TRUE },
+ { NULL, NULL, 0 }
};
+#endif
-static const enum_val_t highlight_style_vals[] = {
- { "Bold", 0 },
- { "Inverse", 1 },
- { 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 }
};
-/* Set to FALSE initially; set to TRUE if the user ever hits "OK" on
- the "Colors..." dialog, so that we know that they (probably) changed
- colors, and therefore that the "apply" function needs to recolor
- any marked packets. */
-static gboolean colors_changed;
+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[] = {
+ { "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
the "Font..." dialog, so that we know that they (probably) changed
has been set to the name of the font the user selected. */
static gchar *new_font_name;
-#define GUI_TABLE_ROWS 8
+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 5
+#else
+#define GUI_TABLE_ROWS 4
+#endif
+
GtkWidget*
gui_prefs_show(void)
{
- GtkWidget *main_tb, *main_vb, *hbox, *font_bt, *color_bt;
- GtkWidget *scrollbar_om, *plist_browse_om;
- GtkWidget *ptree_browse_om, *line_style_om;
- GtkWidget *expander_style_om, *highlight_style_om;
- GtkWidget *save_position_cb, *save_size_cb;
-
- /* The colors or font haven't been changed yet. */
- colors_changed = FALSE;
+ 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 therea 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, 3, 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), 1, 50 );
-
- /* Scrollbar placement */
- scrollbar_om = create_preference_option_menu(main_tb, 0,
- "Vertical scrollbar placement:", NULL, scrollbar_placement_vals,
- prefs.gui_scrollbar_on_right);
- gtk_object_set_data(GTK_OBJECT(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, 1,
- "Packet list mouse behavior:", NULL, selection_mode_vals,
+ plist_browse_om = create_preference_option_menu(main_tb, pos++,
+ "Packet list selection mode:", NULL, selection_mode_vals,
prefs.gui_plist_sel_browse);
- gtk_object_set_data(GTK_OBJECT(main_vb), PLIST_SEL_BROWSE_KEY,
- plist_browse_om);
+ 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, 2,
- "Protocol tree mouse behavior:", NULL, selection_mode_vals,
+ ptree_browse_om = create_preference_option_menu(main_tb, pos++,
+ "Protocol tree selection mode:", NULL, selection_mode_vals,
prefs.gui_ptree_sel_browse);
- gtk_object_set_data(GTK_OBJECT(main_vb), PTREE_SEL_BROWSE_KEY,
- ptree_browse_om);
-
- /* Tree line style */
- line_style_om = create_preference_option_menu(main_tb, 3,
- "Tree line style:", NULL, line_style_vals,
- prefs.gui_ptree_line_style);
- gtk_object_set_data(GTK_OBJECT(main_vb), PTREE_LINE_STYLE_KEY,
- line_style_om);
-
- /* Tree expander style */
- expander_style_om = create_preference_option_menu(main_tb, 4,
- "Tree expander style:", NULL, expander_style_vals,
- prefs.gui_ptree_expander_style);
- gtk_object_set_data(GTK_OBJECT(main_vb), PTREE_EXPANDER_STYLE_KEY,
- expander_style_om);
-
- /* Hex Dump highlight style */
- highlight_style_om = create_preference_option_menu(main_tb, 5,
- "Hex display highlight style:", NULL, highlight_style_vals,
- prefs.gui_hex_dump_highlight_style);
- gtk_object_set_data(GTK_OBJECT(main_vb), HEX_DUMP_HIGHLIGHT_STYLE_KEY,
- highlight_style_om);
-
+ 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);
+
/* Geometry prefs */
- save_position_cb = create_preference_check_button(main_tb,
- 6, "Save window position:", NULL, prefs.gui_geometry_save_position);
- gtk_object_set_data(GTK_OBJECT(main_vb), GEOMETRY_POSITION_KEY,
- save_position_cb);
-
- save_size_cb = create_preference_check_button(main_tb,
- 7, "Save window size:", NULL, prefs.gui_geometry_save_size);
- gtk_object_set_data(GTK_OBJECT(main_vb), GEOMETRY_SIZE_KEY,
- save_size_cb);
-
- /* "Font..." button - click to open a font selection dialog box. */
- font_bt = gtk_button_new_with_label("Font...");
- gtk_signal_connect(GTK_OBJECT(font_bt), "clicked",
- GTK_SIGNAL_FUNC(font_browse_cb), NULL);
- gtk_table_attach_defaults( GTK_TABLE(main_tb), font_bt, 2, 3, 0, 1 );
-
- /* "Colors..." button - click to open a color selection dialog box. */
- color_bt = gtk_button_new_with_label("Colors...");
- gtk_signal_connect(GTK_OBJECT(color_bt), "clicked",
- GTK_SIGNAL_FUNC(color_browse_cb), NULL);
- gtk_table_attach_defaults( GTK_TABLE(main_tb), color_bt, 2, 3, 1, 2 );
+ 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:",
+ "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);
+ 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++,
+ "\"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);
+
+ /* 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);
return(main_vb);
}
-/* Create a font dialog for browsing. */
-static void
-font_browse_cb(GtkWidget *w, gpointer data _U_)
-{
- GtkWidget *caller = gtk_widget_get_toplevel(w);
- GtkWidget *font_browse_w;
- static gchar *fixedwidths[] = { "c", "m", NULL };
-
- /* Has a font dialog box already been opened for that top-level
- widget? */
- font_browse_w = gtk_object_get_data(GTK_OBJECT(caller),
- FONT_DIALOG_PTR_KEY);
-
- if (font_browse_w != NULL) {
- /* Yes. Just re-activate that dialog box. */
- reactivate_window(font_browse_w);
- return;
- }
-
- /* Now create a new dialog. */
- font_browse_w = gtk_font_selection_dialog_new("Ethereal: Select Font");
- gtk_window_set_transient_for(GTK_WINDOW(font_browse_w),
- GTK_WINDOW(top_level));
-
- /* Call a handler when we're destroyed, so we can inform
- our caller, if any, that we've been destroyed. */
- gtk_signal_connect(GTK_OBJECT(font_browse_w), "destroy",
- GTK_SIGNAL_FUNC(font_browse_destroy), NULL);
-
- /* Set its filter to show only fixed_width fonts. */
- gtk_font_selection_dialog_set_filter(
- GTK_FONT_SELECTION_DIALOG(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?) */
-
- /* Set the font to the current font.
- XXX - GTK+ 1.2.8, and probably earlier versions, have a bug
- wherein that doesn't necessarily cause that font to be
- selected in the dialog box. I've sent to the GTK+ folk
- a fix; hopefully, it'll show up in 1.2.9 if, as, and when
- they put out a 1.2.9 release. */
- gtk_font_selection_dialog_set_font_name(
- GTK_FONT_SELECTION_DIALOG(font_browse_w), prefs.gui_font_name);
-
- /* Set the FONT_CALLER_PTR_KEY for the new dialog to point to
- our caller. */
- gtk_object_set_data(GTK_OBJECT(font_browse_w), FONT_CALLER_PTR_KEY,
- caller);
-
- /* Set the FONT_DIALOG_PTR_KEY for the caller to point to us */
- gtk_object_set_data(GTK_OBJECT(caller), FONT_DIALOG_PTR_KEY,
- font_browse_w);
-
- /* Connect the ok_button to font_browse_ok_cb function and pass along a
- pointer to the font selection box widget */
- gtk_signal_connect(
- GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(font_browse_w)->ok_button),
- "clicked", (GtkSignalFunc)font_browse_ok_cb, font_browse_w);
-
- /* Connect the cancel_button to destroy the widget */
- gtk_signal_connect_object(
- GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(font_browse_w)->cancel_button),
- "clicked", (GtkSignalFunc)gtk_widget_destroy,
- GTK_OBJECT(font_browse_w));
-
- /* Catch the "key_press_event" signal in the window, so that we can
- catch the ESC key being pressed and act as if the "Cancel" button
- had been selected. */
- dlg_set_cancel(font_browse_w,
- GTK_FONT_SELECTION_DIALOG(font_browse_w)->cancel_button);
+/* Create a font widget for browsing. */
+GtkWidget *
+gui_font_prefs_show(void)
+{
+ /* Create the font selection widget. */
+ font_browse_w = (GtkWidget *) gtk_font_selection_new();
gtk_widget_show(font_browse_w);
+
+ return font_browse_w;
}
-static void
-font_browse_ok_cb(GtkWidget *w _U_, GtkFontSelectionDialog *fs)
+
+static gboolean
+font_fetch(void)
{
- gchar *font_name, *bold_font_name;
- GdkFont *new_r_font, *new_b_font;
+ gchar *font_name;
- font_name = g_strdup(gtk_font_selection_dialog_get_font_name(
- GTK_FONT_SELECTION_DIALOG(fs)));
+ font_name = g_strdup(gtk_font_selection_get_font_name(
+ GTK_FONT_SELECTION(font_browse_w)));
if (font_name == NULL) {
/* No font was selected; let the user know, but don't
tear down the font selection dialog, so they can
try again. */
- simple_dialog(ESD_TYPE_CRIT | ESD_TYPE_MODAL, NULL,
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"You have not selected a font.");
- return;
- }
-
- /* Get the name that the boldface version of that font would have. */
- bold_font_name = boldify(font_name);
-
- /* Now load those fonts, just to make sure we can. */
- new_r_font = gdk_font_load(font_name);
- 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_CRIT | ESD_TYPE_MODAL, NULL,
- "The font you selected cannot be loaded.");
-
- g_free(font_name);
- g_free(bold_font_name);
- return;
+ return FALSE;
}
- new_b_font = gdk_font_load(bold_font_name);
- 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_CRIT | ESD_TYPE_MODAL, NULL,
- "The font you selected doesn't have a boldface version.");
-
+ 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);
- g_free(bold_font_name);
- gdk_font_unref(new_r_font);
- return;
+ return FALSE;
}
-
- font_changed = TRUE;
new_font_name = font_name;
-
- gtk_widget_hide(GTK_WIDGET(fs));
- gtk_widget_destroy(GTK_WIDGET(fs));
+ return TRUE;
}
-static void
-font_browse_destroy(GtkWidget *win, gpointer data _U_)
-{
- GtkWidget *caller;
-
- /* Get the widget that requested that we be popped up, if any.
- (It should arrange to destroy us if it's destroyed, so
- that we don't get a pointer to a non-existent window here.) */
- caller = gtk_object_get_data(GTK_OBJECT(win), FONT_CALLER_PTR_KEY);
-
- if (caller != NULL) {
- /* Tell it we no longer exist. */
- gtk_object_set_data(GTK_OBJECT(caller), FONT_DIALOG_PTR_KEY,
- NULL);
- }
-
- /* Now nuke this window. */
- gtk_grab_remove(GTK_WIDGET(win));
- gtk_widget_destroy(GTK_WIDGET(win));
-}
static gint
fetch_enum_value(gpointer control, const enum_val_t *enumvals)
void
gui_prefs_fetch(GtkWidget *w)
{
- prefs.gui_scrollbar_on_right = fetch_enum_value(
- gtk_object_get_data(GTK_OBJECT(w), SCROLLBAR_PLACEMENT_KEY),
- scrollbar_placement_vals);
prefs.gui_plist_sel_browse = fetch_enum_value(
- gtk_object_get_data(GTK_OBJECT(w), PLIST_SEL_BROWSE_KEY),
- selection_mode_vals);
+ OBJECT_GET_DATA(w, PLIST_SEL_BROWSE_KEY), selection_mode_vals);
prefs.gui_ptree_sel_browse = fetch_enum_value(
- gtk_object_get_data(GTK_OBJECT(w), PTREE_SEL_BROWSE_KEY),
- selection_mode_vals);
- prefs.gui_ptree_line_style = fetch_enum_value(
- gtk_object_get_data(GTK_OBJECT(w), PTREE_LINE_STYLE_KEY),
- line_style_vals);
- prefs.gui_ptree_expander_style = fetch_enum_value(
- gtk_object_get_data(GTK_OBJECT(w), PTREE_EXPANDER_STYLE_KEY),
- expander_style_vals);
- prefs.gui_hex_dump_highlight_style = fetch_enum_value(
- gtk_object_get_data(GTK_OBJECT(w), HEX_DUMP_HIGHLIGHT_STYLE_KEY),
- highlight_style_vals);
- prefs.gui_geometry_save_position =
- gtk_toggle_button_get_active(gtk_object_get_data(GTK_OBJECT(w),
- GEOMETRY_POSITION_KEY));
- prefs.gui_geometry_save_size =
- gtk_toggle_button_get_active(gtk_object_get_data(GTK_OBJECT(w),
- GEOMETRY_SIZE_KEY));
-
- if (font_changed) {
- if (prefs.gui_font_name != NULL)
- g_free(prefs.gui_font_name);
- prefs.gui_font_name = g_strdup(new_font_name);
+ OBJECT_GET_DATA(w, PTREE_SEL_BROWSE_KEY), selection_mode_vals);
+ prefs.gui_geometry_save_position =
+ 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
+ * weren't any errors in those fetches, as there are several
+ * places where there *can* be a bad preference value.
+ */
+ if (font_fetch()) {
+ if (strcmp(new_font_name, prefs.PREFS_GUI_FONT_NAME) != 0) {
+ font_changed = TRUE;
+ if (prefs.PREFS_GUI_FONT_NAME != NULL)
+ g_free(prefs.PREFS_GUI_FONT_NAME);
+ prefs.PREFS_GUI_FONT_NAME = g_strdup(new_font_name);
+ }
}
-
- if (colors_changed)
- fetch_colors();
}
+
+
void
gui_prefs_apply(GtkWidget *w _U_)
{
- GdkFont *new_r_font, *new_b_font;
- char *bold_font_name;
- GdkFont *old_r_font = NULL, *old_b_font = NULL;
+
+#ifdef _WIN32
+ /* user immediately wants to see a console */
+ if (prefs.gui_console_open == console_open_always) {
+ create_console();
+ }
+#endif
if (font_changed) {
- /* XXX - what if the world changed out from under
- us, so that one or both of these fonts cannot
- be loaded? */
- new_r_font = gdk_font_load(prefs.gui_font_name);
- bold_font_name = boldify(prefs.gui_font_name);
- new_b_font = gdk_font_load(bold_font_name);
- 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;
- set_fonts(new_r_font, new_b_font);
- g_free(bold_font_name);
+ /* This redraws the hex dump windows. */
+ switch (user_font_apply()) {
+
+ case FA_SUCCESS:
+ break;
+
+ case FA_FONT_NOT_RESIZEABLE:
+ /* "user_font_apply()" popped up an alert box. */
+ /* turn off zooming - font can't be resized */
+ recent.gui_zoom_level = 0;
+ break;
+
+ case FA_FONT_NOT_AVAILABLE:
+ /* We assume this means that the specified size
+ isn't available. */
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ "That font isn't available at the specified zoom level;\n"
+ "turning zooming off.");
+ recent.gui_zoom_level = 0;
+ break;
+ }
+ } else {
+ /* Redraw the hex dump windows, in case the
+ highlight style changed.
+ XXX - do it only if the highlight style *did* change. */
+ redraw_hex_dump_all();
}
- /* Redraw the hex dump windows, in case either the font or the
- highlight style changed. */
- redraw_hex_dump_all();
-
- /* Redraw the help window. */
+ /* Redraw the help window(s). */
+ supported_redraw();
help_redraw();
- /* Redraw the "Follow TCP Stream" windows, in case either the font
- or the colors to use changed. */
- follow_redraw_all();
+ /* 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_ctree_styles_all();
- if (colors_changed)
- update_marked_frames();
-
- /* 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);
+ set_tree_styles_all();
+ main_widgets_rearrange();
}
void
-gui_prefs_destroy(GtkWidget *w)
+gui_prefs_destroy(GtkWidget *w _U_)
{
- GtkWidget *caller = gtk_widget_get_toplevel(w);
- GtkWidget *fs;
-
- /* Is there a font selection dialog associated with this
- Preferences dialog? */
- fs = gtk_object_get_data(GTK_OBJECT(caller), FONT_DIALOG_PTR_KEY);
-
- if (fs != NULL) {
- /* Yes. Destroy it. */
- gtk_widget_destroy(fs);
- }
-
- /* Is there a color selection dialog associated with this
- Preferences dialog? */
- fs = gtk_object_get_data(GTK_OBJECT(caller), COLOR_DIALOG_PTR_KEY);
-
- if (fs != NULL) {
- /* Yes. Destroy it. */
- gtk_widget_destroy(fs);
- }
-
/* Free up any saved font name. */
if (new_font_name != NULL) {
g_free(new_font_name);
}
}
-/* color selection part */
-#define MAX_HANDLED_COL 2
+static gint
+recent_files_count_changed_cb(GtkWidget *recent_files_entry _U_,
+ GdkEvent *event _U_, gpointer parent_w)
+{
+ GtkWidget *recent_files_count_te;
+ guint newval;
+
+ recent_files_count_te = (GtkWidget *)OBJECT_GET_DATA(parent_w, GUI_RECENT_FILES_COUNT_KEY);
-typedef struct {
- GdkColor color;
- char *label;
-} color_info_t;
+ /*
+ * Now, just convert the string to a number and store it in the prefs
+ * filed ...
+ */
-static color_info_t color_info[MAX_HANDLED_COL] = {
-#define MFG_IDX 0
- { {0.0, 0.0, 0.0, 0.0}, "Marked frame foreground" },
-#define MBG_IDX 1
- { {0.0, 0.0, 0.0, 0.0}, "Marked frame background" }
-};
+ newval = strtol(gtk_entry_get_text (GTK_ENTRY(recent_files_count_te)), NULL, 10);
-#define SAMPLE_MARKED_TEXT "Sample marked frame text\n"
+ if (newval > 0) {
+ prefs.gui_recent_files_count_max = newval;
+ }
-#define CS_RED 0
-#define CS_GREEN 1
-#define CS_BLUE 2
-#define CS_OPACITY 3
+ /* We really should pop up a nasty dialog box if newval <= 0 */
-static GdkColor *curcolor = NULL;
+ return FALSE;
+}
-static void
-color_browse_cb(GtkWidget *w, gpointer data _U_)
+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);
- GtkWidget *main_vb, *main_tb, *label, *optmenu, *menu, *menuitem;
- GtkWidget *sample, *colorsel, *bbox, *cancel_bt, *ok_bt, *color_w;
- int width, height, i;
- gdouble scolor[4];
- GtkWidget *caller = gtk_widget_get_toplevel(w);
-
- /* Has a color dialog box already been opened for that top-level
- widget? */
- color_w = gtk_object_get_data(GTK_OBJECT(caller),
- COLOR_DIALOG_PTR_KEY);
-
- if (color_w != NULL) {
- /* Yes. Just re-activate that dialog box. */
- reactivate_window(color_w);
- return;
- }
-
- color_t_to_gdkcolor(&color_info[MFG_IDX].color, &prefs.gui_marked_fg);
- color_t_to_gdkcolor(&color_info[MBG_IDX].color, &prefs.gui_marked_bg);
- curcolor = &color_info[MFG_IDX].color;
- scolor[CS_RED] = (gdouble) (curcolor->red) / 65535.0;
- scolor[CS_GREEN] = (gdouble) (curcolor->green) / 65535.0;
- scolor[CS_BLUE] = (gdouble) (curcolor->blue) / 65535.0;
- scolor[CS_OPACITY] = 1.0;
-
- /* Now create a new dialog.
- You can't put your own extra widgets into a color selection
- dialog, as you can with a file selection dialog, so we have to
- construct our own dialog and put a color selection widget
- into it. */
- color_w = dlg_window_new("Ethereal: Select Color");
-
- gtk_signal_connect(GTK_OBJECT(color_w), "delete_event",
- GTK_SIGNAL_FUNC(color_delete_cb), NULL);
-
- /* Call a handler when we're destroyed, so we can inform our caller,
- if any, that we've been destroyed. */
- gtk_signal_connect(GTK_OBJECT(color_w), "destroy",
- GTK_SIGNAL_FUNC(color_destroy_cb), NULL);
-
- main_vb = gtk_vbox_new(FALSE, 5);
- gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
- gtk_container_add (GTK_CONTAINER (color_w), main_vb);
- main_tb = gtk_table_new(3, 3, 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);
- gtk_widget_show(main_tb);
- label = gtk_label_new("Set:");
- gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
- gtk_table_attach_defaults(GTK_TABLE(main_tb), label, 0, 1, 0, 1);
- gtk_widget_show(label);
-
- colorsel = gtk_color_selection_new();
- optmenu = gtk_option_menu_new();
- menu = gtk_menu_new();
- for (i = 0; i < MAX_HANDLED_COL; i++){
- menuitem = gtk_menu_item_new_with_label(color_info[i].label);
- gtk_object_set_data(GTK_OBJECT(menuitem), COLOR_SELECTION_PTR_KEY,
- (gpointer) colorsel);
- gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
- GTK_SIGNAL_FUNC(update_current_color),
- &color_info[i].color);
- gtk_widget_show(menuitem);
- gtk_menu_append(GTK_MENU (menu), menuitem);
- }
- gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu), menu);
- gtk_table_attach_defaults(GTK_TABLE(main_tb), optmenu, 1, 2, 0, 1);
- gtk_widget_show(optmenu);
-
- sample = gtk_text_new(FALSE, FALSE);
- height = sample->style->font->ascent + sample->style->font->descent;
- width = gdk_string_width(sample->style->font, SAMPLE_MARKED_TEXT);
- gtk_widget_set_usize(GTK_WIDGET(sample), width, height);
- gtk_text_set_editable(GTK_TEXT(sample), FALSE);
- gtk_text_insert(GTK_TEXT(sample), NULL,
- &color_info[MFG_IDX].color,
- &color_info[MBG_IDX].color,
- SAMPLE_MARKED_TEXT, -1);
- gtk_table_attach_defaults(GTK_TABLE(main_tb), sample, 2, 3, 0, 2);
- gtk_widget_show(sample);
- gtk_color_selection_set_color(GTK_COLOR_SELECTION(colorsel),
- &scolor[CS_RED]);
- gtk_table_attach_defaults(GTK_TABLE(main_tb), colorsel, 0, 3, 2, 3);
- gtk_object_set_data(GTK_OBJECT(colorsel), COLOR_SAMPLE_PTR_KEY,
- (gpointer) sample);
- gtk_signal_connect(GTK_OBJECT(colorsel), "color-changed",
- GTK_SIGNAL_FUNC(update_text_color), NULL);
- gtk_widget_show(colorsel);
- gtk_widget_show(main_vb);
-
- gtk_object_set_data(GTK_OBJECT(color_w), COLOR_CALLER_PTR_KEY, caller);
- gtk_object_set_data(GTK_OBJECT(caller), COLOR_DIALOG_PTR_KEY, color_w);
-
- /* Ok, Cancel Buttons */
- bbox = gtk_hbutton_box_new();
- gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
- gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
- gtk_container_add(GTK_CONTAINER(main_vb), bbox);
- gtk_widget_show(bbox);
-
- ok_bt = gtk_button_new_with_label ("OK");
- gtk_signal_connect(GTK_OBJECT(ok_bt), "clicked",
- GTK_SIGNAL_FUNC(color_ok_cb), color_w);
- GTK_WIDGET_SET_FLAGS(ok_bt, GTK_CAN_DEFAULT);
- gtk_box_pack_start(GTK_BOX (bbox), ok_bt, TRUE, TRUE, 0);
- gtk_widget_grab_default(ok_bt);
- gtk_widget_show(ok_bt);
- cancel_bt = gtk_button_new_with_label ("Cancel");
- gtk_signal_connect_object(GTK_OBJECT(cancel_bt), "clicked",
- (GtkSignalFunc)gtk_widget_destroy,
- GTK_OBJECT(color_w));
- gtk_box_pack_start(GTK_BOX (bbox), cancel_bt, TRUE, TRUE, 0);
- gtk_widget_show(cancel_bt);
- dlg_set_cancel(color_w, cancel_bt);
-
- gtk_widget_show(color_w);
-}
-
-static void
-update_text_color(GtkWidget *w, gpointer data _U_) {
- GtkText *sample = gtk_object_get_data(GTK_OBJECT(w), COLOR_SAMPLE_PTR_KEY);
- gdouble scolor[4];
-
- gtk_color_selection_get_color(GTK_COLOR_SELECTION(w), &scolor[CS_RED]);
-
- curcolor->red = (gushort) (scolor[CS_RED] * 65535.0);
- curcolor->green = (gushort) (scolor[CS_GREEN] * 65535.0);
- curcolor->blue = (gushort) (scolor[CS_BLUE] * 65535.0);
-
- gtk_text_freeze(sample);
- gtk_text_set_point(sample, 0);
- gtk_text_forward_delete(sample, gtk_text_get_length(sample));
- gtk_text_insert(GTK_TEXT(sample), NULL,
- &color_info[MFG_IDX].color,
- &color_info[MBG_IDX].color,
- SAMPLE_MARKED_TEXT, -1);
- gtk_text_thaw(sample);
-}
+ /*
+ * Now, just convert the string to a number and store it in the prefs
+ * filed ...
+ */
-static void
-update_current_color(GtkWidget *w, gpointer data)
-{
- GtkColorSelection *colorsel;
- gdouble scolor[4];
-
- colorsel = GTK_COLOR_SELECTION(gtk_object_get_data(GTK_OBJECT(w),
- COLOR_SELECTION_PTR_KEY));
- curcolor = (GdkColor *)data;
- scolor[CS_RED] = (gdouble) (curcolor->red) / 65535.0;
- scolor[CS_GREEN] = (gdouble) (curcolor->green) / 65535.0;
- scolor[CS_BLUE] = (gdouble) (curcolor->blue) / 65535.0;
- scolor[CS_OPACITY] = 1.0;
-
- gtk_color_selection_set_color(colorsel, &scolor[CS_RED]);
-}
+ newval = strtol(gtk_entry_get_text (GTK_ENTRY(fileopen_preview_te)), NULL, 10);
-static void
-color_ok_cb(GtkWidget *w _U_, gpointer data)
-{
- /* We assume the user actually changed a color here. */
- colors_changed = TRUE;
+ if (newval > 0) {
+ prefs.gui_fileopen_preview = newval;
+ }
- gtk_widget_hide(GTK_WIDGET(data));
- gtk_widget_destroy(GTK_WIDGET(data));
-}
+ /* We really should pop up a nasty dialog box if newval <= 0 */
-static void
-color_cancel_cb(GtkWidget *w _U_, gpointer data)
-{
- /* Revert the colors to the current preference settings. */
- color_t_to_gdkcolor(&color_info[MFG_IDX].color, &prefs.gui_marked_fg);
- color_t_to_gdkcolor(&color_info[MBG_IDX].color, &prefs.gui_marked_bg);
- gtk_widget_hide(GTK_WIDGET(data));
- gtk_widget_destroy(GTK_WIDGET(data));
+ return FALSE;
}
-/* Treat this as a cancel, by calling "color_cancel_cb()".
- XXX - that'll destroy the Select Color dialog; will that upset
- a higher-level handler that says "OK, we've been asked to delete
- this, so destroy it"? */
-static gboolean
-color_delete_cb(GtkWidget *prefs_w _U_, gpointer dummy _U_)
+static gint
+fileopen_dir_changed_cb(GtkWidget *fileopen_entry _U_, GdkEvent *event _U_, gpointer parent_w)
{
- color_cancel_cb(NULL, NULL);
- return FALSE;
+ GtkWidget *fileopen_dir_te;
+ char *lastchar;
+ gint fileopen_dir_te_length;
+
+ fileopen_dir_te = (GtkWidget *)OBJECT_GET_DATA(parent_w, GUI_FILEOPEN_DIR_KEY);
+ fileopen_dir_te_length = strlen(gtk_entry_get_text (GTK_ENTRY(fileopen_entry)));
+ if (fileopen_dir_te_length == 0)
+ return FALSE;
+ lastchar = gtk_editable_get_chars(GTK_EDITABLE(fileopen_entry), fileopen_dir_te_length-1, -1);
+ if (strcmp(lastchar, G_DIR_SEPARATOR_S) != 0)
+ gtk_entry_append_text(GTK_ENTRY(fileopen_entry), G_DIR_SEPARATOR_S);
+ return FALSE;
}
static void
-color_destroy_cb(GtkWidget *w, gpointer data _U_)
+fileopen_selected_cb(GtkWidget *mybutton_rb _U_, gpointer parent_w)
{
- GtkWidget *caller = gtk_object_get_data(GTK_OBJECT(w),
- COLOR_CALLER_PTR_KEY);
- if (caller != NULL) {
- gtk_object_set_data(GTK_OBJECT(caller), COLOR_DIALOG_PTR_KEY, NULL);
- }
- gtk_grab_remove(GTK_WIDGET(w));
- gtk_widget_destroy(GTK_WIDGET(w));
+ GtkWidget *fileopen_rb, *fileopen_dir_te;
+
+ fileopen_rb = (GtkWidget *)OBJECT_GET_DATA(parent_w, GUI_FILEOPEN_KEY);
+ fileopen_dir_te = (GtkWidget *)OBJECT_GET_DATA(parent_w, GUI_FILEOPEN_DIR_KEY);
+
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(fileopen_rb)))
+ {
+ gtk_widget_set_sensitive(GTK_WIDGET(fileopen_dir_te), TRUE);
+ }
+ else
+ {
+ gtk_widget_set_sensitive(GTK_WIDGET(fileopen_dir_te), FALSE);
+ }
+ return;
}
-static void
-fetch_colors(void)
-{
- gdkcolor_to_color_t(&prefs.gui_marked_fg, &color_info[MFG_IDX].color);
- gdkcolor_to_color_t(&prefs.gui_marked_bg, &color_info[MBG_IDX].color);
-}