aboutsummaryrefslogtreecommitdiffstats
path: root/prefs.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 /prefs.c
parent57d8e47ad0ef7be6aa8e9d378d9aac2d6468ed27 (diff)
downloadwireshark-0a71de81373a2e08f0f0b7f76265d823ba46f821.tar.gz
wireshark-0a71de81373a2e08f0f0b7f76265d823ba46f821.tar.bz2
wireshark-0a71de81373a2e08f0f0b7f76265d823ba46f821.zip
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 'prefs.c')
-rw-r--r--prefs.c44
1 files changed, 34 insertions, 10 deletions
diff --git a/prefs.c b/prefs.c
index e4b2e18829..77f99d0494 100644
--- a/prefs.c
+++ b/prefs.c
@@ -1,7 +1,7 @@
/* prefs.c
* Routines for handling preferences
*
- * $Id: prefs.c,v 1.31 2000/07/05 09:40:41 guy Exp $
+ * $Id: prefs.c,v 1.32 2000/07/09 03:29:28 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -100,6 +100,7 @@ prefs_register_module(const char *name, const char *title,
module->apply_cb = apply_cb;
module->prefs = NULL; /* no preferences, to start */
module->numprefs = 0;
+ module->prefs_changed = FALSE;
modules = g_list_append(modules, module);
@@ -161,11 +162,18 @@ call_apply_cb(gpointer data, gpointer user_data)
{
module_t *module = data;
- (*module->apply_cb)();
+ if (module->prefs_changed) {
+ if (module->apply_cb != NULL)
+ (*module->apply_cb)();
+ module->prefs_changed = FALSE;
+ }
}
/*
- * Call the "apply" callback function for each module.
+ * Call the "apply" callback function for each module if any of its
+ * preferences have changed, and then clear the flag saying its
+ * preferences have changed, as the module has been notified of that
+ * fact.
*/
void
prefs_apply_all(void)
@@ -714,6 +722,8 @@ set_pref(gchar *pref_name, gchar *value)
fmt_data *cfmt;
unsigned long int cval;
guint uval;
+ gboolean bval;
+ gint enum_val;
char *p;
gchar *dotp;
module_t *module;
@@ -836,27 +846,41 @@ set_pref(gchar *pref_name, gchar *value)
uval = strtoul(value, &p, pref->info.base);
if (p == value || *p != '\0')
return PREFS_SET_SYNTAX_ERR; /* number was bad */
- *pref->varp.uint = uval;
+ if (*pref->varp.uint != uval) {
+ module->prefs_changed = TRUE;
+ *pref->varp.uint = uval;
+ }
break;
case PREF_BOOL:
/* XXX - give an error if it's neither "true" nor "false"? */
if (strcasecmp(value, "true") == 0)
- *pref->varp.bool = TRUE;
+ bval = TRUE;
else
- *pref->varp.bool = FALSE;
+ bval = FALSE;
+ if (*pref->varp.bool != bval) {
+ module->prefs_changed = TRUE;
+ *pref->varp.bool = bval;
+ }
break;
case PREF_ENUM:
/* XXX - give an error if it doesn't match? */
- *pref->varp.enump = find_val_for_string(value,
+ enum_val = find_val_for_string(value,
pref->info.enum_info.enumvals, 1);
+ if (*pref->varp.enump != enum_val) {
+ module->prefs_changed = TRUE;
+ *pref->varp.enump = enum_val;
+ }
break;
case PREF_STRING:
- if (*pref->varp.string != NULL)
- g_free(*pref->varp.string);
- *pref->varp.string = g_strdup(value);
+ if (*pref->varp.string == NULL || strcmp(*pref->varp.string, value) != 0) {
+ module->prefs_changed = TRUE;
+ if (*pref->varp.string != NULL)
+ g_free(*pref->varp.string);
+ *pref->varp.string = g_strdup(value);
+ }
break;
}
}