Merge branch '2390_panel_format_init'
* 2390_panel_format_init: Refactoring. Refactoring. Ticket #2390: file list format of panel is intialized incorrectly
Этот коммит содержится в:
Коммит
d21eb43152
@ -587,6 +587,25 @@ panel_do_cols (int idx)
|
||||
panel_update_cols (panels[idx].widget, frame_half);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/** Save current list_view widget directory into panel */
|
||||
|
||||
static Widget *
|
||||
restore_into_right_dir_panel (int idx, Widget * from_widget)
|
||||
{
|
||||
Widget *new_widget = NULL;
|
||||
const char *saved_dir = panels[idx].last_saved_dir;
|
||||
gboolean last_was_panel = (from_widget && get_display_type (idx) != view_listing);
|
||||
const char *p_name = get_nth_panel_name (idx);
|
||||
|
||||
if (last_was_panel)
|
||||
new_widget = (Widget *) panel_new_with_dir (p_name, saved_dir);
|
||||
else
|
||||
new_widget = (Widget *) panel_new (p_name);
|
||||
|
||||
return new_widget;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static inline void
|
||||
@ -966,7 +985,7 @@ void
|
||||
set_display_type (int num, panel_view_mode_t type)
|
||||
{
|
||||
int x = 0, y = 0, cols = 0, lines = 0;
|
||||
int the_other = 0; /* Index to the other panel */
|
||||
unsigned int the_other = 0; /* Index to the other panel */
|
||||
const char *file_name = NULL; /* For Quick view */
|
||||
Widget *new_widget = NULL, *old_widget = NULL;
|
||||
WPanel *the_other_panel = NULL;
|
||||
@ -986,16 +1005,16 @@ set_display_type (int num, panel_view_mode_t type)
|
||||
}
|
||||
|
||||
/* Get rid of it */
|
||||
if (panels[num].widget)
|
||||
if (panels[num].widget != NULL)
|
||||
{
|
||||
Widget *w = panels[num].widget;
|
||||
WPanel *panel = (WPanel *) panels[num].widget;
|
||||
WPanel *panel = (WPanel *) w;
|
||||
|
||||
x = w->x;
|
||||
y = w->y;
|
||||
cols = w->cols;
|
||||
lines = w->lines;
|
||||
old_widget = panels[num].widget;
|
||||
old_widget = w;
|
||||
|
||||
if (panels[num].type == view_listing)
|
||||
{
|
||||
@ -1056,14 +1075,19 @@ set_display_type (int num, panel_view_mode_t type)
|
||||
/* We use replace to keep the circular list of the dialog in the */
|
||||
/* same state. Maybe we could just kill it and then replace it */
|
||||
if ((midnight_dlg != NULL) && (old_widget != NULL))
|
||||
dlg_replace_widget (old_widget, panels[num].widget);
|
||||
dlg_replace_widget (old_widget, new_widget);
|
||||
|
||||
if (type == view_listing)
|
||||
{
|
||||
WPanel *panel = (WPanel *) new_widget;
|
||||
|
||||
if (num == 0)
|
||||
left_panel = (WPanel *) new_widget;
|
||||
left_panel = panel;
|
||||
else
|
||||
right_panel = (WPanel *) new_widget;
|
||||
right_panel = panel;
|
||||
|
||||
/* forced update format after set new sizes */
|
||||
set_panel_formats (panel);
|
||||
}
|
||||
|
||||
if (type == view_tree)
|
||||
@ -1077,12 +1101,49 @@ set_display_type (int num, panel_view_mode_t type)
|
||||
* - as long as you stay in the left panel almost everything that uses
|
||||
* current_panel causes segfault, e.g. C-Enter, C-x c, ...
|
||||
*/
|
||||
|
||||
if ((type != view_listing) && (current_panel == (WPanel *) old_widget))
|
||||
current_panel = num == 0 ? right_panel : left_panel;
|
||||
|
||||
g_free (old_widget);
|
||||
}
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
panel_update_cols (Widget * widget, panel_display_t frame_size)
|
||||
{
|
||||
int cols, origin;
|
||||
|
||||
/* don't touch panel if it is not in dialog yet */
|
||||
/* if panel is not in dialog it is not in widgets list
|
||||
and cannot be compared with get_panel_widget() result */
|
||||
if (widget->owner == NULL)
|
||||
return;
|
||||
|
||||
if (horizontal_split)
|
||||
{
|
||||
widget->cols = COLS;
|
||||
return;
|
||||
}
|
||||
|
||||
if (frame_size == frame_full)
|
||||
{
|
||||
cols = COLS;
|
||||
origin = 0;
|
||||
}
|
||||
else if (widget == get_panel_widget (0))
|
||||
{
|
||||
cols = first_panel_size;
|
||||
origin = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
cols = COLS - first_panel_size;
|
||||
origin = first_panel_size;
|
||||
}
|
||||
|
||||
widget->cols = cols;
|
||||
widget->x = origin;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/** This routine is deeply sticked to the two panels idea.
|
||||
@ -1288,25 +1349,6 @@ save_panel_dir (int idx)
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/** Save current list_view widget directory into panel */
|
||||
|
||||
Widget *
|
||||
restore_into_right_dir_panel (int idx, Widget * from_widget)
|
||||
{
|
||||
Widget *new_widget = NULL;
|
||||
const char *saved_dir = panels[idx].last_saved_dir;
|
||||
gboolean last_was_panel = (from_widget && get_display_type (idx) != view_listing);
|
||||
const char *p_name = get_nth_panel_name (idx);
|
||||
|
||||
if (last_was_panel)
|
||||
new_widget = (Widget *) panel_new_with_dir (p_name, saved_dir);
|
||||
else
|
||||
new_widget = (Widget *) panel_new (p_name);
|
||||
|
||||
return new_widget;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/** Return working dir, if it's view_listing - cwd,
|
||||
but for other types - last_saved_dir */
|
||||
|
@ -42,6 +42,7 @@ void destroy_panels (void);
|
||||
void sigwinch_handler (int dummy);
|
||||
void change_screen_size (void);
|
||||
void set_display_type (int num, panel_view_mode_t type);
|
||||
void panel_update_cols (Widget * widget, panel_display_t frame_size);
|
||||
void swap_panels (void);
|
||||
panel_view_mode_t get_display_type (int idx);
|
||||
panel_view_mode_t get_current_type (void);
|
||||
@ -55,7 +56,6 @@ struct Widget *get_panel_widget (int idx);
|
||||
struct WPanel *get_other_panel (void);
|
||||
|
||||
void save_panel_dir (int idx);
|
||||
Widget *restore_into_right_dir_panel (int idx, Widget * from_widget);
|
||||
const char *get_panel_dir_for (const WPanel * widget);
|
||||
|
||||
void set_hintbar (const char *str);
|
||||
|
@ -991,6 +991,25 @@ toggle_show_hidden (void)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Repaint the contents of the panels without frames. To schedule panel
|
||||
* for repainting, set panel->dirty to 1. There are many reasons why
|
||||
* the panels need to be repainted, and this is a costly operation, so
|
||||
* it's done once per event.
|
||||
*/
|
||||
|
||||
static void
|
||||
update_dirty_panels (void)
|
||||
{
|
||||
if (get_current_type () == view_listing && current_panel->dirty)
|
||||
send_message ((Widget *) current_panel, WIDGET_DRAW, 0);
|
||||
|
||||
if (get_other_type () == view_listing && other_panel->dirty)
|
||||
send_message ((Widget *) other_panel, WIDGET_DRAW, 0);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static cb_ret_t
|
||||
midnight_execute_cmd (Widget * sender, unsigned long command)
|
||||
{
|
||||
|
@ -79,8 +79,6 @@ int torben_fj_mode = 0;
|
||||
/* The hook list for the select file function */
|
||||
hook_t *select_file_hook = NULL;
|
||||
|
||||
|
||||
|
||||
static const char *string_file_name (file_entry *, int);
|
||||
static const char *string_file_size (file_entry *, int);
|
||||
static const char *string_file_size_brief (file_entry *, int);
|
||||
@ -1145,19 +1143,6 @@ adjust_top_file (WPanel * panel)
|
||||
panel->top_file = panel->count - llines (panel);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/** Repaint everything, including frame and separator */
|
||||
|
||||
static void
|
||||
paint_panel (WPanel * panel)
|
||||
{
|
||||
paint_frame (panel); /* including show_dir */
|
||||
paint_dir (panel);
|
||||
mini_info_separator (panel);
|
||||
display_mini_info (panel);
|
||||
panel->dirty = 0;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/** add "#enc:encodning" to end of path */
|
||||
/* if path end width a previous #enc:, only encoding is changed no additional
|
||||
@ -1262,7 +1247,8 @@ panel_paint_sort_info (WPanel * panel)
|
||||
{
|
||||
if (*panel->sort_info.sort_field->hotkey != '\0')
|
||||
{
|
||||
const char *sort_sign = panel->sort_info.reverse ? panel_sort_down_sign : panel_sort_up_sign;
|
||||
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));
|
||||
@ -1373,7 +1359,7 @@ paint_frame (WPanel * panel)
|
||||
static const char *
|
||||
parse_panel_size (WPanel * panel, const char *format, int isstatus)
|
||||
{
|
||||
int frame = frame_half;
|
||||
panel_display_t frame = frame_half;
|
||||
format = skip_separators (format);
|
||||
|
||||
if (!strncmp (format, "full", 4))
|
||||
@ -2156,7 +2142,7 @@ do_search (WPanel * panel, int c_code)
|
||||
unselect_item (panel);
|
||||
panel->selected = sel;
|
||||
select_item (panel);
|
||||
paint_panel (panel);
|
||||
send_message ((Widget *) panel, WIDGET_DRAW, 0);
|
||||
}
|
||||
else if (c_code != KEY_BACKSPACE)
|
||||
{
|
||||
@ -2927,7 +2913,12 @@ panel_callback (Widget * w, widget_msg_t msg, int parm)
|
||||
switch (msg)
|
||||
{
|
||||
case WIDGET_DRAW:
|
||||
paint_panel (panel);
|
||||
/* Repaint everything, including frame and separator */
|
||||
paint_frame (panel); /* including show_dir */
|
||||
paint_dir (panel);
|
||||
mini_info_separator (panel);
|
||||
display_mini_info (panel);
|
||||
panel->dirty = 0;
|
||||
return MSG_HANDLED;
|
||||
|
||||
case WIDGET_FOCUS:
|
||||
@ -3216,7 +3207,7 @@ panel_event (Gpm_Event * event, void *data)
|
||||
|
||||
ret = do_panel_event (event, panel, &redir);
|
||||
if (!redir)
|
||||
paint_panel (panel);
|
||||
send_message ((Widget *) panel, WIDGET_DRAW, 0);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -3367,24 +3358,6 @@ remove_encoding_from_path (const char *path)
|
||||
return g_string_free (ret, FALSE);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Repaint the contents of the panels without frames. To schedule panel
|
||||
* for repainting, set panel->dirty to 1. There are many reasons why
|
||||
* the panels need to be repainted, and this is a costly operation, so
|
||||
* it's done once per event.
|
||||
*/
|
||||
|
||||
void
|
||||
update_dirty_panels (void)
|
||||
{
|
||||
if (current_panel->dirty)
|
||||
paint_panel (current_panel);
|
||||
|
||||
if ((get_other_type () == view_listing) && other_panel->dirty)
|
||||
paint_panel (other_panel);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
@ -3446,42 +3419,6 @@ try_to_select (WPanel * panel, const char *name)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
panel_update_cols (Widget * widget, int frame_size)
|
||||
{
|
||||
int cols, origin;
|
||||
|
||||
if (horizontal_split)
|
||||
{
|
||||
widget->cols = COLS;
|
||||
return;
|
||||
}
|
||||
|
||||
if (frame_size == frame_full)
|
||||
{
|
||||
cols = COLS;
|
||||
origin = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (widget == get_panel_widget (0))
|
||||
{
|
||||
cols = first_panel_size;
|
||||
origin = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
cols = COLS - first_panel_size;
|
||||
origin = first_panel_size;
|
||||
}
|
||||
}
|
||||
|
||||
widget->cols = cols;
|
||||
widget->x = origin;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
panel_clean_dir (WPanel * panel)
|
||||
{
|
||||
|
@ -44,11 +44,11 @@ typedef enum
|
||||
view_nothing = 4, /* Undefined */
|
||||
} panel_view_mode_t;
|
||||
|
||||
enum panel_display_enum
|
||||
typedef enum
|
||||
{
|
||||
frame_full, /* full screen frame */
|
||||
frame_half /* half screen frame */
|
||||
};
|
||||
} panel_display_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@ -102,7 +102,7 @@ typedef struct WPanel
|
||||
int selected; /* Index to the selected file */
|
||||
int split; /* Split panel to allow two columns */
|
||||
int is_panelized; /* Flag: special filelisting, can't reload */
|
||||
int frame_size; /* half or full frame */
|
||||
panel_display_t frame_size; /* half or full frame */
|
||||
char *filter; /* File name filter */
|
||||
panel_sort_info_t sort_info; /* Sort descriptor */
|
||||
|
||||
@ -149,9 +149,7 @@ void panel_set_sort_order (WPanel * panel, const panel_field_t * sort_order);
|
||||
void panel_re_sort (WPanel * panel);
|
||||
void panel_change_encoding (WPanel * panel);
|
||||
|
||||
void update_dirty_panels (void);
|
||||
void update_panels (panel_update_flags_t flags, const char *current_file);
|
||||
void panel_update_cols (Widget * widget, int frame_size);
|
||||
int set_panel_formats (WPanel * p);
|
||||
|
||||
void try_to_select (WPanel * panel, const char *name);
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user