diff --git a/lib/widget/dialog-switch.c b/lib/widget/dialog-switch.c index 7f3e1de4e..7f4b4269a 100644 --- a/lib/widget/dialog-switch.c +++ b/lib/widget/dialog-switch.c @@ -28,14 +28,14 @@ #include "lib/global.h" #include "lib/tty/tty.h" /* LINES, COLS */ +#include "lib/tty/color.h" /* tty_set_normal_attrs() */ #include "lib/widget.h" - -/* TODO: these includes should be removed! */ -#include "src/filemanager/layout.h" /* repaint_screen() */ -#include "src/filemanager/midnight.h" /* midnight_dlg */ +#include "lib/event.h" /*** global variables ****************************************************************************/ +Dlg_head *midnight_dlg = NULL; + /*** file scope macro definitions ****************************************************************/ /*** file scope type declarations ****************************************************************/ @@ -242,7 +242,7 @@ dialog_switch_process_pending (void) if (mc_global.mc_run_mode == MC_RUN_FULL) { mc_current = g_list_find (mc_dialogs, midnight_dlg); - update_panels (UP_OPTIMIZE, UP_KEEPSEL); + mc_event_raise (MCEVENT_GROUP_FILEMANAGER, "update_panels", NULL); } } } @@ -279,3 +279,22 @@ dialog_switch_shutdown (void) } /* --------------------------------------------------------------------------------------------- */ + +void +clr_scr (void) +{ + tty_set_normal_attrs (); + tty_fill_region (0, 0, LINES, COLS, ' '); + tty_refresh (); +} + +/* --------------------------------------------------------------------------------------------- */ + +void +repaint_screen (void) +{ + do_refresh (); + tty_refresh (); +} + +/* --------------------------------------------------------------------------------------------- */ diff --git a/lib/widget/dialog-switch.h b/lib/widget/dialog-switch.h index 1919139c7..5ab5c9edb 100644 --- a/lib/widget/dialog-switch.h +++ b/lib/widget/dialog-switch.h @@ -12,6 +12,8 @@ /*** global variables defined in .c file *********************************************************/ +extern Dlg_head *midnight_dlg; + /*** declarations of public functions ************************************************************/ void dialog_switch_add (struct Dlg_head *h); @@ -26,5 +28,10 @@ int dialog_switch_process_pending (void); void dialog_switch_got_winch (void); void dialog_switch_shutdown (void); +/* Clear screen */ +void clr_scr (void); +void repaint_screen (void); + /*** inline functions ****************************************************************************/ + #endif /* MC__DIALOG_SWITCH_H */ diff --git a/src/background.c b/src/background.c index df6f6b470..1e878f95a 100644 --- a/src/background.c +++ b/src/background.c @@ -47,7 +47,6 @@ #include "lib/tty/key.h" /* add_select_channel(), delete_select_channel() */ #include "lib/widget.h" /* message() */ -#include "filemanager/layout.h" /* repaint_screen() */ #include "filemanager/fileopctx.h" /* FileOpContext */ #include "background.h" diff --git a/src/editor/editcmd.c b/src/editor/editcmd.c index 8fed62155..c1355e9b9 100644 --- a/src/editor/editcmd.c +++ b/src/editor/editcmd.c @@ -57,8 +57,6 @@ #include "lib/widget.h" #include "lib/charsets.h" -#include "src/filemanager/layout.h" /* clr_scr() */ - #include "src/history.h" #include "src/setup.h" /* option_tab_spacing */ #include "src/help.h" /* interactive_display() */ @@ -66,6 +64,8 @@ #include "src/keybind-defaults.h" #include "src/clipboard.h" /* copy_file_to_ext_clip, paste_to_file_from_ext_clip */ #include "src/util.h" /* check_for_default() */ +#include "src/filemanager/layout.h" /* mc_refresh() */ + #include "edit-impl.h" #include "edit-widget.h" diff --git a/src/filemanager/achown.c b/src/filemanager/achown.c index ae014ce9a..d523f7264 100644 --- a/src/filemanager/achown.c +++ b/src/filemanager/achown.c @@ -46,7 +46,6 @@ #include "dir.h" #include "midnight.h" /* current_panel */ #include "chmod.h" -#include "layout.h" /* repaint_screen() */ #include "achown.h" diff --git a/src/filemanager/chmod.c b/src/filemanager/chmod.c index a2c611992..c2cb6c31f 100644 --- a/src/filemanager/chmod.c +++ b/src/filemanager/chmod.c @@ -41,7 +41,6 @@ #include "lib/widget.h" #include "midnight.h" /* current_panel */ -#include "layout.h" /* repaint_screen() */ #include "chmod.h" /*** global variables ****************************************************************************/ diff --git a/src/filemanager/chown.c b/src/filemanager/chown.c index 422450cc4..e5e053945 100644 --- a/src/filemanager/chown.c +++ b/src/filemanager/chown.c @@ -46,7 +46,6 @@ /* Needed for the extern declarations of integer parameters */ #include "chmod.h" #include "midnight.h" /* current_panel */ -#include "layout.h" /* repaint_screen() */ #include "chown.h" diff --git a/src/filemanager/find.c b/src/filemanager/find.c index e5913a321..adc2e436d 100644 --- a/src/filemanager/find.c +++ b/src/filemanager/find.c @@ -52,7 +52,6 @@ #include "cmd.h" /* view_file_at_line */ #include "midnight.h" /* current_panel */ #include "boxes.h" -#include "layout.h" /* mc_refresh() */ #include "find.h" diff --git a/src/filemanager/hotlist.c b/src/filemanager/hotlist.c index 72020ceab..fa797343e 100644 --- a/src/filemanager/hotlist.c +++ b/src/filemanager/hotlist.c @@ -56,7 +56,6 @@ #include "src/history.h" #include "midnight.h" /* current_panel */ -#include "layout.h" /* repaint_screen() */ #include "command.h" /* cmdline */ #include "hotlist.h" diff --git a/src/filemanager/layout.c b/src/filemanager/layout.c index d9feb2df9..3a597bb9b 100644 --- a/src/filemanager/layout.c +++ b/src/filemanager/layout.c @@ -688,25 +688,6 @@ layout_box (void) /* --------------------------------------------------------------------------------------------- */ -void -clr_scr (void) -{ - tty_set_normal_attrs (); - tty_fill_region (0, 0, LINES, COLS, ' '); - tty_refresh (); -} - -/* --------------------------------------------------------------------------------------------- */ - -void -repaint_screen (void) -{ - do_refresh (); - tty_refresh (); -} - -/* --------------------------------------------------------------------------------------------- */ - void mc_refresh (void) { diff --git a/src/filemanager/layout.h b/src/filemanager/layout.h index 0ce2da262..1d84e68d9 100644 --- a/src/filemanager/layout.h +++ b/src/filemanager/layout.h @@ -62,8 +62,6 @@ void use_dash (gboolean flag); /* Disable/Enable rotate_dash routines */ void rotate_dash (void); /* Clear screen */ -void clr_scr (void); -void repaint_screen (void); void mc_refresh (void); /*** inline functions ****************************************************************************/ diff --git a/src/filemanager/listmode.c b/src/filemanager/listmode.c index 38433a090..38a385686 100644 --- a/src/filemanager/listmode.c +++ b/src/filemanager/listmode.c @@ -46,7 +46,6 @@ #include "dir.h" #include "panel.h" /* Needed for the externs */ #include "file.h" -#include "layout.h" /* repaint_screen() */ #include "listmode.h" /*** global variables ****************************************************************************/ diff --git a/src/filemanager/midnight.c b/src/filemanager/midnight.c index 9b61f53fe..4e01d7354 100644 --- a/src/filemanager/midnight.c +++ b/src/filemanager/midnight.c @@ -113,9 +113,6 @@ WLabel *the_hint; /* The button bar */ WButtonBar *the_bar; -/* The dialog handle for the main program */ -Dlg_head *midnight_dlg = NULL; - /*** file scope macro definitions ****************************************************************/ #ifdef HAVE_CHARSET diff --git a/src/filemanager/panel.c b/src/filemanager/panel.c index 08b9ea579..c259d2ef9 100644 --- a/src/filemanager/panel.c +++ b/src/filemanager/panel.c @@ -48,6 +48,7 @@ #ifdef HAVE_CHARSET #include "lib/charsets.h" /* get_codepage_id () */ #endif +#include "lib/event.h" #include "src/setup.h" /* For loading/saving panel options */ #include "src/execute.h" @@ -3409,6 +3410,25 @@ do_try_to_select (WPanel * panel, const char *name) /* --------------------------------------------------------------------------------------------- */ +/* event callback */ +static gboolean +event_update_panels (const gchar * event_group_name, const gchar * event_name, + gpointer init_data, gpointer data) +{ + (void) event_group_name; + (void) event_name; + (void) init_data; + (void) data; + + update_panels (UP_RELOAD, UP_KEEPSEL); + + return TRUE; +} + +/* --------------------------------------------------------------------------------------------- */ +/*** public functions ****************************************************************************/ +/* --------------------------------------------------------------------------------------------- */ + void try_to_select (WPanel * panel, const char *name) { @@ -4103,6 +4123,8 @@ panel_init (void) panel_history_next_item_sign = mc_skin_get ("widget-panel", "history-next-item-sign", ">"); panel_history_show_list_sign = mc_skin_get ("widget-panel", "history-show-list-sign", "^"); + mc_event_add (MCEVENT_GROUP_FILEMANAGER, "update_panels", event_update_panels, NULL, NULL); + } /* --------------------------------------------------------------------------------------------- */ diff --git a/src/filemanager/panelize.c b/src/filemanager/panelize.c index 8d6d441c4..9d2fb969e 100644 --- a/src/filemanager/panelize.c +++ b/src/filemanager/panelize.c @@ -47,7 +47,6 @@ #include "dir.h" #include "midnight.h" /* current_panel */ -#include "layout.h" /* repaint_screen() */ #include "panelize.h" diff --git a/src/learn.c b/src/learn.c index 2bf7ca581..417a170d8 100644 --- a/src/learn.c +++ b/src/learn.c @@ -44,7 +44,7 @@ #include "lib/util.h" /* convert_controls() */ #include "lib/widget.h" -#include "filemanager/layout.h" /* repaint_screen() */ +#include "src/filemanager/layout.h" /* mc_refresh() */ #include "setup.h" #include "learn.h"