Refactoring.

(paint_panel): removed. Sending of WIDGET_DRAW message is used instead.
(update_dirty_panels): moved from panel.c to midnight.c.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
Andrew Borodin 2011-01-14 15:00:57 +03:00
parent 57cdd0a08a
commit 1f98ee6dc7
3 changed files with 29 additions and 38 deletions

View File

@ -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)
{

View File

@ -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));
@ -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

View File

@ -149,7 +149,6 @@ 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);
int set_panel_formats (WPanel * p);