diff --git a/lib/Makefile.am b/lib/Makefile.am index 98cfbb35f..bec2d63c5 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -13,7 +13,7 @@ SUBLIB_includes = \ widget.h SRC_mc_utils = \ - utilunix.c \ + utilunix.c utilunix.h \ unixcompat.h \ util.c util.h diff --git a/lib/filehighlight.h b/lib/filehighlight.h index 997b5ab1f..44bafc862 100644 --- a/lib/filehighlight.h +++ b/lib/filehighlight.h @@ -4,7 +4,7 @@ #include "lib/mcconfig.h" #include "lib/search.h" -#include "src/filemanager/dir.h" +#include "lib/util.h" /*** typedefs(not structures) and defined constants **********************************************/ diff --git a/lib/global.c b/lib/global.c index eb6eedc58..beb5329ca 100644 --- a/lib/global.c +++ b/lib/global.c @@ -71,6 +71,8 @@ mc_global_t mc_global = { .sysconfig_dir = NULL, .share_data_dir = NULL, + .is_right = FALSE, + .args = { .disable_colors = FALSE, diff --git a/lib/global.h b/lib/global.h index f86f0eadf..c476a9812 100644 --- a/lib/global.h +++ b/lib/global.h @@ -199,6 +199,10 @@ typedef struct /* share_data_dir: Area for default settings from developers */ char *share_data_dir; + /* Ugly hack in order to distinguish between left and right panel in menubar */ + /* Set if the command is being run from the "Right" menu */ + gboolean is_right; /* If the selected menu was the right */ + struct { /* Use the specified skin */ diff --git a/lib/util.h b/lib/util.h index ea9dadec5..95b4af607 100644 --- a/lib/util.h +++ b/lib/util.h @@ -47,6 +47,28 @@ enum compression_type /*** structures declarations (and typedefs of structures)*****************************************/ +/* keys are set only during sorting */ +typedef struct +{ + /* File attributes */ + size_t fnamelen; + char *fname; + struct stat st; + /* key used for comparing names */ + char *sort_key; + /* key used for comparing extensions */ + char *second_sort_key; + + /* Flags */ + struct + { + unsigned int marked:1; /* File marked in pane window */ + unsigned int link_to_dir:1; /* If this is a link, does it point to directory? */ + unsigned int stale_link:1; /* If this is a symlink and points to Charon's land */ + unsigned int dir_size_computed:1; /* Size of directory was computed with dirsizes_cmd */ + } f; +} file_entry; + /*** global variables defined in .c file *********************************************************/ extern struct sigaction startup_handler; diff --git a/lib/utilunix.c b/lib/utilunix.c index b81be0896..354a9b3b7 100644 --- a/lib/utilunix.c +++ b/lib/utilunix.c @@ -57,11 +57,12 @@ #include "lib/util.h" #include "lib/widget.h" /* message() */ -#include "src/execute.h" #ifdef HAVE_CHARSET -#include "charsets.h" +#include "lib/charsets.h" #endif +#include "utilunix.h" + /*** global variables ****************************************************************************/ struct sigaction startup_handler; diff --git a/lib/utilunix.h b/lib/utilunix.h new file mode 100644 index 000000000..922d2657a --- /dev/null +++ b/lib/utilunix.h @@ -0,0 +1,25 @@ +/** \file execute.h + * \brief Header: execution routines + */ + +#ifndef MC__UTILUNIX_H +#define MC__UTILUNIX_H + +/*** typedefs(not structures) and defined constants **********************************************/ + +/* flags for shell_execute */ +#define EXECUTE_INTERNAL (1 << 0) +#define EXECUTE_AS_SHELL (1 << 2) +#define EXECUTE_HIDE (1 << 3) + +/*** enums ***************************************************************************************/ + +/*** structures declarations (and typedefs of structures)*****************************************/ + +/*** global variables defined in .c file *********************************************************/ + +/*** declarations of public functions ************************************************************/ + +/*** inline functions ****************************************************************************/ + +#endif /* MC__UTILUNIX_H */ diff --git a/lib/widget/dialog.c b/lib/widget/dialog.c index 2d280dba7..9fb18e132 100644 --- a/lib/widget/dialog.c +++ b/lib/widget/dialog.c @@ -39,10 +39,6 @@ #include "lib/widget.h" #include "lib/event.h" /* mc_event_raise() */ -/* TODO: these includes should be removed! */ -#include "src/help.h" /* interactive_display() */ -#include "src/filemanager/layout.h" - /*** global variables ****************************************************************************/ /* Color styles for normal and error dialogs */ diff --git a/lib/widget/input.c b/lib/widget/input.c index 1e38dea4c..e7f33b18b 100644 --- a/lib/widget/input.c +++ b/lib/widget/input.c @@ -52,9 +52,6 @@ #include "input_complete.h" -#include "src/main.h" /* home_dir */ -#include "src/filemanager/midnight.h" /* current_panel */ - /*** global variables ****************************************************************************/ int quote = 0; diff --git a/lib/widget/menu.c b/lib/widget/menu.c index 11f7f986b..1595cd18f 100644 --- a/lib/widget/menu.c +++ b/lib/widget/menu.c @@ -36,11 +36,6 @@ #include "lib/widget.h" #include "lib/event.h" /* mc_event_raise() */ -/* TODO: these includes should be removed! */ -#include "src/keybind-defaults.h" /* CK_IgnoreKey */ -#include "src/help.h" -#include "src/filemanager/midnight.h" /* is_right */ - /*** global variables ****************************************************************************/ /*** file scope macro definitions ****************************************************************/ @@ -297,7 +292,7 @@ menubar_execute (WMenuBar * menubar) if ((entry != NULL) && (entry->command != CK_IgnoreKey)) { - is_right = (menubar->selected != 0); + mc_global.is_right = (menubar->selected != 0); menubar_finish (menubar); menubar->widget.owner->callback (menubar->widget.owner, &menubar->widget, DLG_ACTION, entry->command, NULL); diff --git a/src/execute.h b/src/execute.h index a626c4403..0ca97967d 100644 --- a/src/execute.h +++ b/src/execute.h @@ -5,12 +5,9 @@ #ifndef MC__EXECUTE_H #define MC__EXECUTE_H -/*** typedefs(not structures) and defined constants **********************************************/ +#include "lib/utilunix.h" -/* flags for shell_execute */ -#define EXECUTE_INTERNAL (1 << 0) -#define EXECUTE_AS_SHELL (1 << 2) -#define EXECUTE_HIDE (1 << 3) +/*** typedefs(not structures) and defined constants **********************************************/ /*** enums ***************************************************************************************/ @@ -50,4 +47,5 @@ void post_exec (void); void pre_exec (void); /*** inline functions ****************************************************************************/ + #endif /* MC__EXECUTE_H */ diff --git a/src/filemanager/dir.h b/src/filemanager/dir.h index 44a3b89d9..dd135421f 100644 --- a/src/filemanager/dir.h +++ b/src/filemanager/dir.h @@ -8,6 +8,7 @@ #include #include "lib/global.h" +#include "lib/util.h" /*** typedefs(not structures) and defined constants **********************************************/ @@ -20,28 +21,6 @@ typedef int sortfn (const void *, const void *); /*** structures declarations (and typedefs of structures)*****************************************/ -/* keys are set only during sorting */ -typedef struct -{ - /* File attributes */ - size_t fnamelen; - char *fname; - struct stat st; - /* key used for comparing names */ - char *sort_key; - /* key used for comparing extensions */ - char *second_sort_key; - - /* Flags */ - struct - { - unsigned int marked:1; /* File marked in pane window */ - unsigned int link_to_dir:1; /* If this is a link, does it point to directory? */ - unsigned int stale_link:1; /* If this is a symlink and points to Charon's land */ - unsigned int dir_size_computed:1; /* Size of directory was computed with dirsizes_cmd */ - } f; -} file_entry; - typedef struct { file_entry *list; diff --git a/src/filemanager/midnight.c b/src/filemanager/midnight.c index bba1107a4..b4197a473 100644 --- a/src/filemanager/midnight.c +++ b/src/filemanager/midnight.c @@ -100,9 +100,6 @@ WPanel *right_panel = NULL; /* Pointer to the selected and unselected panel */ WPanel *current_panel = NULL; -/* Set if the command is being run from the "Right" menu */ -int is_right = 0; - /* The Menubar */ WMenuBar *the_menubar = NULL; /* The widget where we draw the prompt */ diff --git a/src/filemanager/midnight.h b/src/filemanager/midnight.h index 891aa6160..4fd86a683 100644 --- a/src/filemanager/midnight.h +++ b/src/filemanager/midnight.h @@ -14,9 +14,9 @@ /*** typedefs(not structures) and defined constants **********************************************/ -#define MENU_PANEL (is_right ? right_panel : left_panel) -#define MENU_PANEL_IDX (is_right ? 1 : 0) -#define SELECTED_IS_PANEL (get_display_type (is_right ? 1 : 0) == view_listing) +#define MENU_PANEL (mc_global.is_right ? right_panel : left_panel) +#define MENU_PANEL_IDX (mc_global.is_right ? 1 : 0) +#define SELECTED_IS_PANEL (get_display_type (mc_global.is_right ? 1 : 0) == view_listing) #define other_panel get_other_panel() @@ -34,9 +34,6 @@ extern WLabel *the_prompt; extern WLabel *the_hint; extern WButtonBar *the_bar; -/* Ugly hack in order to distinguish between left and right panel in menubar */ -extern gboolean is_right; /* If the selected menu was the right */ - extern WPanel *left_panel; extern WPanel *right_panel; extern WPanel *current_panel;