root/src/filemanager/boxes.c

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

DEFINITIONS

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

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

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