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

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

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