now: Don't have a Save button in the following settings dialogs:
- Edit/Preferences - View/Coloring Rules - Capture/Capture Filters - Analyze/Display Filters - Analyze/Enabled Protocols The settings will be automatically saved when pressing the Ok button. If someone really wants the explicit Save buttons as before - you can get them back at the Edit/Preferences/User Interface page. svn path=/trunk/; revision=19415
This commit is contained in:
parent
699c5c66b6
commit
cdb57f37a2
15
epan/prefs.c
15
epan/prefs.c
|
@ -1033,6 +1033,7 @@ init_prefs(void) {
|
|||
prefs.gui_fileopen_preview = 3;
|
||||
prefs.gui_ask_unsaved = TRUE;
|
||||
prefs.gui_find_wrap = TRUE;
|
||||
prefs.gui_use_pref_save = FALSE;
|
||||
prefs.gui_webbrowser = g_strdup(HTML_VIEWER " %s");
|
||||
prefs.gui_window_title = g_strdup("");
|
||||
prefs.gui_layout_type = layout_type_5;
|
||||
|
@ -1380,6 +1381,7 @@ prefs_set_pref(char *prefarg)
|
|||
#define PRS_GUI_FILEOPEN_PREVIEW "gui.fileopen.preview"
|
||||
#define PRS_GUI_ASK_UNSAVED "gui.ask_unsaved"
|
||||
#define PRS_GUI_FIND_WRAP "gui.find_wrap"
|
||||
#define PRS_GUI_USE_PREF_SAVE "gui.use_pref_save"
|
||||
#define PRS_GUI_GEOMETRY_SAVE_POSITION "gui.geometry.save.position"
|
||||
#define PRS_GUI_GEOMETRY_SAVE_SIZE "gui.geometry.save.size"
|
||||
#define PRS_GUI_GEOMETRY_SAVE_MAXIMIZED "gui.geometry.save.maximized"
|
||||
|
@ -1724,6 +1726,13 @@ set_pref(gchar *pref_name, gchar *value)
|
|||
else {
|
||||
prefs.gui_find_wrap = FALSE;
|
||||
}
|
||||
} else if (strcmp(pref_name, PRS_GUI_USE_PREF_SAVE) == 0) {
|
||||
if (strcasecmp(value, "true") == 0) {
|
||||
prefs.gui_use_pref_save = TRUE;
|
||||
}
|
||||
else {
|
||||
prefs.gui_use_pref_save = FALSE;
|
||||
}
|
||||
} else if (strcmp(pref_name, PRS_GUI_WEBBROWSER) == 0) {
|
||||
g_free(prefs.gui_webbrowser);
|
||||
prefs.gui_webbrowser = g_strdup(value);
|
||||
|
@ -2355,6 +2364,11 @@ write_prefs(char **pf_path_return)
|
|||
fprintf(pf, PRS_GUI_FIND_WRAP ": %s\n",
|
||||
prefs.gui_find_wrap == TRUE ? "TRUE" : "FALSE");
|
||||
|
||||
fprintf(pf, "\n# Settings dialogs use a save button?\n");
|
||||
fprintf(pf, "# TRUE or FALSE (case-insensitive).\n");
|
||||
fprintf(pf, PRS_GUI_USE_PREF_SAVE ": %s\n",
|
||||
prefs.gui_use_pref_save == TRUE ? "TRUE" : "FALSE");
|
||||
|
||||
fprintf(pf, "\n# The path to the webbrowser.\n");
|
||||
fprintf(pf, "# Ex: mozilla %%s\n");
|
||||
fprintf(pf, PRS_GUI_WEBBROWSER ": %s\n", prefs.gui_webbrowser);
|
||||
|
@ -2568,6 +2582,7 @@ copy_prefs(e_prefs *dest, e_prefs *src)
|
|||
dest->gui_fileopen_preview = src->gui_fileopen_preview;
|
||||
dest->gui_ask_unsaved = src->gui_ask_unsaved;
|
||||
dest->gui_find_wrap = src->gui_find_wrap;
|
||||
dest->gui_use_pref_save = src->gui_use_pref_save;
|
||||
dest->gui_layout_type = src->gui_layout_type;
|
||||
dest->gui_layout_content_1 = src->gui_layout_content_1;
|
||||
dest->gui_layout_content_2 = src->gui_layout_content_2;
|
||||
|
|
|
@ -133,6 +133,7 @@ typedef struct _e_prefs {
|
|||
guint gui_fileopen_preview;
|
||||
gboolean gui_ask_unsaved;
|
||||
gboolean gui_find_wrap;
|
||||
gboolean gui_use_pref_save;
|
||||
gchar *gui_webbrowser;
|
||||
gchar *gui_window_title;
|
||||
layout_type_e gui_layout_type;
|
||||
|
|
|
@ -462,6 +462,12 @@ colorize_dialog_new (char *filter)
|
|||
OBJECT_SET_DATA(color_win, COLOR_FILTER_LIST, &color_filter_edit_list);
|
||||
|
||||
gtk_widget_show_all(color_win);
|
||||
|
||||
/* hide the Save button if the user uses implicit save */
|
||||
if(!prefs.gui_use_pref_save) {
|
||||
gtk_widget_hide(color_save);
|
||||
}
|
||||
|
||||
window_present(color_win);
|
||||
|
||||
if(filter){
|
||||
|
@ -1136,6 +1142,13 @@ color_ok_cb(GtkButton *button _U_, gpointer user_data _U_)
|
|||
{
|
||||
color_filters_apply(color_filter_edit_list);
|
||||
|
||||
/* if we don't have a Save button, just save the settings now */
|
||||
if (!prefs.gui_use_pref_save) {
|
||||
if (!color_filters_write(color_filter_edit_list))
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Could not open filter file: %s", strerror(errno));
|
||||
}
|
||||
|
||||
/* colorize list */
|
||||
cf_colorize_packets(&cfile);
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "compat_macros.h"
|
||||
#include "gtkglobals.h"
|
||||
#include "help_dlg.h"
|
||||
#include <epan/prefs.h>
|
||||
|
||||
#define E_FILT_DIALOG_PTR_KEY "filter_dialog_ptr"
|
||||
#define E_FILT_BUTTON_PTR_KEY "filter_button_ptr"
|
||||
|
@ -71,6 +72,7 @@ static void filter_dlg_dclick(GtkWidget *dummy, gpointer main_w_arg,
|
|||
static void filter_dlg_ok_cb(GtkWidget *ok_bt, gpointer dummy);
|
||||
static void filter_dlg_apply_cb(GtkWidget *apply_bt, gpointer dummy);
|
||||
static void filter_apply(GtkWidget *main_w, gboolean destroy);
|
||||
static void filter_dlg_save(filter_list_type_t list_type);
|
||||
static void filter_dlg_save_cb(GtkWidget *save_bt, gpointer parent_w);
|
||||
static void filter_dlg_destroy_cb(GtkWidget *win, gpointer data);
|
||||
|
||||
|
@ -616,47 +618,28 @@ filter_dialog_new(GtkWidget *button, GtkWidget *parent_filter_te,
|
|||
}
|
||||
|
||||
|
||||
/* button row */
|
||||
if (parent_filter_te != NULL) {
|
||||
if (construct_args->wants_apply_button) {
|
||||
bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_APPLY, GTK_STOCK_SAVE, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
|
||||
} else {
|
||||
bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_SAVE, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
|
||||
}
|
||||
} else {
|
||||
if (construct_args->wants_apply_button) {
|
||||
bbox = dlg_button_row_new(GTK_STOCK_APPLY, GTK_STOCK_SAVE, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
|
||||
} else {
|
||||
bbox = dlg_button_row_new(GTK_STOCK_SAVE, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
|
||||
}
|
||||
}
|
||||
/* button row (create all possible buttons and hide the unrequired later - it's a lot easier) */
|
||||
bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_APPLY, GTK_STOCK_SAVE, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
|
||||
gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5);
|
||||
gtk_widget_show(bbox);
|
||||
|
||||
ok_bt = NULL;
|
||||
if (parent_filter_te != NULL) {
|
||||
/*
|
||||
* We have a filter text entry that we can fill in if
|
||||
* the "OK" button is clicked, so put in an "OK" button.
|
||||
*/
|
||||
ok_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_OK);
|
||||
SIGNAL_CONNECT(ok_bt, "clicked", filter_dlg_ok_cb, NULL);
|
||||
gtk_tooltips_set_tip (tooltips, ok_bt, ("Apply the filters and close this dialog"), NULL);
|
||||
ok_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_OK);
|
||||
SIGNAL_CONNECT(ok_bt, "clicked", filter_dlg_ok_cb, filter_list_type_p);
|
||||
gtk_tooltips_set_tip (tooltips, ok_bt, ("Apply the filters and close this dialog"), NULL);
|
||||
|
||||
/* Catch the "activate" signal on the filter name and filter
|
||||
expression text entries, so that if the user types Return
|
||||
there, we act as if the "OK" button had been selected, as
|
||||
happens if Return is typed if some widget that *doesn't*
|
||||
handle the Return key has the input focus. */
|
||||
/* Catch the "activate" signal on the filter name and filter
|
||||
expression text entries, so that if the user types Return
|
||||
there, we act as if the "OK" button had been selected, as
|
||||
happens if Return is typed if some widget that *doesn't*
|
||||
handle the Return key has the input focus. */
|
||||
if (parent_filter_te != NULL) {
|
||||
dlg_set_activate(name_te, ok_bt);
|
||||
dlg_set_activate(filter_te, ok_bt);
|
||||
}
|
||||
|
||||
if (construct_args->wants_apply_button) {
|
||||
apply_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_APPLY);
|
||||
SIGNAL_CONNECT(apply_bt, "clicked", filter_dlg_apply_cb, NULL);
|
||||
gtk_tooltips_set_tip (tooltips, apply_bt, ("Apply the filters and keep this dialog open"), NULL);
|
||||
}
|
||||
apply_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_APPLY);
|
||||
SIGNAL_CONNECT(apply_bt, "clicked", filter_dlg_apply_cb, NULL);
|
||||
gtk_tooltips_set_tip (tooltips, apply_bt, ("Apply the filters and keep this dialog open"), NULL);
|
||||
|
||||
save_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_SAVE);
|
||||
SIGNAL_CONNECT(save_bt, "clicked", filter_dlg_save_cb, filter_list_type_p);
|
||||
|
@ -712,6 +695,22 @@ filter_dialog_new(GtkWidget *button, GtkWidget *parent_filter_te,
|
|||
SIGNAL_CONNECT(main_w, "destroy", filter_dlg_destroy_cb, filter_list_type_p);
|
||||
|
||||
gtk_widget_show(main_w);
|
||||
|
||||
/* hide the Ok button, if we don't have to apply it and our caller wants a Save button */
|
||||
if (parent_filter_te == NULL && prefs.gui_use_pref_save) {
|
||||
gtk_widget_hide(ok_bt);
|
||||
}
|
||||
|
||||
/* hide the Apply button, if our caller don't wants one */
|
||||
if (!construct_args->wants_apply_button) {
|
||||
gtk_widget_hide(apply_bt);
|
||||
}
|
||||
|
||||
/* hide the Save button if the user uses implicit save */
|
||||
if (!prefs.gui_use_pref_save) {
|
||||
gtk_widget_hide(save_bt);
|
||||
}
|
||||
|
||||
window_present(main_w);
|
||||
|
||||
return main_w;
|
||||
|
@ -783,12 +782,19 @@ filter_dlg_dclick(GtkWidget *filter_l, gpointer main_w_arg, gpointer activate)
|
|||
}
|
||||
|
||||
static void
|
||||
filter_dlg_ok_cb(GtkWidget *ok_bt, gpointer data _U_)
|
||||
filter_dlg_ok_cb(GtkWidget *ok_bt, gpointer data)
|
||||
{
|
||||
filter_list_type_t list_type = *(filter_list_type_t *)data;
|
||||
|
||||
/*
|
||||
* Destroy the dialog box and apply the filter.
|
||||
*/
|
||||
filter_apply(gtk_widget_get_toplevel(ok_bt), TRUE);
|
||||
|
||||
/* if we don't have a Save button, just save the settings now */
|
||||
if (!prefs.gui_use_pref_save) {
|
||||
filter_dlg_save(list_type);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -856,10 +862,10 @@ filter_apply(GtkWidget *main_w, gboolean destroy)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
filter_dlg_save_cb(GtkWidget *save_bt _U_, gpointer data)
|
||||
filter_dlg_save(filter_list_type_t list_type)
|
||||
{
|
||||
filter_list_type_t list_type = *(filter_list_type_t *)data;
|
||||
char *pf_dir_path;
|
||||
char *f_path;
|
||||
int f_save_errno;
|
||||
|
@ -905,6 +911,15 @@ filter_dlg_save_cb(GtkWidget *save_bt _U_, gpointer data)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
filter_dlg_save_cb(GtkWidget *save_bt _U_, gpointer data)
|
||||
{
|
||||
filter_list_type_t list_type = *(filter_list_type_t *)data;
|
||||
|
||||
filter_dlg_save(list_type);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* update a remaining dialog if another one was cancelled */
|
||||
static void filter_dlg_update_list_cb(gpointer data, gpointer user_data)
|
||||
|
|
|
@ -70,6 +70,7 @@ static gint recent_files_count_changed_cb(GtkWidget *recent_files_entry _U_,
|
|||
#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[] = {
|
||||
{ "FALSE", "Left", FALSE },
|
||||
|
@ -177,6 +178,7 @@ gui_prefs_show(void)
|
|||
#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;
|
||||
|
||||
|
@ -297,6 +299,14 @@ gui_prefs_show(void)
|
|||
"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++,
|
||||
|
@ -391,6 +401,9 @@ gui_prefs_fetch(GtkWidget *w)
|
|||
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(
|
||||
|
|
113
gtk/prefs_dlg.c
113
gtk/prefs_dlg.c
|
@ -75,6 +75,7 @@ static void prefs_tree_select_cb(GtkTreeSelection *, gpointer);
|
|||
#define E_PREFSW_SCROLLW_KEY "prefsw_scrollw"
|
||||
#define E_PREFSW_TREE_KEY "prefsw_tree"
|
||||
#define E_PREFSW_NOTEBOOK_KEY "prefsw_notebook"
|
||||
#define E_PREFSW_SAVE_BT_KEY "prefsw_save_bt"
|
||||
#define E_PAGE_ITER_KEY "page_iter"
|
||||
#define E_PAGE_MODULE_KEY "page_module"
|
||||
#define E_PAGESW_FRAME_KEY "pagesw_frame"
|
||||
|
@ -619,7 +620,7 @@ prefs_cb(GtkWidget *w _U_, gpointer dummy _U_)
|
|||
cts.is_protocol = FALSE;
|
||||
prefs_module_list_foreach(NULL, module_prefs_show, &cts);
|
||||
|
||||
/* Button row: OK and cancel buttons */
|
||||
/* Button row: OK and alike buttons */
|
||||
|
||||
if(topic_available(HELP_PREFERENCES_DIALOG)) {
|
||||
bbox = dlg_button_row_new(GTK_STOCK_HELP, GTK_STOCK_OK, GTK_STOCK_APPLY, GTK_STOCK_SAVE, GTK_STOCK_CANCEL, NULL);
|
||||
|
@ -637,6 +638,7 @@ prefs_cb(GtkWidget *w _U_, gpointer dummy _U_)
|
|||
|
||||
save_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_SAVE);
|
||||
SIGNAL_CONNECT(save_bt, "clicked", prefs_main_save_cb, prefs_w);
|
||||
OBJECT_SET_DATA(prefs_w, E_PREFSW_SAVE_BT_KEY, save_bt);
|
||||
|
||||
cancel_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CANCEL);
|
||||
SIGNAL_CONNECT(cancel_bt, "clicked", prefs_main_cancel_cb, prefs_w);
|
||||
|
@ -653,6 +655,12 @@ prefs_cb(GtkWidget *w _U_, gpointer dummy _U_)
|
|||
SIGNAL_CONNECT(prefs_w, "destroy", prefs_main_destroy_cb, prefs_w);
|
||||
|
||||
gtk_widget_show(prefs_w);
|
||||
|
||||
/* hide the Save button if the user uses implicit save */
|
||||
if(!prefs.gui_use_pref_save) {
|
||||
gtk_widget_hide(save_bt);
|
||||
}
|
||||
|
||||
window_present(prefs_w);
|
||||
|
||||
#if GTK_MAJOR_VERSION >= 2
|
||||
|
@ -1167,6 +1175,8 @@ prefs_main_fetch_all(GtkWidget *dlg, gboolean *must_redissect)
|
|||
static void
|
||||
prefs_main_apply_all(GtkWidget *dlg)
|
||||
{
|
||||
GtkWidget *save_bt;
|
||||
|
||||
/*
|
||||
* Apply the protocol preferences first - "gui_prefs_apply()" could
|
||||
* cause redissection, and we have to make sure the protocol
|
||||
|
@ -1191,6 +1201,14 @@ prefs_main_apply_all(GtkWidget *dlg)
|
|||
#endif /* HAVE_LIBPCAP */
|
||||
printer_prefs_apply(OBJECT_GET_DATA(dlg, E_PRINT_PAGE_KEY));
|
||||
nameres_prefs_apply(OBJECT_GET_DATA(dlg, E_NAMERES_PAGE_KEY));
|
||||
|
||||
/* show/hide the Save button - depending on setting */
|
||||
save_bt = OBJECT_GET_DATA(prefs_w, E_PREFSW_SAVE_BT_KEY);
|
||||
if(prefs.gui_use_pref_save) {
|
||||
gtk_widget_show(save_bt);
|
||||
} else {
|
||||
gtk_widget_hide(save_bt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1236,51 +1254,12 @@ prefs_main_destroy_all(GtkWidget *dlg)
|
|||
|
||||
|
||||
static void
|
||||
prefs_main_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
|
||||
prefs_main_write(void)
|
||||
{
|
||||
gboolean must_redissect = FALSE;
|
||||
|
||||
if (!prefs_main_fetch_all(parent_w, &must_redissect))
|
||||
return; /* Errors in some preference setting */
|
||||
|
||||
prefs_main_apply_all(parent_w);
|
||||
|
||||
/* Now destroy the "Preferences" dialog. */
|
||||
window_destroy(GTK_WIDGET(parent_w));
|
||||
|
||||
if (must_redissect) {
|
||||
/* Redissect all the packets, and re-evaluate the display filter. */
|
||||
cf_redissect_packets(&cfile);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
prefs_main_apply_cb(GtkWidget *apply_bt _U_, gpointer parent_w)
|
||||
{
|
||||
gboolean must_redissect = FALSE;
|
||||
|
||||
if (!prefs_main_fetch_all(parent_w, &must_redissect))
|
||||
return; /* Errors in some preference setting */
|
||||
|
||||
prefs_main_apply_all(parent_w);
|
||||
|
||||
if (must_redissect) {
|
||||
/* Redissect all the packets, and re-evaluate the display filter. */
|
||||
cf_redissect_packets(&cfile);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
prefs_main_save_cb(GtkWidget *save_bt _U_, gpointer parent_w)
|
||||
{
|
||||
gboolean must_redissect = FALSE;
|
||||
int err;
|
||||
char *pf_dir_path;
|
||||
char *pf_path;
|
||||
|
||||
if (!prefs_main_fetch_all(parent_w, &must_redissect))
|
||||
return; /* Errors in some preference setting */
|
||||
|
||||
/* Create the directory that holds personal configuration files, if
|
||||
necessary. */
|
||||
if (create_persconffile_dir(&pf_dir_path) == -1) {
|
||||
|
@ -1298,6 +1277,58 @@ prefs_main_save_cb(GtkWidget *save_bt _U_, gpointer parent_w)
|
|||
g_free(pf_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
prefs_main_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
|
||||
{
|
||||
gboolean must_redissect = FALSE;
|
||||
|
||||
if (!prefs_main_fetch_all(parent_w, &must_redissect))
|
||||
return; /* Errors in some preference setting - already reported */
|
||||
|
||||
/* if we don't have a Save button, just save the settings now */
|
||||
if (!prefs.gui_use_pref_save) {
|
||||
prefs_main_write();
|
||||
}
|
||||
|
||||
prefs_main_apply_all(parent_w);
|
||||
|
||||
/* Now destroy the "Preferences" dialog. */
|
||||
window_destroy(GTK_WIDGET(parent_w));
|
||||
|
||||
if (must_redissect) {
|
||||
/* Redissect all the packets, and re-evaluate the display filter. */
|
||||
cf_redissect_packets(&cfile);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
prefs_main_apply_cb(GtkWidget *apply_bt _U_, gpointer parent_w)
|
||||
{
|
||||
gboolean must_redissect = FALSE;
|
||||
|
||||
if (!prefs_main_fetch_all(parent_w, &must_redissect))
|
||||
return; /* Errors in some preference setting - already reported */
|
||||
|
||||
prefs_main_apply_all(parent_w);
|
||||
|
||||
if (must_redissect) {
|
||||
/* Redissect all the packets, and re-evaluate the display filter. */
|
||||
cf_redissect_packets(&cfile);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
prefs_main_save_cb(GtkWidget *save_bt _U_, gpointer parent_w)
|
||||
{
|
||||
gboolean must_redissect = FALSE;
|
||||
|
||||
if (!prefs_main_fetch_all(parent_w, &must_redissect))
|
||||
return; /* Errors in some preference setting - already reported */
|
||||
|
||||
prefs_main_write();
|
||||
|
||||
/* Now apply those preferences.
|
||||
XXX - should we do this? The user didn't click "OK" or "Apply".
|
||||
|
|
|
@ -97,7 +97,7 @@ proto_cb(GtkWidget *w _U_, gpointer data _U_)
|
|||
{
|
||||
|
||||
GtkWidget *main_vb, *bbox, *proto_list, *label, *proto_sw, *proto_frame,
|
||||
*proto_vb, *button;
|
||||
*proto_vb, *button, *ok_bt, *apply_bt, *save_bt, *cancel_bt, *help_bt;
|
||||
const gchar *titles[] = { "Status", "Protocol", "Description" };
|
||||
#if GTK_MAJOR_VERSION < 2
|
||||
gint width;
|
||||
|
@ -228,22 +228,22 @@ proto_cb(GtkWidget *w _U_, gpointer data _U_)
|
|||
gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show(bbox);
|
||||
|
||||
button = OBJECT_GET_DATA(bbox, GTK_STOCK_OK);
|
||||
SIGNAL_CONNECT(button, "clicked", proto_ok_cb, proto_w);
|
||||
gtk_widget_grab_default(button);
|
||||
ok_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_OK);
|
||||
SIGNAL_CONNECT(ok_bt, "clicked", proto_ok_cb, proto_w);
|
||||
gtk_widget_grab_default(ok_bt);
|
||||
|
||||
button = OBJECT_GET_DATA(bbox, GTK_STOCK_APPLY);
|
||||
SIGNAL_CONNECT(button, "clicked", proto_apply_cb, proto_w);
|
||||
apply_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_APPLY);
|
||||
SIGNAL_CONNECT(apply_bt, "clicked", proto_apply_cb, proto_w);
|
||||
|
||||
button = OBJECT_GET_DATA(bbox, GTK_STOCK_SAVE);
|
||||
SIGNAL_CONNECT(button, "clicked", proto_save_cb, proto_w);
|
||||
save_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_SAVE);
|
||||
SIGNAL_CONNECT(save_bt, "clicked", proto_save_cb, proto_w);
|
||||
|
||||
button = OBJECT_GET_DATA(bbox, GTK_STOCK_CANCEL);
|
||||
window_set_cancel_button(proto_w, button, proto_cancel_cb);
|
||||
cancel_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CANCEL);
|
||||
window_set_cancel_button(proto_w, cancel_bt, proto_cancel_cb);
|
||||
|
||||
if(topic_available(HELP_ENABLED_PROTOCOLS_DIALOG)) {
|
||||
button = OBJECT_GET_DATA(bbox, GTK_STOCK_HELP);
|
||||
SIGNAL_CONNECT(button, "clicked", topic_cb, HELP_ENABLED_PROTOCOLS_DIALOG);
|
||||
help_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_HELP);
|
||||
SIGNAL_CONNECT(help_bt, "clicked", topic_cb, HELP_ENABLED_PROTOCOLS_DIALOG);
|
||||
}
|
||||
|
||||
SIGNAL_CONNECT(proto_w, "delete_event", proto_delete_event_cb, NULL);
|
||||
|
@ -252,6 +252,12 @@ proto_cb(GtkWidget *w _U_, gpointer data _U_)
|
|||
gtk_quit_add_destroy(gtk_main_level(), GTK_OBJECT(proto_w));
|
||||
|
||||
gtk_widget_show(proto_w);
|
||||
|
||||
/* hide the Save button if the user uses implicit save */
|
||||
if(!prefs.gui_use_pref_save) {
|
||||
gtk_widget_hide(save_bt);
|
||||
}
|
||||
|
||||
window_present(proto_w);
|
||||
} /* proto_cb */
|
||||
|
||||
|
@ -408,11 +414,40 @@ proto_delete_event_cb(GtkWidget *proto_w, GdkEvent *event _U_,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static void proto_write(gpointer parent_w)
|
||||
{
|
||||
char *pf_dir_path;
|
||||
char *pf_path;
|
||||
int pf_save_errno;
|
||||
|
||||
/* Create the directory that holds personal configuration files, if
|
||||
necessary. */
|
||||
if (create_persconffile_dir(&pf_dir_path) == -1) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Can't create directory\n\"%s\"\nfor disabled protocols file: %s.", pf_dir_path,
|
||||
strerror(errno));
|
||||
g_free(pf_dir_path);
|
||||
} else {
|
||||
save_disabled_protos_list(&pf_path, &pf_save_errno);
|
||||
if (pf_path != NULL) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Could not save to your disabled protocols file\n\"%s\": %s.",
|
||||
pf_path, strerror(pf_save_errno));
|
||||
g_free(pf_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
proto_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
|
||||
{
|
||||
gboolean redissect;
|
||||
|
||||
/* if we don't have a Save button, just save the settings now */
|
||||
if (!prefs.gui_use_pref_save) {
|
||||
proto_write(parent_w);
|
||||
}
|
||||
|
||||
redissect = set_proto_selection(GTK_WIDGET(parent_w));
|
||||
window_destroy(GTK_WIDGET(parent_w));
|
||||
if (redissect)
|
||||
|
@ -429,34 +464,10 @@ proto_apply_cb(GtkWidget *apply_bt _U_, gpointer parent_w)
|
|||
static void
|
||||
proto_save_cb(GtkWidget *save_bt _U_, gpointer parent_w)
|
||||
{
|
||||
gboolean must_redissect = FALSE;
|
||||
char *pf_dir_path;
|
||||
char *pf_path;
|
||||
int pf_save_errno;
|
||||
|
||||
/* Create the directory that holds personal configuration files, if
|
||||
necessary. */
|
||||
if (create_persconffile_dir(&pf_dir_path) == -1) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Can't create directory\n\"%s\"\nfor disabled protocols file: %s.", pf_dir_path,
|
||||
strerror(errno));
|
||||
g_free(pf_dir_path);
|
||||
} else {
|
||||
/*
|
||||
* make disabled/enabled protocol settings current
|
||||
*/
|
||||
must_redissect = set_proto_selection(GTK_WIDGET(parent_w));
|
||||
proto_write(parent_w);
|
||||
|
||||
save_disabled_protos_list(&pf_path, &pf_save_errno);
|
||||
if (pf_path != NULL) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Could not save to your disabled protocols file\n\"%s\": %s.",
|
||||
pf_path, strerror(pf_save_errno));
|
||||
g_free(pf_path);
|
||||
}
|
||||
}
|
||||
|
||||
if (must_redissect) {
|
||||
if (set_proto_selection(GTK_WIDGET(parent_w))) {
|
||||
/* Redissect all the packets, and re-evaluate the display filter. */
|
||||
cf_redissect_packets(&cfile);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue