From 7cfaeca0638b5c6f8911cb31f9d36bd6035c6743 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Thu, 16 Dec 2010 14:26:31 +0300 Subject: [PATCH] Panel update: type accuracy. Signed-off-by: Andrew Borodin --- src/filemanager/cmd.c | 9 ++++----- src/filemanager/panel.c | 25 ++++++++++++------------- src/filemanager/panel.h | 13 ++++++++----- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/filemanager/cmd.c b/src/filemanager/cmd.c index 8964f1bbe..4d91851a6 100644 --- a/src/filemanager/cmd.c +++ b/src/filemanager/cmd.c @@ -956,12 +956,11 @@ filter_cmd (void) void reread_cmd (void) { - int flag; + panel_update_flags_t flag = UP_ONLY_CURRENT; - if (get_current_type () == view_listing && get_other_type () == view_listing) - flag = strcmp (current_panel->cwd, other_panel->cwd) ? UP_ONLY_CURRENT : 0; - else - flag = UP_ONLY_CURRENT; + if (get_current_type () == view_listing && get_other_type () == view_listing + && strcmp (current_panel->cwd, other_panel->cwd) == 0) + flag = UP_OPTIMIZE; update_panels (UP_RELOAD | flag, UP_KEEPSEL); repaint_screen (); diff --git a/src/filemanager/panel.c b/src/filemanager/panel.c index ff8a30522..06a4c5c0d 100644 --- a/src/filemanager/panel.c +++ b/src/filemanager/panel.c @@ -3268,12 +3268,12 @@ reload_panelized (WPanel * panel) /* --------------------------------------------------------------------------------------------- */ static void -update_one_panel_widget (WPanel * panel, int force_update, const char *current_file) +update_one_panel_widget (WPanel * panel, panel_update_flags_t flags, const char *current_file) { - int free_pointer; + gboolean free_pointer; char *my_current_file = NULL; - if (force_update & UP_RELOAD) + if ((flags & UP_RELOAD) != 0) { panel->is_panelized = 0; mc_setctl (panel->cwd, VFS_SETCTL_FLUSH, 0); @@ -3281,14 +3281,13 @@ update_one_panel_widget (WPanel * panel, int force_update, const char *current_f } /* If current_file == -1 (an invalid pointer) then preserve selection */ - if (current_file == UP_KEEPSEL) + free_pointer = current_file == UP_KEEPSEL; + + if (free_pointer) { - free_pointer = 1; my_current_file = g_strdup (panel->dir.list[panel->selected].fname); current_file = my_current_file; } - else - free_pointer = 0; if (panel->is_panelized) reload_panelized (panel); @@ -3305,13 +3304,13 @@ update_one_panel_widget (WPanel * panel, int force_update, const char *current_f /* --------------------------------------------------------------------------------------------- */ static void -update_one_panel (int which, int force_update, const char *current_file) +update_one_panel (int which, panel_update_flags_t flags, const char *current_file) { if (get_display_type (which) == view_listing) { WPanel *panel; panel = (WPanel *) get_panel_widget (which); - update_one_panel_widget (panel, force_update, current_file); + update_one_panel_widget (panel, flags, current_file); } } @@ -3995,15 +3994,15 @@ panel_change_encoding (WPanel * panel) */ void -update_panels (int force_update, const char *current_file) +update_panels (panel_update_flags_t flags, const char *current_file) { - int reload_other = !(force_update & UP_ONLY_CURRENT); + gboolean reload_other = (flags & UP_ONLY_CURRENT) == 0; WPanel *panel; int ret; - update_one_panel (get_current_index (), force_update, current_file); + update_one_panel (get_current_index (), flags, current_file); if (reload_other) - update_one_panel (get_other_index (), force_update, UP_KEEPSEL); + update_one_panel (get_other_index (), flags, UP_KEEPSEL); if (get_current_type () == view_listing) panel = (WPanel *) get_panel_widget (get_current_index ()); diff --git a/src/filemanager/panel.h b/src/filemanager/panel.h index bf136c53e..e1b1e5450 100644 --- a/src/filemanager/panel.h +++ b/src/filemanager/panel.h @@ -23,10 +23,6 @@ #define LIST_TYPES 4 -#define UP_OPTIMIZE 0 -#define UP_RELOAD 1 -#define UP_ONLY_CURRENT 2 - #define UP_KEEPSEL ((char *) -1) /*** enums ***************************************************************************************/ @@ -54,6 +50,13 @@ enum panel_display_enum frame_half /* half screen frame */ }; +typedef enum +{ + UP_OPTIMIZE = 0, + UP_RELOAD = 1, + UP_ONLY_CURRENT = 2 +} panel_update_flags_t; + /*** structures declarations (and typedefs of structures)*****************************************/ struct format_e; @@ -142,7 +145,7 @@ void panel_re_sort (WPanel * panel); void panel_change_encoding (WPanel * panel); void update_dirty_panels (void); -void update_panels (int force_update, const char *current_file); +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); -- 2.11.4.GIT