mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 12:32:40 +03:00
Ticket #3066: refactoring of dir_list class and related code.
Initial commit: use GCompareFunc instead of sortfn. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
a339ad354b
commit
d8d1f90082
@ -1648,7 +1648,7 @@ single_dirsize_cmd (void)
|
||||
|
||||
recalculate_panel_summary (panel);
|
||||
|
||||
if (current_panel->sort_info.sort_field->sort_routine == (sortfn *) sort_size)
|
||||
if (current_panel->sort_info.sort_field->sort_routine == (GCompareFunc) sort_size)
|
||||
panel_re_sort (panel);
|
||||
|
||||
panel->dirty = 1;
|
||||
@ -1691,7 +1691,7 @@ dirsizes_cmd (void)
|
||||
|
||||
recalculate_panel_summary (panel);
|
||||
|
||||
if (current_panel->sort_info.sort_field->sort_routine == (sortfn *) sort_size)
|
||||
if (current_panel->sort_info.sort_field->sort_routine == (GCompareFunc) sort_size)
|
||||
panel_re_sort (panel);
|
||||
|
||||
panel->dirty = 1;
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2013
|
||||
Andrew Borodin <aborodin@vmail.ru>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -437,7 +438,7 @@ sort_size (file_entry * a, file_entry * b)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
do_sort (dir_list * list, sortfn * sort, int top, gboolean reverse_f, gboolean case_sensitive_f,
|
||||
do_sort (dir_list * list, GCompareFunc sort, int top, gboolean reverse_f, gboolean case_sensitive_f,
|
||||
gboolean exec_first_f)
|
||||
{
|
||||
int dot_dot_found = 0;
|
||||
@ -545,7 +546,7 @@ handle_path (dir_list * list, const char *path,
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
do_load_dir (const vfs_path_t * vpath, dir_list * list, sortfn * sort, gboolean lc_reverse,
|
||||
do_load_dir (const vfs_path_t * vpath, dir_list * list, GCompareFunc sort, gboolean lc_reverse,
|
||||
gboolean lc_case_sensitive, gboolean exec_ff, const char *fltr)
|
||||
{
|
||||
DIR *dirp;
|
||||
@ -630,7 +631,7 @@ if_link_is_exe (const vfs_path_t * full_name_vpath, const file_entry * file)
|
||||
/** If fltr is null, then it is a match */
|
||||
|
||||
int
|
||||
do_reload_dir (const vfs_path_t * vpath, dir_list * list, sortfn * sort, int count,
|
||||
do_reload_dir (const vfs_path_t * vpath, dir_list * list, GCompareFunc sort, int count,
|
||||
gboolean lc_reverse, gboolean lc_case_sensitive, gboolean exec_ff, const char *fltr)
|
||||
{
|
||||
DIR *dirp;
|
||||
|
@ -16,8 +16,6 @@
|
||||
#define MIN_FILES 128
|
||||
#define RESIZE_STEPS 128
|
||||
|
||||
typedef int sortfn (const void *, const void *);
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
/*** structures declarations (and typedefs of structures)*****************************************/
|
||||
@ -32,11 +30,11 @@ typedef struct
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
int do_load_dir (const vfs_path_t * vpath, dir_list * list, sortfn * sort, gboolean reverse,
|
||||
int do_load_dir (const vfs_path_t * vpath, dir_list * list, GCompareFunc sort, gboolean reverse,
|
||||
gboolean case_sensitive, gboolean exec_ff, const char *fltr);
|
||||
void do_sort (dir_list * list, sortfn * sort, int top, gboolean reverse,
|
||||
void do_sort (dir_list * list, GCompareFunc sort, int top, gboolean reverse,
|
||||
gboolean case_sensitive, gboolean exec_ff);
|
||||
int do_reload_dir (const vfs_path_t * vpath, dir_list * list, sortfn * sort, int count,
|
||||
int do_reload_dir (const vfs_path_t * vpath, dir_list * list, GCompareFunc sort, int count,
|
||||
gboolean reverse, gboolean case_sensitive, gboolean exec_ff, const char *fltr);
|
||||
void clean_dir (dir_list * list, int count);
|
||||
gboolean set_zero_dir (dir_list * list);
|
||||
|
@ -117,7 +117,7 @@ panel_field_t panel_fields[] = {
|
||||
N_("sort|u"),
|
||||
N_("&Unsorted"), TRUE, FALSE,
|
||||
string_file_name,
|
||||
(sortfn *) unsorted
|
||||
(GCompareFunc) unsorted
|
||||
}
|
||||
,
|
||||
{
|
||||
@ -127,7 +127,7 @@ panel_field_t panel_fields[] = {
|
||||
N_("sort|n"),
|
||||
N_("&Name"), TRUE, TRUE,
|
||||
string_file_name,
|
||||
(sortfn *) sort_name
|
||||
(GCompareFunc) sort_name
|
||||
}
|
||||
,
|
||||
{
|
||||
@ -137,7 +137,7 @@ panel_field_t panel_fields[] = {
|
||||
N_("sort|v"),
|
||||
N_("&Version"), TRUE, FALSE,
|
||||
string_file_name,
|
||||
(sortfn *) sort_vers
|
||||
(GCompareFunc) sort_vers
|
||||
}
|
||||
,
|
||||
{
|
||||
@ -147,7 +147,7 @@ panel_field_t panel_fields[] = {
|
||||
N_("sort|e"),
|
||||
N_("E&xtension"), TRUE, FALSE,
|
||||
string_file_name, /* TODO: string_file_ext */
|
||||
(sortfn *) sort_ext
|
||||
(GCompareFunc) sort_ext
|
||||
}
|
||||
,
|
||||
{
|
||||
@ -157,7 +157,7 @@ panel_field_t panel_fields[] = {
|
||||
N_("sort|s"),
|
||||
N_("&Size"), TRUE, TRUE,
|
||||
string_file_size,
|
||||
(sortfn *) sort_size
|
||||
(GCompareFunc) sort_size
|
||||
}
|
||||
,
|
||||
{
|
||||
@ -165,7 +165,7 @@ panel_field_t panel_fields[] = {
|
||||
"",
|
||||
N_("Block Size"), FALSE, FALSE,
|
||||
string_file_size_brief,
|
||||
(sortfn *) sort_size
|
||||
(GCompareFunc) sort_size
|
||||
}
|
||||
,
|
||||
{
|
||||
@ -183,7 +183,7 @@ panel_field_t panel_fields[] = {
|
||||
N_("sort|m"),
|
||||
N_("&Modify time"), TRUE, TRUE,
|
||||
string_file_mtime,
|
||||
(sortfn *) sort_time
|
||||
(GCompareFunc) sort_time
|
||||
}
|
||||
,
|
||||
{
|
||||
@ -193,7 +193,7 @@ panel_field_t panel_fields[] = {
|
||||
N_("sort|a"),
|
||||
N_("&Access time"), TRUE, TRUE,
|
||||
string_file_atime,
|
||||
(sortfn *) sort_atime
|
||||
(GCompareFunc) sort_atime
|
||||
}
|
||||
,
|
||||
{
|
||||
@ -203,7 +203,7 @@ panel_field_t panel_fields[] = {
|
||||
N_("sort|h"),
|
||||
N_("C&hange time"), TRUE, TRUE,
|
||||
string_file_ctime,
|
||||
(sortfn *) sort_ctime
|
||||
(GCompareFunc) sort_ctime
|
||||
}
|
||||
,
|
||||
{
|
||||
@ -236,7 +236,7 @@ panel_field_t panel_fields[] = {
|
||||
N_("sort|i"),
|
||||
N_("&Inode"), TRUE, TRUE,
|
||||
string_inode,
|
||||
(sortfn *) sort_inode
|
||||
(GCompareFunc) sort_inode
|
||||
}
|
||||
,
|
||||
{
|
||||
@ -4476,7 +4476,7 @@ panel_set_sort_order (WPanel * panel, const panel_field_t * sort_order)
|
||||
panel->sort_info.sort_field = sort_order;
|
||||
|
||||
/* The directory is already sorted, we have to load the unsorted stuff */
|
||||
if (sort_order->sort_routine == (sortfn *) unsorted)
|
||||
if (sort_order->sort_routine == (GCompareFunc) unsorted)
|
||||
{
|
||||
char *current_file;
|
||||
|
||||
|
@ -70,7 +70,7 @@ typedef struct panel_field_struct
|
||||
gboolean is_user_choice;
|
||||
gboolean use_in_user_format;
|
||||
const char *(*string_fn) (file_entry *, int);
|
||||
sortfn *sort_routine; /* used by mouse_sort_col() */
|
||||
GCompareFunc sort_routine; /* used by mouse_sort_col() */
|
||||
} panel_field_t;
|
||||
|
||||
typedef struct
|
||||
|
@ -305,8 +305,8 @@ mcview_load_next_prev_init (mcview_t * view)
|
||||
view->dir_count = g_new (int, 1);
|
||||
view->dir_idx = g_new (int, 1);
|
||||
|
||||
*view->dir_count = do_load_dir (view->workdir_vpath, view->dir, (sortfn *) sort_name, FALSE,
|
||||
TRUE, FALSE, NULL);
|
||||
*view->dir_count = do_load_dir (view->workdir_vpath, view->dir, (GCompareFunc) sort_name,
|
||||
FALSE, TRUE, FALSE, NULL);
|
||||
|
||||
fname = x_basename (vfs_path_as_str (view->filename_vpath));
|
||||
fname_len = strlen (fname);
|
||||
|
Loading…
Reference in New Issue
Block a user