1 /* Some misc dialog boxes for the program.
3 Copyright (C) 1994, 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 2005, 2006, 2009 Free Software Foundation, Inc.
6 Authors: 1994, 1995 Miguel de Icaza
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
24 * \brief Source: Some misc dialog boxes for the program
34 #include <sys/types.h>
37 #include "lib/global.h"
39 #include "lib/tty/tty.h"
40 #include "lib/skin.h" /* INPUT_COLOR */
41 #include "lib/tty/key.h" /* XCTRL and ALT macros */
42 #include "lib/mcconfig.h" /* Load/save user formats */
43 #include "lib/strutil.h"
46 # include "lib/vfs/mc-vfs/ftpfs.h"
50 #include "lib/vfs/mc-vfs/gc.h"
53 #include "dialog.h" /* The nice dialog manager */
54 #include "widget.h" /* The widgets for the nice dialog manager */
56 #include "setup.h" /* For profile_name */
57 #include "command.h" /* For cmdline */
59 #include "panel.h" /* LIST_TYPES */
61 #include "main.h" /* For the confirm_* variables */
63 #include "layout.h" /* for get_nth_panel_name proto */
64 #include "background.h" /* task_list */
68 #include "selcodepage.h"
72 static WRadio
*display_radio
;
73 static WInput
*display_user_format
;
74 static WInput
*display_mini_status
;
75 static WCheck
*display_check_status
;
76 static char **displays_status
;
77 static int display_user_hotkey
= 'u';
80 display_callback (Dlg_head
*h
, Widget
*sender
,
81 dlg_msg_t msg
, int parm
, void *data
)
85 if (dlg_widget_active (display_radio
)) {
86 assign_text (display_mini_status
, displays_status
[display_radio
->sel
]);
87 input_set_point (display_mini_status
, 0);
93 if (dlg_widget_active (display_radio
)) {
94 assign_text (display_mini_status
, displays_status
[display_radio
->sel
]);
99 if (dlg_widget_active (display_user_format
)) {
100 h
->ret_value
= B_USER
+ 6;
105 if (dlg_widget_active (display_mini_status
)) {
106 h
->ret_value
= B_USER
+ 7;
112 if (g_ascii_tolower (parm
) == display_user_hotkey
&& dlg_widget_active (display_user_format
)
113 && dlg_widget_active (display_mini_status
)) {
114 display_radio
->sel
= 3;
115 dlg_select_widget (display_radio
); /* force redraw */
116 dlg_select_widget (display_user_format
);
119 return MSG_NOT_HANDLED
;
122 return default_dlg_callback (h
, sender
, msg
, parm
, data
);
127 display_init (int radio_sel
, char *init_text
, int _check_status
,
130 int dlg_width
= 48, dlg_height
= 15;
133 /* Controls whether the array strings have been translated */
134 const char *displays
[LIST_TYPES
] =
136 N_("&Full file list"),
137 N_("&Brief file list"),
138 N_("&Long file list"),
142 /* Index in displays[] for "user defined" */
143 const int user_type_idx
= 3;
145 const char *display_title
= N_("Listing mode");
146 const char *user_mini_status
= N_("user &Mini status");
147 const char *ok_name
= N_("&OK");
148 const char *cancel_name
= N_("&Cancel");
150 WButton
*ok_button
, *cancel_button
;
155 int ok_len
, cancel_len
;
158 display_title
= _(display_title
);
159 user_mini_status
= _(user_mini_status
);
160 ok_name
= _(ok_name
);
161 cancel_name
= _(cancel_name
);
163 for (i
= 0; i
< LIST_TYPES
; i
++)
164 displays
[i
] = _(displays
[i
]);
167 /* get hotkey of user-defined format string */
168 cp
= strchr (displays
[user_type_idx
], '&');
169 if (cp
!= NULL
&& *++cp
!= '\0')
170 display_user_hotkey
= g_ascii_tolower (*cp
);
172 /* xpos will be fixed later */
173 ok_button
= button_new (dlg_height
- 3, 0, B_ENTER
, DEFPUSH_BUTTON
, ok_name
, 0);
174 ok_len
= button_get_len (ok_button
);
175 cancel_button
= button_new (dlg_height
- 3, 0, B_CANCEL
, NORMAL_BUTTON
, cancel_name
, 0);
176 cancel_len
= button_get_len (cancel_button
);
178 dlg_width
= max (dlg_width
, str_term_width1 (display_title
) + 10);
179 /* calculate max width of radiobutons */
180 for (i
= 0; i
< LIST_TYPES
; i
++)
181 maxlen
= max (maxlen
, str_term_width1 (displays
[i
]));
182 dlg_width
= max (dlg_width
, maxlen
);
183 dlg_width
= max (dlg_width
, str_term_width1 (user_mini_status
) + 13);
186 dlg_width
= max (dlg_width
, ok_len
+ cancel_len
+ 8);
187 ok_button
->widget
.x
= dlg_width
/3 - ok_len
/2;
188 cancel_button
->widget
.x
= dlg_width
* 2/3 - cancel_len
/2;
191 displays_status
= _status
;
193 dd
= create_dlg (0, 0, dlg_height
, dlg_width
, dialog_colors
,
194 display_callback
, "[Listing Mode...]", display_title
,
195 DLG_CENTER
| DLG_REVERSE
);
197 add_widget (dd
, cancel_button
);
198 add_widget (dd
, ok_button
);
200 display_mini_status
= input_new (10, 8, INPUT_COLOR
, dlg_width
- 12, _status
[radio_sel
],
201 "mini-input", INPUT_COMPLETE_DEFAULT
);
202 add_widget (dd
, display_mini_status
);
203 input_set_point (display_mini_status
, 0);
205 display_check_status
= check_new (9, 4, _check_status
, user_mini_status
);
206 add_widget (dd
, display_check_status
);
208 display_user_format
= input_new (7, 8, INPUT_COLOR
, dlg_width
- 12, init_text
,
209 "user-fmt-input", INPUT_COMPLETE_DEFAULT
);
210 add_widget (dd
, display_user_format
);
211 input_set_point (display_user_format
, 0);
213 display_radio
= radio_new (3, 4, LIST_TYPES
, displays
);
214 display_radio
->sel
= display_radio
->pos
= radio_sel
;
215 add_widget (dd
, display_radio
);
220 /* return list type */
222 display_box (WPanel
*panel
, char **userp
, char **minip
, int *use_msformat
, int num
)
226 char *section
= NULL
;
230 const char *p
= get_nth_panel_name (num
);
231 panel
= g_new (WPanel
, 1);
232 panel
->list_type
= list_full
;
233 panel
->user_format
= g_strdup (DEFAULT_USER_FORMAT
);
234 panel
->user_mini_status
= 0;
235 for (i
= 0; i
< LIST_TYPES
; i
++)
236 panel
->user_status_format
[i
] = g_strdup (DEFAULT_USER_FORMAT
);
237 section
= g_strconcat ("Temporal:", p
, (char *) NULL
);
238 if (! mc_config_has_group (mc_main_config
, section
)) {
240 section
= g_strdup (p
);
242 panel_load_setup (panel
, section
);
246 dd
= display_init (panel
->list_type
, panel
->user_format
,
247 panel
->user_mini_status
, panel
->user_status_format
);
249 if (run_dlg (dd
) != B_CANCEL
) {
250 result
= display_radio
->sel
;
251 *userp
= g_strdup (display_user_format
->buffer
);
252 *minip
= g_strdup (display_mini_status
->buffer
);
253 *use_msformat
= display_check_status
->state
& C_BOOL
;
256 if (section
!= NULL
) {
257 g_free (panel
->user_format
);
258 for (i
= 0; i
< LIST_TYPES
; i
++)
259 g_free (panel
->user_status_format
[i
]);
268 const panel_field_t
*
269 sort_box (const panel_field_t
*sort_format
, int *reverse
, int *case_sensitive
, int *exec_first
)
271 int dlg_width
= 40, dlg_height
= 7;
273 const char **sort_orders_names
;
274 gsize sort_names_num
;
278 const panel_field_t
*result
= sort_format
;
280 sort_orders_names
= panel_get_sortable_fields(&sort_names_num
);
281 dlg_height
+= sort_names_num
;
284 int max_radio
= 0, max_check
= 0;
285 int ok_len
, cancel_len
;
288 QuickWidget quick_widgets
[] =
291 QUICK_BUTTON (0, dlg_width
, dlg_height
- 3, dlg_height
, N_("&Cancel"), B_CANCEL
, NULL
),
293 QUICK_BUTTON (0, dlg_width
, dlg_height
- 3, dlg_height
, N_("&OK"), B_ENTER
, NULL
),
295 QUICK_CHECKBOX (0, dlg_width
, 5, dlg_height
, N_("&Reverse"), reverse
),
297 QUICK_CHECKBOX (0, dlg_width
, 4, dlg_height
, N_("Case sensi&tive"), case_sensitive
),
299 QUICK_CHECKBOX (0, dlg_width
, 3, dlg_height
, N_("Executable &first"), exec_first
),
301 QUICK_RADIO (4, dlg_width
, 3, dlg_height
, 0,
306 QuickDialog quick_dlg
=
308 dlg_width
, dlg_height
, -1, -1,
309 N_("Sort order"), "[Sort Order...]",
313 quick_widgets
[5].u
.radio
.items
= sort_orders_names
;
314 quick_widgets
[5].u
.radio
.count
= sort_names_num
;
316 for (i
= 0; i
< sort_names_num
; i
++)
317 if (strcmp (sort_orders_names
[i
], _(sort_format
->title_hotkey
)) == 0 ) {
323 quick_dlg
.title
= _(quick_dlg
.title
);
325 for (i
= 0; i
< 2; i
++)
326 quick_widgets
[i
].u
.button
.text
= _(quick_widgets
[i
].u
.button
.text
);
328 for (i
= 2; i
< 5; i
++)
329 quick_widgets
[i
].u
.checkbox
.text
= _(quick_widgets
[i
].u
.checkbox
.text
);
330 #endif /* ENABLE_NlS */
333 cancel_len
= str_term_width1 (quick_widgets
[0].u
.button
.text
) + 4;
334 ok_len
= str_term_width1 (quick_widgets
[1].u
.button
.text
) + 6;
336 for (i
= 2; i
< 5; i
++)
337 max_check
= max (max_check
, str_term_width1 (quick_widgets
[i
].u
.checkbox
.text
) + 4);
339 for (i
= 0; i
< sort_names_num
; i
++)
340 max_radio
= max (max_radio
, str_term_width1 (sort_orders_names
[i
]) + 4);
343 dlg_width
= max (dlg_width
, str_term_width1 (quick_dlg
.title
) + 8);
344 dlg_width
= max (dlg_width
, ok_len
+ cancel_len
+ 8);
345 dlg_width
= max (dlg_width
, 2 * max (max_radio
, max_check
) + 8);
347 /* fix widget and dialog parameters */
349 quick_dlg
.xlen
= dlg_width
;
351 for (i
= 0; (size_t) i
< sizeof (quick_widgets
)/sizeof (quick_widgets
[0]) - 1; i
++)
352 quick_widgets
[i
].x_divisions
= dlg_width
;
354 quick_widgets
[0].relative_x
= dlg_width
* 2/3 - cancel_len
/2;
355 quick_widgets
[1].relative_x
= dlg_width
/3 - ok_len
/2;
357 for (i
= 2; i
< 5; i
++)
358 quick_widgets
[i
].relative_x
= dlg_width
/2 + 2;
360 if (quick_dialog (&quick_dlg
) != B_CANCEL
)
361 result
= panel_get_field_by_title_hotkey(sort_orders_names
[sort_idx
]);
364 result
= sort_format
;
366 g_strfreev((gchar
**)sort_orders_names
);
374 const char *title
= _("Confirmation");
376 QuickWidget conf_widgets
[] =
378 /* 0 */ QUICK_BUTTON (29, 46, 10, 13, N_("&Cancel"), B_CANCEL
, NULL
),
379 /* 1 */ QUICK_BUTTON (12, 46, 10, 13, N_("&OK"), B_ENTER
, NULL
),
380 /* TRANSLATORS: no need to translate 'Confirmation', it's just a context prefix */
381 /* 2 */ QUICK_CHECKBOX (3, 46, 8, 13, N_("Confirmation|&History cleanup"), &confirm_history_cleanup
),
382 /* 3 */ QUICK_CHECKBOX (3, 46, 7, 13, N_("Confirmation|&Directory hotlist delete"), &confirm_directory_hotlist_delete
),
383 /* 4 */ QUICK_CHECKBOX (3, 46, 6, 13, N_("Confirmation|E&xit"), &confirm_exit
),
384 /* 5 */ QUICK_CHECKBOX (3, 46, 5, 13, N_("Confirmation|&Execute"), &confirm_execute
),
385 /* 6 */ QUICK_CHECKBOX (3, 46, 4, 13, N_("Confirmation|O&verwrite"), &confirm_overwrite
),
386 /* 7 */ QUICK_CHECKBOX (3, 46, 3, 13, N_("Confirmation|&Delete"), &confirm_delete
),
390 const size_t w_num
= sizeof (conf_widgets
) / sizeof (conf_widgets
[0]) - 1;
394 int dlg_height
= w_num
+ 5;
398 int cancel_len
, ok_len
, blen
;
403 for (i
= 0; i
< 2; i
++)
404 conf_widgets
[i
].u
.button
.text
= _(conf_widgets
[i
].u
.button
.text
);
406 for (i
= 2; i
< w_num
; i
++)
407 conf_widgets
[i
].u
.checkbox
.text
= Q_(conf_widgets
[i
].u
.checkbox
.text
);
408 #endif /* ENABLE_NLS */
410 /* maximumr length of checkboxes */
411 for (i
= 2; i
< w_num
; i
++)
412 maxlen
= max (maxlen
, str_term_width1 (conf_widgets
[i
].u
.checkbox
.text
) + 4);
414 /* length of buttons */
415 cancel_len
= str_term_width1 (conf_widgets
[0].u
.button
.text
) + 3;
416 ok_len
= str_term_width1 (conf_widgets
[1].u
.button
.text
) + 5; /* default button */
418 blen
= cancel_len
+ ok_len
+ 2;
420 dlg_width
= max (maxlen
, blen
) + 6;
421 dlg_width
= max (dlg_width
, str_term_width1 (title
) + 4);
423 /* correct widget parameters */
424 for (i
= 0; i
< w_num
; i
++) {
425 conf_widgets
[i
].x_divisions
= dlg_width
;
426 conf_widgets
[i
].y_divisions
= dlg_height
;
429 conf_widgets
[1].relative_x
= dlg_width
/2 - blen
/2;
430 conf_widgets
[0].relative_x
= conf_widgets
[1].relative_x
+ ok_len
+ 2;
433 QuickDialog confirmation
=
435 dlg_width
, dlg_height
, -1, -1, title
,
436 "[Confirmation]", conf_widgets
, 1
439 (void) quick_dialog (&confirmation
);
446 display_bits_box (void) /* AB:FIXME: test dialog */
449 const int DISPY
= 13;
450 const int DISPX
= 46;
455 const char *display_bits_str
[] =
458 N_("Full 8 bits output"),
463 QuickWidget display_widgets
[] =
465 /* 0 */ QUICK_BUTTON (15, DISPX
, DISPY
- 3, DISPY
, N_("&Cancel"), B_CANCEL
, NULL
),
466 /* 1 */ QUICK_BUTTON (29, DISPX
, DISPY
- 3, DISPY
, N_("&OK"), B_ENTER
, NULL
),
467 /* 2 */ QUICK_CHECKBOX (3, DISPX
, 8, DISPY
, N_("F&ull 8 bits input"), &new_meta
),
468 /* 3 */ QUICK_RADIO (3, DISPX
, 3, DISPY
, 4, display_bits_str
, ¤t_mode
),
472 QuickDialog display_bits
=
474 DISPX
, DISPY
, -1, -1, _(" Display bits "),
475 "[Display bits]", display_widgets
, TRUE
480 int ok_len
, cancel_len
;
483 static gboolean i18n_flag
= FALSE
;
486 for (i
= 0; i
< 3; i
++) {
487 display_bits_str
[i
] = _(display_bits_str
[i
]);
490 display_widgets
[0].u
.button
.text
= _(display_widgets
[0].u
.button
.text
);
491 display_widgets
[1].u
.button
.text
= _(display_widgets
[1].u
.button
.text
);
492 display_widgets
[2].u
.checkbox
.text
= _(display_widgets
[2].u
.checkbox
.text
);
496 #endif /* ENABLE_NLS */
499 for (i
= 0; i
< 3; i
++)
500 maxlen
= max (maxlen
, str_term_width1 (display_bits_str
[i
]));
503 cancel_len
= str_term_width1 (display_widgets
[0].u
.button
.text
) + 2;
504 ok_len
= str_term_width1 (display_widgets
[1].u
.button
.text
) + 4; /* default button */
506 l1
= max (cancel_len
, ok_len
);
508 display_bits
.xlen
= max (maxlen
, l1
) + 20;
510 for (i
= 0; i
< 4; i
++)
511 display_widgets
[i
].x_divisions
= display_bits
.xlen
;
513 display_widgets
[0].relative_x
= display_bits
.xlen
* 2/3 - cancel_len
/2;
514 display_widgets
[1].relative_x
= display_bits
.xlen
/3 - ok_len
/2;
518 else if (eight_bit_clean
)
523 new_meta
= !use_8th_bit_as_meta
;
525 if (quick_dialog (&display_bits
) != B_CANCEL
) {
526 eight_bit_clean
= current_mode
< 3;
527 full_eight_bits
= current_mode
< 2;
529 meta (stdscr
, eight_bit_clean
);
531 SLsmg_Display_Eight_Bit
= full_eight_bits
? 128 : 160;
533 use_8th_bit_as_meta
= !new_meta
;
537 #else /* HAVE_CHARSET */
539 static int new_display_codepage
;
541 static WLabel
*cplabel
;
542 static WCheck
*inpcheck
;
545 sel_charset_button (int action
)
551 new_dcp
= select_charset (-1, -1, new_display_codepage
, TRUE
);
553 if (new_dcp
!= SELECT_CHARSET_CANCEL
) {
557 new_display_codepage
= new_dcp
;
558 cpname
= (new_display_codepage
== SELECT_CHARSET_OTHER_8BIT
) ?
559 _("Other 8 bit") : codepages
[new_display_codepage
].name
;
561 utf8_display
= str_isutf8 (cpname
);
562 /* avoid strange bug with label repainting */
563 g_snprintf (buf
, sizeof (buf
), "%-27s", cpname
);
564 label_set_text (cplabel
, buf
);
571 init_disp_bits_box (void)
574 const int DISPY
= 11;
575 const int DISPX
= 46;
583 create_dlg (0, 0, DISPY
, DISPX
, dialog_colors
, NULL
,
584 "[Display bits]", _(" Display bits "), DLG_CENTER
| DLG_REVERSE
);
586 add_widget (dbits_dlg
,
587 label_new (3, 4, _("Input / display codepage:")));
589 cpname
= (new_display_codepage
< 0)
591 : codepages
[new_display_codepage
].name
;
592 cplabel
= label_new (4, 4, cpname
);
593 add_widget (dbits_dlg
, cplabel
);
595 add_widget (dbits_dlg
,
596 button_new (DISPY
- 3, DISPX
/ 2 + 3, B_CANCEL
,
597 NORMAL_BUTTON
, _("&Cancel"), 0));
598 add_widget (dbits_dlg
,
599 button_new (DISPY
- 3, 7, B_ENTER
, NORMAL_BUTTON
, _("&OK"),
603 check_new (6, 4, !use_8th_bit_as_meta
, _("F&ull 8 bits input"));
604 add_widget (dbits_dlg
, inpcheck
);
606 cpname
= _("&Select");
607 add_widget (dbits_dlg
,
608 button_new (4, DISPX
- 7 - str_term_width1 (cpname
), B_USER
,
609 NORMAL_BUTTON
, cpname
, sel_charset_button
));
615 display_bits_box (void)
618 new_display_codepage
= display_codepage
;
620 application_keypad_mode ();
621 dbits_dlg
= init_disp_bits_box ();
625 if (dbits_dlg
->ret_value
== B_ENTER
) {
627 display_codepage
= new_display_codepage
;
629 init_translation_table (source_codepage
, display_codepage
);
631 message (D_ERROR
, MSG_ERROR
, "%s", errmsg
);
633 tty_display_8bit (display_codepage
!= 0 && display_codepage
!= 1);
635 tty_display_8bit (display_codepage
!= 0);
637 use_8th_bit_as_meta
= !(inpcheck
->state
& C_BOOL
);
639 destroy_dlg (dbits_dlg
);
643 #endif /* HAVE_CHARSET */
646 tree_callback (Dlg_head
*h
, Widget
*sender
,
647 dlg_msg_t msg
, int parm
, void *data
)
651 /* The enter key will be processed by the tree widget */
653 h
->ret_value
= B_ENTER
;
659 /* command from buttonbar */
660 return send_message ((Widget
*) find_tree (h
), WIDGET_COMMAND
, parm
);
663 return default_dlg_callback (h
, sender
, msg
, parm
, data
);
667 /* Show tree in a box, not on a panel */
669 tree_box (const char *current_dir
)
678 /* Create the components */
679 dlg
= create_dlg (0, 0, LINES
- 9, COLS
- 20, dialog_colors
,
680 tree_callback
, "[Directory Tree]",
681 NULL
, DLG_CENTER
| DLG_REVERSE
);
683 mytree
= tree_new (0, 2, 2, dlg
->lines
- 6, dlg
->cols
- 5);
684 add_widget (dlg
, mytree
);
685 bar
= buttonbar_new (TRUE
);
686 add_widget (dlg
, bar
);
687 /* restore ButtonBar coordinates after add_widget() */
688 ((Widget
*) bar
)->x
= 0;
689 ((Widget
*) bar
)->y
= LINES
- 1;
691 if (run_dlg (dlg
) == B_ENTER
)
692 val
= g_strdup (tree_selected_name (mytree
));
700 static char *ret_timeout
;
703 static char *ret_passwd
;
704 static char *ret_directory_timeout
;
705 static char *ret_ftp_proxy
;
719 char buffer2
[BUF_TINY
];
721 char buffer3
[BUF_TINY
];
724 QuickWidget confvfs_widgets
[] =
726 /* 0 */ QUICK_BUTTON (30, VFSX
, VFSY
- 3, VFSY
, N_("&Cancel"), B_CANCEL
, NULL
),
727 /* 1 */ QUICK_BUTTON (12, VFSX
, VFSY
- 3, VFSY
, N_("&OK"), B_ENTER
, NULL
),
729 /* 2 */ QUICK_CHECKBOX (4, VFSX
, 12, VFSY
, N_("Use passive mode over pro&xy"), &ftpfs_use_passive_connections_over_proxy
),
730 /* 3 */ QUICK_CHECKBOX (4, VFSX
, 11, VFSY
, N_("Use &passive mode"), &ftpfs_use_passive_connections
),
731 /* 4 */ QUICK_CHECKBOX (4, VFSX
, 10, VFSY
, N_("&Use ~/.netrc"), &use_netrc
),
732 /* 5 */ QUICK_INPUT (4, VFSX
, 9, VFSY
, ftpfs_proxy_host
, 48, 0, "input-ftp-proxy", &ret_ftp_proxy
),
733 /* 6 */ QUICK_CHECKBOX (4, VFSX
, 8, VFSY
, N_("&Always use ftp proxy"), &ftpfs_always_use_proxy
),
734 /* 7 */ QUICK_LABEL (49, VFSX
, 7, VFSY
, N_("sec")),
735 /* 8 */ QUICK_INPUT (38, VFSX
, 7, VFSY
, buffer3
, 10, 0, "input-timeout", &ret_directory_timeout
),
736 /* 9 */ QUICK_LABEL (4, VFSX
, 7, VFSY
, N_("ftpfs directory cache timeout:")),
737 /* 10 */ QUICK_INPUT (4, VFSX
, 6, VFSY
, ftpfs_anonymous_passwd
, 48, 0, "input-passwd", &ret_passwd
),
738 /* 11 */ QUICK_LABEL (4, VFSX
, 5, VFSY
, N_("ftp anonymous password:")),
740 /* 12 */ QUICK_LABEL (49, VFSX
, 3, VFSY
, N_("sec")),
741 /* 13 */ QUICK_INPUT (38, VFSX
, 3, VFSY
, buffer2
, 10, 0, "input-timo-vfs", &ret_timeout
),
742 /* 14 */ QUICK_LABEL (4, VFSX
, 3, VFSY
, N_("Timeout for freeing VFSs:")),
746 QuickDialog confvfs_dlg
=
748 VFSX
, VFSY
, -1, -1, N_(" Virtual File System Setting "),
749 "[Virtual FS]", confvfs_widgets
, FALSE
753 g_snprintf (buffer3
, sizeof (buffer3
), "%i", ftpfs_directory_timeout
);
755 g_snprintf (buffer2
, sizeof (buffer2
), "%i", vfs_timeout
);
757 if (quick_dialog (&confvfs_dlg
) != B_CANCEL
) {
758 vfs_timeout
= atoi (ret_timeout
);
759 g_free (ret_timeout
);
761 if (vfs_timeout
< 0 || vfs_timeout
> 10000)
764 g_free (ftpfs_anonymous_passwd
);
765 ftpfs_anonymous_passwd
= ret_passwd
;
766 g_free (ftpfs_proxy_host
);
767 ftpfs_proxy_host
= ret_ftp_proxy
;
768 ftpfs_directory_timeout
= atoi(ret_directory_timeout
);
769 g_free (ret_directory_timeout
);
777 #endif /* ENABLE_VFS */
782 const char *label
= N_("cd");
792 len
= str_term_width1 (label
);
797 QuickWidget quick_widgets
[] =
799 /* 0 */ QUICK_INPUT (4 + len
, xlen
, 2, ylen
, "", xlen
- 7 - len
, 2, "input" , &my_str
),
800 /* 1 */ QUICK_LABEL (3, xlen
, 2, ylen
, label
),
804 QuickDialog Quick_input
=
806 xlen
, ylen
, 2, LINES
- 2 - ylen
, _("Quick cd"),
807 "[Quick cd]", quick_widgets
, TRUE
810 return (quick_dialog (&Quick_input
) != B_CANCEL
) ? my_str
: NULL
;
815 symlink_dialog (const char *existing
, const char *new, char **ret_existing
,
818 QuickWidget quick_widgets
[] =
820 /* 0 */ QUICK_BUTTON (50, 80, 6, 8, N_("&Cancel"), B_CANCEL
, NULL
),
821 /* 1 */ QUICK_BUTTON (16, 80, 6, 8, N_("&OK"), B_ENTER
, NULL
),
822 /* 2 */ QUICK_INPUT (4, 80, 5, 8, new, 58, 0, "input-1", ret_new
),
823 /* 3 */ QUICK_LABEL (4, 80, 4, 8, N_("Symbolic link filename:")),
824 /* 4 */ QUICK_INPUT (4, 80, 3, 8, existing
, 58, 0, "input-2", ret_existing
),
825 /* 5 */ QUICK_LABEL (4, 80, 2, 8, N_("Existing filename (filename symlink will point to):")),
829 QuickDialog Quick_input
=
831 64, 12, -1, -1, N_("Symbolic link"),
832 "[File Menu]", quick_widgets
, FALSE
835 if (quick_dialog (&Quick_input
) == B_CANCEL
) {
837 *ret_existing
= NULL
;
841 #ifdef WITH_BACKGROUND
842 #define B_STOP (B_USER+1)
843 #define B_RESUME (B_USER+2)
844 #define B_KILL (B_USER+3)
846 static int JOBS_X
= 60;
848 static WListbox
*bg_list
;
849 static Dlg_head
*jobs_dlg
;
852 jobs_fill_listbox (void)
854 static const char *state_str
[2];
855 TaskList
*tl
= task_list
;
858 state_str
[0] = _("Running ");
859 state_str
[1] = _("Stopped");
865 s
= g_strconcat (state_str
[tl
->state
], " ", tl
->info
, (char *) NULL
);
866 listbox_add_item (bg_list
, LISTBOX_APPEND_AT_END
, 0, s
, (void *) tl
);
881 /* Get this instance information */
882 listbox_get_current (bg_list
, NULL
, (void **) &tl
);
885 if (action
== B_STOP
){
887 tl
->state
= Task_Stopped
;
888 } else if (action
== B_RESUME
){
890 tl
->state
= Task_Running
;
893 if (action
== B_KILL
){
898 unregister_task_running (tl
->pid
, tl
->fd
);
901 listbox_remove_list (bg_list
);
902 jobs_fill_listbox ();
904 /* This can be optimized to just redraw this widget :-) */
905 dlg_redraw (jobs_dlg
);
915 int (*callback
)(int);
919 {N_("&Stop"), 3, B_STOP
, task_cb
},
920 {N_("&Resume"), 12, B_RESUME
, task_cb
},
921 {N_("&Kill"), 23, B_KILL
, task_cb
},
922 {N_("&OK"), 35, B_CANCEL
, NULL
}
929 int n_buttons
= sizeof (job_buttons
) / sizeof (job_buttons
[0]);
932 static int i18n_flag
= 0;
935 int startx
= job_buttons
[0].xpos
;
938 for (i
= 0; i
< n_buttons
; i
++)
940 job_buttons
[i
].name
= _(job_buttons
[i
].name
);
942 len
= str_term_width1 (job_buttons
[i
].name
) + 4;
943 JOBS_X
= max (JOBS_X
, startx
+ len
+ 3);
945 job_buttons
[i
].xpos
= startx
;
949 /* Last button - Ok a.k.a. Cancel :) */
950 job_buttons
[n_buttons
- 1].xpos
=
951 JOBS_X
- str_term_width1 (job_buttons
[n_buttons
- 1].name
) - 7;
955 #endif /* ENABLE_NLS */
957 jobs_dlg
= create_dlg (0, 0, JOBS_Y
, JOBS_X
, dialog_colors
, NULL
,
958 "[Background jobs]", _("Background Jobs"),
959 DLG_CENTER
| DLG_REVERSE
);
961 bg_list
= listbox_new (2, 3, JOBS_Y
- 9, JOBS_X
- 7, FALSE
, NULL
);
962 add_widget (jobs_dlg
, bg_list
);
967 add_widget (jobs_dlg
, button_new (JOBS_Y
-4,
968 job_buttons
[i
].xpos
, job_buttons
[i
].value
,
969 NORMAL_BUTTON
, job_buttons
[i
].name
,
970 job_buttons
[i
].callback
));
973 /* Insert all of task information in the list */
974 jobs_fill_listbox ();
977 destroy_dlg (jobs_dlg
);
979 #endif /* WITH_BACKGROUND */
981 #ifdef ENABLE_VFS_SMB
982 struct smb_authinfo
*
983 vfs_smb_get_authinfo (const char *host
, const char *share
, const char *domain
,
986 static int dialog_x
= 44;
987 enum { b0
= 3, dialog_y
= 12};
988 struct smb_authinfo
*return_value
;
989 static const char* lc_labs
[] = {N_("Domain:"), N_("Username:"), N_("Password:")};
990 static const char* buts
[] = {N_("&OK"), N_("&Cancel")};
991 static int ilen
= 30, istart
= 14;
1000 static int i18n_flag
= 0;
1004 register int i
= sizeof(lc_labs
)/sizeof(lc_labs
[0]);
1009 l1
= str_term_width1 (lc_labs
[i
] = _(lc_labs
[i
]));
1013 i
= maxlen
+ ilen
+ 7;
1017 for (i
= sizeof(buts
)/sizeof(buts
[0]), l1
= 0; i
--; )
1019 l1
+= str_term_width1 (buts
[i
] = _(buts
[i
]));
1025 ilen
= dialog_x
- 7 - maxlen
; /* for the case of very long buttons :) */
1026 istart
= dialog_x
- 3 - ilen
;
1028 b2
= dialog_x
- (str_term_width1 (buts
[1]) + 6);
1033 #endif /* ENABLE_NLS */
1040 title
= g_strdup_printf (_("Password for \\\\%s\\%s"), host
, share
);
1042 auth_dlg
= create_dlg (0, 0, dialog_y
, dialog_x
, dialog_colors
, NULL
,
1043 "[Smb Authinfo]", title
, DLG_CENTER
| DLG_REVERSE
);
1047 in_user
= input_new (5, istart
, INPUT_COLOR
, ilen
, user
, "auth_name", INPUT_COMPLETE_DEFAULT
);
1048 add_widget (auth_dlg
, in_user
);
1050 in_domain
= input_new (3, istart
, INPUT_COLOR
, ilen
, domain
, "auth_domain", INPUT_COMPLETE_DEFAULT
);
1051 add_widget (auth_dlg
, in_domain
);
1052 add_widget (auth_dlg
, button_new (9, b2
, B_CANCEL
, NORMAL_BUTTON
,
1054 add_widget (auth_dlg
, button_new (9, b0
, B_ENTER
, DEFPUSH_BUTTON
,
1057 in_password
= input_new (7, istart
, INPUT_COLOR
, ilen
, "", "auth_password", INPUT_COMPLETE_DEFAULT
);
1058 in_password
->completion_flags
= 0;
1059 in_password
->is_password
= 1;
1060 add_widget (auth_dlg
, in_password
);
1062 add_widget (auth_dlg
, label_new (7, 3, lc_labs
[2]));
1063 add_widget (auth_dlg
, label_new (5, 3, lc_labs
[1]));
1064 add_widget (auth_dlg
, label_new (3, 3, lc_labs
[0]));
1068 switch (auth_dlg
->ret_value
) {
1073 return_value
= g_try_new (struct smb_authinfo
, 1);
1075 return_value
->host
= g_strdup (host
);
1076 return_value
->share
= g_strdup (share
);
1077 return_value
->domain
= g_strdup (in_domain
->buffer
);
1078 return_value
->user
= g_strdup (in_user
->buffer
);
1079 return_value
->password
= g_strdup (in_password
->buffer
);
1083 destroy_dlg (auth_dlg
);
1085 return return_value
;
1087 #endif /* ENABLE_VFS_SMB */