diff options
author | Guy Harris <guy@alum.mit.edu> | 2003-10-02 21:06:11 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2003-10-02 21:06:11 +0000 |
commit | 301bc24c438a713a19ca5b3c85286af879e3c721 (patch) | |
tree | 249709a80e878db17c29af25f82b2f285fa96b67 /prefs.c | |
parent | 72282f4301f2f72b6a91900674f6d660187a367d (diff) |
Don't put an entry for a protocol into the Preferences dialog if it
doesn't have any settable preferences (for example, if it has only
obsolete preferences).
svn path=/trunk/; revision=8590
Diffstat (limited to 'prefs.c')
-rw-r--r-- | prefs.c | 58 |
1 files changed, 27 insertions, 31 deletions
@@ -1,7 +1,7 @@ /* prefs.c * Routines for handling preferences * - * $Id: prefs.c,v 1.107 2003/09/10 23:55:52 guy Exp $ + * $Id: prefs.c,v 1.108 2003/10/02 21:06:11 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -575,43 +575,39 @@ prefs_register_obsolete_preference(module_t *module, const char *name) register_preference(module, name, NULL, NULL, PREF_OBSOLETE); } -typedef struct { - pref_cb callback; - gpointer user_data; -} pref_cb_arg_t; - -static void -do_pref_callback(gpointer data, gpointer user_data) -{ - pref_t *pref = data; - pref_cb_arg_t *arg = user_data; - - if (pref->type == PREF_OBSOLETE) { - /* - * This preference is no longer supported; it's not a - * real preference, so we don't call the callback for - * it (i.e., we treat it as if it weren't found in the - * list of preferences, and we weren't called in the - * first place). - */ - return; - } - - (*arg->callback)(pref, arg->user_data); -} - /* * Call a callback function, with a specified argument, for each preference * in a given module. + * + * If any of the callbacks return a non-zero value, stop and return that + * value, otherwise return 0. */ -void +guint prefs_pref_foreach(module_t *module, pref_cb callback, gpointer user_data) { - pref_cb_arg_t arg; + GList *elem; + pref_t *pref; + guint ret; + + for (elem = g_list_first(module->prefs); elem != NULL; + elem = g_list_next(elem)) { + pref = elem->data; + if (pref->type == PREF_OBSOLETE) { + /* + * This preference is no longer supported; it's + * not a real preference, so we don't call the + * callback for it (i.e., we treat it as if it + * weren't found in the list of preferences, + * and we weren't called in the first place). + */ + continue; + } - arg.callback = callback; - arg.user_data = user_data; - g_list_foreach(module->prefs, do_pref_callback, &arg); + ret = (*callback)(pref, user_data); + if (ret != 0) + return ret; + } + return 0; } /* |