diff options
author | Tomas Kukosa <tomas.kukosa@siemens.com> | 2007-11-29 07:52:52 +0000 |
---|---|---|
committer | Tomas Kukosa <tomas.kukosa@siemens.com> | 2007-11-29 07:52:52 +0000 |
commit | a5ca7ec3848a18fb25834774e87a8e5e84a78d0f (patch) | |
tree | 20d8805d5bb0184271472dcf21f6b1dadbe07b18 | |
parent | 7f4df19970e0669d38f7560ffe45a43e901cfe55 (diff) |
hide implementation of module list
(it makes easier change from GList to GTree as we have many modules now and GList implementation is slow for searching)
svn path=/trunk/; revision=23669
-rw-r--r-- | epan/libwireshark.def | 3 | ||||
-rw-r--r-- | epan/prefs.c | 26 | ||||
-rw-r--r-- | epan/prefs.h | 24 | ||||
-rw-r--r-- | gtk/prefs_dlg.c | 18 |
4 files changed, 50 insertions, 21 deletions
diff --git a/epan/libwireshark.def b/epan/libwireshark.def index edbf67f2e4..e56be340f4 100644 --- a/epan/libwireshark.def +++ b/epan/libwireshark.def @@ -559,8 +559,9 @@ prefs_apply_all prefs_find_module prefs_get_title_by_name prefs_is_registered_protocol -prefs_module_list_foreach +prefs_module_has_submodules prefs_modules_foreach +prefs_modules_foreach_submodules prefs_pref_foreach prefs_register_bool_preference prefs_register_enum_preference diff --git a/epan/prefs.c b/epan/prefs.c index 684d1494d5..23f2c0e533 100644 --- a/epan/prefs.c +++ b/epan/prefs.c @@ -452,7 +452,7 @@ find_subtree(module_t *parent, const char *name) * silently ignored in preference files. Does not ignore subtrees, * as this can be used when walking the display tree of modules. */ -guint +static guint prefs_module_list_foreach(GList *module_list, module_cb callback, gpointer user_data) { @@ -476,6 +476,14 @@ prefs_module_list_foreach(GList *module_list, module_cb callback, } /* + * Returns TRUE if module has any submodules + */ +gboolean prefs_module_has_submodules(module_t *module) +{ + return (module->submodules != NULL); +} + +/* * Call a callback function, with a specified argument, for each module * in the list of all modules. (This list does not include subtrees.) * @@ -489,6 +497,22 @@ prefs_modules_foreach(module_cb callback, gpointer user_data) return prefs_module_list_foreach(modules, callback, user_data); } +/* + * Call a callback function, with a specified argument, for each submodule + * of specified modules. If the module is NULL, goes through the top-level + * list in the display tree of modules. + * + * Ignores "obsolete" modules; their sole purpose is to allow old + * preferences for dissectors that no longer have preferences to be + * silently ignored in preference files. Does not ignore subtrees, + * as this can be used when walking the display tree of modules. + */ +guint +prefs_modules_foreach_submodules(module_t *module, module_cb callback, gpointer user_data) +{ + return prefs_module_list_foreach((module)?module->submodules:top_level_modules, callback, user_data); +} + static void call_apply_cb(gpointer data, gpointer user_data _U_) { diff --git a/epan/prefs.h b/epan/prefs.h index fe3f2e1a35..b0c3e2af60 100644 --- a/epan/prefs.h +++ b/epan/prefs.h @@ -216,17 +216,9 @@ extern module_t *prefs_register_protocol_obsolete(int id); typedef guint (*module_cb)(module_t *module, gpointer user_data); /* - * Call a callback function, with a specified argument, for each module - * in a list of modules. If the list is NULL, searches the top-level - * list in the display tree of modules. - * - * Ignores "obsolete" modules; their sole purpose is to allow old - * preferences for dissectors that no longer have preferences to be - * silently ignored in preference files. Does not ignore subtrees, - * as this can be used when walking the display tree of modules. + * Returns TRUE if module has any submodules */ -extern guint prefs_module_list_foreach(GList *module_list, module_cb callback, - gpointer user_data); +extern gboolean prefs_module_has_submodules(module_t *module); /* * Call a callback function, with a specified argument, for each module @@ -239,6 +231,18 @@ extern guint prefs_module_list_foreach(GList *module_list, module_cb callback, extern guint prefs_modules_foreach(module_cb callback, gpointer user_data); /* + * Call a callback function, with a specified argument, for each submodule + * of specified modules. If the module is NULL, goes through the top-level + * list in the display tree of modules. + * + * Ignores "obsolete" modules; their sole purpose is to allow old + * preferences for dissectors that no longer have preferences to be + * silently ignored in preference files. Does not ignore subtrees, + * as this can be used when walking the display tree of modules. + */ +extern guint prefs_modules_foreach_submodules(module_t *module, module_cb callback, gpointer user_data); + +/* * 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 diff --git a/gtk/prefs_dlg.c b/gtk/prefs_dlg.c index f5a689fdbf..465be9e966 100644 --- a/gtk/prefs_dlg.c +++ b/gtk/prefs_dlg.c @@ -283,7 +283,7 @@ module_prefs_show(module_t *module, gpointer user_data) /* * Is this module a subtree, with modules underneath it? */ - if (!module->submodules) { + if (!prefs_module_has_submodules(module)) { /* * No. * Does it have any preferences (other than possibly obsolete ones)? @@ -305,11 +305,11 @@ module_prefs_show(module_t *module, gpointer user_data) strcpy(label_str, module->title); #if GTK_MAJOR_VERSION < 2 ct_node = gtk_ctree_insert_node(GTK_CTREE(cts->tree), cts->node, NULL, - &label_ptr, 5, NULL, NULL, NULL, NULL, !module->submodules, + &label_ptr, 5, NULL, NULL, NULL, NULL, !prefs_module_has_submodules(module), FALSE); #else model = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(cts->tree))); - if (module->submodules && !cts->iter.stamp) + if (prefs_module_has_submodules(module) && !cts->iter.stamp) gtk_tree_store_append(model, &iter, NULL); else gtk_tree_store_append(model, &iter, &cts->iter); @@ -318,7 +318,7 @@ module_prefs_show(module_t *module, gpointer user_data) /* * Is this a subtree? */ - if (module->submodules) { + if (prefs_module_has_submodules(module)) { /* * Yes. */ @@ -341,7 +341,7 @@ module_prefs_show(module_t *module, gpointer user_data) #endif if (module == protocols_module) child_cts.is_protocol = TRUE; - prefs_module_list_foreach(module->submodules, module_prefs_show, &child_cts); + prefs_modules_foreach_submodules(module, module_prefs_show, &child_cts); /* keep the page count right */ cts->page = child_cts.page; @@ -677,7 +677,7 @@ prefs_cb(GtkWidget *w _U_, gpointer dummy _U_) /* Registered prefs */ cts.notebook = prefs_nb; cts.is_protocol = FALSE; - prefs_module_list_foreach(NULL, module_prefs_show, &cts); + prefs_modules_foreach_submodules(NULL, module_prefs_show, &cts); /* Button row: OK and alike buttons */ @@ -1703,8 +1703,8 @@ module_search_properties(module_t *module, gpointer user_data) return 1; /* stops the search */ } - if(module->submodules) - return prefs_module_list_foreach(module->submodules, module_search_properties, p); + if(prefs_module_has_submodules(module)) + return prefs_modules_foreach_submodules(module, module_search_properties, p); return 0; } @@ -1816,7 +1816,7 @@ properties_cb(GtkWidget *w, gpointer dummy) XXX - should we just associate protocols with modules directly? */ p.title = title; p.module = NULL; - prefs_module_list_foreach(protocols_module->submodules, module_search_properties, + prefs_modules_foreach_submodules(protocols_module, module_search_properties, &p); if (p.module == NULL) { /* We didn't find it - that protocol probably has no preferences. */ |