root/src/filemanager/boxes.c

/* [previous][next][first][last][top][bottom][index][help]  */

DEFINITIONS

This source file includes following definitions.
  1. configure_callback
  2. skin_apply
  3. skin_name_to_label
  4. skin_dlg_callback
  5. sel_skin_button
  6. appearance_box_callback
  7. panel_listing_callback
  8. sel_charset_button
  9. tree_callback
  10. confvfs_callback
  11. jobs_fill_listbox
  12. task_cb
  13. configure_box
  14. appearance_box
  15. panel_options_box
  16. panel_listing_box
  17. sort_box
  18. confirm_box
  19. display_bits_box
  20. display_bits_box
  21. tree_box
  22. configure_vfs_box
  23. cd_box
  24. symlink_box
  25. jobs_box
  26. vfs_smb_get_authinfo

   1 /*
   2    Some misc dialog boxes for the program.
   3 
   4    Copyright (C) 1994-2021
   5    Free Software Foundation, Inc.
   6 
   7    Written by:
   8    Miguel de Icaza, 1994, 1995
   9    Jakub Jelinek, 1995
  10    Andrew Borodin <aborodin@vmail.ru>, 2009-2015
  11 
  12    This file is part of the Midnight Commander.
  13 
  14    The Midnight Commander is free software: you can redistribute it
  15    and/or modify it under the terms of the GNU General Public License as
  16    published by the Free Software Foundation, either version 3 of the License,
  17    or (at your option) any later version.
  18 
  19    The Midnight Commander is distributed in the hope that it will be useful,
  20    but WITHOUT ANY WARRANTY; without even the implied warranty of
  21    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  22    GNU General Public License for more details.
  23 
  24    You should have received a copy of the GNU General Public License
  25    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  26  */
  27 
  28 /** \file boxes.c
  29  *  \brief Source: Some misc dialog boxes for the program
  30  */
  31 
  32 #include <config.h>
  33 
  34 #include <ctype.h>
  35 #include <signal.h>
  36 #include <stdio.h>
  37 #include <stdlib.h>
  38 #include <string.h>
  39 #include <sys/types.h>
  40 #include <sys/stat.h>
  41 
  42 #include "lib/global.h"
  43 
  44 #include "lib/tty/tty.h"
  45 #include "lib/tty/color.h"      /* tty_use_colors() */
  46 #include "lib/tty/key.h"        /* XCTRL and ALT macros  */
  47 #include "lib/skin.h"           /* INPUT_COLOR */
  48 #include "lib/mcconfig.h"       /* Load/save user formats */
  49 #include "lib/strutil.h"
  50 
  51 #include "lib/vfs/vfs.h"
  52 #ifdef ENABLE_VFS_FTP
  53 #include "src/vfs/ftpfs/ftpfs.h"
  54 #endif /* ENABLE_VFS_FTP */
  55 #ifdef ENABLE_VFS_SMB
  56 #include "src/vfs/smbfs/smbfs.h"
  57 #endif /* ENABLE_VFS_SMB */
  58 
  59 #include "lib/util.h"           /* Q_() */
  60 #include "lib/widget.h"
  61 
  62 #include "src/setup.h"
  63 #include "src/history.h"        /* MC_HISTORY_ESC_TIMEOUT */
  64 #include "src/execute.h"        /* pause_after_run */
  65 #ifdef ENABLE_BACKGROUND
  66 #include "src/background.h"     /* task_list */
  67 #endif
  68 
  69 #ifdef HAVE_CHARSET
  70 #include "lib/charsets.h"
  71 #include "src/selcodepage.h"
  72 #endif
  73 
  74 #include "command.h"            /* For cmdline */
  75 #include "dir.h"
  76 #include "tree.h"
  77 #include "layout.h"             /* for get_nth_panel_name proto */
  78 #include "filemanager.h"
  79 
  80 #include "boxes.h"
  81 
  82 /*** global variables ****************************************************************************/
  83 
  84 /*** file scope macro definitions ****************************************************************/
  85 
  86 #ifdef ENABLE_BACKGROUND
  87 #define B_STOP   (B_USER+1)
  88 #define B_RESUME (B_USER+2)
  89 #define B_KILL   (B_USER+3)
  90 #endif /* ENABLE_BACKGROUND */
  91 
  92 /*** file scope type declarations ****************************************************************/
  93 
  94 /*** file scope variables ************************************************************************/
  95 
  96 static unsigned long configure_old_esc_mode_id, configure_time_out_id;
  97 
  98 /* Index in list_formats[] for "brief" */
  99 static const int panel_list_brief_idx = 1;
 100 /* Index in list_formats[] for "user defined" */
 101 static const int panel_list_user_idx = 3;
 102 
 103 static char **status_format;
 104 static unsigned long panel_list_formats_id, panel_user_format_id, panel_brief_cols_id;
 105 static unsigned long user_mini_status_id, mini_user_format_id;
 106 
 107 #ifdef HAVE_CHARSET
 108 static int new_display_codepage;
 109 #endif /* HAVE_CHARSET */
 110 
 111 #if defined(ENABLE_VFS) && defined(ENABLE_VFS_FTP)
 112 static unsigned long ftpfs_always_use_proxy_id, ftpfs_proxy_host_id;
 113 #endif /* ENABLE_VFS && ENABLE_VFS_FTP */
 114 
 115 static GPtrArray *skin_names;
 116 static gchar *current_skin_name;
 117 
 118 #ifdef ENABLE_BACKGROUND
 119 static WListbox *bg_list = NULL;
 120 #endif /* ENABLE_BACKGROUND */
 121 
 122 static unsigned long shadows_id;
 123 
 124 /* --------------------------------------------------------------------------------------------- */
 125 /*** file scope functions ************************************************************************/
 126 /* --------------------------------------------------------------------------------------------- */
 127 
 128 static cb_ret_t
 129 configure_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
     /* [previous][next][first][last][top][bottom][index][help]  */
 130 {
 131     switch (msg)
 132     {
 133     case MSG_NOTIFY:
 134         /* message from "Single press" checkbutton */
 135         if (sender != NULL && sender->id == configure_old_esc_mode_id)
 136         {
 137             const gboolean not_single = !CHECK (sender)->state;
 138             Widget *ww;
 139 
 140             /* input line */
 141             ww = widget_find_by_id (w, configure_time_out_id);
 142             widget_disable (ww, not_single);
 143 
 144             return MSG_HANDLED;
 145         }
 146         return MSG_NOT_HANDLED;
 147 
 148     default:
 149         return dlg_default_callback (w, sender, msg, parm, data);
 150     }
 151 }
 152 
 153 /* --------------------------------------------------------------------------------------------- */
 154 
 155 static void
 156 skin_apply (const gchar * skin_override)
     /* [previous][next][first][last][top][bottom][index][help]  */
 157 {
 158     GError *mcerror = NULL;
 159 
 160     mc_skin_deinit ();
 161     mc_skin_init (skin_override, &mcerror);
 162     mc_fhl_free (&mc_filehighlight);
 163     mc_filehighlight = mc_fhl_new (TRUE);
 164     dlg_set_default_colors ();
 165     input_set_default_colors ();
 166     if (mc_global.mc_run_mode == MC_RUN_FULL)
 167         command_set_default_colors ();
 168     panel_deinit ();
 169     panel_init ();
 170     repaint_screen ();
 171 
 172     mc_error_message (&mcerror, NULL);
 173 }
 174 
 175 /* --------------------------------------------------------------------------------------------- */
 176 
 177 static const gchar *
 178 skin_name_to_label (const gchar * name)
     /* [previous][next][first][last][top][bottom][index][help]  */
 179 {
 180     if (strcmp (name, "default") == 0)
 181         return _("< Default >");
 182     return name;
 183 }
 184 
 185 /* --------------------------------------------------------------------------------------------- */
 186 
 187 static cb_ret_t
 188 skin_dlg_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
     /* [previous][next][first][last][top][bottom][index][help]  */
 189 {
 190     switch (msg)
 191     {
 192     case MSG_RESIZE:
 193         {
 194             WDialog *d = DIALOG (w);
 195             Widget *wd = WIDGET (d->data);
 196             int y, x;
 197             WRect r;
 198 
 199             y = wd->y + (wd->lines - w->lines) / 2;
 200             x = wd->x + wd->cols / 2;
 201             rect_init (&r, y, x, w->lines, w->cols);
 202 
 203             return dlg_default_callback (w, NULL, MSG_RESIZE, 0, &r);
 204         }
 205 
 206     default:
 207         return dlg_default_callback (w, sender, msg, parm, data);
 208     }
 209 }
 210 
 211 /* --------------------------------------------------------------------------------------------- */
 212 
 213 static int
 214 sel_skin_button (WButton * button, int action)
     /* [previous][next][first][last][top][bottom][index][help]  */
 215 {
 216     int result;
 217     WListbox *skin_list;
 218     WDialog *skin_dlg;
 219     const gchar *skin_name;
 220     unsigned int i;
 221     unsigned int pos = 1;
 222 
 223     (void) action;
 224 
 225     skin_dlg =
 226         dlg_create (TRUE, 0, 0, 13, 24, WPOS_KEEP_DEFAULT, TRUE, dialog_colors, skin_dlg_callback,
 227                     NULL, "[Appearance]", _("Skins"));
 228     /* use Appearance dialog for positioning */
 229     skin_dlg->data = WIDGET (button)->owner;
 230 
 231     /* set dialog location before all */
 232     send_message (skin_dlg, NULL, MSG_RESIZE, 0, NULL);
 233 
 234     skin_list = listbox_new (1, 1, 11, 22, FALSE, NULL);
 235     skin_name = "default";
 236     listbox_add_item (skin_list, LISTBOX_APPEND_AT_END, 0, skin_name_to_label (skin_name),
 237                       (void *) skin_name, FALSE);
 238 
 239     if (strcmp (skin_name, current_skin_name) == 0)
 240         listbox_select_entry (skin_list, 0);
 241 
 242     for (i = 0; i < skin_names->len; i++)
 243     {
 244         skin_name = g_ptr_array_index (skin_names, i);
 245         if (strcmp (skin_name, "default") != 0)
 246         {
 247             listbox_add_item (skin_list, LISTBOX_APPEND_AT_END, 0, skin_name_to_label (skin_name),
 248                               (void *) skin_name, FALSE);
 249             if (strcmp (skin_name, current_skin_name) == 0)
 250                 listbox_select_entry (skin_list, pos);
 251             pos++;
 252         }
 253     }
 254 
 255     /* make list stick to all sides of dialog, effectively make it be resized with dialog */
 256     group_add_widget_autopos (GROUP (skin_dlg), skin_list, WPOS_KEEP_ALL, NULL);
 257 
 258     result = dlg_run (skin_dlg);
 259     if (result == B_ENTER)
 260     {
 261         gchar *skin_label;
 262 
 263         listbox_get_current (skin_list, &skin_label, (void **) &skin_name);
 264         g_free (current_skin_name);
 265         current_skin_name = g_strdup (skin_name);
 266         skin_apply (skin_name);
 267 
 268         button_set_text (button, str_fit_to_term (skin_label, 20, J_LEFT_FIT));
 269     }
 270     widget_destroy (WIDGET (skin_dlg));
 271 
 272     return 0;
 273 }
 274 
 275 /* --------------------------------------------------------------------------------------------- */
 276 
 277 static cb_ret_t
 278 appearance_box_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
     /* [previous][next][first][last][top][bottom][index][help]  */
 279 {
 280     switch (msg)
 281     {
 282     case MSG_INIT:
 283 #ifdef ENABLE_SHADOWS
 284         if (!tty_use_colors ())
 285 #endif
 286         {
 287             Widget *shadow;
 288 
 289             shadow = widget_find_by_id (w, shadows_id);
 290             CHECK (shadow)->state = FALSE;
 291             widget_disable (shadow, TRUE);
 292         }
 293         return MSG_HANDLED;
 294 
 295     case MSG_NOTIFY:
 296         if (sender != NULL && sender->id == shadows_id)
 297         {
 298             mc_global.tty.shadows = CHECK (sender)->state;
 299             repaint_screen ();
 300             return MSG_HANDLED;
 301         }
 302         return MSG_NOT_HANDLED;
 303 
 304     default:
 305         return dlg_default_callback (w, sender, msg, parm, data);
 306     }
 307 }
 308 
 309 /* --------------------------------------------------------------------------------------------- */
 310 
 311 static cb_ret_t
 312 panel_listing_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
     /* [previous][next][first][last][top][bottom][index][help]  */
 313 {
 314     switch (msg)
 315     {
 316     case MSG_NOTIFY:
 317         if (sender != NULL && sender->id == panel_list_formats_id)
 318         {
 319             WCheck *ch;
 320             WInput *in1, *in2, *in3;
 321 
 322             in1 = INPUT (widget_find_by_id (w, panel_user_format_id));
 323             in2 = INPUT (widget_find_by_id (w, panel_brief_cols_id));
 324             ch = CHECK (widget_find_by_id (w, user_mini_status_id));
 325             in3 = INPUT (widget_find_by_id (w, mini_user_format_id));
 326 
 327             if (!ch->state)
 328                 input_assign_text (in3, status_format[RADIO (sender)->sel]);
 329             input_update (in1, FALSE);
 330             input_update (in2, FALSE);
 331             input_update (in3, FALSE);
 332             widget_disable (WIDGET (in1), RADIO (sender)->sel != panel_list_user_idx);
 333             widget_disable (WIDGET (in2), RADIO (sender)->sel != panel_list_brief_idx);
 334             return MSG_HANDLED;
 335         }
 336 
 337         if (sender != NULL && sender->id == user_mini_status_id)
 338         {
 339             WInput *in;
 340 
 341             in = INPUT (widget_find_by_id (w, mini_user_format_id));
 342 
 343             if (CHECK (sender)->state)
 344             {
 345                 widget_disable (WIDGET (in), FALSE);
 346                 input_assign_text (in, status_format[3]);
 347             }
 348             else
 349             {
 350                 WRadio *r;
 351 
 352                 r = RADIO (widget_find_by_id (w, panel_list_formats_id));
 353                 widget_disable (WIDGET (in), TRUE);
 354                 input_assign_text (in, status_format[r->sel]);
 355             }
 356             /* input_update (in, FALSE); */
 357             return MSG_HANDLED;
 358         }
 359 
 360         return MSG_NOT_HANDLED;
 361 
 362     default:
 363         return dlg_default_callback (w, sender, msg, parm, data);
 364     }
 365 }
 366 
 367 /* --------------------------------------------------------------------------------------------- */
 368 
 369 #ifdef HAVE_CHARSET
 370 static int
 371 sel_charset_button (WButton * button, int action)
     /* [previous][next][first][last][top][bottom][index][help]  */
 372 {
 373     int new_dcp;
 374 
 375     (void) action;
 376 
 377     new_dcp = select_charset (-1, -1, new_display_codepage, TRUE);
 378 
 379     if (new_dcp != SELECT_CHARSET_CANCEL)
 380     {
 381         const char *cpname;
 382 
 383         new_display_codepage = new_dcp;
 384         cpname = (new_display_codepage == SELECT_CHARSET_OTHER_8BIT) ?
 385             _("Other 8 bit") :
 386             ((codepage_desc *) g_ptr_array_index (codepages, new_display_codepage))->name;
 387         if (cpname != NULL)
 388             mc_global.utf8_display = str_isutf8 (cpname);
 389         else
 390             cpname = _("7-bit ASCII");  /* FIXME */
 391 
 392         button_set_text (button, cpname);
 393         widget_draw (WIDGET (WIDGET (button)->owner));
 394     }
 395 
 396     return 0;
 397 }
 398 #endif /* HAVE_CHARSET */
 399 
 400 /* --------------------------------------------------------------------------------------------- */
 401 
 402 static cb_ret_t
 403 tree_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
     /* [previous][next][first][last][top][bottom][index][help]  */
 404 {
 405     WDialog *h = DIALOG (w);
 406 
 407     switch (msg)
 408     {
 409     case MSG_RESIZE:
 410         {
 411             WRect r;
 412             Widget *bar;
 413 
 414             rect_init (&r, w->y, w->x, LINES - 9, COLS - 20);
 415             dlg_default_callback (w, NULL, MSG_RESIZE, 0, &r);
 416 
 417             bar = WIDGET (find_buttonbar (h));
 418             bar->x = 0;
 419             bar->y = LINES - 1;
 420             return MSG_HANDLED;
 421         }
 422 
 423     case MSG_ACTION:
 424         return send_message (find_tree (h), NULL, MSG_ACTION, parm, NULL);
 425 
 426     default:
 427         return dlg_default_callback (w, sender, msg, parm, data);
 428     }
 429 }
 430 
 431 /* --------------------------------------------------------------------------------------------- */
 432 
 433 #if defined(ENABLE_VFS) && defined (ENABLE_VFS_FTP)
 434 static cb_ret_t
 435 confvfs_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
     /* [previous][next][first][last][top][bottom][index][help]  */
 436 {
 437     switch (msg)
 438     {
 439     case MSG_NOTIFY:
 440         /* message from "Always use ftp proxy" checkbutton */
 441         if (sender != NULL && sender->id == ftpfs_always_use_proxy_id)
 442         {
 443             const gboolean not_use = !CHECK (sender)->state;
 444             Widget *wi;
 445 
 446             /* input */
 447             wi = widget_find_by_id (w, ftpfs_proxy_host_id);
 448             widget_disable (wi, not_use);
 449             return MSG_HANDLED;
 450         }
 451         return MSG_NOT_HANDLED;
 452 
 453     default:
 454         return dlg_default_callback (w, sender, msg, parm, data);
 455     }
 456 }
 457 #endif /* ENABLE_VFS && ENABLE_VFS_FTP */
 458 
 459 /* --------------------------------------------------------------------------------------------- */
 460 
 461 #ifdef ENABLE_BACKGROUND
 462 static void
 463 jobs_fill_listbox (WListbox * list)
     /* [previous][next][first][last][top][bottom][index][help]  */
 464 {
 465     static const char *state_str[2] = { "", "" };
 466     TaskList *tl;
 467 
 468     if (state_str[0][0] == '\0')
 469     {
 470         state_str[0] = _("Running");
 471         state_str[1] = _("Stopped");
 472     }
 473 
 474     for (tl = task_list; tl != NULL; tl = tl->next)
 475     {
 476         char *s;
 477 
 478         s = g_strconcat (state_str[tl->state], " ", tl->info, (char *) NULL);
 479         listbox_add_item (list, LISTBOX_APPEND_AT_END, 0, s, (void *) tl, FALSE);
 480         g_free (s);
 481     }
 482 }
 483 
 484 /* --------------------------------------------------------------------------------------------- */
 485 
 486 static int
 487 task_cb (WButton * button, int action)
     /* [previous][next][first][last][top][bottom][index][help]  */
 488 {
 489     TaskList *tl;
 490     int sig = 0;
 491 
 492     (void) button;
 493 
 494     if (bg_list->list == NULL)
 495         return 0;
 496 
 497     /* Get this instance information */
 498     listbox_get_current (bg_list, NULL, (void **) &tl);
 499 
 500 #ifdef SIGTSTP
 501     if (action == B_STOP)
 502     {
 503         sig = SIGSTOP;
 504         tl->state = Task_Stopped;
 505     }
 506     else if (action == B_RESUME)
 507     {
 508         sig = SIGCONT;
 509         tl->state = Task_Running;
 510     }
 511     else
 512 #endif
 513     if (action == B_KILL)
 514         sig = SIGKILL;
 515 
 516     if (sig == SIGKILL)
 517         unregister_task_running (tl->pid, tl->fd);
 518 
 519     kill (tl->pid, sig);
 520     listbox_remove_list (bg_list);
 521     jobs_fill_listbox (bg_list);
 522 
 523     /* This can be optimized to just redraw this widget :-) */
 524     widget_draw (WIDGET (WIDGET (button)->owner));
 525 
 526     return 0;
 527 }
 528 #endif /* ENABLE_BACKGROUND */
 529 
 530 /* --------------------------------------------------------------------------------------------- */
 531 /*** public functions ****************************************************************************/
 532 /* --------------------------------------------------------------------------------------------- */
 533 
 534 void
 535 configure_box (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 536 {
 537     const char *pause_options[] = {
 538         N_("&Never"),
 539         N_("On dum&b terminals"),
 540         N_("Alwa&ys")
 541     };
 542 
 543     int pause_options_num;
 544 
 545     pause_options_num = G_N_ELEMENTS (pause_options);
 546 
 547     {
 548         char time_out[BUF_TINY] = "";
 549         char *time_out_new;
 550 
 551         quick_widget_t quick_widgets[] = {
 552             /* *INDENT-OFF* */
 553             QUICK_START_COLUMNS,
 554                 QUICK_START_GROUPBOX (N_("File operations")),
 555                     QUICK_CHECKBOX (N_("&Verbose operation"), &verbose, NULL),
 556                     QUICK_CHECKBOX (N_("Compute tota&ls"), &file_op_compute_totals, NULL),
 557                     QUICK_CHECKBOX (N_("Classic pro&gressbar"), &classic_progressbar, NULL),
 558                     QUICK_CHECKBOX (N_("Mkdi&r autoname"), &auto_fill_mkdir_name, NULL),
 559                     QUICK_CHECKBOX (N_("&Preallocate space"), &mc_global.vfs.preallocate_space,
 560                                     NULL),
 561                 QUICK_STOP_GROUPBOX,
 562                 QUICK_START_GROUPBOX (N_("Esc key mode")),
 563                     QUICK_CHECKBOX (N_("S&ingle press"), &old_esc_mode, &configure_old_esc_mode_id),
 564                     QUICK_LABELED_INPUT (N_("Timeout:"), input_label_left,
 565                                          (const char *) time_out, MC_HISTORY_ESC_TIMEOUT,
 566                                          &time_out_new, &configure_time_out_id, FALSE, FALSE,
 567                                          INPUT_COMPLETE_NONE),
 568                 QUICK_STOP_GROUPBOX,
 569                 QUICK_START_GROUPBOX (N_("Pause after run")),
 570                     QUICK_RADIO (pause_options_num, pause_options, &pause_after_run, NULL),
 571                 QUICK_STOP_GROUPBOX,
 572             QUICK_NEXT_COLUMN,
 573                 QUICK_START_GROUPBOX (N_("Other options")),
 574                     QUICK_CHECKBOX (N_("Use internal edi&t"), &use_internal_edit, NULL),
 575                     QUICK_CHECKBOX (N_("Use internal vie&w"), &use_internal_view, NULL),
 576                     QUICK_CHECKBOX (N_("A&sk new file name"),
 577                                     &editor_ask_filename_before_edit, NULL),
 578                     QUICK_CHECKBOX (N_("Auto m&enus"), &auto_menu, NULL),
 579                     QUICK_CHECKBOX (N_("&Drop down menus"), &drop_menus, NULL),
 580                     QUICK_CHECKBOX (N_("S&hell patterns"), &easy_patterns, NULL),
 581                     QUICK_CHECKBOX (N_("Co&mplete: show all"),
 582                                     &mc_global.widget.show_all_if_ambiguous, NULL),
 583                     QUICK_CHECKBOX (N_("Rotating d&ash"), &nice_rotating_dash, NULL),
 584                     QUICK_CHECKBOX (N_("Cd follows lin&ks"), &mc_global.vfs.cd_symlinks, NULL),
 585                     QUICK_CHECKBOX (N_("Sa&fe delete"), &safe_delete, NULL),
 586                     QUICK_CHECKBOX (N_("Safe overwrite"), &safe_overwrite, NULL),       /* w/o hotkey */
 587                     QUICK_CHECKBOX (N_("A&uto save setup"), &auto_save_setup, NULL),
 588                     QUICK_SEPARATOR (FALSE),
 589                     QUICK_SEPARATOR (FALSE),
 590                 QUICK_STOP_GROUPBOX,
 591             QUICK_STOP_COLUMNS,
 592             QUICK_BUTTONS_OK_CANCEL,
 593             QUICK_END
 594             /* *INDENT-ON* */
 595         };
 596 
 597         quick_dialog_t qdlg = {
 598             -1, -1, 60,
 599             N_("Configure options"), "[Configuration]",
 600             quick_widgets, configure_callback, NULL
 601         };
 602 
 603         g_snprintf (time_out, sizeof (time_out), "%d", old_esc_mode_timeout);
 604 
 605 #ifndef USE_INTERNAL_EDIT
 606         quick_widgets[17].state = WST_DISABLED;
 607 #endif
 608 
 609         if (!old_esc_mode)
 610             quick_widgets[10].state = quick_widgets[11].state = WST_DISABLED;
 611 
 612 #ifndef HAVE_POSIX_FALLOCATE
 613         mc_global.vfs.preallocate_space = FALSE;
 614         quick_widgets[7].state = WST_DISABLED;
 615 #endif
 616 
 617         if (quick_dialog (&qdlg) == B_ENTER)
 618             old_esc_mode_timeout = atoi (time_out_new);
 619 
 620         g_free (time_out_new);
 621     }
 622 }
 623 
 624 /* --------------------------------------------------------------------------------------------- */
 625 
 626 void
 627 appearance_box (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 628 {
 629     gboolean shadows = mc_global.tty.shadows;
 630 
 631     current_skin_name = g_strdup (mc_skin__default.name);
 632     skin_names = mc_skin_list ();
 633 
 634     {
 635         quick_widget_t quick_widgets[] = {
 636             /* *INDENT-OFF* */
 637             QUICK_START_COLUMNS,
 638                 QUICK_LABEL (N_("Skin:"), NULL),
 639             QUICK_NEXT_COLUMN,
 640                 QUICK_BUTTON (str_fit_to_term (skin_name_to_label (current_skin_name), 20, J_LEFT_FIT),
 641                               B_USER, sel_skin_button, NULL),
 642             QUICK_STOP_COLUMNS,
 643             QUICK_SEPARATOR (TRUE),
 644             QUICK_CHECKBOX (N_("&Shadows"), &mc_global.tty.shadows, &shadows_id),
 645             QUICK_BUTTONS_OK_CANCEL,
 646             QUICK_END
 647             /* *INDENT-ON* */
 648         };
 649 
 650         quick_dialog_t qdlg = {
 651             -1, -1, 54,
 652             N_("Appearance"), "[Appearance]",
 653             quick_widgets, appearance_box_callback, NULL
 654         };
 655 
 656         if (quick_dialog (&qdlg) == B_ENTER)
 657             mc_config_set_string (mc_global.main_config, CONFIG_APP_SECTION, "skin",
 658                                   current_skin_name);
 659         else
 660         {
 661             skin_apply (NULL);
 662             mc_global.tty.shadows = shadows;
 663         }
 664     }
 665 
 666     g_free (current_skin_name);
 667     g_ptr_array_foreach (skin_names, (GFunc) g_free, NULL);
 668     g_ptr_array_free (skin_names, TRUE);
 669 }
 670 
 671 /* --------------------------------------------------------------------------------------------- */
 672 
 673 void
 674 panel_options_box (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 675 {
 676     gboolean simple_swap;
 677 
 678     simple_swap = mc_config_get_bool (mc_global.main_config, CONFIG_PANELS_SECTION,
 679                                       "simple_swap", FALSE);
 680     {
 681         const char *qsearch_options[] = {
 682             N_("Case &insensitive"),
 683             N_("Cas&e sensitive"),
 684             N_("Use panel sort mo&de")
 685         };
 686 
 687         quick_widget_t quick_widgets[] = {
 688             /* *INDENT-OFF* */
 689             QUICK_START_COLUMNS,
 690                 QUICK_START_GROUPBOX (N_("Main options")),
 691                     QUICK_CHECKBOX (N_("Show mi&ni-status"), &panels_options.show_mini_info, NULL),
 692                     QUICK_CHECKBOX (N_("Use SI si&ze units"), &panels_options.kilobyte_si, NULL),
 693                     QUICK_CHECKBOX (N_("Mi&x all files"), &panels_options.mix_all_files, NULL),
 694                     QUICK_CHECKBOX (N_("Show &backup files"), &panels_options.show_backups, NULL),
 695                     QUICK_CHECKBOX (N_("Show &hidden files"), &panels_options.show_dot_files, NULL),
 696                     QUICK_CHECKBOX (N_("&Fast dir reload"), &panels_options.fast_reload, NULL),
 697                     QUICK_CHECKBOX (N_("Ma&rk moves down"), &panels_options.mark_moves_down, NULL),
 698                     QUICK_CHECKBOX (N_("Re&verse files only"), &panels_options.reverse_files_only,
 699                                     NULL),
 700                     QUICK_CHECKBOX (N_("Simple s&wap"), &simple_swap, NULL),
 701                     QUICK_CHECKBOX (N_("A&uto save panels setup"), &panels_options.auto_save_setup,
 702                                     NULL),
 703                     QUICK_SEPARATOR (FALSE),
 704                     QUICK_SEPARATOR (FALSE),
 705                     QUICK_SEPARATOR (FALSE),
 706                 QUICK_STOP_GROUPBOX,
 707             QUICK_NEXT_COLUMN,
 708                 QUICK_START_GROUPBOX (N_("Navigation")),
 709                     QUICK_CHECKBOX (N_("L&ynx-like motion"), &panels_options.navigate_with_arrows,
 710                                     NULL),
 711                     QUICK_CHECKBOX (N_("Pa&ge scrolling"), &panels_options.scroll_pages, NULL),
 712                     QUICK_CHECKBOX (N_("Center &scrolling"), &panels_options.scroll_center, NULL),
 713                     QUICK_CHECKBOX (N_("&Mouse page scrolling"), &panels_options.mouse_move_pages,
 714                                     NULL),
 715                 QUICK_STOP_GROUPBOX,
 716                 QUICK_START_GROUPBOX (N_("File highlight")),
 717                     QUICK_CHECKBOX (N_("File &types"), &panels_options.filetype_mode, NULL),
 718                     QUICK_CHECKBOX (N_("&Permissions"), &panels_options.permission_mode, NULL),
 719                 QUICK_STOP_GROUPBOX,
 720                 QUICK_START_GROUPBOX (N_("Quick search")),
 721                     QUICK_RADIO (QSEARCH_NUM, qsearch_options, (int *) &panels_options.qsearch_mode,
 722                                  NULL),
 723                 QUICK_STOP_GROUPBOX,
 724             QUICK_STOP_COLUMNS,
 725             QUICK_BUTTONS_OK_CANCEL,
 726             QUICK_END
 727             /* *INDENT-ON* */
 728         };
 729 
 730         quick_dialog_t qdlg = {
 731             -1, -1, 60,
 732             N_("Panel options"), "[Panel options]",
 733             quick_widgets, NULL, NULL
 734         };
 735 
 736         if (quick_dialog (&qdlg) != B_ENTER)
 737             return;
 738     }
 739 
 740     mc_config_set_bool (mc_global.main_config, CONFIG_PANELS_SECTION, "simple_swap", simple_swap);
 741 
 742     if (!panels_options.fast_reload_msg_shown && panels_options.fast_reload)
 743     {
 744         message (D_NORMAL, _("Information"),
 745                  _("Using the fast reload option may not reflect the exact\n"
 746                    "directory contents. In this case you'll need to do a\n"
 747                    "manual reload of the directory. See the man page for\n" "the details."));
 748         panels_options.fast_reload_msg_shown = TRUE;
 749     }
 750 
 751     update_panels (UP_RELOAD, UP_KEEPSEL);
 752 }
 753 
 754 /* --------------------------------------------------------------------------------------------- */
 755 
 756 /* return list type */
 757 int
 758 panel_listing_box (WPanel * panel, int num, char **userp, char **minip, gboolean * use_msformat,
     /* [previous][next][first][last][top][bottom][index][help]  */
 759                    int *brief_cols)
 760 {
 761     int result = -1;
 762     const char *p = NULL;
 763 
 764     if (panel == NULL)
 765     {
 766         p = get_nth_panel_name (num);
 767         panel = panel_empty_new (p);
 768     }
 769 
 770     {
 771         gboolean user_mini_status;
 772         char panel_brief_cols_in[BUF_TINY];
 773         char *panel_brief_cols_out = NULL;
 774         char *panel_user_format = NULL;
 775         char *mini_user_format = NULL;
 776 
 777         /* Controls whether the array strings have been translated */
 778         const char *list_formats[LIST_FORMATS] = {
 779             N_("&Full file list"),
 780             N_("&Brief file list:"),
 781             N_("&Long file list"),
 782             N_("&User defined:")
 783         };
 784 
 785         quick_widget_t quick_widgets[] = {
 786             /* *INDENT-OFF* */
 787             QUICK_START_COLUMNS,
 788                 QUICK_RADIO (LIST_FORMATS, list_formats, &result, &panel_list_formats_id),
 789             QUICK_NEXT_COLUMN,
 790                 QUICK_SEPARATOR (FALSE),
 791                 QUICK_LABELED_INPUT (_ ("columns"), input_label_right, panel_brief_cols_in,
 792                                      "panel-brief-cols-input", &panel_brief_cols_out,
 793                                      &panel_brief_cols_id, FALSE, FALSE, INPUT_COMPLETE_NONE),
 794             QUICK_STOP_COLUMNS,
 795             QUICK_INPUT (panel->user_format, "user-fmt-input", &panel_user_format,
 796                          &panel_user_format_id, FALSE, FALSE, INPUT_COMPLETE_NONE),
 797             QUICK_SEPARATOR (TRUE),
 798             QUICK_CHECKBOX (N_("User &mini status"), &user_mini_status, &user_mini_status_id),
 799             QUICK_INPUT (panel->user_status_format[panel->list_format], "mini_input",
 800                          &mini_user_format, &mini_user_format_id, FALSE, FALSE, INPUT_COMPLETE_NONE),
 801             QUICK_BUTTONS_OK_CANCEL,
 802             QUICK_END
 803             /* *INDENT-ON* */
 804         };
 805 
 806         quick_dialog_t qdlg = {
 807             -1, -1, 48,
 808             N_("Listing format"), "[Listing Format...]",
 809             quick_widgets, panel_listing_callback, NULL
 810         };
 811 
 812         user_mini_status = panel->user_mini_status;
 813         result = panel->list_format;
 814         status_format = panel->user_status_format;
 815 
 816         g_snprintf (panel_brief_cols_in, sizeof (panel_brief_cols_in), "%d", panel->brief_cols);
 817 
 818         if ((int) panel->list_format != panel_list_brief_idx)
 819             quick_widgets[4].state = WST_DISABLED;
 820 
 821         if ((int) panel->list_format != panel_list_user_idx)
 822             quick_widgets[6].state = WST_DISABLED;
 823 
 824         if (!user_mini_status)
 825             quick_widgets[9].state = WST_DISABLED;
 826 
 827         if (quick_dialog (&qdlg) == B_CANCEL)
 828             result = -1;
 829         else
 830         {
 831             int cols;
 832             char *error = NULL;
 833 
 834             *userp = panel_user_format;
 835             *minip = mini_user_format;
 836             *use_msformat = user_mini_status;
 837 
 838             cols = strtol (panel_brief_cols_out, &error, 10);
 839             if (*error == '\0')
 840                 *brief_cols = cols;
 841             else
 842                 *brief_cols = panel->brief_cols;
 843 
 844             g_free (panel_brief_cols_out);
 845         }
 846     }
 847 
 848     if (p != NULL)
 849     {
 850         int i;
 851 
 852         g_free (panel->user_format);
 853         for (i = 0; i < LIST_FORMATS; i++)
 854             g_free (panel->user_status_format[i]);
 855         g_free (panel);
 856     }
 857 
 858     return result;
 859 }
 860 
 861 /* --------------------------------------------------------------------------------------------- */
 862 
 863 const panel_field_t *
 864 sort_box (dir_sort_options_t * op, const panel_field_t * sort_field)
     /* [previous][next][first][last][top][bottom][index][help]  */
 865 {
 866     char **sort_orders_names;
 867     gsize i;
 868     gsize sort_names_num = 0;
 869     int sort_idx = 0;
 870     const panel_field_t *result = NULL;
 871 
 872     sort_orders_names = panel_get_sortable_fields (&sort_names_num);
 873 
 874     for (i = 0; i < sort_names_num; i++)
 875         if (strcmp (sort_orders_names[i], _(sort_field->title_hotkey)) == 0)
 876         {
 877             sort_idx = i;
 878             break;
 879         }
 880 
 881     {
 882         quick_widget_t quick_widgets[] = {
 883             /* *INDENT-OFF* */
 884             QUICK_START_COLUMNS,
 885                 QUICK_RADIO (sort_names_num, (const char **) sort_orders_names, &sort_idx, NULL),
 886             QUICK_NEXT_COLUMN,
 887                 QUICK_CHECKBOX (N_("Executable &first"), &op->exec_first, NULL),
 888                 QUICK_CHECKBOX (N_("Cas&e sensitive"), &op->case_sensitive, NULL),
 889                 QUICK_CHECKBOX (N_("&Reverse"), &op->reverse, NULL),
 890             QUICK_STOP_COLUMNS,
 891             QUICK_BUTTONS_OK_CANCEL,
 892             QUICK_END
 893             /* *INDENT-ON* */
 894         };
 895 
 896         quick_dialog_t qdlg = {
 897             -1, -1, 40,
 898             N_("Sort order"), "[Sort Order...]",
 899             quick_widgets, NULL, NULL
 900         };
 901 
 902         if (quick_dialog (&qdlg) != B_CANCEL)
 903             result = panel_get_field_by_title_hotkey (sort_orders_names[sort_idx]);
 904 
 905         if (result == NULL)
 906             result = sort_field;
 907     }
 908 
 909     g_strfreev (sort_orders_names);
 910 
 911     return result;
 912 }
 913 
 914 /* --------------------------------------------------------------------------------------------- */
 915 
 916 void
 917 confirm_box (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 918 {
 919     quick_widget_t quick_widgets[] = {
 920         /* *INDENT-OFF* */
 921         /* TRANSLATORS: no need to translate 'Confirmation', it's just a context prefix */
 922         QUICK_CHECKBOX (Q_("Confirmation|&Delete"), &confirm_delete, NULL),
 923         QUICK_CHECKBOX (Q_("Confirmation|O&verwrite"), &confirm_overwrite, NULL),
 924         QUICK_CHECKBOX (Q_("Confirmation|&Execute"), &confirm_execute, NULL),
 925         QUICK_CHECKBOX (Q_("Confirmation|E&xit"), &confirm_exit, NULL),
 926         QUICK_CHECKBOX (Q_("Confirmation|Di&rectory hotlist delete"),
 927                         &confirm_directory_hotlist_delete, NULL),
 928         QUICK_CHECKBOX (Q_("Confirmation|&History cleanup"),
 929                         &mc_global.widget.confirm_history_cleanup, NULL),
 930         QUICK_BUTTONS_OK_CANCEL,
 931         QUICK_END
 932         /* *INDENT-ON* */
 933     };
 934 
 935     quick_dialog_t qdlg = {
 936         -1, -1, 46,
 937         N_("Confirmation"), "[Confirmation]",
 938         quick_widgets, NULL, NULL
 939     };
 940 
 941     (void) quick_dialog (&qdlg);
 942 }
 943 
 944 /* --------------------------------------------------------------------------------------------- */
 945 
 946 #ifndef HAVE_CHARSET
 947 void
 948 display_bits_box (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 949 {
 950     gboolean new_meta;
 951     int current_mode;
 952 
 953     const char *display_bits_str[] = {
 954         N_("&UTF-8 output"),
 955         N_("&Full 8 bits output"),
 956         N_("&ISO 8859-1"),
 957         N_("7 &bits")
 958     };
 959 
 960     quick_widget_t quick_widgets[] = {
 961         /* *INDENT-OFF* */
 962         QUICK_RADIO (4, display_bits_str, &current_mode, NULL),
 963         QUICK_SEPARATOR (TRUE),
 964         QUICK_CHECKBOX (N_("F&ull 8 bits input"), &new_meta, NULL),
 965         QUICK_BUTTONS_OK_CANCEL,
 966         QUICK_END
 967         /* *INDENT-ON* */
 968     };
 969 
 970     quick_dialog_t qdlg = {
 971         -1, -1, 46,
 972         _("Display bits"), "[Display bits]",
 973         quick_widgets, NULL, NULL
 974     };
 975 
 976     if (mc_global.full_eight_bits)
 977         current_mode = 0;
 978     else if (mc_global.eight_bit_clean)
 979         current_mode = 1;
 980     else
 981         current_mode = 2;
 982 
 983     new_meta = !use_8th_bit_as_meta;
 984 
 985     if (quick_dialog (&qdlg) != B_CANCEL)
 986     {
 987         mc_global.eight_bit_clean = current_mode < 3;
 988         mc_global.full_eight_bits = current_mode < 2;
 989 #ifndef HAVE_SLANG
 990         tty_display_8bit (mc_global.eight_bit_clean);
 991 #else
 992         tty_display_8bit (mc_global.full_eight_bits);
 993 #endif
 994         use_8th_bit_as_meta = !new_meta;
 995     }
 996 }
 997 
 998 /* --------------------------------------------------------------------------------------------- */
 999 #else /* HAVE_CHARSET */
1000 
1001 void
1002 display_bits_box (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
1003 {
1004     const char *cpname;
1005 
1006     new_display_codepage = mc_global.display_codepage;
1007 
1008     cpname = (new_display_codepage < 0) ? _("Other 8 bit")
1009         : ((codepage_desc *) g_ptr_array_index (codepages, new_display_codepage))->name;
1010 
1011     {
1012         gboolean new_meta;
1013 
1014         quick_widget_t quick_widgets[] = {
1015             /* *INDENT-OFF* */
1016             QUICK_START_COLUMNS,
1017                 QUICK_LABEL (N_("Input / display codepage:"), NULL),
1018             QUICK_NEXT_COLUMN,
1019                 QUICK_BUTTON (cpname, B_USER, sel_charset_button, NULL),
1020             QUICK_STOP_COLUMNS,
1021             QUICK_SEPARATOR (TRUE),
1022                 QUICK_CHECKBOX (N_("F&ull 8 bits input"), &new_meta, NULL),
1023             QUICK_BUTTONS_OK_CANCEL,
1024             QUICK_END
1025             /* *INDENT-ON* */
1026         };
1027 
1028         quick_dialog_t qdlg = {
1029             -1, -1, 46,
1030             N_("Display bits"), "[Display bits]",
1031             quick_widgets, NULL, NULL
1032         };
1033 
1034         new_meta = !use_8th_bit_as_meta;
1035         application_keypad_mode ();
1036 
1037         if (quick_dialog (&qdlg) == B_ENTER)
1038         {
1039             char *errmsg;
1040 
1041             mc_global.display_codepage = new_display_codepage;
1042 
1043             errmsg = init_translation_table (mc_global.source_codepage, mc_global.display_codepage);
1044             if (errmsg != NULL)
1045             {
1046                 message (D_ERROR, MSG_ERROR, "%s", errmsg);
1047                 g_free (errmsg);
1048             }
1049 
1050 #ifdef HAVE_SLANG
1051             tty_display_8bit (mc_global.display_codepage != 0 && mc_global.display_codepage != 1);
1052 #else
1053             tty_display_8bit (mc_global.display_codepage != 0);
1054 #endif
1055             use_8th_bit_as_meta = !new_meta;
1056 
1057             repaint_screen ();
1058         }
1059     }
1060 }
1061 #endif /* HAVE_CHARSET */
1062 
1063 /* --------------------------------------------------------------------------------------------- */
1064 /** Show tree in a box, not on a panel */
1065 
1066 char *
1067 tree_box (const char *current_dir)
     /* [previous][next][first][last][top][bottom][index][help]  */
1068 {
1069     WTree *mytree;
1070     WDialog *dlg;
1071     WGroup *g;
1072     Widget *wd;
1073     char *val = NULL;
1074     WButtonBar *bar;
1075 
1076     (void) current_dir;
1077 
1078     /* Create the components */
1079     dlg = dlg_create (TRUE, 0, 0, LINES - 9, COLS - 20, WPOS_CENTER, FALSE, dialog_colors,
1080                       tree_callback, NULL, "[Directory Tree]", _("Directory tree"));
1081     g = GROUP (dlg);
1082     wd = WIDGET (dlg);
1083 
1084     mytree = tree_new (2, 2, wd->lines - 6, wd->cols - 5, FALSE);
1085     group_add_widget_autopos (g, mytree, WPOS_KEEP_ALL, NULL);
1086     group_add_widget_autopos (g, hline_new (wd->lines - 4, 1, -1), WPOS_KEEP_BOTTOM, NULL);
1087     bar = buttonbar_new ();
1088     group_add_widget (g, bar);
1089     /* restore ButtonBar coordinates after add_widget() */
1090     WIDGET (bar)->x = 0;
1091     WIDGET (bar)->y = LINES - 1;
1092 
1093     if (dlg_run (dlg) == B_ENTER)
1094     {
1095         const vfs_path_t *selected_name;
1096 
1097         selected_name = tree_selected_name (mytree);
1098         val = g_strdup (vfs_path_as_str (selected_name));
1099     }
1100 
1101     widget_destroy (wd);
1102     return val;
1103 }
1104 
1105 /* --------------------------------------------------------------------------------------------- */
1106 
1107 #ifdef ENABLE_VFS
1108 void
1109 configure_vfs_box (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
1110 {
1111     char buffer2[BUF_TINY];
1112 #ifdef ENABLE_VFS_FTP
1113     char buffer3[BUF_TINY];
1114 
1115     g_snprintf (buffer3, sizeof (buffer3), "%i", ftpfs_directory_timeout);
1116 #endif
1117 
1118     g_snprintf (buffer2, sizeof (buffer2), "%i", vfs_timeout);
1119 
1120     {
1121         char *ret_timeout;
1122 #ifdef ENABLE_VFS_FTP
1123         char *ret_passwd;
1124         char *ret_ftp_proxy;
1125         char *ret_directory_timeout;
1126 #endif /* ENABLE_VFS_FTP */
1127 
1128         quick_widget_t quick_widgets[] = {
1129             /* *INDENT-OFF* */
1130             QUICK_LABELED_INPUT (N_("Timeout for freeing VFSs (sec):"), input_label_left,
1131                                  buffer2, "input-timo-vfs", &ret_timeout, NULL, FALSE, FALSE,
1132                                  INPUT_COMPLETE_NONE),
1133 #ifdef ENABLE_VFS_FTP
1134             QUICK_SEPARATOR (TRUE),
1135             QUICK_LABELED_INPUT (N_("FTP anonymous password:"), input_label_left,
1136                                  ftpfs_anonymous_passwd, "input-passwd", &ret_passwd, NULL,
1137                                  FALSE, FALSE, INPUT_COMPLETE_NONE),
1138             QUICK_LABELED_INPUT (N_("FTP directory cache timeout (sec):"), input_label_left,
1139                                  buffer3, "input-timeout", &ret_directory_timeout, NULL,
1140                                  FALSE, FALSE, INPUT_COMPLETE_NONE),
1141             QUICK_CHECKBOX (N_("&Always use ftp proxy:"), &ftpfs_always_use_proxy,
1142                             &ftpfs_always_use_proxy_id),
1143             QUICK_INPUT (ftpfs_proxy_host, "input-ftp-proxy", &ret_ftp_proxy,
1144                          &ftpfs_proxy_host_id, FALSE, FALSE, INPUT_COMPLETE_HOSTNAMES),
1145             QUICK_CHECKBOX (N_("&Use ~/.netrc"), &ftpfs_use_netrc, NULL),
1146             QUICK_CHECKBOX (N_("Use &passive mode"), &ftpfs_use_passive_connections, NULL),
1147             QUICK_CHECKBOX (N_("Use passive mode over pro&xy"),
1148                             &ftpfs_use_passive_connections_over_proxy, NULL),
1149 #endif /* ENABLE_VFS_FTP */
1150             QUICK_BUTTONS_OK_CANCEL,
1151             QUICK_END
1152             /* *INDENT-ON* */
1153         };
1154 
1155         quick_dialog_t qdlg = {
1156             -1, -1, 56,
1157             N_("Virtual File System Setting"), "[Virtual FS]",
1158             quick_widgets,
1159 #ifdef ENABLE_VFS_FTP
1160             confvfs_callback,
1161 #else
1162             NULL,
1163 #endif
1164             NULL,
1165         };
1166 
1167 #ifdef ENABLE_VFS_FTP
1168         if (!ftpfs_always_use_proxy)
1169             quick_widgets[5].state = WST_DISABLED;
1170 #endif
1171 
1172         if (quick_dialog (&qdlg) != B_CANCEL)
1173         {
1174             /* cppcheck-suppress uninitvar */
1175             vfs_timeout = atoi (ret_timeout);
1176             g_free (ret_timeout);
1177 
1178             if (vfs_timeout < 0 || vfs_timeout > 10000)
1179                 vfs_timeout = 10;
1180 #ifdef ENABLE_VFS_FTP
1181             g_free (ftpfs_anonymous_passwd);
1182             /* cppcheck-suppress uninitvar */
1183             ftpfs_anonymous_passwd = ret_passwd;
1184             g_free (ftpfs_proxy_host);
1185             /* cppcheck-suppress uninitvar */
1186             ftpfs_proxy_host = ret_ftp_proxy;
1187             /* cppcheck-suppress uninitvar */
1188             ftpfs_directory_timeout = atoi (ret_directory_timeout);
1189             g_free (ret_directory_timeout);
1190 #endif
1191         }
1192     }
1193 }
1194 
1195 #endif /* ENABLE_VFS */
1196 
1197 /* --------------------------------------------------------------------------------------------- */
1198 
1199 char *
1200 cd_box (const WPanel * panel)
     /* [previous][next][first][last][top][bottom][index][help]  */
1201 {
1202     const Widget *w = CONST_WIDGET (panel);
1203     char *my_str;
1204 
1205     quick_widget_t quick_widgets[] = {
1206         QUICK_LABELED_INPUT (N_("cd"), input_label_left, "", "input", &my_str, NULL, FALSE, TRUE,
1207                              INPUT_COMPLETE_FILENAMES | INPUT_COMPLETE_CD),
1208         QUICK_END
1209     };
1210 
1211     quick_dialog_t qdlg = {
1212         w->y + w->lines - 6, w->x, w->cols,
1213         N_("Quick cd"), "[Quick cd]",
1214         quick_widgets, NULL, NULL
1215     };
1216 
1217     return (quick_dialog (&qdlg) != B_CANCEL) ? my_str : NULL;
1218 }
1219 
1220 /* --------------------------------------------------------------------------------------------- */
1221 
1222 void
1223 symlink_box (const vfs_path_t * existing_vpath, const vfs_path_t * new_vpath,
     /* [previous][next][first][last][top][bottom][index][help]  */
1224              char **ret_existing, char **ret_new)
1225 {
1226     quick_widget_t quick_widgets[] = {
1227         /* *INDENT-OFF* */
1228         QUICK_LABELED_INPUT (N_("Existing filename (filename symlink will point to):"),
1229                              input_label_above, vfs_path_as_str (existing_vpath), "input-2",
1230                              ret_existing, NULL, FALSE, FALSE, INPUT_COMPLETE_FILENAMES),
1231         QUICK_SEPARATOR (FALSE),
1232         QUICK_LABELED_INPUT (N_("Symbolic link filename:"), input_label_above,
1233                              vfs_path_as_str (new_vpath), "input-1",
1234                              ret_new, NULL, FALSE, FALSE, INPUT_COMPLETE_FILENAMES),
1235         QUICK_BUTTONS_OK_CANCEL,
1236         QUICK_END
1237         /* *INDENT-ON* */
1238     };
1239 
1240     quick_dialog_t qdlg = {
1241         -1, -1, 64,
1242         N_("Symbolic link"), "[File Menu]",
1243         quick_widgets, NULL, NULL
1244     };
1245 
1246     if (quick_dialog (&qdlg) == B_CANCEL)
1247     {
1248         *ret_new = NULL;
1249         *ret_existing = NULL;
1250     }
1251 }
1252 
1253 /* --------------------------------------------------------------------------------------------- */
1254 
1255 #ifdef ENABLE_BACKGROUND
1256 void
1257 jobs_box (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
1258 {
1259     struct
1260     {
1261         const char *name;
1262         int flags;
1263         int value;
1264         int len;
1265         bcback_fn callback;
1266     }
1267     job_but[] =
1268     {
1269         /* *INDENT-OFF* */
1270         { N_("&Stop"), NORMAL_BUTTON, B_STOP, 0, task_cb },
1271         { N_("&Resume"), NORMAL_BUTTON, B_RESUME, 0, task_cb },
1272         { N_("&Kill"), NORMAL_BUTTON, B_KILL, 0, task_cb },
1273         { N_("&OK"), DEFPUSH_BUTTON, B_CANCEL, 0, NULL }
1274         /* *INDENT-ON* */
1275     };
1276 
1277     size_t i;
1278     const size_t n_but = G_N_ELEMENTS (job_but);
1279 
1280     WDialog *jobs_dlg;
1281     WGroup *g;
1282     int cols = 60;
1283     int lines = 15;
1284     int x = 0;
1285 
1286     for (i = 0; i < n_but; i++)
1287     {
1288 #ifdef ENABLE_NLS
1289         job_but[i].name = _(job_but[i].name);
1290 #endif /* ENABLE_NLS */
1291 
1292         job_but[i].len = str_term_width1 (job_but[i].name) + 3;
1293         if (job_but[i].flags == DEFPUSH_BUTTON)
1294             job_but[i].len += 2;
1295         x += job_but[i].len;
1296     }
1297 
1298     x += (int) n_but - 1;
1299     cols = MAX (cols, x + 6);
1300 
1301     jobs_dlg = dlg_create (TRUE, 0, 0, lines, cols, WPOS_CENTER, FALSE, dialog_colors, NULL, NULL,
1302                            "[Background jobs]", _("Background jobs"));
1303     g = GROUP (jobs_dlg);
1304 
1305     bg_list = listbox_new (2, 2, lines - 6, cols - 6, FALSE, NULL);
1306     jobs_fill_listbox (bg_list);
1307     group_add_widget (g, bg_list);
1308 
1309     group_add_widget (g, hline_new (lines - 4, -1, -1));
1310 
1311     x = (cols - x) / 2;
1312     for (i = 0; i < n_but; i++)
1313     {
1314         group_add_widget (g, button_new (lines - 3, x, job_but[i].value, job_but[i].flags,
1315                                          job_but[i].name, job_but[i].callback));
1316         x += job_but[i].len + 1;
1317     }
1318 
1319     (void) dlg_run (jobs_dlg);
1320     widget_destroy (WIDGET (jobs_dlg));
1321 }
1322 #endif /* ENABLE_BACKGROUND */
1323 
1324 /* --------------------------------------------------------------------------------------------- */
1325 
1326 #ifdef ENABLE_VFS_SMB
1327 struct smb_authinfo *
1328 vfs_smb_get_authinfo (const char *host, const char *share, const char *domain, const char *user)
     /* [previous][next][first][last][top][bottom][index][help]  */
1329 {
1330     char *label;
1331     struct smb_authinfo *return_value = NULL;
1332 
1333     if (domain == NULL)
1334         domain = "";
1335     if (user == NULL)
1336         user = "";
1337 
1338     label = g_strdup_printf (_("Password for \\\\%s\\%s"), host, share);
1339 
1340     {
1341         char *ret_domain, *ret_user, *ret_password;
1342 
1343         quick_widget_t quick_widgets[] = {
1344             /* *INDENT-OFF* */
1345             QUICK_LABEL (label, NULL),
1346             QUICK_SEPARATOR (TRUE),
1347             QUICK_START_COLUMNS,
1348                 QUICK_LABEL (N_("Domain:"), NULL),
1349                 QUICK_SEPARATOR (FALSE),
1350                 QUICK_LABEL (N_("Username:"), NULL),
1351                 QUICK_SEPARATOR (FALSE),
1352                 QUICK_LABEL (N_("Password:"), NULL),
1353             QUICK_NEXT_COLUMN,
1354                 QUICK_INPUT (domain, "auth_domain", &ret_domain, NULL, FALSE, FALSE, INPUT_COMPLETE_HOSTNAMES),
1355                 QUICK_SEPARATOR (FALSE),
1356                 QUICK_INPUT (user, "auth_name", &ret_user, NULL, FALSE, FALSE, INPUT_COMPLETE_USERNAMES),
1357                 QUICK_SEPARATOR (FALSE),
1358                 QUICK_INPUT ("", "auth_password", &ret_password, NULL, TRUE, FALSE, INPUT_COMPLETE_NONE),
1359             QUICK_STOP_COLUMNS,
1360             QUICK_BUTTONS_OK_CANCEL,
1361             QUICK_END
1362             /* *INDENT-ON* */
1363         };
1364 
1365         quick_dialog_t qdlg = {
1366             -1, -1, 40,
1367             N_("SMB authentication"), "[Smb Authinfo]",
1368             quick_widgets, NULL, NULL
1369         };
1370 
1371         if (quick_dialog (&qdlg) != B_CANCEL)
1372         {
1373             return_value = vfs_smb_authinfo_new (host, share, ret_domain, ret_user, ret_password);
1374 
1375             g_free (ret_domain);
1376             g_free (ret_user);
1377             g_free (ret_password);
1378         }
1379     }
1380 
1381     g_free (label);
1382 
1383     return return_value;
1384 }
1385 #endif /* ENABLE_VFS_SMB */
1386 
1387 /* --------------------------------------------------------------------------------------------- */

/* [previous][next][first][last][top][bottom][index][help]  */