Don't give ordinal numbers to preferences that aren't displayed.

svn path=/trunk/; revision=5554
This commit is contained in:
Guy Harris 2002-05-25 01:47:46 +00:00
parent 16c7726c04
commit d3604ae33e
2 changed files with 13 additions and 5 deletions

View File

@ -2,7 +2,7 @@
* Definitions for implementation of preference handling routines;
* used by "friends" of the preferences type.
*
* $Id: prefs-int.h,v 1.5 2002/05/11 18:58:02 guy Exp $
* $Id: prefs-int.h,v 1.6 2002/05/25 01:47:46 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -31,7 +31,7 @@ struct pref_module {
const char *title; /* title of module (displayed in preferences notebook) */
void (*apply_cb)(void); /* routine to call when preferences applied */
GList *prefs; /* list of its preferences */
int numprefs; /* number of preferences */
int numprefs; /* number of non-obsolete preferences */
gboolean prefs_changed; /* if TRUE, a preference has changed since we last checked */
gboolean obsolete; /* if TRUE, this is a module that used to
exist but no longer does */

14
prefs.c
View File

@ -1,7 +1,7 @@
/* prefs.c
* Routines for handling preferences
*
* $Id: prefs.c,v 1.82 2002/05/11 18:58:02 guy Exp $
* $Id: prefs.c,v 1.83 2002/05/25 01:47:46 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -260,6 +260,10 @@ prefs_apply_all(void)
/*
* Register a preference in a module's list of preferences.
* If it has a title, give it an ordinal number; otherwise, it's a
* preference that won't show up in the UI, so it shouldn't get an
* ordinal number (the ordinal should be the ordinal in the set of
* *visible* preferences).
*/
static pref_t *
register_preference(module_t *module, const char *name, const char *title,
@ -272,7 +276,10 @@ register_preference(module_t *module, const char *name, const char *title,
preference->name = name;
preference->title = title;
preference->description = description;
preference->ordinal = module->numprefs;
if (title != NULL)
preference->ordinal = module->numprefs;
else
preference->ordinal = -1; /* no ordinal for you */
/*
* Make sure that only lower-case ASCII letters, numbers,
@ -301,7 +308,8 @@ register_preference(module_t *module, const char *name, const char *title,
* preference.
*/
module->prefs = g_list_append(module->prefs, preference);
module->numprefs++;
if (title != NULL)
module->numprefs++;
return preference;
}