1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

[FileBrowser] Add option to group directories ahead of files. (#1352)

This commit is contained in:
TonCherAmi 2021-07-11 00:58:27 +03:00 committed by GitHub
parent b7dfb423a1
commit c1ff6baecd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 3 deletions

View file

@ -1185,6 +1185,8 @@ configuration {
* \- "ctime" (change time)
*/
sorting\-method: "name";
/** Group directories before files. */
directories\-first: true;
}
}

View file

@ -713,6 +713,8 @@ configuration {
* - "ctime" (change time)
*/
sorting-method: "name";
/** Group directories before files. */
directories-first: true;
}
}
```

View file

@ -107,9 +107,11 @@ struct
{
enum FBSortingMethod sorting_method;
enum FBSortingTime sorting_time;
gboolean directories_first;
} file_browser_config = {
.sorting_method = FB_SORT_NAME,
.sorting_time = FB_MTIME,
.sorting_method = FB_SORT_NAME,
.sorting_time = FB_MTIME,
.directories_first = TRUE,
};
static void free_list ( FileBrowserModePrivateData *pd )
@ -131,7 +133,7 @@ static gint compare_name ( gconstpointer a, gconstpointer b, G_GNUC_UNUSED gpoin
FBFile *fa = (FBFile *) a;
FBFile *fb = (FBFile *) b;
if ( fa->type != fb->type ) {
if ( file_browser_config.directories_first && fa->type != fb->type ) {
return fa->type - fb->type;
}
@ -143,6 +145,10 @@ static gint compare_time ( gconstpointer a, gconstpointer b, G_GNUC_UNUSED gpoin
FBFile *fa = (FBFile *) a;
FBFile *fb = (FBFile *) b;
if ( file_browser_config.directories_first && fa->type != fb->type ) {
return fa->type - fb->type;
}
if ( fa->time < 0 ) {
return -1;
}
@ -333,6 +339,11 @@ static void file_browser_mode_init_config ( Mode *sw )
}
}
p = rofi_theme_find_property ( wid, P_BOOLEAN, "directories-first", TRUE );
if ( p != NULL && p->type == P_BOOLEAN ) {
file_browser_config.directories_first = p->value.b;
}
if ( found_error ) {
rofi_view_error_dialog ( msg, FALSE );