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:
parent
b7dfb423a1
commit
c1ff6baecd
3 changed files with 18 additions and 3 deletions
|
@ -1185,6 +1185,8 @@ configuration {
|
|||
* \- "ctime" (change time)
|
||||
*/
|
||||
sorting\-method: "name";
|
||||
/** Group directories before files. */
|
||||
directories\-first: true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -713,6 +713,8 @@ configuration {
|
|||
* - "ctime" (change time)
|
||||
*/
|
||||
sorting-method: "name";
|
||||
/** Group directories before files. */
|
||||
directories-first: true;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
|
@ -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 );
|
||||
|
||||
|
|
Loading…
Reference in a new issue