(query_dialog): add horizontal line.
[midnight-commander.git] / src / filemanager / boxes.c
blobf1fc1521da0627a91dbc2c4608fc33fcfa2458df
1 /*
2 Some misc dialog boxes for the program.
4 Copyright (C) 1994, 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
5 2005, 2006, 2009, 2010, 2011, 2012
6 The Free Software Foundation, Inc.
8 Written by:
9 Miguel de Icaza, 1994, 1995
10 Jakub Jelinek, 1995
11 Andrew Borodin <aborodin@vmail.ru>, 2009, 2010, 2011, 2012
13 This file is part of the Midnight Commander.
15 The Midnight Commander is free software: you can redistribute it
16 and/or modify it under the terms of the GNU General Public License as
17 published by the Free Software Foundation, either version 3 of the License,
18 or (at your option) any later version.
20 The Midnight Commander is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
25 You should have received a copy of the GNU General Public License
26 along with this program. If not, see <http://www.gnu.org/licenses/>.
29 /** \file boxes.c
30 * \brief Source: Some misc dialog boxes for the program
33 #include <config.h>
35 #include <ctype.h>
36 #include <signal.h>
37 #include <stdio.h>
38 #include <stdlib.h>
39 #include <string.h>
40 #include <sys/types.h>
41 #include <sys/stat.h>
43 #include "lib/global.h"
45 #include "lib/tty/tty.h"
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"
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 */
59 #include "lib/util.h" /* Q_() */
60 #include "lib/widget.h"
62 #include "src/setup.h" /* For profile_name */
63 #ifdef ENABLE_BACKGROUND
64 #include "src/background.h" /* task_list */
65 #endif
67 #ifdef HAVE_CHARSET
68 #include "lib/charsets.h"
69 #include "src/selcodepage.h"
70 #endif
72 #include "command.h" /* For cmdline */
73 #include "dir.h"
74 #include "panel.h" /* LIST_TYPES */
75 #include "tree.h"
76 #include "layout.h" /* for get_nth_panel_name proto */
77 #include "midnight.h" /* current_panel */
79 #include "boxes.h"
81 /*** global variables ****************************************************************************/
83 /*** file scope macro definitions ****************************************************************/
85 #ifdef ENABLE_BACKGROUND
86 #define B_STOP (B_USER+1)
87 #define B_RESUME (B_USER+2)
88 #define B_KILL (B_USER+3)
89 #endif /* ENABLE_BACKGROUND */
91 /*** file scope type declarations ****************************************************************/
93 /*** file scope variables ************************************************************************/
95 /* Index in list_types[] for "user defined" */
96 static const int panel_listing_user_idx = 3;
98 static char **status_format;
99 static int listing_user_hotkey = 'u';
100 static unsigned long panel_listing_types_id, panel_user_format_id;
101 static unsigned long mini_user_status_id, mini_user_format_id;
103 #ifdef HAVE_CHARSET
104 static int new_display_codepage;
105 static unsigned long disp_bits_name_id;
106 #endif /* HAVE_CHARSET */
108 #if defined(ENABLE_VFS) && defined(ENABLE_VFS_FTP)
109 static unsigned long ftpfs_always_use_proxy_id, ftpfs_proxy_host_id;
110 #endif /* ENABLE_VFS && ENABLE_VFS_FTP */
112 #ifdef ENABLE_BACKGROUND
113 static WListbox *bg_list = NULL;
114 #endif /* ENABLE_BACKGROUND */
116 /* --------------------------------------------------------------------------------------------- */
117 /*** file scope functions ************************************************************************/
118 /* --------------------------------------------------------------------------------------------- */
120 static cb_ret_t
121 panel_listing_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data)
123 switch (msg)
125 case DLG_KEY:
126 if (parm == '\n')
128 Widget *wi;
130 wi = dlg_find_by_id (h, panel_listing_types_id);
131 if (dlg_widget_active (wi))
133 WInput *in;
135 in = (WInput *) dlg_find_by_id (h, mini_user_format_id);
136 input_assign_text (in, status_format[((WRadio *) wi)->sel]);
137 dlg_stop (h);
138 return MSG_HANDLED;
141 wi = dlg_find_by_id (h, panel_user_format_id);
142 if (dlg_widget_active (wi))
144 h->ret_value = B_USER + 6;
145 dlg_stop (h);
146 return MSG_HANDLED;
149 wi = dlg_find_by_id (h, mini_user_format_id);
150 if (dlg_widget_active (wi))
152 h->ret_value = B_USER + 7;
153 dlg_stop (h);
154 return MSG_HANDLED;
158 if (g_ascii_tolower (parm) == listing_user_hotkey)
160 Widget *wi;
162 wi = dlg_find_by_id (h, panel_user_format_id);
163 if (dlg_widget_active (wi))
165 wi = dlg_find_by_id (h, mini_user_format_id);
166 if (dlg_widget_active (wi))
168 WRadio *r;
170 r = (WRadio *) dlg_find_by_id (h, panel_listing_types_id);
171 r->pos = r->sel = panel_listing_user_idx;
172 dlg_select_widget (WIDGET (r)); /* force redraw */
173 h->callback (h, WIDGET (r), DLG_ACTION, 0, NULL);
174 return MSG_HANDLED;
178 return MSG_NOT_HANDLED;
180 case DLG_ACTION:
181 if (sender != NULL && sender->id == panel_listing_types_id)
183 WCheck *ch;
184 WInput *in1, *in2;
186 in1 = (WInput *) dlg_find_by_id (h, panel_user_format_id);
187 ch = (WCheck *) dlg_find_by_id (h, mini_user_status_id);
188 in2 = (WInput *) dlg_find_by_id (h, mini_user_format_id);
190 if (!(ch->state & C_BOOL))
191 input_assign_text (in2, status_format[((WRadio *) sender)->sel]);
192 input_update (in2, FALSE);
193 input_update (in1, FALSE);
194 widget_disable (WIDGET (in1), ((WRadio *) sender)->sel != panel_listing_user_idx);
195 return MSG_HANDLED;
198 if (sender != NULL && sender->id == mini_user_status_id)
200 WInput *in;
202 in = (WInput *) dlg_find_by_id (h, mini_user_format_id);
204 if (((WCheck *) sender)->state & C_BOOL)
206 widget_disable (WIDGET (in), FALSE);
207 input_assign_text (in, status_format[3]);
209 else
211 WRadio *r;
213 r = (WRadio *) dlg_find_by_id (h, panel_listing_types_id);
214 widget_disable (WIDGET (in), TRUE);
215 input_assign_text (in, status_format[r->sel]);
217 /* input_update (in, FALSE); */
218 return MSG_HANDLED;
221 return MSG_NOT_HANDLED;
223 default:
224 return default_dlg_callback (h, sender, msg, parm, data);
228 /* --------------------------------------------------------------------------------------------- */
230 #ifdef HAVE_CHARSET
231 static int
232 sel_charset_button (WButton * button, int action)
234 int new_dcp;
236 (void) action;
238 new_dcp = select_charset (-1, -1, new_display_codepage, TRUE);
240 if (new_dcp != SELECT_CHARSET_CANCEL)
242 const char *cpname;
243 char buf[BUF_TINY];
244 Widget *w;
246 new_display_codepage = new_dcp;
247 cpname = (new_display_codepage == SELECT_CHARSET_OTHER_8BIT) ?
248 _("Other 8 bit") :
249 ((codepage_desc *) g_ptr_array_index (codepages, new_display_codepage))->name;
250 if (cpname != NULL)
251 mc_global.utf8_display = str_isutf8 (cpname);
252 /* avoid strange bug with label repainting */
253 g_snprintf (buf, sizeof (buf), "%-27s", cpname);
254 w = dlg_find_by_id (WIDGET (button)->owner, disp_bits_name_id);
255 label_set_text ((WLabel *) w, buf);
258 return 0;
260 #endif /* HAVE_CHARSET */
262 /* --------------------------------------------------------------------------------------------- */
264 static cb_ret_t
265 tree_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data)
267 switch (msg)
269 case DLG_POST_KEY:
270 /* The enter key will be processed by the tree widget */
271 if (parm == '\n')
273 h->ret_value = B_ENTER;
274 dlg_stop (h);
276 return MSG_HANDLED;
278 case DLG_RESIZE:
280 Widget *bar;
282 /* simply call dlg_set_size() with new size */
283 dlg_set_size (h, LINES - 9, COLS - 20);
284 bar = WIDGET (find_buttonbar (h));
285 bar->x = 0;
286 bar->y = LINES - 1;
287 return MSG_HANDLED;
290 case DLG_ACTION:
291 return send_message (WIDGET (find_tree (h)), NULL, WIDGET_COMMAND, parm, NULL);
293 default:
294 return default_dlg_callback (h, sender, msg, parm, data);
298 /* --------------------------------------------------------------------------------------------- */
300 #if defined(ENABLE_VFS) && defined (ENABLE_VFS_FTP)
301 static cb_ret_t
302 confvfs_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data)
304 switch (msg)
306 case DLG_ACTION:
307 /* message from "Always use ftp proxy" checkbutton */
308 if (sender != NULL && sender->id == ftpfs_always_use_proxy_id)
310 const gboolean not_use = !(((WCheck *) sender)->state & C_BOOL);
311 Widget *w;
313 /* input */
314 w = dlg_find_by_id (h, ftpfs_proxy_host_id);
315 widget_disable (w, not_use);
316 return MSG_HANDLED;
318 return MSG_NOT_HANDLED;
320 default:
321 return default_dlg_callback (h, sender, msg, parm, data);
324 #endif /* ENABLE_VFS && ENABLE_VFS_FTP */
326 /* --------------------------------------------------------------------------------------------- */
328 #ifdef ENABLE_BACKGROUND
329 static void
330 jobs_fill_listbox (WListbox * list)
332 static const char *state_str[2] = { "", "" };
333 TaskList *tl;
335 if (state_str[0] == '\0')
337 state_str[0] = _("Running");
338 state_str[1] = _("Stopped");
341 for (tl = task_list; tl != NULL; tl = tl->next)
343 char *s;
345 s = g_strconcat (state_str[tl->state], " ", tl->info, (char *) NULL);
346 listbox_add_item (list, LISTBOX_APPEND_AT_END, 0, s, (void *) tl);
347 g_free (s);
351 /* --------------------------------------------------------------------------------------------- */
353 static int
354 task_cb (WButton * button, int action)
356 TaskList *tl;
357 int sig = 0;
359 (void) button;
361 if (bg_list->list == NULL)
362 return 0;
364 /* Get this instance information */
365 listbox_get_current (bg_list, NULL, (void **) &tl);
367 #ifdef SIGTSTP
368 if (action == B_STOP)
370 sig = SIGSTOP;
371 tl->state = Task_Stopped;
373 else if (action == B_RESUME)
375 sig = SIGCONT;
376 tl->state = Task_Running;
378 else
379 #endif
380 if (action == B_KILL)
381 sig = SIGKILL;
383 if (sig == SIGKILL)
384 unregister_task_running (tl->pid, tl->fd);
386 kill (tl->pid, sig);
387 listbox_remove_list (bg_list);
388 jobs_fill_listbox (bg_list);
390 /* This can be optimized to just redraw this widget :-) */
391 dlg_redraw (WIDGET (button)->owner);
393 return 0;
395 #endif /* ENABLE_BACKGROUND */
397 /* --------------------------------------------------------------------------------------------- */
398 /*** public functions ****************************************************************************/
399 /* --------------------------------------------------------------------------------------------- */
401 /* return list type */
403 panel_listing_box (WPanel * panel, char **userp, char **minip, int *use_msformat, int num)
405 int result = -1;
406 char *section = NULL;
408 if (panel == NULL)
410 const char *p;
411 size_t i;
413 p = get_nth_panel_name (num);
414 panel = g_new (WPanel, 1);
415 panel->list_type = list_full;
416 panel->user_format = g_strdup (DEFAULT_USER_FORMAT);
417 panel->user_mini_status = 0;
418 for (i = 0; i < LIST_TYPES; i++)
419 panel->user_status_format[i] = g_strdup (DEFAULT_USER_FORMAT);
420 section = g_strconcat ("Temporal:", p, (char *) NULL);
421 if (!mc_config_has_group (mc_main_config, section))
423 g_free (section);
424 section = g_strdup (p);
426 panel_load_setup (panel, section);
427 g_free (section);
431 int mini_user_status;
432 char *panel_user_format;
433 char *mini_user_format;
434 const char *cp;
436 /* Controls whether the array strings have been translated */
437 const char *list_types[LIST_TYPES] = {
438 N_("&Full file list"),
439 N_("&Brief file list"),
440 N_("&Long file list"),
441 N_("&User defined:")
444 quick_widget_t quick_widgets[] = {
445 /* *INDENT-OFF* */
446 QUICK_RADIO (LIST_TYPES, list_types, &result, &panel_listing_types_id),
447 QUICK_INPUT (panel->user_format, INPUT_COMPLETE_DEFAULT, "user-fmt-input",
448 &panel_user_format, &panel_user_format_id),
449 QUICK_SEPARATOR (TRUE),
450 QUICK_CHECKBOX (N_("User &mini status"), &mini_user_status, &mini_user_status_id),
451 QUICK_INPUT (panel->user_status_format[panel->list_type], INPUT_COMPLETE_DEFAULT,
452 "mini_input", &mini_user_format, &mini_user_format_id),
453 QUICK_BUTTONS_OK_CANCEL,
454 QUICK_END
455 /* *INDENT-ON* */
458 quick_dialog_t qdlg = {
459 -1, -1, 48,
460 N_("Listing mode"), "[Listing Mode...]",
461 quick_widgets, panel_listing_callback, NULL
464 /* get hotkey of user-defined format string */
465 cp = strchr (_(list_types[panel_listing_user_idx]), '&');
466 if (cp != NULL && *++cp != '\0')
467 listing_user_hotkey = g_ascii_tolower (*cp);
469 mini_user_status = panel->user_mini_status;
470 result = panel->list_type;
471 status_format = panel->user_status_format;
473 if (panel->list_type != panel_listing_user_idx)
474 quick_widgets[1].options = W_DISABLED;
476 if (!mini_user_status)
477 quick_widgets[4].options = W_DISABLED;
479 if (quick_dialog (&qdlg) == B_CANCEL)
480 result = -1;
481 else
483 *userp = panel_user_format;
484 *minip = mini_user_format;
485 *use_msformat = mini_user_status;
489 if (section != NULL)
491 int i;
493 g_free (panel->user_format);
494 for (i = 0; i < LIST_TYPES; i++)
495 g_free (panel->user_status_format[i]);
496 g_free (panel);
499 return result;
502 /* --------------------------------------------------------------------------------------------- */
504 const panel_field_t *
505 sort_box (panel_sort_info_t * info)
507 const char **sort_orders_names;
508 gsize sort_names_num, i;
509 int sort_idx = 0;
510 const panel_field_t *result = info->sort_field;
512 sort_orders_names = panel_get_sortable_fields (&sort_names_num);
514 for (i = 0; i < sort_names_num; i++)
515 if (strcmp (sort_orders_names[i], _(info->sort_field->title_hotkey)) == 0)
517 sort_idx = i;
518 break;
522 quick_widget_t quick_widgets[] = {
523 /* *INDENT-OFF* */
524 QUICK_START_COLUMNS,
525 QUICK_RADIO (sort_names_num, sort_orders_names, &sort_idx, NULL),
526 QUICK_NEXT_COLUMN,
527 QUICK_CHECKBOX (N_("Executable &first"), &info->exec_first, NULL),
528 QUICK_CHECKBOX (N_("Case sensi&tive"), &info->case_sensitive, NULL),
529 QUICK_CHECKBOX (N_("&Reverse"), &info->reverse, NULL),
530 QUICK_STOP_COLUMNS,
531 QUICK_BUTTONS_OK_CANCEL,
532 QUICK_END
533 /* *INDENT-ON* */
536 quick_dialog_t qdlg = {
537 -1, -1, 40,
538 N_("Sort order"), "[Sort Order...]",
539 quick_widgets, NULL, NULL
542 if (quick_dialog (&qdlg) != B_CANCEL)
543 result = panel_get_field_by_title_hotkey (sort_orders_names[sort_idx]);
545 if (result == NULL)
546 result = info->sort_field;
549 g_strfreev ((gchar **) sort_orders_names);
551 return result;
554 /* --------------------------------------------------------------------------------------------- */
556 void
557 confirm_box (void)
559 quick_widget_t quick_widgets[] = {
560 /* *INDENT-OFF* */
561 /* TRANSLATORS: no need to translate 'Confirmation', it's just a context prefix */
562 QUICK_CHECKBOX (N_("Confirmation|&Delete"), &confirm_delete, NULL),
563 QUICK_CHECKBOX (N_("Confirmation|O&verwrite"), &confirm_overwrite, NULL),
564 QUICK_CHECKBOX (N_("Confirmation|&Execute"), &confirm_execute, NULL),
565 QUICK_CHECKBOX (N_("Confirmation|E&xit"), &confirm_exit, NULL),
566 QUICK_CHECKBOX (N_("Confirmation|Di&rectory hotlist delete"),
567 &confirm_directory_hotlist_delete, NULL),
568 QUICK_CHECKBOX (N_("Confirmation|&History cleanup"),
569 &mc_global.widget.confirm_history_cleanup, NULL),
570 QUICK_BUTTONS_OK_CANCEL,
571 QUICK_END
572 /* *INDENT-ON* */
575 quick_dialog_t qdlg = {
576 -1, -1, 46,
577 N_("Confirmation"), "[Confirmation]",
578 quick_widgets, NULL, NULL
581 (void) quick_dialog (&qdlg);
584 /* --------------------------------------------------------------------------------------------- */
586 #ifndef HAVE_CHARSET
587 void
588 display_bits_box (void)
590 int new_meta;
591 int current_mode;
593 const char *display_bits_str[] = {
594 N_("&UTF-8 output"),
595 N_("&Full 8 bits output"),
596 N_("&ISO 8859-1"),
597 N_("7 &bits")
600 quick_widget_t quick_widgets[] = {
601 /* *INDENT-OFF* */
602 QUICK_RADIO (4, display_bits_str, &current_mode, NULL),
603 QUICK_SEPARATOR (TRUE),
604 QUICK_CHECKBOX (N_("F&ull 8 bits input"), &new_meta, NULL),
605 QUICK_BUTTONS_OK_CANCEL,
606 QUICK_END
607 /* *INDENT-ON* */
610 quick_dialog_t qdlg = {
611 -1, -1, 46,
612 _("Display bits"), "[Display bits]",
613 quick_widgets, NULL, NULL
616 if (mc_global.full_eight_bits)
617 current_mode = 0;
618 else if (mc_global.eight_bit_clean)
619 current_mode = 1;
620 else
621 current_mode = 2;
623 new_meta = !use_8th_bit_as_meta;
625 if (quick_dialog (&qdlg) != B_CANCEL)
627 mc_global.eight_bit_clean = current_mode < 3;
628 mc_global.full_eight_bits = current_mode < 2;
629 #ifndef HAVE_SLANG
630 meta (stdscr, mc_global.eight_bit_clean);
631 #else
632 SLsmg_Display_Eight_Bit = mc_global.full_eight_bits ? 128 : 160;
633 #endif
634 use_8th_bit_as_meta = !new_meta;
638 /* --------------------------------------------------------------------------------------------- */
639 #else /* HAVE_CHARSET */
641 void
642 display_bits_box (void)
644 const char *cpname;
646 cpname = (new_display_codepage < 0) ? _("Other 8 bit")
647 : ((codepage_desc *) g_ptr_array_index (codepages, new_display_codepage))->name;
649 new_display_codepage = mc_global.display_codepage;
652 int new_meta;
654 quick_widget_t quick_widgets[] = {
655 /* *INDENT-OFF* */
656 QUICK_START_COLUMNS,
657 QUICK_LABEL (N_("Input / display codepage:"), NULL),
658 QUICK_NEXT_COLUMN,
659 QUICK_STOP_COLUMNS,
660 QUICK_START_COLUMNS,
661 QUICK_LABEL (cpname, &disp_bits_name_id),
662 QUICK_NEXT_COLUMN,
663 QUICK_BUTTON (N_("&Select"), B_USER, sel_charset_button, NULL),
664 QUICK_STOP_COLUMNS,
665 QUICK_SEPARATOR (TRUE),
666 QUICK_CHECKBOX (N_("F&ull 8 bits input"), &new_meta, NULL),
667 QUICK_BUTTONS_OK_CANCEL,
668 QUICK_END
669 /* *INDENT-ON* */
672 quick_dialog_t qdlg = {
673 -1, -1, 46,
674 N_("Display bits"), "[Display bits]",
675 quick_widgets, NULL, NULL
678 new_meta = !use_8th_bit_as_meta;
679 application_keypad_mode ();
681 if (quick_dialog (&qdlg) == B_ENTER)
683 char *errmsg;
685 mc_global.display_codepage = new_display_codepage;
687 errmsg = init_translation_table (mc_global.source_codepage, mc_global.display_codepage);
688 if (errmsg != NULL)
690 message (D_ERROR, MSG_ERROR, "%s", errmsg);
691 g_free (errmsg);
694 #ifdef HAVE_SLANG
695 tty_display_8bit (mc_global.display_codepage != 0 && mc_global.display_codepage != 1);
696 #else
697 tty_display_8bit (mc_global.display_codepage != 0);
698 #endif
699 use_8th_bit_as_meta = !new_meta;
701 repaint_screen ();
705 #endif /* HAVE_CHARSET */
707 /* --------------------------------------------------------------------------------------------- */
708 /** Show tree in a box, not on a panel */
710 char *
711 tree_box (const char *current_dir)
713 WTree *mytree;
714 Dlg_head *dlg;
715 Widget *wd;
716 char *val = NULL;
717 WButtonBar *bar;
719 (void) current_dir;
721 /* Create the components */
722 dlg = create_dlg (TRUE, 0, 0, LINES - 9, COLS - 20, dialog_colors, tree_callback, NULL,
723 "[Directory Tree]", _("Directory tree"), DLG_CENTER);
724 wd = WIDGET (dlg);
726 mytree = tree_new (2, 2, wd->lines - 6, wd->cols - 5, FALSE);
727 add_widget_autopos (dlg, mytree, WPOS_KEEP_ALL, NULL);
728 add_widget_autopos (dlg, hline_new (wd->lines - 4, 1, -1), WPOS_KEEP_BOTTOM, NULL);
729 bar = buttonbar_new (TRUE);
730 add_widget (dlg, bar);
731 /* restore ButtonBar coordinates after add_widget() */
732 WIDGET (bar)->x = 0;
733 WIDGET (bar)->y = LINES - 1;
735 if (run_dlg (dlg) == B_ENTER)
736 val = vfs_path_to_str (tree_selected_name (mytree));
738 destroy_dlg (dlg);
739 return val;
742 /* --------------------------------------------------------------------------------------------- */
744 #ifdef ENABLE_VFS
745 void
746 configure_vfs (void)
748 char buffer2[BUF_TINY];
749 #ifdef ENABLE_VFS_FTP
750 char buffer3[BUF_TINY];
752 g_snprintf (buffer3, sizeof (buffer3), "%i", ftpfs_directory_timeout);
753 #endif
755 g_snprintf (buffer2, sizeof (buffer2), "%i", vfs_timeout);
758 char *ret_timeout;
759 #ifdef ENABLE_VFS_FTP
760 char *ret_passwd;
761 char *ret_ftp_proxy;
762 char *ret_directory_timeout;
763 #endif /* ENABLE_VFS_FTP */
765 quick_widget_t quick_widgets[] = {
766 /* *INDENT-OFF* */
767 QUICK_LABELED_INPUT (N_("Timeout for freeing VFSs (sec):"), input_label_left,
768 buffer2, 0, "input-timo-vfs", &ret_timeout, NULL),
769 #ifdef ENABLE_VFS_FTP
770 QUICK_SEPARATOR (TRUE),
771 QUICK_LABELED_INPUT (N_("FTP anonymous password:"), input_label_left,
772 ftpfs_anonymous_passwd, 0, "input-passwd", &ret_passwd, NULL),
773 QUICK_LABELED_INPUT (N_("FTP directory cache timeout (sec):"), input_label_left,
774 buffer3, 0, "input-timeout", &ret_directory_timeout, NULL),
775 QUICK_CHECKBOX (N_("&Always use ftp proxy:"), &ftpfs_always_use_proxy,
776 &ftpfs_always_use_proxy_id),
777 QUICK_INPUT (ftpfs_proxy_host, 0, "input-ftp-proxy", &ret_ftp_proxy,
778 &ftpfs_proxy_host_id),
779 QUICK_CHECKBOX (N_("&Use ~/.netrc"), &ftpfs_use_netrc, NULL),
780 QUICK_CHECKBOX (N_("Use &passive mode"), &ftpfs_use_passive_connections, NULL),
781 QUICK_CHECKBOX (N_("Use passive mode over pro&xy"),
782 &ftpfs_use_passive_connections_over_proxy, NULL),
783 #endif /* ENABLE_VFS_FTP */
784 QUICK_BUTTONS_OK_CANCEL,
785 QUICK_END
786 /* *INDENT-ON* */
789 quick_dialog_t qdlg = {
790 -1, -1, 56,
791 N_("Virtual File System Setting"), "[Virtual FS]",
792 quick_widgets,
793 #ifdef ENABLE_VFS_FTP
794 confvfs_callback,
795 #else
796 NULL,
797 #endif
798 NULL,
801 #ifdef ENABLE_VFS_FTP
802 if (!ftpfs_always_use_proxy)
803 quick_widgets[5].options = W_DISABLED;
804 #endif
806 if (quick_dialog (&qdlg) != B_CANCEL)
808 vfs_timeout = atoi (ret_timeout);
809 g_free (ret_timeout);
811 if (vfs_timeout < 0 || vfs_timeout > 10000)
812 vfs_timeout = 10;
813 #ifdef ENABLE_VFS_FTP
814 g_free (ftpfs_anonymous_passwd);
815 ftpfs_anonymous_passwd = ret_passwd;
816 g_free (ftpfs_proxy_host);
817 ftpfs_proxy_host = ret_ftp_proxy;
818 ftpfs_directory_timeout = atoi (ret_directory_timeout);
819 g_free (ret_directory_timeout);
820 #endif
825 #endif /* ENABLE_VFS */
827 /* --------------------------------------------------------------------------------------------- */
829 char *
830 cd_dialog (void)
832 const Widget *w = WIDGET (current_panel);
833 char *my_str;
835 quick_widget_t quick_widgets[] = {
836 QUICK_LABELED_INPUT (N_("cd"), input_label_left, "", 2, "input", &my_str, NULL),
837 QUICK_END
840 quick_dialog_t qdlg = {
841 w->y + w->lines - 6, w->x, w->cols,
842 N_("Quick cd"), "[Quick cd]",
843 quick_widgets, NULL, NULL
846 return (quick_dialog (&qdlg) != B_CANCEL) ? my_str : NULL;
849 /* --------------------------------------------------------------------------------------------- */
851 void
852 symlink_dialog (const vfs_path_t * existing_vpath, const vfs_path_t * new_vpath,
853 char **ret_existing, char **ret_new)
855 char *existing;
856 char *new;
858 existing = vfs_path_to_str (existing_vpath);
859 new = vfs_path_to_str (new_vpath);
862 quick_widget_t quick_widgets[] = {
863 /* *INDENT-OFF* */
864 QUICK_LABELED_INPUT (N_("Existing filename (filename symlink will point to):"),
865 input_label_above,
866 existing, 0, "input-2", ret_existing, NULL),
867 QUICK_SEPARATOR (FALSE),
868 QUICK_LABELED_INPUT (N_("Symbolic link filename:"), input_label_above,
869 new, 0, "input-1", ret_new, NULL),
870 QUICK_BUTTONS_OK_CANCEL,
871 QUICK_END
872 /* *INDENT-ON* */
875 quick_dialog_t qdlg = {
876 -1, -1, 64,
877 N_("Symbolic link"), "[File Menu]",
878 quick_widgets, NULL, NULL
881 if (quick_dialog (&qdlg) == B_CANCEL)
883 *ret_new = NULL;
884 *ret_existing = NULL;
888 g_free (existing);
889 g_free (new);
892 /* --------------------------------------------------------------------------------------------- */
894 #ifdef ENABLE_BACKGROUND
895 void
896 jobs_cmd (void)
898 struct
900 const char *name;
901 int flags;
902 int value;
903 int len;
904 bcback_fn callback;
906 job_but[] =
908 /* *INDENT-OFF* */
909 { N_("&Stop"), NORMAL_BUTTON, B_STOP, 0, task_cb },
910 { N_("&Resume"), NORMAL_BUTTON, B_RESUME, 0, task_cb },
911 { N_("&Kill"), NORMAL_BUTTON, B_KILL, 0, task_cb },
912 { N_("&OK"), DEFPUSH_BUTTON, B_CANCEL, 0, NULL }
913 /* *INDENT-ON* */
916 size_t i;
917 const size_t n_but = G_N_ELEMENTS (job_but);
919 Dlg_head *jobs_dlg;
920 int cols = 60;
921 int lines = 15;
922 int x = 0;
924 for (i = 0; i < n_but; i++)
926 #ifdef ENABLE_NLS
927 job_but[i].name = _(job_but[i].name);
928 #endif /* ENABLE_NLS */
930 job_but[i].len = str_term_width1 (job_but[i].name) + 3;
931 if (job_but[i].flags == DEFPUSH_BUTTON)
932 job_but[i].len += 2;
933 x += job_but[i].len;
936 x += (int) n_but - 1;
937 cols = max (cols, x + 6);
939 jobs_dlg = create_dlg (TRUE, 0, 0, lines, cols, dialog_colors, NULL, NULL,
940 "[Background jobs]", _("Background jobs"), DLG_CENTER);
942 bg_list = listbox_new (2, 2, lines - 6, cols - 6, FALSE, NULL);
943 jobs_fill_listbox (bg_list);
944 add_widget (jobs_dlg, bg_list);
946 add_widget (jobs_dlg, hline_new (lines - 4, -1, -1));
948 x = (cols - x) / 2;
949 for (i = 0; i < n_but; i++)
951 add_widget (jobs_dlg,
952 button_new (lines - 3, x, job_but[i].value, job_but[i].flags, job_but[i].name,
953 job_but[i].callback));
954 x += job_but[i].len + 1;
957 (void) run_dlg (jobs_dlg);
958 destroy_dlg (jobs_dlg);
960 #endif /* ENABLE_BACKGROUND */
962 /* --------------------------------------------------------------------------------------------- */
964 #ifdef ENABLE_VFS_SMB
965 struct smb_authinfo *
966 vfs_smb_get_authinfo (const char *host, const char *share, const char *domain, const char *user)
968 char *label;
969 struct smb_authinfo *return_value = NULL;
971 if (domain == NULL)
972 domain = "";
973 if (user == NULL)
974 user = "";
976 label = g_strdup_printf (_("Password for \\\\%s\\%s"), host, share);
979 char *ret_domain, *ret_user, *ret_password;
981 quick_widget_t quick_widgets[] = {
982 /* *INDENT-OFF* */
983 QUICK_LABEL (label, NULL),
984 QUICK_SEPARATOR (TRUE),
985 QUICK_START_COLUMNS,
986 QUICK_LABEL (N_("Domain:"), NULL),
987 QUICK_SEPARATOR (FALSE),
988 QUICK_LABEL (N_("Username:"), NULL),
989 QUICK_SEPARATOR (FALSE),
990 QUICK_LABEL (N_("Password:"), NULL),
991 QUICK_NEXT_COLUMN,
992 QUICK_INPUT (domain, 0, "auth_domain", &ret_domain, NULL),
993 QUICK_SEPARATOR (FALSE),
994 QUICK_INPUT (user, 0, "auth_name", &ret_user, NULL),
995 QUICK_SEPARATOR (FALSE),
996 QUICK_INPUT ("", 1, "auth_password", &ret_password, NULL),
997 QUICK_STOP_COLUMNS,
998 QUICK_BUTTONS_OK_CANCEL,
999 QUICK_END
1000 /* *INDENT-ON* */
1003 quick_dialog_t qdlg = {
1004 -1, -1, 40,
1005 N_("SMB authentication"), "[Smb Authinfo]",
1006 quick_widgets, NULL, NULL
1009 if (quick_dialog (&qdlg) != B_CANCEL)
1011 return_value = vfs_smb_authinfo_new (host, share, ret_domain, ret_user, ret_password);
1013 g_free (ret_domain);
1014 g_free (ret_user);
1015 g_free (ret_password);
1019 g_free (label);
1021 return return_value;
1023 #endif /* ENABLE_VFS_SMB */
1025 /* --------------------------------------------------------------------------------------------- */