file_browser.c - Display files and folders by alphabetical order
This commit is contained in:
parent
64c6f73630
commit
0163faffed
@ -366,6 +366,13 @@ file_browser_free(struct file_browser *browser)
|
||||
memset(browser, 0, sizeof(*browser));
|
||||
}
|
||||
|
||||
int cmp_fn(const void *str1, const void *str2)
|
||||
{
|
||||
const char *str1_ret = *(const char **)str1;
|
||||
const char *str2_ret = *(const char **)str2;
|
||||
return strcmp(str1_ret, str2_ret);
|
||||
}
|
||||
|
||||
static int
|
||||
file_browser_run(struct file_browser *browser, struct nk_context *ctx)
|
||||
{
|
||||
@ -448,6 +455,7 @@ file_browser_run(struct file_browser *browser, struct nk_context *ctx)
|
||||
if (nk_button_image(ctx,media->icons.directory))
|
||||
index = (int)j;
|
||||
|
||||
qsort(browser->directories, browser->dir_count, sizeof(char *), cmp_fn);
|
||||
nk_label(ctx, browser->directories[j], NK_TEXT_LEFT);
|
||||
} else {
|
||||
/* draw and execute files buttons */
|
||||
@ -464,6 +472,7 @@ file_browser_run(struct file_browser *browser, struct nk_context *ctx)
|
||||
/* draw one column of labels */
|
||||
if (j >= browser->dir_count) {
|
||||
size_t t = j - browser->dir_count;
|
||||
qsort(browser->files, browser->file_count, sizeof(char *), cmp_fn);
|
||||
nk_label(ctx,browser->files[t],NK_TEXT_LEFT);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user