Move sort_field member out from panel_sort_info_t structure.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Этот коммит содержится в:
родитель
d8d1f90082
Коммит
72ad268a9c
@ -703,17 +703,17 @@ panel_listing_box (WPanel * panel, char **userp, char **minip, int *use_msformat
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
const panel_field_t *
|
||||
sort_box (panel_sort_info_t * info)
|
||||
sort_box (panel_sort_info_t * info, const panel_field_t * sort_field)
|
||||
{
|
||||
const char **sort_orders_names;
|
||||
gsize sort_names_num, i;
|
||||
int sort_idx = 0;
|
||||
const panel_field_t *result = info->sort_field;
|
||||
const panel_field_t *result = NULL;
|
||||
|
||||
sort_orders_names = panel_get_sortable_fields (&sort_names_num);
|
||||
|
||||
for (i = 0; i < sort_names_num; i++)
|
||||
if (strcmp (sort_orders_names[i], _(info->sort_field->title_hotkey)) == 0)
|
||||
if (strcmp (sort_orders_names[i], _(sort_field->title_hotkey)) == 0)
|
||||
{
|
||||
sort_idx = i;
|
||||
break;
|
||||
@ -744,7 +744,7 @@ sort_box (panel_sort_info_t * info)
|
||||
result = panel_get_field_by_title_hotkey (sort_orders_names[sort_idx]);
|
||||
|
||||
if (result == NULL)
|
||||
result = info->sort_field;
|
||||
result = sort_field;
|
||||
}
|
||||
|
||||
g_strfreev ((gchar **) sort_orders_names);
|
||||
|
@ -21,7 +21,7 @@
|
||||
void configure_box (void);
|
||||
void panel_options_box (void);
|
||||
int panel_listing_box (WPanel * p, char **user, char **mini, int *use_msformat, int num);
|
||||
const panel_field_t *sort_box (panel_sort_info_t * info);
|
||||
const panel_field_t *sort_box (panel_sort_info_t * info, const panel_field_t * sort_field);
|
||||
void confirm_box (void);
|
||||
void display_bits_box (void);
|
||||
void configure_vfs (void);
|
||||
|
@ -1648,7 +1648,7 @@ single_dirsize_cmd (void)
|
||||
|
||||
recalculate_panel_summary (panel);
|
||||
|
||||
if (current_panel->sort_info.sort_field->sort_routine == (GCompareFunc) sort_size)
|
||||
if (current_panel->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 == (GCompareFunc) sort_size)
|
||||
if (current_panel->sort_field->sort_routine == (GCompareFunc) sort_size)
|
||||
panel_re_sort (panel);
|
||||
|
||||
panel->dirty = 1;
|
||||
|
@ -403,7 +403,7 @@ sort_cmd (void)
|
||||
return;
|
||||
|
||||
p = MENU_PANEL;
|
||||
sort_order = sort_box (&p->sort_info);
|
||||
sort_order = sort_box (&p->sort_info, p->sort_field);
|
||||
panel_set_sort_order (p, sort_order);
|
||||
}
|
||||
|
||||
|
@ -1505,13 +1505,13 @@ panel_format_modified (WPanel * panel)
|
||||
static void
|
||||
panel_paint_sort_info (WPanel * panel)
|
||||
{
|
||||
if (*panel->sort_info.sort_field->hotkey != '\0')
|
||||
if (*panel->sort_field->hotkey != '\0')
|
||||
{
|
||||
const char *sort_sign =
|
||||
panel->sort_info.reverse ? panel_sort_down_sign : panel_sort_up_sign;
|
||||
char *str;
|
||||
|
||||
str = g_strdup_printf ("%s%s", sort_sign, Q_ (panel->sort_info.sort_field->hotkey));
|
||||
str = g_strdup_printf ("%s%s", sort_sign, Q_ (panel->sort_field->hotkey));
|
||||
widget_move (panel, 1, 1);
|
||||
tty_print_string (str);
|
||||
g_free (str);
|
||||
@ -1580,7 +1580,7 @@ paint_frame (WPanel * panel)
|
||||
g_string_set_size (format_txt, 0);
|
||||
|
||||
if (panel->list_type == list_long
|
||||
&& strcmp (format->id, panel->sort_info.sort_field->id) == 0)
|
||||
&& strcmp (format->id, panel->sort_field->id) == 0)
|
||||
g_string_append (format_txt,
|
||||
panel->sort_info.reverse
|
||||
? panel_sort_down_sign : panel_sort_up_sign);
|
||||
@ -2817,7 +2817,7 @@ panel_toggle_sort_order_prev (WPanel * panel)
|
||||
|
||||
const panel_field_t *pfield = NULL;
|
||||
|
||||
title = panel_get_title_without_hotkey (panel->sort_info.sort_field->title_hotkey);
|
||||
title = panel_get_title_without_hotkey (panel->sort_field->title_hotkey);
|
||||
lc_index = panel_get_format_field_index_by_name (panel, title);
|
||||
g_free (title);
|
||||
|
||||
@ -2837,7 +2837,7 @@ panel_toggle_sort_order_prev (WPanel * panel)
|
||||
|
||||
if (pfield != NULL)
|
||||
{
|
||||
panel->sort_info.sort_field = pfield;
|
||||
panel->sort_field = pfield;
|
||||
panel_set_sort_order (panel, pfield);
|
||||
}
|
||||
}
|
||||
@ -2853,7 +2853,7 @@ panel_toggle_sort_order_next (WPanel * panel)
|
||||
gchar *title;
|
||||
|
||||
format_field_count = panel_get_format_field_count (panel);
|
||||
title = panel_get_title_without_hotkey (panel->sort_info.sort_field->title_hotkey);
|
||||
title = panel_get_title_without_hotkey (panel->sort_field->title_hotkey);
|
||||
lc_index = panel_get_format_field_index_by_name (panel, title);
|
||||
g_free (title);
|
||||
|
||||
@ -2875,7 +2875,7 @@ panel_toggle_sort_order_next (WPanel * panel)
|
||||
|
||||
if (pfield != NULL)
|
||||
{
|
||||
panel->sort_info.sort_field = pfield;
|
||||
panel->sort_field = pfield;
|
||||
panel_set_sort_order (panel, pfield);
|
||||
}
|
||||
}
|
||||
@ -2887,10 +2887,10 @@ panel_select_sort_order (WPanel * panel)
|
||||
{
|
||||
const panel_field_t *sort_order;
|
||||
|
||||
sort_order = sort_box (&panel->sort_info);
|
||||
sort_order = sort_box (&panel->sort_info, panel->sort_field);
|
||||
if (sort_order != NULL)
|
||||
{
|
||||
panel->sort_info.sort_field = sort_order;
|
||||
panel->sort_field = sort_order;
|
||||
panel_set_sort_order (panel, sort_order);
|
||||
}
|
||||
}
|
||||
@ -2946,19 +2946,19 @@ panel_content_scroll_right (WPanel * panel)
|
||||
static void
|
||||
panel_set_sort_type_by_id (WPanel * panel, const char *name)
|
||||
{
|
||||
if (strcmp (panel->sort_info.sort_field->id, name) != 0)
|
||||
if (strcmp (panel->sort_field->id, name) != 0)
|
||||
{
|
||||
const panel_field_t *sort_order;
|
||||
|
||||
sort_order = panel_get_field_by_id (name);
|
||||
if (sort_order == NULL)
|
||||
return;
|
||||
panel->sort_info.sort_field = sort_order;
|
||||
panel->sort_field = sort_order;
|
||||
}
|
||||
else
|
||||
panel->sort_info.reverse = !panel->sort_info.reverse;
|
||||
|
||||
panel_set_sort_order (panel, panel->sort_info.sort_field);
|
||||
panel_set_sort_order (panel, panel->sort_field);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -3064,7 +3064,7 @@ _do_panel_cd (WPanel * panel, const vfs_path_t * new_dir_vpath, enum cd_enum cd_
|
||||
panel_clean_dir (panel);
|
||||
|
||||
panel->count =
|
||||
do_load_dir (panel->cwd_vpath, &panel->dir, panel->sort_info.sort_field->sort_routine,
|
||||
do_load_dir (panel->cwd_vpath, &panel->dir, panel->sort_field->sort_routine,
|
||||
panel->sort_info.reverse, panel->sort_info.case_sensitive,
|
||||
panel->sort_info.exec_first, panel->filter);
|
||||
try_to_select (panel, get_parent_dir_name (panel->cwd_vpath, olddir_vpath));
|
||||
@ -3336,7 +3336,7 @@ panel_execute_cmd (WPanel * panel, unsigned long command)
|
||||
break;
|
||||
case CK_SortReverse:
|
||||
panel->sort_info.reverse = !panel->sort_info.reverse;
|
||||
panel_set_sort_order (panel, panel->sort_info.sort_field);
|
||||
panel_set_sort_order (panel, panel->sort_field);
|
||||
break;
|
||||
case CK_SortByName:
|
||||
panel_set_sort_type_by_id (panel, "name");
|
||||
@ -3562,7 +3562,7 @@ mouse_sort_col (WPanel * panel, int x)
|
||||
if (col_sort_format == NULL)
|
||||
return;
|
||||
|
||||
if (panel->sort_info.sort_field == col_sort_format)
|
||||
if (panel->sort_field == col_sort_format)
|
||||
{
|
||||
/* reverse the sort if clicked column is already the sorted column */
|
||||
panel->sort_info.reverse = !panel->sort_info.reverse;
|
||||
@ -4143,7 +4143,7 @@ panel_new_with_dir (const char *panel_name, const vfs_path_t * vpath)
|
||||
|
||||
/* Load the default format */
|
||||
panel->count =
|
||||
do_load_dir (panel->cwd_vpath, &panel->dir, panel->sort_info.sort_field->sort_routine,
|
||||
do_load_dir (panel->cwd_vpath, &panel->dir, panel->sort_field->sort_routine,
|
||||
panel->sort_info.reverse, panel->sort_info.case_sensitive,
|
||||
panel->sort_info.exec_first, panel->filter);
|
||||
|
||||
@ -4190,7 +4190,7 @@ panel_reload (WPanel * panel)
|
||||
show_dir (panel);
|
||||
|
||||
panel->count =
|
||||
do_reload_dir (panel->cwd_vpath, &panel->dir, panel->sort_info.sort_field->sort_routine,
|
||||
do_reload_dir (panel->cwd_vpath, &panel->dir, panel->sort_field->sort_routine,
|
||||
panel->count, panel->sort_info.reverse, panel->sort_info.case_sensitive,
|
||||
panel->sort_info.exec_first, panel->filter);
|
||||
|
||||
@ -4447,7 +4447,7 @@ panel_re_sort (WPanel * panel)
|
||||
|
||||
filename = g_strdup (selection (panel)->fname);
|
||||
unselect_item (panel);
|
||||
do_sort (&panel->dir, panel->sort_info.sort_field->sort_routine, panel->count - 1,
|
||||
do_sort (&panel->dir, panel->sort_field->sort_routine, panel->count - 1,
|
||||
panel->sort_info.reverse, panel->sort_info.case_sensitive,
|
||||
panel->sort_info.exec_first);
|
||||
panel->selected = -1;
|
||||
@ -4473,7 +4473,7 @@ panel_set_sort_order (WPanel * panel, const panel_field_t * sort_order)
|
||||
if (sort_order == NULL)
|
||||
return;
|
||||
|
||||
panel->sort_info.sort_field = sort_order;
|
||||
panel->sort_field = sort_order;
|
||||
|
||||
/* The directory is already sorted, we have to load the unsorted stuff */
|
||||
if (sort_order->sort_routine == (GCompareFunc) unsorted)
|
||||
|
@ -85,7 +85,6 @@ typedef struct panel_sort_info_struct
|
||||
gboolean reverse; /* Show listing in reverse? */
|
||||
gboolean case_sensitive; /* Listing is case sensitive? */
|
||||
gboolean exec_first; /* Show executable top in list? */
|
||||
const panel_field_t *sort_field;
|
||||
} panel_sort_info_t;
|
||||
|
||||
typedef struct WPanel
|
||||
@ -110,7 +109,10 @@ typedef struct WPanel
|
||||
gboolean is_panelized; /* Flag: special filelisting, can't reload */
|
||||
panel_display_t frame_size; /* half or full frame */
|
||||
char *filter; /* File name filter */
|
||||
panel_sort_info_t sort_info; /* Sort descriptor */
|
||||
|
||||
/* sort */
|
||||
panel_sort_info_t sort_info;
|
||||
const panel_field_t *sort_field;
|
||||
|
||||
int dirty; /* Should we redisplay the panel? */
|
||||
|
||||
|
@ -1385,9 +1385,9 @@ panel_load_setup (WPanel * panel, const char *section)
|
||||
|
||||
/* Load sort order */
|
||||
buffer = mc_config_get_string (mc_panels_config, section, "sort_order", "name");
|
||||
panel->sort_info.sort_field = panel_get_field_by_id (buffer);
|
||||
if (panel->sort_info.sort_field == NULL)
|
||||
panel->sort_info.sort_field = panel_get_field_by_id ("name");
|
||||
panel->sort_field = panel_get_field_by_id (buffer);
|
||||
if (panel->sort_field == NULL)
|
||||
panel->sort_field = panel_get_field_by_id ("name");
|
||||
|
||||
g_free (buffer);
|
||||
|
||||
@ -1431,7 +1431,7 @@ panel_save_setup (struct WPanel *panel, const char *section)
|
||||
panel->sort_info.case_sensitive);
|
||||
mc_config_set_int (mc_panels_config, section, "exec_first", panel->sort_info.exec_first);
|
||||
|
||||
mc_config_set_string (mc_panels_config, section, "sort_order", panel->sort_info.sort_field->id);
|
||||
mc_config_set_string (mc_panels_config, section, "sort_order", panel->sort_field->id);
|
||||
|
||||
for (i = 0; list_types[i].key != NULL; i++)
|
||||
if (list_types[i].list_type == panel->list_type)
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user