all repos — tint2 @ 860c100a040d0431b97b5eaa80a85e96bf46c388

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

launcher: sort desktop files by name in launcher_apps_dir
o9000 o9000
commit

860c100a040d0431b97b5eaa80a85e96bf46c388

parent

9040764cf1c575ac035da4ca3e9729a37614e249

1 files changed, 33 insertions(+), 7 deletions(-)

jump to
M src/config.csrc/config.c

@@ -41,6 +41,7 @@ #ifndef TINT2CONF

#include "common.h" #include "server.h" +#include "strnatcmp.h" #include "panel.h" #include "task.h" #include "taskbar.h"

@@ -153,23 +154,48 @@ // monitor == "all" or monitor not found or xrandr can't identify monitors

return -1; } +static gint compare_strings(gconstpointer a, gconstpointer b) +{ + return strnatcasecmp((const char*)a, (const char*)b); +} + void load_launcher_app_dir(const char *path) { - GDir *d = g_dir_open(path, 0, NULL); + GList *subdirs = NULL; + GList *files = NULL; + + GDir *d = g_dir_open(path, 0, NULL); if (d) { const gchar *name; while ((name = g_dir_read_name(d))) { gchar *file = g_build_filename(path, name, NULL); - if (!g_file_test(file, G_FILE_TEST_IS_DIR) && - g_str_has_suffix(file, ".desktop")) { - panel_config.launcher.list_apps = g_slist_append(panel_config.launcher.list_apps, strdup(file)); + if (!g_file_test(file, G_FILE_TEST_IS_DIR) && g_str_has_suffix(file, ".desktop")) { + files = g_list_append(files, file); } else if (g_file_test(file, G_FILE_TEST_IS_DIR)) { - load_launcher_app_dir(file); - } - g_free(file); + subdirs = g_list_append(subdirs, file); + } else { + g_free(file); + } } g_dir_close(d); } + + subdirs = g_list_sort(subdirs, compare_strings); + GList *l; + for (l = subdirs; l; l = g_list_next(l)) { + gchar *dir = (gchar *)l->data; + load_launcher_app_dir(dir); + g_free(dir); + } + g_list_free(subdirs); + + files = g_list_sort(files, compare_strings); + for (l = files; l; l = g_list_next(l)) { + gchar *file = (gchar *)l->data; + panel_config.launcher.list_apps = g_slist_append(panel_config.launcher.list_apps, strdup(file)); + g_free(file); + } + g_list_free(files); } void add_entry (char *key, char *value)