aboutsummaryrefslogtreecommitdiffstats
path: root/gtk/prefs_dlg.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2000-07-09 03:29:42 +0000
committerGuy Harris <guy@alum.mit.edu>2000-07-09 03:29:42 +0000
commit0a71de81373a2e08f0f0b7f76265d823ba46f821 (patch)
tree41d0d42efe9bb5a669c4f5448a652571fa6db814 /gtk/prefs_dlg.c
parent57d8e47ad0ef7be6aa8e9d378d9aac2d6468ed27 (diff)
Turn the code of "colorize_packet()" into a static routine that is given
a word to use in the progress dialog, and a flag indicating whether the display filter is to be reevaluated or not, and: have "colorize_packet()" call that routine with "Colorizing" and FALSE as those arguments; have the filtering code call that routine with "Filtering" and TRUE as those arguments; add an exported routine to call that routine with "Reprocessing" and TRUE as those arguments, to use to re-generate the packet list and to re-filter the packets if a protocol preference has been changed. Keep track of whether preferences are changed from their initial value by a preferences file or a command-line option, or from their previous value by the "Preferences" dialog box; have "prefs_apply_all()" only call the "apply" callback for a module if they have. Call "prefs_apply_all()" after the command-line arguments have been parsed and after "OK" has been clicked in the "Preferences" dialog box, to notify modules of preference changes if they've registered a callback for that. After "OK" has been clicked in the "Preferences" dialog box, if any preferences have changed, call the reprocessing routine, as the summary line for some frames and/or the current display filter's value when applied to some frames may have changed as a result of a preference change. Do the same after "OK" or "Apply" has been clicked in the "Display Options" dialog box (as it controls a protocol preferences item. svn path=/trunk/; revision=2126
Diffstat (limited to 'gtk/prefs_dlg.c')
-rw-r--r--gtk/prefs_dlg.c54
1 files changed, 44 insertions, 10 deletions
diff --git a/gtk/prefs_dlg.c b/gtk/prefs_dlg.c
index a107816ac5..7af69af96b 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.14 2000/07/05 09:41:07 guy Exp $
+ * $Id: prefs_dlg.c,v 1.15 2000/07/09 03:29:42 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -334,8 +334,11 @@ pref_fetch(pref_t *pref, gpointer user_data)
char *str_val;
char *p;
guint uval;
+ gboolean bval;
GSList *rb_entry;
GtkWidget *button;
+ gint enumval;
+ gboolean *pref_changed_p = user_data;
/* Fetch the value of the preference, and set the appropriate variable
to it. */
@@ -348,11 +351,18 @@ pref_fetch(pref_t *pref, gpointer user_data)
if (p == value || *p != '\0')
return PREFS_SET_SYNTAX_ERR; /* number was bad */
#endif
- *pref->varp.uint = uval;
+ if (*pref->varp.uint != uval) {
+ *pref_changed_p = TRUE;
+ *pref->varp.uint = uval;
+ }
break;
case PREF_BOOL:
- *pref->varp.bool = GTK_TOGGLE_BUTTON(pref->control)->active;
+ bval = GTK_TOGGLE_BUTTON(pref->control)->active;
+ if (*pref->varp.bool != bval) {
+ *pref_changed_p = TRUE;
+ *pref->varp.bool = bval;
+ }
break;
case PREF_ENUM:
@@ -377,15 +387,22 @@ pref_fetch(pref_t *pref, gpointer user_data)
/* Get the label, and translate it to a value. */
gtk_label_get(GTK_LABEL(label), &label_string);
- *pref->varp.enump = find_val_for_string(label_string,
+ enumval = find_val_for_string(label_string,
pref->info.enum_info.enumvals, 1);
+ if (*pref->varp.enump != enumval) {
+ *pref_changed_p = TRUE;
+ *pref->varp.enump = enumval;
+ }
break;
case PREF_STRING:
str_val = gtk_entry_get_text(GTK_ENTRY(pref->control));
- if (*pref->varp.string != NULL)
- g_free(*pref->varp.string);
- *pref->varp.string = g_strdup(str_val);
+ if (*pref->varp.string == NULL || strcmp(*pref->varp.string, str_val) != 0) {
+ *pref_changed_p = TRUE;
+ if (*pref->varp.string != NULL)
+ g_free(*pref->varp.string);
+ *pref->varp.string = g_strdup(str_val);
+ }
break;
}
}
@@ -393,9 +410,18 @@ pref_fetch(pref_t *pref, gpointer user_data)
static void
module_prefs_fetch(module_t *module, gpointer user_data)
{
+ gboolean *must_redissect_p = user_data;
+
/* For all preferences in this module, fetch its value from this
- module's notebook page. */
- prefs_pref_foreach(module, pref_fetch, NULL);
+ module's notebook page. Find out whether any of them changed. */
+ module->prefs_changed = FALSE; /* assume none of them changed */
+ prefs_pref_foreach(module, pref_fetch, &module->prefs_changed);
+
+ /* If any of them changed, indicate that we must redissect and refilter
+ the current capture (if we have one), as the preference change
+ could cause packets to be dissected differently. */
+ if (module->prefs_changed)
+ *must_redissect_p = TRUE;
}
static void
@@ -432,13 +458,21 @@ module_prefs_clean(module_t *module, gpointer user_data)
static void
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));
- prefs_module_foreach(module_prefs_fetch, NULL);
+ prefs_module_foreach(module_prefs_fetch, &must_redissect);
+ prefs_apply_all();
prefs_module_foreach(module_prefs_clean, NULL);
gtk_widget_destroy(GTK_WIDGET(parent_w));
+
+ if (must_redissect) {
+ /* Redissect all the packets, and re-evaluate the display filter. */
+ redissect_packets(&cfile);
+ }
}
static void