Browse Source

Added option to change mode of panel swap.

New "Simple panels swap" checkbox in "Panel options" configuration
dialog window. Unchecked by default.

Documentation update.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Andrew Borodin 14 years ago
parent
commit
16c13be47b
6 changed files with 36 additions and 16 deletions
  1. 6 0
      doc/man/mc.1.in
  2. 7 0
      doc/man/ru/mc.1.in
  3. 1 0
      lib/mcconfig.h
  4. 2 1
      src/filemanager/layout.c
  5. 15 7
      src/filemanager/option.c
  6. 5 8
      src/setup.c

+ 6 - 0
doc/man/mc.1.in

@@ -2008,6 +2008,12 @@ The selection of directories is untouched. If off, the reverse selection
 is applied to files as well to directories: all unselected items become
 is applied to files as well to directories: all unselected items become
 selected, and vice versa.
 selected, and vice versa.
 .PP
 .PP
+.I Simple swap.
+If both panels contain file listing, simple swap means that panels exchange
+its screen positions: left panel become right one, and vice versa. If this
+option is unchecked, file listing panels exchange its content keeping listing
+format and sort options. Unchecked by default.
+.PP
 .I Auto save panels setup.
 .I Auto save panels setup.
 If this option is enabled, when you exit the Midnight Commander the
 If this option is enabled, when you exit the Midnight Commander the
 current settings of panels are saved in the ~/.mc/panels.ini file.
 current settings of panels are saved in the ~/.mc/panels.ini file.

+ 7 - 0
doc/man/ru/mc.1.in

@@ -2157,6 +2157,13 @@ Commander будет использовать для вывода содержи
 не изменяется. Если не установлена, производится инвертирование как файлов,
 не изменяется. Если не установлена, производится инвертирование как файлов,
 так и каталогов. Все невыбранные объекты становятся выбранными и наоборот.
 так и каталогов. Все невыбранные объекты становятся выбранными и наоборот.
 .PP
 .PP
+.I Простая перестановка.
+Если обе панели содержат списки файлов и каталогов, простая перестановка
+представляет собой изменение расположения панелей на экране: правая панель
+становится левой и наоборот. Если эта опция выключена, панели со списками файлов
+обмениваются соим содержимым, сохраняя формат списка и параметры сортировки.
+По умолчанию выключено.
+.PP
 .I Автосохранение настроек панелей.
 .I Автосохранение настроек панелей.
 Если опция включена (по умолчанию она выключена), то при выходе из
 Если опция включена (по умолчанию она выключена), то при выходе из
 Midnight Commander'а текущие настройки панелей соханяются в файле
 Midnight Commander'а текущие настройки панелей соханяются в файле

+ 1 - 0
lib/mcconfig.h

@@ -4,6 +4,7 @@
 /*** typedefs(not structures) and defined constants ********************/
 /*** typedefs(not structures) and defined constants ********************/
 
 
 #define CONFIG_APP_SECTION "Midnight-Commander"
 #define CONFIG_APP_SECTION "Midnight-Commander"
+#define CONFIG_PANELS_SECTION "Panels"
 
 
 /*** enums *************************************************************/
 /*** enums *************************************************************/
 
 

+ 2 - 1
src/filemanager/layout.c

@@ -1097,7 +1097,8 @@ swap_panels (void)
     panel1 = (WPanel *) panels[0].widget;
     panel1 = (WPanel *) panels[0].widget;
     panel2 = (WPanel *) panels[1].widget;
     panel2 = (WPanel *) panels[1].widget;
 
 
