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.
9 Miguel de Icaza, 1994, 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/>.
30 * \brief Source: Some misc dialog boxes for the program
40 #include <sys/types.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"
53 #include "src/vfs/ftpfs/ftpfs.h"
54 #endif /* ENABLE_VFS_FTP */
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 */
68 #include "lib/charsets.h"
69 #include "src/selcodepage.h"
72 #include "command.h" /* For cmdline */
74 #include "panel.h" /* LIST_TYPES */
76 #include "layout.h" /* for get_nth_panel_name proto */
77 #include "midnight.h" /* current_panel */
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)
90 #endif /* ENABLE_BACKGROUND */
92 /*** file scope type declarations ****************************************************************/
94 /*** file scope variables ************************************************************************/
96 static WRadio
*display_radio
;
97 static WInput
*display_user_format
;
98 static WInput
*display_mini_status
;
99 static WCheck
*display_check_status
;
100 static char **displays_status
;
101 static int display_user_hotkey
= 'u';
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 int JOBS_X
= 60;
114 static WListbox
*bg_list
;
115 static Dlg_head
*jobs_dlg
;
117 static int task_cb (WButton
* button
, int action
);
129 { N_("&Stop"), 3, B_STOP
, task_cb
},
130 { N_("&Resume"), 12, B_RESUME
, task_cb
},
131 { N_("&Kill"), 23, B_KILL
, task_cb
},
132 { N_("&OK"), 35, B_CANCEL
, NULL
}
136 #endif /* ENABLE_BACKGROUND */
138 /*** file scope functions ************************************************************************/
139 /* --------------------------------------------------------------------------------------------- */
142 display_callback (Dlg_head
* h
, Widget
* sender
, dlg_msg_t msg
, int parm
, void *data
)
149 if (dlg_widget_active (display_radio
))
151 input_assign_text (display_mini_status
, displays_status
[display_radio
->sel
]);
156 if (dlg_widget_active (display_user_format
))
158 h
->ret_value
= B_USER
+ 6;
163 if (dlg_widget_active (display_mini_status
))
165 h
->ret_value
= B_USER
+ 7;
171 if ((g_ascii_tolower (parm
) == display_user_hotkey
)
172 && dlg_widget_active (display_user_format
) && dlg_widget_active (display_mini_status
))
174 display_radio
->pos
= display_radio
->sel
= 3;
175 dlg_select_widget (display_radio
); /* force redraw */
176 h
->callback (h
, WIDGET (display_radio
), DLG_ACTION
, 0, NULL
);
179 return MSG_NOT_HANDLED
;
182 if (sender
== WIDGET (display_radio
))
184 if (!(display_check_status
->state
& C_BOOL
))
185 input_assign_text (display_mini_status
, displays_status
[display_radio
->sel
]);
186 input_update (display_mini_status
, FALSE
);
187 input_update (display_user_format
, FALSE
);
188 widget_disable (WIDGET (display_user_format
), display_radio
->sel
!= 3);
192 if (sender
== WIDGET (display_check_status
))
194 if (display_check_status
->state
& C_BOOL
)
196 widget_disable (WIDGET (display_mini_status
), FALSE
);
197 input_assign_text (display_mini_status
, displays_status
[3]);
201 widget_disable (WIDGET (display_mini_status
), TRUE
);
202 input_assign_text (display_mini_status
, displays_status
[display_radio
->sel
]);
204 input_update (display_mini_status
, FALSE
);
208 return MSG_NOT_HANDLED
;
211 return default_dlg_callback (h
, sender
, msg
, parm
, data
);
215 /* --------------------------------------------------------------------------------------------- */
218 display_init (int radio_sel
, char *init_text
, int _check_status
, char **_status
)
220 int dlg_width
= 48, dlg_height
= 15;
223 /* Controls whether the array strings have been translated */
224 const char *displays
[LIST_TYPES
] = {
225 N_("&Full file list"),
226 N_("&Brief file list"),
227 N_("&Long file list"),
231 /* Index in displays[] for "user defined" */
232 const int user_type_idx
= 3;
234 const char *display_title
= N_("Listing mode");
235 const char *user_mini_status
= N_("User &mini status");
236 const char *ok_name
= N_("&OK");
237 const char *cancel_name
= N_("&Cancel");
239 WButton
*ok_button
, *cancel_button
;
244 int ok_len
, cancel_len
, b_len
, gap
;
247 display_title
= _(display_title
);
248 user_mini_status
= _(user_mini_status
);
249 ok_name
= _(ok_name
);
250 cancel_name
= _(cancel_name
);
252 for (i
= 0; i
< LIST_TYPES
; i
++)
253 displays
[i
] = _(displays
[i
]);
256 /* get hotkey of user-defined format string */
257 cp
= strchr (displays
[user_type_idx
], '&');
258 if (cp
!= NULL
&& *++cp
!= '\0')
259 display_user_hotkey
= g_ascii_tolower (*cp
);
261 /* xpos will be fixed later */
262 ok_button
= button_new (dlg_height
- 3, 0, B_ENTER
, DEFPUSH_BUTTON
, ok_name
, 0);
263 ok_len
= button_get_len (ok_button
);
264 cancel_button
= button_new (dlg_height
- 3, 0, B_CANCEL
, NORMAL_BUTTON
, cancel_name
, 0);
265 cancel_len
= button_get_len (cancel_button
);
266 b_len
= ok_len
+ cancel_len
+ 2;
268 dlg_width
= max (dlg_width
, str_term_width1 (display_title
) + 10);
269 /* calculate max width of radiobutons */
270 for (i
= 0; i
< LIST_TYPES
; i
++)
271 maxlen
= max (maxlen
, str_term_width1 (displays
[i
]));
272 dlg_width
= max (dlg_width
, maxlen
);
273 dlg_width
= max (dlg_width
, str_term_width1 (user_mini_status
) + 13);
276 dlg_width
= max (dlg_width
, b_len
+ 6);
277 gap
= (dlg_width
- 6 - b_len
) / 3;
278 WIDGET (ok_button
)->x
= 3 + gap
;
279 WIDGET (cancel_button
)->x
= WIDGET (ok_button
)->x
+ ok_len
+ gap
+ 2;
282 displays_status
= _status
;
284 dd
= create_dlg (TRUE
, 0, 0, dlg_height
, dlg_width
, dialog_colors
,
285 display_callback
, NULL
, "[Listing Mode...]", display_title
,
286 DLG_CENTER
| DLG_REVERSE
);
288 add_widget (dd
, cancel_button
);
289 add_widget (dd
, ok_button
);
291 display_mini_status
=
292 input_new (10, 8, input_get_default_colors (), dlg_width
- 12, _status
[radio_sel
],
293 "mini-input", INPUT_COMPLETE_DEFAULT
);
294 add_widget (dd
, display_mini_status
);
296 display_check_status
= check_new (9, 4, _check_status
, user_mini_status
);
297 add_widget (dd
, display_check_status
);
299 display_user_format
= input_new (7, 8, input_get_default_colors (), dlg_width
- 12, init_text
,
300 "user-fmt-input", INPUT_COMPLETE_DEFAULT
);
301 add_widget (dd
, display_user_format
);
303 display_radio
= radio_new (3, 4, LIST_TYPES
, displays
);
304 display_radio
->sel
= display_radio
->pos
= radio_sel
;
305 add_widget (dd
, display_radio
);
310 /* --------------------------------------------------------------------------------------------- */
314 sel_charset_button (WButton
* button
, int action
)
320 new_dcp
= select_charset (-1, -1, new_display_codepage
, TRUE
);
322 if (new_dcp
!= SELECT_CHARSET_CANCEL
)
328 new_display_codepage
= new_dcp
;
329 cpname
= (new_display_codepage
== SELECT_CHARSET_OTHER_8BIT
) ?
331 ((codepage_desc
*) g_ptr_array_index (codepages
, new_display_codepage
))->name
;
333 mc_global
.utf8_display
= str_isutf8 (cpname
);
334 /* avoid strange bug with label repainting */
335 g_snprintf (buf
, sizeof (buf
), "%-27s", cpname
);
336 w
= dlg_find_by_id (WIDGET (button
)->owner
, disp_bits_name_id
);
337 label_set_text ((WLabel
*) w
, buf
);
342 #endif /* HAVE_CHARSET */
344 /* --------------------------------------------------------------------------------------------- */
347 tree_callback (Dlg_head
* h
, Widget
* sender
, dlg_msg_t msg
, int parm
, void *data
)
352 /* The enter key will be processed by the tree widget */
355 h
->ret_value
= B_ENTER
;
361 return send_message (WIDGET (find_tree (h
)), NULL
, WIDGET_COMMAND
, parm
, NULL
);
364 return default_dlg_callback (h
, sender
, msg
, parm
, data
);
368 /* --------------------------------------------------------------------------------------------- */
370 #if defined(ENABLE_VFS) && defined (ENABLE_VFS_FTP)
372 confvfs_callback (Dlg_head
* h
, Widget
* sender
, dlg_msg_t msg
, int parm
, void *data
)
377 /* message from "Always use ftp proxy" checkbutton */
378 if (sender
!= NULL
&& sender
->id
== ftpfs_always_use_proxy_id
)
380 const gboolean not_use
= !(((WCheck
*) sender
)->state
& C_BOOL
);
384 w
= dlg_find_by_id (h
, ftpfs_proxy_host_id
);
385 widget_disable (w
, not_use
);
388 return MSG_NOT_HANDLED
;
391 return default_dlg_callback (h
, sender
, msg
, parm
, data
);
394 #endif /* ENABLE_VFS && ENABLE_VFS_FTP */
396 /* --------------------------------------------------------------------------------------------- */
398 #ifdef ENABLE_BACKGROUND
400 jobs_fill_listbox (void)
402 static const char *state_str
[2];
403 TaskList
*tl
= task_list
;
407 state_str
[0] = _("Running");
408 state_str
[1] = _("Stopped");
415 s
= g_strconcat (state_str
[tl
->state
], " ", tl
->info
, (char *) NULL
);
416 listbox_add_item (bg_list
, LISTBOX_APPEND_AT_END
, 0, s
, (void *) tl
);
422 /* --------------------------------------------------------------------------------------------- */
425 task_cb (WButton
* button
, int action
)
432 if (bg_list
->list
== NULL
)
435 /* Get this instance information */
436 listbox_get_current (bg_list
, NULL
, (void **) &tl
);
439 if (action
== B_STOP
)
442 tl
->state
= Task_Stopped
;
444 else if (action
== B_RESUME
)
447 tl
->state
= Task_Running
;
451 if (action
== B_KILL
)
457 unregister_task_running (tl
->pid
, tl
->fd
);
460 listbox_remove_list (bg_list
);
461 jobs_fill_listbox ();
463 /* This can be optimized to just redraw this widget :-) */
464 dlg_redraw (jobs_dlg
);
468 #endif /* ENABLE_BACKGROUND */
470 /* --------------------------------------------------------------------------------------------- */
471 /*** public functions ****************************************************************************/
472 /* --------------------------------------------------------------------------------------------- */
474 /* return list type */
476 display_box (WPanel
* panel
, char **userp
, char **minip
, int *use_msformat
, int num
)
480 char *section
= NULL
;
485 const char *p
= get_nth_panel_name (num
);
486 panel
= g_new (WPanel
, 1);
487 panel
->list_type
= list_full
;
488 panel
->user_format
= g_strdup (DEFAULT_USER_FORMAT
);
489 panel
->user_mini_status
= 0;
490 for (i
= 0; i
< LIST_TYPES
; i
++)
491 panel
->user_status_format
[i
] = g_strdup (DEFAULT_USER_FORMAT
);
492 section
= g_strconcat ("Temporal:", p
, (char *) NULL
);
493 if (!mc_config_has_group (mc_main_config
, section
))
496 section
= g_strdup (p
);
498 panel_load_setup (panel
, section
);
502 dd
= display_init (panel
->list_type
, panel
->user_format
,
503 panel
->user_mini_status
, panel
->user_status_format
);
505 if (run_dlg (dd
) != B_CANCEL
)
507 result
= display_radio
->sel
;
508 *userp
= g_strdup (display_user_format
->buffer
);
509 *minip
= g_strdup (display_mini_status
->buffer
);
510 *use_msformat
= display_check_status
->state
& C_BOOL
;
515 g_free (panel
->user_format
);
516 for (i
= 0; i
< LIST_TYPES
; i
++)
517 g_free (panel
->user_status_format
[i
]);
526 /* --------------------------------------------------------------------------------------------- */
528 const panel_field_t
*
529 sort_box (panel_sort_info_t
* info
)
531 const char **sort_orders_names
;
532 gsize sort_names_num
, i
;
534 const panel_field_t
*result
= info
->sort_field
;
536 sort_orders_names
= panel_get_sortable_fields (&sort_names_num
);
538 for (i
= 0; i
< sort_names_num
; i
++)
539 if (strcmp (sort_orders_names
[i
], _(info
->sort_field
->title_hotkey
)) == 0)
546 quick_widget_t quick_widgets
[] = {
549 QUICK_RADIO (sort_names_num
, sort_orders_names
, &sort_idx
, NULL
),
551 QUICK_CHECKBOX (N_("Executable &first"), &info
->exec_first
, NULL
),
552 QUICK_CHECKBOX (N_("Case sensi&tive"), &info
->case_sensitive
, NULL
),
553 QUICK_CHECKBOX (N_("&Reverse"), &info
->reverse
, NULL
),
555 QUICK_START_BUTTONS (TRUE
, TRUE
),
556 QUICK_BUTTON (N_("&OK"), B_ENTER
, NULL
, NULL
),
557 QUICK_BUTTON (N_("&Cancel"), B_CANCEL
, NULL
, NULL
),
562 quick_dialog_t qdlg
= {
564 N_("Sort order"), "[Sort Order...]",
565 quick_widgets
, NULL
, NULL
568 if (quick_dialog (&qdlg
) != B_CANCEL
)
569 result
= panel_get_field_by_title_hotkey (sort_orders_names
[sort_idx
]);
572 result
= info
->sort_field
;
575 g_strfreev ((gchar
**) sort_orders_names
);
580 /* --------------------------------------------------------------------------------------------- */
585 quick_widget_t quick_widgets
[] = {
587 /* TRANSLATORS: no need to translate 'Confirmation', it's just a context prefix */
588 QUICK_CHECKBOX (N_("Confirmation|&Delete"), &confirm_delete
, NULL
),
589 QUICK_CHECKBOX (N_("Confirmation|O&verwrite"), &confirm_overwrite
, NULL
),
590 QUICK_CHECKBOX (N_("Confirmation|&Execute"), &confirm_execute
, NULL
),
591 QUICK_CHECKBOX (N_("Confirmation|E&xit"), &confirm_exit
, NULL
),
592 QUICK_CHECKBOX (N_("Confirmation|Di&rectory hotlist delete"),
593 &confirm_directory_hotlist_delete
, NULL
),
594 QUICK_CHECKBOX (N_("Confirmation|&History cleanup"),
595 &mc_global
.widget
.confirm_history_cleanup
, NULL
),
596 QUICK_START_BUTTONS (TRUE
, TRUE
),
597 QUICK_BUTTON (N_("&OK"), B_ENTER
, NULL
, NULL
),
598 QUICK_BUTTON (N_("&Cancel"), B_CANCEL
, NULL
, NULL
),
603 quick_dialog_t qdlg
= {
605 N_("Confirmation"), "[Confirmation]",
606 quick_widgets
, NULL
, NULL
609 (void) quick_dialog (&qdlg
);
612 /* --------------------------------------------------------------------------------------------- */
616 display_bits_box (void)
621 const char *display_bits_str
[] = {
623 N_("&Full 8 bits output"),
628 quick_widget_t quick_widgets
[] = {
630 QUICK_RADIO (4, display_bits_str
, ¤t_mode
, NULL
),
631 QUICK_SEPARATOR (TRUE
),
632 QUICK_CHECKBOX (N_("F&ull 8 bits input"), &new_meta
, NULL
),
633 QUICK_START_BUTTONS (TRUE
, TRUE
),
634 QUICK_BUTTON (N_("&OK"), B_ENTER
, NULL
, NULL
),
635 QUICK_BUTTON (N_("&Cancel"), B_CANCEL
, NULL
, NULL
),
640 quick_dialog_t qdlg
= {
642 _("Display bits"), "[Display bits]",
643 quick_widgets
, NULL
, NULL
646 if (mc_global
.full_eight_bits
)
648 else if (mc_global
.eight_bit_clean
)
653 new_meta
= !use_8th_bit_as_meta
;
655 if (quick_dialog (&qdlg
) != B_CANCEL
)
657 mc_global
.eight_bit_clean
= current_mode
< 3;
658 mc_global
.full_eight_bits
= current_mode
< 2;
660 meta (stdscr
, mc_global
.eight_bit_clean
);
662 SLsmg_Display_Eight_Bit
= mc_global
.full_eight_bits
? 128 : 160;
664 use_8th_bit_as_meta
= !new_meta
;
668 /* --------------------------------------------------------------------------------------------- */
669 #else /* HAVE_CHARSET */
672 display_bits_box (void)
676 cpname
= (new_display_codepage
< 0) ? _("Other 8 bit")
677 : ((codepage_desc
*) g_ptr_array_index (codepages
, new_display_codepage
))->name
;
679 new_display_codepage
= mc_global
.display_codepage
;
684 quick_widget_t quick_widgets
[] = {
687 QUICK_LABEL (N_("Input / display codepage:"), NULL
),
691 QUICK_LABEL (cpname
, &disp_bits_name_id
),
693 QUICK_BUTTON (N_("&Select"), B_USER
, sel_charset_button
, NULL
),
695 QUICK_SEPARATOR (TRUE
),
696 QUICK_CHECKBOX (N_("F&ull 8 bits input"), &new_meta
, NULL
),
697 QUICK_START_BUTTONS (TRUE
, TRUE
),
698 QUICK_BUTTON (N_("&OK"), B_ENTER
, NULL
, NULL
),
699 QUICK_BUTTON (N_("&Cancel"), B_CANCEL
, NULL
, NULL
),
704 quick_dialog_t qdlg
= {
706 N_("Display bits"), "[Display bits]",
707 quick_widgets
, NULL
, NULL
710 new_meta
= !use_8th_bit_as_meta
;
711 application_keypad_mode ();
713 if (quick_dialog (&qdlg
) == B_ENTER
)
717 mc_global
.display_codepage
= new_display_codepage
;
719 errmsg
= init_translation_table (mc_global
.source_codepage
, mc_global
.display_codepage
);
722 message (D_ERROR
, MSG_ERROR
, "%s", errmsg
);
727 tty_display_8bit (mc_global
.display_codepage
!= 0 && mc_global
.display_codepage
!= 1);
729 tty_display_8bit (mc_global
.display_codepage
!= 0);
731 use_8th_bit_as_meta
= !new_meta
;
737 #endif /* HAVE_CHARSET */
739 /* --------------------------------------------------------------------------------------------- */
740 /** Show tree in a box, not on a panel */
743 tree_box (const char *current_dir
)
753 /* Create the components */
754 dlg
= create_dlg (TRUE
, 0, 0, LINES
- 9, COLS
- 20, dialog_colors
,
755 tree_callback
, NULL
, "[Directory Tree]",
756 _("Directory tree"), DLG_CENTER
| DLG_REVERSE
);
759 mytree
= tree_new (2, 2, wd
->lines
- 6, wd
->cols
- 5, FALSE
);
760 add_widget (dlg
, mytree
);
761 add_widget (dlg
, hline_new (wd
->lines
- 4, 1, -1));
762 bar
= buttonbar_new (TRUE
);
763 add_widget (dlg
, bar
);
764 /* restore ButtonBar coordinates after add_widget() */
766 WIDGET (bar
)->y
= LINES
- 1;
768 if (run_dlg (dlg
) == B_ENTER
)
769 val
= vfs_path_to_str (tree_selected_name (mytree
));
775 /* --------------------------------------------------------------------------------------------- */
781 char buffer2
[BUF_TINY
];
782 #ifdef ENABLE_VFS_FTP
783 char buffer3
[BUF_TINY
];
785 g_snprintf (buffer3
, sizeof (buffer3
), "%i", ftpfs_directory_timeout
);
788 g_snprintf (buffer2
, sizeof (buffer2
), "%i", vfs_timeout
);
792 #ifdef ENABLE_VFS_FTP
795 char *ret_directory_timeout
;
796 #endif /* ENABLE_VFS_FTP */
798 quick_widget_t quick_widgets
[] = {
800 QUICK_LABELED_INPUT (N_("Timeout for freeing VFSs (sec):"), input_label_left
,
801 buffer2
, 0, "input-timo-vfs", &ret_timeout
, NULL
),
802 #ifdef ENABLE_VFS_FTP
803 QUICK_SEPARATOR (TRUE
),
804 QUICK_LABELED_INPUT (N_("FTP anonymous password:"), input_label_left
,
805 ftpfs_anonymous_passwd
, 0, "input-passwd", &ret_passwd
, NULL
),
806 QUICK_LABELED_INPUT (N_("FTP directory cache timeout (sec):"), input_label_left
,
807 buffer3
, 0, "input-timeout", &ret_directory_timeout
, NULL
),
808 QUICK_CHECKBOX (N_("&Always use ftp proxy:"), &ftpfs_always_use_proxy
,
809 &ftpfs_always_use_proxy_id
),
810 QUICK_INPUT (ftpfs_proxy_host
, 0, "input-ftp-proxy", &ret_ftp_proxy
,
811 &ftpfs_proxy_host_id
),
812 QUICK_CHECKBOX (N_("&Use ~/.netrc"), &ftpfs_use_netrc
, NULL
),
813 QUICK_CHECKBOX (N_("Use &passive mode"), &ftpfs_use_passive_connections
, NULL
),
814 QUICK_CHECKBOX (N_("Use passive mode over pro&xy"),
815 &ftpfs_use_passive_connections_over_proxy
, NULL
),
816 #endif /* ENABLE_VFS_FTP */
817 QUICK_START_BUTTONS (TRUE
, TRUE
),
818 QUICK_BUTTON (N_("&OK"), B_ENTER
, NULL
, NULL
),
819 QUICK_BUTTON (N_("&Cancel"), B_CANCEL
, NULL
, NULL
),
824 quick_dialog_t qdlg
= {
826 N_("Virtual File System Setting"), "[Virtual FS]",
828 #ifdef ENABLE_VFS_FTP
836 #ifdef ENABLE_VFS_FTP
837 if (!ftpfs_always_use_proxy
)
838 quick_widgets
[5].options
= W_DISABLED
;
841 if (quick_dialog (&qdlg
) != B_CANCEL
)
843 vfs_timeout
= atoi (ret_timeout
);
844 g_free (ret_timeout
);
846 if (vfs_timeout
< 0 || vfs_timeout
> 10000)
848 #ifdef ENABLE_VFS_FTP
849 g_free (ftpfs_anonymous_passwd
);
850 ftpfs_anonymous_passwd
= ret_passwd
;
851 g_free (ftpfs_proxy_host
);
852 ftpfs_proxy_host
= ret_ftp_proxy
;
853 ftpfs_directory_timeout
= atoi (ret_directory_timeout
);
854 g_free (ret_directory_timeout
);
860 #endif /* ENABLE_VFS */
862 /* --------------------------------------------------------------------------------------------- */
867 const Widget
*w
= WIDGET (current_panel
);
870 quick_widget_t quick_widgets
[] = {
871 QUICK_LABELED_INPUT (N_("cd"), input_label_left
, "", 2, "input", &my_str
, NULL
),
875 quick_dialog_t qdlg
= {
876 w
->y
+ w
->lines
- 6, w
->x
, w
->cols
,
877 N_("Quick cd"), "[Quick cd]",
878 quick_widgets
, NULL
, NULL
881 return (quick_dialog (&qdlg
) != B_CANCEL
) ? my_str
: NULL
;
884 /* --------------------------------------------------------------------------------------------- */
887 symlink_dialog (const vfs_path_t
* existing_vpath
, const vfs_path_t
* new_vpath
,
888 char **ret_existing
, char **ret_new
)
893 existing
= vfs_path_to_str (existing_vpath
);
894 new = vfs_path_to_str (new_vpath
);
897 quick_widget_t quick_widgets
[] = {
899 QUICK_LABELED_INPUT (N_("Existing filename (filename symlink will point to):"),
901 existing
, 0, "input-2", ret_existing
, NULL
),
902 QUICK_SEPARATOR (FALSE
),
903 QUICK_LABELED_INPUT (N_("Symbolic link filename:"), input_label_above
,
904 new, 0, "input-1", ret_new
, NULL
),
905 QUICK_START_BUTTONS (TRUE
, TRUE
),
906 QUICK_BUTTON (N_("&OK"), B_ENTER
, NULL
, NULL
),
907 QUICK_BUTTON (N_("&Cancel"), B_CANCEL
, NULL
, NULL
),
912 quick_dialog_t qdlg
= {
914 N_("Symbolic link"), "[File Menu]",
915 quick_widgets
, NULL
, NULL
918 if (quick_dialog (&qdlg
) == B_CANCEL
)
921 *ret_existing
= NULL
;
929 /* --------------------------------------------------------------------------------------------- */
931 #ifdef ENABLE_BACKGROUND
936 int n_buttons
= sizeof (job_buttons
) / sizeof (job_buttons
[0]);
939 static int i18n_flag
= 0;
942 int startx
= job_buttons
[0].xpos
;
945 for (i
= 0; i
< n_buttons
; i
++)
947 job_buttons
[i
].name
= _(job_buttons
[i
].name
);
949 len
= str_term_width1 (job_buttons
[i
].name
) + 4;
950 JOBS_X
= max (JOBS_X
, startx
+ len
+ 3);
952 job_buttons
[i
].xpos
= startx
;
956 /* Last button - Ok a.k.a. Cancel :) */
957 job_buttons
[n_buttons
- 1].xpos
=
958 JOBS_X
- str_term_width1 (job_buttons
[n_buttons
- 1].name
) - 7;
962 #endif /* ENABLE_NLS */
964 jobs_dlg
= create_dlg (TRUE
, 0, 0, JOBS_Y
, JOBS_X
, dialog_colors
, NULL
, NULL
,
965 "[Background jobs]", _("Background Jobs"), DLG_CENTER
| DLG_REVERSE
);
967 bg_list
= listbox_new (2, 3, JOBS_Y
- 9, JOBS_X
- 7, FALSE
, NULL
);
968 add_widget (jobs_dlg
, bg_list
);
973 add_widget (jobs_dlg
, button_new (JOBS_Y
- 4,
974 job_buttons
[i
].xpos
, job_buttons
[i
].value
,
975 NORMAL_BUTTON
, job_buttons
[i
].name
,
976 job_buttons
[i
].callback
));
979 /* Insert all of task information in the list */
980 jobs_fill_listbox ();
983 destroy_dlg (jobs_dlg
);
985 #endif /* ENABLE_BACKGROUND */
987 /* --------------------------------------------------------------------------------------------- */
989 #ifdef ENABLE_VFS_SMB
990 struct smb_authinfo
*
991 vfs_smb_get_authinfo (const char *host
, const char *share
, const char *domain
, const char *user
)
993 static int dialog_x
= 44;
994 int b0
= 3, dialog_y
= 12;
995 static const char *lc_labs
[] = { N_("Domain:"), N_("Username:"), N_("Password:") };
996 static const char *buts
[] = { N_("&OK"), N_("&Cancel") };
997 static int ilen
= 30, istart
= 14;
1000 WInput
*in_password
;
1004 struct smb_authinfo
*return_value
= NULL
;
1007 static int i18n_flag
= 0;
1011 register int i
= sizeof (lc_labs
) / sizeof (lc_labs
[0]);
1016 l1
= str_term_width1 (lc_labs
[i
] = _(lc_labs
[i
]));
1020 i
= maxlen
+ ilen
+ 7;
1024 for (i
= sizeof (buts
) / sizeof (buts
[0]), l1
= 0; i
--;)
1026 l1
+= str_term_width1 (buts
[i
] = _(buts
[i
]));
1032 ilen
= dialog_x
- 7 - maxlen
; /* for the case of very long buttons :) */
1033 istart
= dialog_x
- 3 - ilen
;
1035 b2
= dialog_x
- (str_term_width1 (buts
[1]) + 6);
1040 #endif /* ENABLE_NLS */
1047 title
= g_strdup_printf (_("Password for \\\\%s\\%s"), host
, share
);
1049 auth_dlg
= create_dlg (TRUE
, 0, 0, dialog_y
, dialog_x
, dialog_colors
, NULL
, NULL
,
1050 "[Smb Authinfo]", title
, DLG_CENTER
| DLG_REVERSE
);
1055 input_new (5, istart
, input_get_default_colors (), ilen
, user
, "auth_name",
1056 INPUT_COMPLETE_DEFAULT
);
1057 add_widget (auth_dlg
, in_user
);
1060 input_new (3, istart
, input_get_default_colors (), ilen
, domain
, "auth_domain",
1061 INPUT_COMPLETE_DEFAULT
);
1063 add_widget (auth_dlg
, in_domain
);
1064 add_widget (auth_dlg
, button_new (9, b2
, B_CANCEL
, NORMAL_BUTTON
, buts
[1], 0));
1065 add_widget (auth_dlg
, button_new (9, b0
, B_ENTER
, DEFPUSH_BUTTON
, buts
[0], 0));
1068 input_new (7, istart
, input_get_default_colors (), ilen
, "", "auth_password",
1069 INPUT_COMPLETE_DEFAULT
);
1071 in_password
->completion_flags
= 0;
1072 in_password
->is_password
= 1;
1073 add_widget (auth_dlg
, in_password
);
1075 add_widget (auth_dlg
, label_new (7, 3, lc_labs
[2]));
1076 add_widget (auth_dlg
, label_new (5, 3, lc_labs
[1]));
1077 add_widget (auth_dlg
, label_new (3, 3, lc_labs
[0]));
1079 if (run_dlg (auth_dlg
) != B_CANCEL
)
1080 return_value
= vfs_smb_authinfo_new (host
, share
, in_domain
->buffer
, in_user
->buffer
,
1081 in_password
->buffer
);
1083 destroy_dlg (auth_dlg
);
1085 return return_value
;
1087 #endif /* ENABLE_VFS_SMB */
1089 /* --------------------------------------------------------------------------------------------- */