(QUICK_BUTTONS_OK_CANCEL): new macro for often-used dialog buttons.
[midnight-commander.git] / src / filemanager / boxes.c
blob141c3f1a2f5a75385bfcd13f217684c682866987
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 #define JOBS_Y 15
90 #endif /* ENABLE_BACKGROUND */
92 /*** file scope type declarations ****************************************************************/
94 /*** file scope variables ************************************************************************/
96 /* Index in list_types[] for "user defined" */
97 static const int panel_listing_user_idx = 3;
99 static char **status_format;
100 static int listing_user_hotkey = 'u';
101 static unsigned long panel_listing_types_id, panel_user_format_id;
102 static unsigned long mini_user_status_id, mini_user_format_id;
104 #ifdef HAVE_CHARSET
105 static int new_display_codepage;
106 static unsigned long disp_bits_name_id;
107 #endif /* HAVE_CHARSET */
109 #if defined(ENABLE_VFS) && defined(ENABLE_VFS_FTP)
110 static unsigned long ftpfs_always_use_proxy_id, ftpfs_proxy_host_id;
111 #endif /* ENABLE_VFS && ENABLE_VFS_FTP */
113 #ifdef ENABLE_BACKGROUND
114 static int JOBS_X = 60;
115 static WListbox *bg_list;
116 static Dlg_head *jobs_dlg;
118 static int task_cb (WButton * button, int action);
120 static struct
122 const char *name;
123 int xpos;
124 int value;
125 bcback_fn callback;
127 job_buttons[] =
129 /* *INDENT-OFF* */
130 { N_("&Stop"), 3, B_STOP, task_cb },
131 { N_("&Resume"), 12, B_RESUME, task_cb },
132 { N_("&Kill"), 23, B_KILL, task_cb },
133 { N_("&OK"), 35, B_CANCEL, NULL }
134 /* *INDENT-ON* */
137 #endif /* ENABLE_BACKGROUND */
139 /* --------------------------------------------------------------------------------------------- */
140 /*** file scope functions ************************************************************************/
141 /* --------------------------------------------------------------------------------------------- */
143 static cb_ret_t
144 panel_listing_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data)
146 switch (msg)
148 case DLG_KEY:
149 if (parm == '\n')
151 Widget *wi;
153 wi = dlg_find_by_id (h, panel_listing_types_id);
154 if (dlg_widget_active (wi))
156 WInput *in;
158 in = (WInput *) dlg_find_by_id (h, mini_user_format_id);
159 input_assign_text (in, status_format[((WRadio *) wi)->sel]);
160 dlg_stop (h);
161 return MSG_HANDLED;
164 wi = dlg_find_by_id (h, panel_user_format_id);
165 if (dlg_widget_active (wi))
167 h->ret_value = B_USER + 6;
168 dlg_stop (h);
169 return MSG_HANDLED;
172 wi = dlg_find_by_id (h, mini_user_format_id);
173 if (dlg_widget_active (wi))
175 h->ret_value = B_USER + 7;
176 dlg_stop (h);
177 return MSG_HANDLED;
181 if (g_ascii_tolower (parm) == listing_user_hotkey)
183 Widget *wi;
185 wi = dlg_find_by_id (h, panel_user_format_id);
186 if (dlg_widget_active (wi))
188 wi = dlg_find_by_id (h, mini_user_format_id);
189 if (dlg_widget_active (wi))
191 WRadio *r;
193 r = (WRadio *) dlg_find_by_id (h, panel_listing_types_id);
194 r->pos = r->sel = panel_listing_user_idx;
195 dlg_select_widget (WIDGET (r)); /* force redraw */
196 h->callback (h, WIDGET (r), DLG_ACTION, 0, NULL);
197 return MSG_HANDLED;
201 return MSG_NOT_HANDLED;
203 case DLG_ACTION:
204 if (sender != NULL && sender->id == panel_listing_types_id)
206 WCheck *ch;
207 WInput *in1, *in2;
209 in1 = (WInput *) dlg_find_by_id (h, panel_user_format_id);
210 ch = (WCheck *) dlg_find_by_id (h, mini_user_status_id);
211 in2 = (WInput *) dlg_find_by_id (h, mini_user_format_id);
213 if (!(ch->state & C_BOOL))
214 input_assign_text (in2, status_format[((WRadio *) sender)->sel]);
215 input_update (in2, FALSE);
216 input_update (in1, FALSE);
217 widget_disable (WIDGET (in1), ((WRadio *) sender)->sel != panel_listing_user_idx);
218 return MSG_HANDLED;
221 if (sender != NULL && sender->id == mini_user_status_id)
223 WInput *in;
225 in = (WInput *) dlg_find_by_id (h, mini_user_format_id);
227 if (((WCheck *) sender)->state & C_BOOL)
229 widget_disable (WIDGET (in), FALSE);
230 input_assign_text (in, status_format[3]);
232 else
234 WRadio *r;
236 r = (WRadio *) dlg_find_by_id (h, panel_listing_types_id);
237 widget_disable (WIDGET (in), TRUE);
238 input_assign_text (in, status_format[r->sel]);
240 /* input_update (in, FALSE); */
241 return MSG_HANDLED;
244 return MSG_NOT_HANDLED;
246 default:
247 return default_dlg_callback (h, sender, msg, parm, data);
251 /* --------------------------------------------------------------------------------------------- */
253 #ifdef HAVE_CHARSET
254 static int
255 sel_charset_button (WButton * button, int action)
257 int new_dcp;
259 (void) action;
261 new_dcp = select_charset (-1, -1, new_display_codepage, TRUE);
263 if (new_dcp != SELECT_CHARSET_CANCEL)
265 const char *cpname;
266 char buf[BUF_TINY];
267 Widget *w;
269 new_display_codepage = new_dcp;
270 cpname = (new_display_codepage == SELECT_CHARSET_OTHER_8BIT) ?
271 _("Other 8 bit") :
272 ((codepage_desc *) g_ptr_array_index (codepages, new_display_codepage))->name;
273 if (cpname != NULL)
274 mc_global.utf8_display = str_isutf8 (cpname);
275 /* avoid strange bug with label repainting */
276 g_snprintf (buf, sizeof (buf), "%-27s", cpname);
277 w = dlg_find_by_id (WIDGET (button)->owner, disp_bits_name_id);
278 label_set_text ((WLabel *) w, buf);
281 return 0;
283 #endif /* HAVE_CHARSET */
285 /* --------------------------------------------------------------------------------------------- */
287 static cb_ret_t
288 tree_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data)
290 switch (msg)
292 case DLG_POST_KEY:
293 /* The enter key will be processed by the tree widget */
294 if (parm == '\n')
296 h->ret_value = B_ENTER;
297 dlg_stop (h);
299 return MSG_HANDLED;
301 case DLG_ACTION:
302 return send_message (WIDGET (find_tree (h)), NULL, WIDGET_COMMAND, parm, NULL);
304 default:
305 return default_dlg_callback (h, sender, msg, parm, data);
309 /* --------------------------------------------------------------------------------------------- */
311 #if defined(ENABLE_VFS) && defined (ENABLE_VFS_FTP)
312 static cb_ret_t
313 confvfs_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data)
315 switch (msg)
317 case DLG_ACTION:
318 /* message from "Always use ftp proxy" checkbutton */
319 if (sender != NULL && sender->id == ftpfs_always_use_proxy_id)
321 const gboolean not_use = !(((WCheck *) sender)->state & C_BOOL);
322 Widget *w;
324 /* input */
325 w = dlg_find_by_id (h, ftpfs_proxy_host_id);
326 widget_disable (w, not_use);
327 return MSG_HANDLED;
329 return MSG_NOT_HANDLED;
331 default:
332 return default_dlg_callback (h, sender, msg, parm, data);
335 #endif /* ENABLE_VFS && ENABLE_VFS_FTP */
337 /* --------------------------------------------------------------------------------------------- */
339 #ifdef ENABLE_BACKGROUND
340 static void
341 jobs_fill_listbox (void)
343 static const char *state_str[2];
344 TaskList *tl = task_list;
346 if (!state_str[0])
348 state_str[0] = _("Running");
349 state_str[1] = _("Stopped");
352 while (tl)
354 char *s;
356 s = g_strconcat (state_str[tl->state], " ", tl->info, (char *) NULL);
357 listbox_add_item (bg_list, LISTBOX_APPEND_AT_END, 0, s, (void *) tl);
358 g_free (s);
359 tl = tl->next;
363 /* --------------------------------------------------------------------------------------------- */
365 static int
366 task_cb (WButton * button, int action)
368 TaskList *tl;
369 int sig = 0;
371 (void) button;
373 if (bg_list->list == NULL)
374 return 0;
376 /* Get this instance information */
377 listbox_get_current (bg_list, NULL, (void **) &tl);
379 #ifdef SIGTSTP
380 if (action == B_STOP)
382 sig = SIGSTOP;
383 tl->state = Task_Stopped;
385 else if (action == B_RESUME)
387 sig = SIGCONT;
388 tl->state = Task_Running;
390 else
391 #endif
392 if (action == B_KILL)
394 sig = SIGKILL;
397 if (sig == SIGKILL)
398 unregister_task_running (tl->pid, tl->fd);
400 kill (tl->pid, sig);
401 listbox_remove_list (bg_list);
402 jobs_fill_listbox ();
404 /* This can be optimized to just redraw this widget :-) */
405 dlg_redraw (jobs_dlg);
407 return 0;
409 #endif /* ENABLE_BACKGROUND */
411 /* --------------------------------------------------------------------------------------------- */
412 /*** public functions ****************************************************************************/
413 /* --------------------------------------------------------------------------------------------- */
415 /* return list type */
417 panel_listing_box (WPanel * panel, char **userp, char **minip, int *use_msformat, int num)
419 int result = -1;
420 char *section = NULL;
422 if (panel == NULL)
424 const char *p;
425 size_t i;
427 p = get_nth_panel_name (num);
428 panel = g_new (WPanel, 1);
429 panel->list_type = list_full;
430 panel->user_format = g_strdup (DEFAULT_USER_FORMAT);
431 panel->user_mini_status = 0;
432 for (i = 0; i < LIST_TYPES; i++)
433 panel->user_status_format[i] = g_strdup (DEFAULT_USER_FORMAT);
434 section = g_strconcat ("Temporal:", p, (char *) NULL);
435 if (!mc_config_has_group (mc_main_config, section))
437 g_free (section);
438 section = g_strdup (p);
440 panel_load_setup (panel, section);
441 g_free (section);
445 int mini_user_status;
446 char *panel_user_format;
447 char *mini_user_format;
448 const char *cp;
450 /* Controls whether the array strings have been translated */
451 const char *list_types[LIST_TYPES] = {
452 N_("&Full file list"),
453 N_("&Brief file list"),
454 N_("&Long file list"),
455 N_("&User defined:")
458 quick_widget_t quick_widgets[] = {
459 /* *INDENT-OFF* */
460 QUICK_RADIO (LIST_TYPES, list_types, &result, &panel_listing_types_id),
461 QUICK_INPUT (panel->user_format, INPUT_COMPLETE_DEFAULT, "user-fmt-input",
462 &panel_user_format, &panel_user_format_id),
463 QUICK_SEPARATOR (TRUE),
464 QUICK_CHECKBOX (N_("User &mini status"), &mini_user_status, &mini_user_status_id),
465 QUICK_INPUT (panel->user_status_format[panel->list_type], INPUT_COMPLETE_DEFAULT,
466 "mini_input", &mini_user_format, &mini_user_format_id),
467 QUICK_BUTTONS_OK_CANCEL,
468 QUICK_END
469 /* *INDENT-ON* */
472 quick_dialog_t qdlg = {
473 -1, -1, 48,
474 N_("Listing mode"), "[Listing Mode...]",
475 quick_widgets, panel_listing_callback, NULL
478 /* get hotkey of user-defined format string */
479 cp = strchr (_(list_types[panel_listing_user_idx]), '&');
480 if (cp != NULL && *++cp != '\0')
481 listing_user_hotkey = g_ascii_tolower (*cp);
483 mini_user_status = panel->user_mini_status;
484 result = panel->list_type;
485 status_format = panel->user_status_format;
487 if (panel->list_type != panel_listing_user_idx)
488 quick_widgets[1].options = W_DISABLED;
490 if (!mini_user_status)
491 quick_widgets[4].options = W_DISABLED;
493 if (quick_dialog (&qdlg) == B_CANCEL)
494 result = -1;
495 else
497 *userp = panel_user_format;
498 *minip = mini_user_format;
499 *use_msformat = mini_user_status;
503 if (section != NULL)
505 int i;
507 g_free (panel->user_format);
508 for (i = 0; i < LIST_TYPES; i++)
509 g_free (panel->user_status_format[i]);
510 g_free (panel);
513 return result;
516 /* --------------------------------------------------------------------------------------------- */
518 const panel_field_t *
519 sort_box (panel_sort_info_t * info)
521 const char **sort_orders_names;
522 gsize sort_names_num, i;
523 int sort_idx = 0;
524 const panel_field_t *result = info->sort_field;
526 sort_orders_names = panel_get_sortable_fields (&sort_names_num);
528 for (i = 0; i < sort_names_num; i++)
529 if (strcmp (sort_orders_names[i], _(info->sort_field->title_hotkey)) == 0)
531 sort_idx = i;
532 break;
536 quick_widget_t quick_widgets[] = {
537 /* *INDENT-OFF* */
538 QUICK_START_COLUMNS,
539 QUICK_RADIO (sort_names_num, sort_orders_names, &sort_idx, NULL),
540 QUICK_NEXT_COLUMN,
541 QUICK_CHECKBOX (N_("Executable &first"), &info->exec_first, NULL),
542 QUICK_CHECKBOX (N_("Case sensi&tive"), &info->case_sensitive, NULL),
543 QUICK_CHECKBOX (N_("&Reverse"), &info->reverse, NULL),
544 QUICK_STOP_COLUMNS,
545 QUICK_BUTTONS_OK_CANCEL,
546 QUICK_END
547 /* *INDENT-ON* */
550 quick_dialog_t qdlg = {
551 -1, -1, 40,
552 N_("Sort order"), "[Sort Order...]",
553 quick_widgets, NULL, NULL
556 if (quick_dialog (&qdlg) != B_CANCEL)
557 result = panel_get_field_by_title_hotkey (sort_orders_names[sort_idx]);
559 if (result == NULL)
560 result = info->sort_field;
563 g_strfreev ((gchar **) sort_orders_names);
565 return result;
568 /* --------------------------------------------------------------------------------------------- */
570 void
571 confirm_box (void)
573 quick_widget_t quick_widgets[] = {
574 /* *INDENT-OFF* */
575 /* TRANSLATORS: no need to translate 'Confirmation', it's just a context prefix */
576 QUICK_CHECKBOX (N_("Confirmation|&Delete"), &confirm_delete, NULL),
577 QUICK_CHECKBOX (N_("Confirmation|O&verwrite"), &confirm_overwrite, NULL),
578 QUICK_CHECKBOX (N_("Confirmation|&Execute"), &confirm_execute, NULL),
579 QUICK_CHECKBOX (N_("Confirmation|E&xit"), &confirm_exit, NULL),
580 QUICK_CHECKBOX (N_("Confirmation|Di&rectory hotlist delete"),
581 &confirm_directory_hotlist_delete, NULL),
582 QUICK_CHECKBOX (N_("Confirmation|&History cleanup"),
583 &mc_global.widget.confirm_history_cleanup, NULL),
584 QUICK_BUTTONS_OK_CANCEL,
585 QUICK_END
586 /* *INDENT-ON* */
589 quick_dialog_t qdlg = {
590 -1, -1, 46,
591 N_("Confirmation"), "[Confirmation]",
592 quick_widgets, NULL, NULL
595 (void) quick_dialog (&qdlg);
598 /* --------------------------------------------------------------------------------------------- */
600 #ifndef HAVE_CHARSET
601 void
602 display_bits_box (void)
604 int new_meta;
605 int current_mode;
607 const char *display_bits_str[] = {
608 N_("&UTF-8 output"),
609 N_("&Full 8 bits output"),
610 N_("&ISO 8859-1"),
611 N_("7 &bits")
614 quick_widget_t quick_widgets[] = {
615 /* *INDENT-OFF* */
616 QUICK_RADIO (4, display_bits_str, &current_mode, NULL),
617 QUICK_SEPARATOR (TRUE),
618 QUICK_CHECKBOX (N_("F&ull 8 bits input"), &new_meta, NULL),
619 QUICK_BUTTONS_OK_CANCEL,
620 QUICK_END
621 /* *INDENT-ON* */
624 quick_dialog_t qdlg = {
625 -1, -1, 46,
626 _("Display bits"), "[Display bits]",
627 quick_widgets, NULL, NULL
630 if (mc_global.full_eight_bits)
631 current_mode = 0;
632 else if (mc_global.eight_bit_clean)
633 current_mode = 1;
634 else
635 current_mode = 2;
637 new_meta = !use_8th_bit_as_meta;
639 if (quick_dialog (&qdlg) != B_CANCEL)
641 mc_global.eight_bit_clean = current_mode < 3;
642 mc_global.full_eight_bits = current_mode < 2;
643 #ifndef HAVE_SLANG
644 meta (stdscr, mc_global.eight_bit_clean);
645 #else
646 SLsmg_Display_Eight_Bit = mc_global.full_eight_bits ? 128 : 160;
647 #endif
648 use_8th_bit_as_meta = !new_meta;
652 /* --------------------------------------------------------------------------------------------- */
653 #else /* HAVE_CHARSET */
655 void
656 display_bits_box (void)
658 const char *cpname;
660 cpname = (new_display_codepage < 0) ? _("Other 8 bit")
661 : ((codepage_desc *) g_ptr_array_index (codepages, new_display_codepage))->name;
663 new_display_codepage = mc_global.display_codepage;
666 int new_meta;
668 quick_widget_t quick_widgets[] = {
669 /* *INDENT-OFF* */
670 QUICK_START_COLUMNS,
671 QUICK_LABEL (N_("Input / display codepage:"), NULL),
672 QUICK_NEXT_COLUMN,
673 QUICK_STOP_COLUMNS,
674 QUICK_START_COLUMNS,
675 QUICK_LABEL (cpname, &disp_bits_name_id),
676 QUICK_NEXT_COLUMN,
677 QUICK_BUTTON (N_("&Select"), B_USER, sel_charset_button, NULL),
678 QUICK_STOP_COLUMNS,
679 QUICK_SEPARATOR (TRUE),
680 QUICK_CHECKBOX (N_("F&ull 8 bits input"), &new_meta, NULL),
681 QUICK_BUTTONS_OK_CANCEL,
682 QUICK_END
683 /* *INDENT-ON* */
686 quick_dialog_t qdlg = {
687 -1, -1, 46,
688 N_("Display bits"), "[Display bits]",
689 quick_widgets, NULL, NULL
692 new_meta = !use_8th_bit_as_meta;
693 application_keypad_mode ();
695 if (quick_dialog (&qdlg) == B_ENTER)
697 char *errmsg;
699 mc_global.display_codepage = new_display_codepage;
701 errmsg = init_translation_table (mc_global.source_codepage, mc_global.display_codepage);
702 if (errmsg != NULL)
704 message (D_ERROR, MSG_ERROR, "%s", errmsg);
705 g_free (errmsg);
708 #ifdef HAVE_SLANG
709 tty_display_8bit (mc_global.display_codepage != 0 && mc_global.display_codepage != 1);
710 #else
711 tty_display_8bit (mc_global.display_codepage != 0);
712 #endif
713 use_8th_bit_as_meta = !new_meta;
715 repaint_screen ();
719 #endif /* HAVE_CHARSET */
721 /* --------------------------------------------------------------------------------------------- */
722 /** Show tree in a box, not on a panel */
724 char *
725 tree_box (const char *current_dir)
727 WTree *mytree;
728 Dlg_head *dlg;
729 Widget *wd;
730 char *val = NULL;
731 WButtonBar *bar;
733 (void) current_dir;
735 /* Create the components */
736 dlg = create_dlg (TRUE, 0, 0, LINES - 9, COLS - 20, dialog_colors,
737 tree_callback, NULL, "[Directory Tree]",
738 _("Directory tree"), DLG_CENTER | DLG_REVERSE);
739 wd = WIDGET (dlg);
741 mytree = tree_new (2, 2, wd->lines - 6, wd->cols - 5, FALSE);
742 add_widget (dlg, mytree);
743 add_widget (dlg, hline_new (wd->lines - 4, 1, -1));
744 bar = buttonbar_new (TRUE);
745 add_widget (dlg, bar);
746 /* restore ButtonBar coordinates after add_widget() */
747 WIDGET (bar)->x = 0;
748 WIDGET (bar)->y = LINES - 1;
750 if (run_dlg (dlg) == B_ENTER)
751 val = vfs_path_to_str (tree_selected_name (mytree));
753 destroy_dlg (dlg);
754 return val;
757 /* --------------------------------------------------------------------------------------------- */
759 #ifdef ENABLE_VFS
760 void
761 configure_vfs (void)
763 char buffer2[BUF_TINY];
764 #ifdef ENABLE_VFS_FTP
765 char buffer3[BUF_TINY];
767 g_snprintf (buffer3, sizeof (buffer3), "%i", ftpfs_directory_timeout);
768 #endif
770 g_snprintf (buffer2, sizeof (buffer2), "%i", vfs_timeout);
773 char *ret_timeout;
774 #ifdef ENABLE_VFS_FTP
775 char *ret_passwd;
776 char *ret_ftp_proxy;
777 char *ret_directory_timeout;
778 #endif /* ENABLE_VFS_FTP */
780 quick_widget_t quick_widgets[] = {
781 /* *INDENT-OFF* */
782 QUICK_LABELED_INPUT (N_("Timeout for freeing VFSs (sec):"), input_label_left,
783 buffer2, 0, "input-timo-vfs", &ret_timeout, NULL),
784 #ifdef ENABLE_VFS_FTP
785 QUICK_SEPARATOR (TRUE),
786 QUICK_LABELED_INPUT (N_("FTP anonymous password:"), input_label_left,
787 ftpfs_anonymous_passwd, 0, "input-passwd", &ret_passwd, NULL),
788 QUICK_LABELED_INPUT (N_("FTP directory cache timeout (sec):"), input_label_left,
789 buffer3, 0, "input-timeout", &ret_directory_timeout, NULL),
790 QUICK_CHECKBOX (N_("&Always use ftp proxy:"), &ftpfs_always_use_proxy,
791 &ftpfs_always_use_proxy_id),
792 QUICK_INPUT (ftpfs_proxy_host, 0, "input-ftp-proxy", &ret_ftp_proxy,
793 &ftpfs_proxy_host_id),
794 QUICK_CHECKBOX (N_("&Use ~/.netrc"), &ftpfs_use_netrc, NULL),
795 QUICK_CHECKBOX (N_("Use &passive mode"), &ftpfs_use_passive_connections, NULL),
796 QUICK_CHECKBOX (N_("Use passive mode over pro&xy"),
797 &ftpfs_use_passive_connections_over_proxy, NULL),
798 #endif /* ENABLE_VFS_FTP */
799 QUICK_BUTTONS_OK_CANCEL,
800 QUICK_END
801 /* *INDENT-ON* */
804 quick_dialog_t qdlg = {
805 -1, -1, 56,
806 N_("Virtual File System Setting"), "[Virtual FS]",
807 quick_widgets,
808 #ifdef ENABLE_VFS_FTP
809 confvfs_callback,
810 #else
811 NULL,
812 #endif
813 NULL,
816 #ifdef ENABLE_VFS_FTP
817 if (!ftpfs_always_use_proxy)
818 quick_widgets[5].options = W_DISABLED;
819 #endif
821 if (quick_dialog (&qdlg) != B_CANCEL)
823 vfs_timeout = atoi (ret_timeout);
824 g_free (ret_timeout);
826 if (vfs_timeout < 0 || vfs_timeout > 10000)
827 vfs_timeout = 10;
828 #ifdef ENABLE_VFS_FTP
829 g_free (ftpfs_anonymous_passwd);
830 ftpfs_anonymous_passwd = ret_passwd;
831 g_free (ftpfs_proxy_host);
832 ftpfs_proxy_host = ret_ftp_proxy;
833 ftpfs_directory_timeout = atoi (ret_directory_timeout);
834 g_free (ret_directory_timeout);
835 #endif
840 #endif /* ENABLE_VFS */
842 /* --------------------------------------------------------------------------------------------- */
844 char *
845 cd_dialog (void)
847 const Widget *w = WIDGET (current_panel);
848 char *my_str;
850 quick_widget_t quick_widgets[] = {
851 QUICK_LABELED_INPUT (N_("cd"), input_label_left, "", 2, "input", &my_str, NULL),
852 QUICK_END
855 quick_dialog_t qdlg = {
856 w->y + w->lines - 6, w->x, w->cols,
857 N_("Quick cd"), "[Quick cd]",
858 quick_widgets, NULL, NULL
861 return (quick_dialog (&qdlg) != B_CANCEL) ? my_str : NULL;
864 /* --------------------------------------------------------------------------------------------- */
866 void
867 symlink_dialog (const vfs_path_t * existing_vpath, const vfs_path_t * new_vpath,
868 char **ret_existing, char **ret_new)
870 char *existing;
871 char *new;
873 existing = vfs_path_to_str (existing_vpath);
874 new = vfs_path_to_str (new_vpath);
877 quick_widget_t quick_widgets[] = {
878 /* *INDENT-OFF* */
879 QUICK_LABELED_INPUT (N_("Existing filename (filename symlink will point to):"),
880 input_label_above,
881 existing, 0, "input-2", ret_existing, NULL),
882 QUICK_SEPARATOR (FALSE),
883 QUICK_LABELED_INPUT (N_("Symbolic link filename:"), input_label_above,
884 new, 0, "input-1", ret_new, NULL),
885 QUICK_BUTTONS_OK_CANCEL,
886 QUICK_END
887 /* *INDENT-ON* */
890 quick_dialog_t qdlg = {
891 -1, -1, 64,
892 N_("Symbolic link"), "[File Menu]",
893 quick_widgets, NULL, NULL
896 if (quick_dialog (&qdlg) == B_CANCEL)
898 *ret_new = NULL;
899 *ret_existing = NULL;
903 g_free (existing);
904 g_free (new);
907 /* --------------------------------------------------------------------------------------------- */
909 #ifdef ENABLE_BACKGROUND
910 void
911 jobs_cmd (void)
913 register int i;
914 int n_buttons = sizeof (job_buttons) / sizeof (job_buttons[0]);
916 #ifdef ENABLE_NLS
917 static int i18n_flag = 0;
918 if (!i18n_flag)
920 int startx = job_buttons[0].xpos;
921 int len;
923 for (i = 0; i < n_buttons; i++)
925 job_buttons[i].name = _(job_buttons[i].name);
927 len = str_term_width1 (job_buttons[i].name) + 4;
928 JOBS_X = max (JOBS_X, startx + len + 3);
930 job_buttons[i].xpos = startx;
931 startx += len;
934 /* Last button - Ok a.k.a. Cancel :) */
935 job_buttons[n_buttons - 1].xpos =
936 JOBS_X - str_term_width1 (job_buttons[n_buttons - 1].name) - 7;
938 i18n_flag = 1;
940 #endif /* ENABLE_NLS */
942 jobs_dlg = create_dlg (TRUE, 0, 0, JOBS_Y, JOBS_X, dialog_colors, NULL, NULL,
943 "[Background jobs]", _("Background Jobs"), DLG_CENTER | DLG_REVERSE);
945 bg_list = listbox_new (2, 3, JOBS_Y - 9, JOBS_X - 7, FALSE, NULL);
946 add_widget (jobs_dlg, bg_list);
948 i = n_buttons;
949 while (i--)
951 add_widget (jobs_dlg, button_new (JOBS_Y - 4,
952 job_buttons[i].xpos, job_buttons[i].value,
953 NORMAL_BUTTON, job_buttons[i].name,
954 job_buttons[i].callback));
957 /* Insert all of task information in the list */
958 jobs_fill_listbox ();
959 run_dlg (jobs_dlg);
961 destroy_dlg (jobs_dlg);
963 #endif /* ENABLE_BACKGROUND */
965 /* --------------------------------------------------------------------------------------------- */
967 #ifdef ENABLE_VFS_SMB
968 struct smb_authinfo *
969 vfs_smb_get_authinfo (const char *host, const char *share, const char *domain, const char *user)
971 char *label;
972 struct smb_authinfo *return_value = NULL;
974 if (domain == NULL)
975 domain = "";
976 if (user == NULL)
977 user = "";
979 label = g_strdup_printf (_("Password for \\\\%s\\%s"), host, share);
982 char *ret_domain, *ret_user, *ret_password;
984 quick_widget_t quick_widgets[] = {
985 /* *INDENT-OFF* */
986 QUICK_LABEL (label, NULL),
987 QUICK_SEPARATOR (TRUE),
988 QUICK_START_COLUMNS,
989 QUICK_LABEL (N_("Domain:"), NULL),
990 QUICK_SEPARATOR (FALSE),
991 QUICK_LABEL (N_("Username:"), NULL),
992 QUICK_SEPARATOR (FALSE),
993 QUICK_LABEL (N_("Password:"), NULL),
994 QUICK_NEXT_COLUMN,
995 QUICK_INPUT (domain, 0, "auth_domain", &ret_domain, NULL),
996 QUICK_SEPARATOR (FALSE),
997 QUICK_INPUT (user, 0, "auth_name", &ret_user, NULL),
998 QUICK_SEPARATOR (FALSE),
999 QUICK_INPUT ("", 1, "auth_password", &ret_password, NULL),
1000 QUICK_STOP_COLUMNS,
1001 QUICK_BUTTONS_OK_CANCEL,
1002 QUICK_END
1003 /* *INDENT-ON* */
1006 quick_dialog_t qdlg = {
1007 -1, -1, 40,
1008 N_("SMB authentication"), "[Smb Authinfo]",
1009 quick_widgets, NULL, NULL
1012 if (quick_dialog (&qdlg) != B_CANCEL)
1014 return_value = vfs_smb_authinfo_new (host, share, ret_domain, ret_user, ret_password);
1016 g_free (ret_domain);
1017 g_free (ret_user);
1018 g_free (ret_password);
1022 g_free (label);
1024 return return_value;
1026 #endif /* ENABLE_VFS_SMB */
1028 /* --------------------------------------------------------------------------------------------- */