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. panel_listing_callback
  7. sel_charset_button
  8. tree_callback
  9. confvfs_callback
  10. jobs_fill_listbox
  11. task_cb
  12. configure_box
  13. appearance_box
  14. panel_options_box
  15. panel_listing_box
  16. sort_box
  17. confirm_box
  18. display_bits_box
  19. display_bits_box
  20. tree_box
  21. configure_vfs_box
  22. cd_box
  23. symlink_box
  24. jobs_box
  25. vfs_smb_get_authinfo

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

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