-    if (panels[0].type == view_listing && panels[1].type == view_listing)
+    if (panels[0].type == view_listing && panels[1].type == view_listing &&
+        !mc_config_get_bool (mc_main_config, CONFIG_PANELS_SECTION, "simple_swap", FALSE))
     {
     {
         WPanel panel;
         WPanel panel;
 
 

+ 15 - 7
src/filemanager/option.c

@@ -32,7 +32,7 @@
 #include <unistd.h>
 #include <unistd.h>
 
 
 #include "lib/global.h"
 #include "lib/global.h"
-#include "lib/mcconfig.h"       /* mc_config_save_file() */
+#include "lib/mcconfig.h"
 #include "lib/strutil.h"        /* str_term_width1() */
 #include "lib/strutil.h"        /* str_term_width1() */
 #include "lib/tty/key.h"        /* old_esc_mode_timeout */
 #include "lib/tty/key.h"        /* old_esc_mode_timeout */
 #include "lib/widget.h"
 #include "lib/widget.h"
@@ -283,6 +283,9 @@ panel_options_box (void)
     int dlg_width = 60;
     int dlg_width = 60;
     int dlg_height = 19;
     int dlg_height = 19;
 
 
+    int simple_swap = mc_config_get_bool (mc_main_config, CONFIG_PANELS_SECTION,
+                                          "simple_swap", FALSE) ? 1 : 0;
+
     const char *qsearch_options[] = {
     const char *qsearch_options[] = {
         N_("Case &insensitive"),
         N_("Case &insensitive"),
         N_("Case s&ensitive"),
         N_("Case s&ensitive"),
@@ -317,8 +320,10 @@ panel_options_box (void)
         QUICK_GROUPBOX (dlg_width / 2, dlg_width, 2, dlg_height, dlg_width / 2 - 4, 5,
         QUICK_GROUPBOX (dlg_width / 2, dlg_width, 2, dlg_height, dlg_width / 2 - 4, 5,
                         N_("Navigation")),
                         N_("Navigation")),
         /* main panel options */
         /* main panel options */
-        QUICK_CHECKBOX (5, dlg_width, 10, dlg_height, N_("A&uto save panels setup"),
+        QUICK_CHECKBOX (5, dlg_width, 11, dlg_height, N_("A&uto save panels setup"),
                         &panels_options.auto_save_setup),
                         &panels_options.auto_save_setup),
+        QUICK_CHECKBOX (5, dlg_width, 10, dlg_height, N_("Simple s&wap"),
+                        &simple_swap),
         QUICK_CHECKBOX (5, dlg_width, 9, dlg_height, N_("Re&verse files only"),
         QUICK_CHECKBOX (5, dlg_width, 9, dlg_height, N_("Re&verse files only"),
                         &panels_options.reverse_files_only),
                         &panels_options.reverse_files_only),
         QUICK_CHECKBOX (5, dlg_width, 8, dlg_height, N_("Ma&rk moves down"),
         QUICK_CHECKBOX (5, dlg_width, 8, dlg_height, N_("Ma&rk moves down"),
@@ -338,7 +343,7 @@ panel_options_box (void)
         QUICK_END
         QUICK_END
     };
     };
 
 
-    const size_t qw_num = sizeof (quick_widgets) / sizeof (quick_widgets[0]) - 1;
+    const size_t qw_num = G_N_ELEMENTS (quick_widgets) - 1;
 
 
     QuickDialog Quick_input = {
     QuickDialog Quick_input = {
         dlg_width, dlg_height, -1, -1,
         dlg_width, dlg_height, -1, -1,
@@ -365,7 +370,7 @@ panel_options_box (void)
                 for (j = 0; j < QSEARCH_NUM; j++)
                 for (j = 0; j < QSEARCH_NUM; j++)
                     qsearch_options[j] = _(qsearch_options[j]);
                     qsearch_options[j] = _(qsearch_options[j]);
             }
             }
-            else if ((i == 4) || (i == 7) || (i == 11) || (i == 20))
+            else if ((i == 4) || (i == 7) || (i == 11) || (i == 21))
                 /* groupboxes */
                 /* groupboxes */
                 quick_widgets[i].u.groupbox.title = _(quick_widgets[i].u.groupbox.title);
                 quick_widgets[i].u.groupbox.title = _(quick_widgets[i].u.groupbox.title);
             else
             else
@@ -387,7 +392,7 @@ panel_options_box (void)
 
 
     /* checkboxes within groupboxes */
     /* checkboxes within groupboxes */
     c_len = 0;
     c_len = 0;
-    for (i = 5; i < 20; i++)
+    for (i = 5; i < 21; i++)
         if ((i != 7) && (i != 11))
         if ((i != 7) && (i != 11))
             c_len = max (c_len, str_term_width1 (quick_widgets[i].u.checkbox.text) + 4);
             c_len = max (c_len, str_term_width1 (quick_widgets[i].u.checkbox.text) + 4);
 
 
@@ -398,7 +403,7 @@ panel_options_box (void)
     g_len = max (c_len + 2, str_term_width1 (quick_widgets[4].u.groupbox.title) + 4);
     g_len = max (c_len + 2, str_term_width1 (quick_widgets[4].u.groupbox.title) + 4);
     g_len = max (g_len, str_term_width1 (quick_widgets[7].u.groupbox.title) + 4);
     g_len = max (g_len, str_term_width1 (quick_widgets[7].u.groupbox.title) + 4);
     g_len = max (g_len, str_term_width1 (quick_widgets[11].u.groupbox.title) + 4);
     g_len = max (g_len, str_term_width1 (quick_widgets[11].u.groupbox.title) + 4);
-    g_len = max (g_len, str_term_width1 (quick_widgets[20].u.groupbox.title) + 4);
+    g_len = max (g_len, str_term_width1 (quick_widgets[21].u.groupbox.title) + 4);
     /* dialog width */
     /* dialog width */
     Quick_input.xlen = max (dlg_width, g_len * 2 + 9);
     Quick_input.xlen = max (dlg_width, g_len * 2 + 9);
     Quick_input.xlen = max (Quick_input.xlen, b_len + 2);
     Quick_input.xlen = max (Quick_input.xlen, b_len + 2);
@@ -413,7 +418,7 @@ panel_options_box (void)
     quick_widgets[4].u.groupbox.width =
     quick_widgets[4].u.groupbox.width =
         quick_widgets[7].u.groupbox.width =
         quick_widgets[7].u.groupbox.width =
         quick_widgets[11].u.groupbox.width = Quick_input.xlen / 2 - 3;
         quick_widgets[11].u.groupbox.width = Quick_input.xlen / 2 - 3;
-    quick_widgets[20].u.groupbox.width = Quick_input.xlen / 2 - 4;
+    quick_widgets[21].u.groupbox.width = Quick_input.xlen / 2 - 4;
 
 
     /* right column */
     /* right column */
     quick_widgets[4].relative_x =
     quick_widgets[4].relative_x =
@@ -431,6 +436,9 @@ panel_options_box (void)
 
 
     if ((qd_result == B_ENTER) || (qd_result == B_EXIT))
     if ((qd_result == B_ENTER) || (qd_result == B_EXIT))
     {
     {
+        mc_config_set_bool (mc_main_config, CONFIG_PANELS_SECTION,
+                           "simple_swap", (gboolean) (simple_swap & C_BOOL));
+
         if (!panels_options.fast_reload_msg_shown && panels_options.fast_reload)
         if (!panels_options.fast_reload_msg_shown && panels_options.fast_reload)
         {
         {
             message (D_NORMAL, _("Information"),
             message (D_NORMAL, _("Information"),

+ 5 - 8
src/setup.c

@@ -368,12 +368,9 @@ static const struct
 };
 };
 /* *INDENT-ON* */
 /* *INDENT-ON* */
 
 
-static const char *panels_section = "Panels";
-
 /*** file scope functions ************************************************************************/
 /*** file scope functions ************************************************************************/
 /* --------------------------------------------------------------------------------------------- */
 /* --------------------------------------------------------------------------------------------- */
 
 
-
 /**
 /**
   Get name of config file.
   Get name of config file.
 
 
@@ -1404,15 +1401,15 @@ panels_load_options (void)
         panels_options.qsearch_mode = (qsearch_mode_t) qmode;
         panels_options.qsearch_mode = (qsearch_mode_t) qmode;
 
 
     /* overwrite by new parameters */
     /* overwrite by new parameters */
-    if (mc_config_has_group (mc_main_config, panels_section))
+    if (mc_config_has_group (mc_main_config, CONFIG_PANELS_SECTION))
     {
     {
         for (i = 0; panels_ini_options[i].opt_name != NULL; i++)
         for (i = 0; panels_ini_options[i].opt_name != NULL; i++)
             *panels_ini_options[i].opt_addr =
             *panels_ini_options[i].opt_addr =
-                mc_config_get_bool (mc_main_config, panels_section,
+                mc_config_get_bool (mc_main_config, CONFIG_PANELS_SECTION,
                                     panels_ini_options[i].opt_name,
                                     panels_ini_options[i].opt_name,
                                     *panels_ini_options[i].opt_addr);
                                     *panels_ini_options[i].opt_addr);
 
 
-        qmode = mc_config_get_int (mc_main_config, panels_section,
+        qmode = mc_config_get_int (mc_main_config, CONFIG_PANELS_SECTION,
                                    "quick_search_mode", (int) panels_options.qsearch_mode);
                                    "quick_search_mode", (int) panels_options.qsearch_mode);
         if (qmode < 0)
         if (qmode < 0)
             panels_options.qsearch_mode = QSEARCH_CASE_INSENSITIVE;
             panels_options.qsearch_mode = QSEARCH_CASE_INSENSITIVE;
@@ -1434,10 +1431,10 @@ panels_save_options (void)
     size_t i;
     size_t i;
 
 
     for (i = 0; panels_ini_options[i].opt_name != NULL; i++)
     for (i = 0; panels_ini_options[i].opt_name != NULL; i++)
-        mc_config_set_bool (mc_main_config, panels_section,
+        mc_config_set_bool (mc_main_config, CONFIG_PANELS_SECTION,
                             panels_ini_options[i].opt_name, *panels_ini_options[i].opt_addr);
                             panels_ini_options[i].opt_name, *panels_ini_options[i].opt_addr);
 
 
-    mc_config_set_int (mc_main_config, panels_section,
+    mc_config_set_int (mc_main_config, CONFIG_PANELS_SECTION,
                        "quick_search_mode", (int) panels_options.qsearch_mode);
                        "quick_search_mode", (int) panels_options.qsearch_mode);
 }
 }