aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2017-11-28 12:52:27 +0100
committerAnders Broman <a.broman58@gmail.com>2017-11-28 16:31:40 +0000
commitda910203539afc7fa37caa17ccf41674d7953ab0 (patch)
tree95af7f8b6e939655a84e76670df52a1a802ef80e
parent87a8877007471c0e3113c21c8675bfe5d81b1289 (diff)
ui: Sort profile names
Not all file systems returns a sorted list of filenames, so we need to sort the entries before using the list in the Profile popup and the Manage Profiles dialog. Change-Id: Ic1f2bfa77fb47fb8c406d891aee49b484876b4f7 Reviewed-on: https://code.wireshark.org/review/24615 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r--ui/profile.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/ui/profile.c b/ui/profile.c
index 24f3d75..4912198 100644
--- a/ui/profile.c
+++ b/ui/profile.c
@@ -313,6 +313,9 @@ init_profile_list(void)
WS_DIR *dir; /* scanned directory */
WS_DIRENT *file; /* current file */
const gchar *name;
+ GList *local_profiles = NULL;
+ GList *global_profiles = NULL;
+ GList *iter;
gchar *profiles_dir, *filename;
empty_profile_list(TRUE);
@@ -328,7 +331,7 @@ init_profile_list(void)
filename = g_strdup_printf ("%s%s%s", profiles_dir, G_DIR_SEPARATOR_S, name);
if (test_for_directory(filename) == EISDIR) {
- /*fl_entry =*/ add_to_profile_list(name, name, PROF_STAT_EXISTS, FALSE, FALSE);
+ local_profiles = g_list_prepend(local_profiles, g_strdup(name));
}
g_free (filename);
}
@@ -336,6 +339,13 @@ init_profile_list(void)
}
g_free(profiles_dir);
+ local_profiles = g_list_sort(local_profiles, (GCompareFunc)g_ascii_strcasecmp);
+ for (iter = g_list_first(local_profiles); iter; iter = g_list_next(iter)) {
+ name = (gchar *)iter->data;
+ add_to_profile_list(name, name, PROF_STAT_EXISTS, FALSE, FALSE);
+ }
+ g_list_free_full(local_profiles, g_free);
+
/* Global profiles */
profiles_dir = get_global_profiles_dir();
if ((dir = ws_dir_open(profiles_dir, 0, NULL)) != NULL) {
@@ -344,8 +354,7 @@ init_profile_list(void)
filename = g_strdup_printf ("%s%s%s", profiles_dir, G_DIR_SEPARATOR_S, name);
if (test_for_directory(filename) == EISDIR) {
- /*fl_entry =*/ add_to_profile_list(name, name, PROF_STAT_EXISTS, TRUE, TRUE);
- /*profile = (profile_def *) fl_entry->data;*/
+ global_profiles = g_list_prepend(global_profiles, g_strdup(name));
}
g_free (filename);
}
@@ -353,6 +362,13 @@ init_profile_list(void)
}
g_free(profiles_dir);
+ global_profiles = g_list_sort(global_profiles, (GCompareFunc)g_ascii_strcasecmp);
+ for (iter = g_list_first(global_profiles); iter; iter = g_list_next(iter)) {
+ name = (gchar *)iter->data;
+ add_to_profile_list(name, name, PROF_STAT_EXISTS, TRUE, TRUE);
+ }
+ g_list_free_full(global_profiles, g_free);
+
/* Make the current list and the edited list equal */
copy_profile_list ();
}