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>
39 #include "../src/tty/tty.h"
40 #include "../src/skin/skin.h" /* INPUT_COLOR */
41 #include "../src/tty/key.h" /* XCTRL and ALT macros */
43 #include "../src/mcconfig/mcconfig.h" /* Load/save user formats */
45 #include "dialog.h" /* The nice dialog manager */
46 #include "widget.h" /* The widgets for the nice dialog manager */
48 #include "setup.h" /* For profile_name */
49 #include "command.h" /* For cmdline */
51 #include "panel.h" /* LIST_TYPES */
53 #include "main.h" /* For the confirm_* variables */
55 #include "layout.h" /* for get_nth_panel_name proto */
56 #include "background.h" /* task_list */
61 #include "selcodepage.h"
65 # include "../vfs/ftpfs.h"
69 #include "../vfs/gc.h"
73 static WRadio
*display_radio
;
74 static WInput
*display_user_format
;
75 static WInput
*display_mini_status
;
76 static WCheck
*display_check_status
;
77 static char **displays_status
;
78 static int display_user_hotkey
= 'u';
81 display_callback (Dlg_head
*h
, dlg_msg_t msg
, int parm
)
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
, msg
, parm
);
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
);
221 display_box (WPanel
*panel
, char **userp
, char **minip
, int *use_msformat
, int num
)
225 char *section
= NULL
;
229 const char *p
= get_nth_panel_name (num
);
230 panel
= g_new (WPanel
, 1);
231 panel
->list_type
= list_full
;
232 panel
->user_format
= g_strdup (DEFAULT_USER_FORMAT
);
233 panel
->user_mini_status
= 0;
234 for (i
= 0; i
< LIST_TYPES
; i
++)
235 panel
->user_status_format
[i
] = g_strdup (DEFAULT_USER_FORMAT
);
236 section
= g_strconcat ("Temporal:", p
, (char *) NULL
);
237 if (! mc_config_has_group (mc_main_config
, section
)) {
239 section
= g_strdup (p
);
241 panel_load_setup (panel
, section
);
245 dd
= display_init (panel
->list_type
, panel
->user_format
,
246 panel
->user_mini_status
, panel
->user_status_format
);
248 if (run_dlg (dd
) != B_CANCEL
) {
249 result
= display_radio
->sel
;
250 *userp
= g_strdup (display_user_format
->buffer
);
251 *minip
= g_strdup (display_mini_status
->buffer
);
252 *use_msformat
= display_check_status
->state
& C_BOOL
;
255 if (section
!= NULL
) {
256 g_free (panel
->user_format
);
257 for (i
= 0; i
< LIST_TYPES
; i
++)
258 g_free (panel
->user_status_format
[i
]);
267 const panel_field_t
*
268 sort_box (const panel_field_t
*sort_format
, int *reverse
, int *case_sensitive
, int *exec_first
)
270 int dlg_width
= 40, dlg_height
= 15;
272 const char **sort_orders_names
;
273 gsize sort_names_num
;
277 const panel_field_t
*result
= sort_format
;
280 int max_radio
= 0, max_check
= 0;
281 int ok_len
, cancel_len
;
284 QuickWidget quick_widgets
[] =
287 QUICK_BUTTON (0, dlg_width
, dlg_height
- 3, dlg_height
, N_("&Cancel"), B_CANCEL
, NULL
),
289 QUICK_BUTTON (0, dlg_width
, dlg_height
- 3, dlg_height
, N_("&OK"), B_ENTER
, NULL
),
291 QUICK_CHECKBOX (0, dlg_width
, 5, dlg_height
, N_("&Reverse"), reverse
),
293 QUICK_CHECKBOX (0, dlg_width
, 4, dlg_height
, N_("Case sensi&tive"), case_sensitive
),
295 QUICK_CHECKBOX (0, dlg_width
, 3, dlg_height
, N_("Executable &first"), exec_first
),
297 QUICK_RADIO (4, dlg_width
, 3, dlg_height
, SORT_TYPES
,
302 QuickDialog quick_dlg
=
304 dlg_width
, dlg_height
, -1, -1,
305 N_("Sort order"), "[Sort Order...]",
309 sort_orders_names
= panel_get_sortable_fields(&sort_names_num
);
310 quick_widgets
[5].u
.radio
.items
= sort_orders_names
;
312 for (i
= 0; i
< sort_names_num
; i
++)
313 if (strcmp (sort_orders_names
[i
], _(sort_format
->title_hotkey
)) == 0 ) {
319 quick_dlg
.title
= _(quick_dlg
.title
);
321 for (i
= 0; i
< 2; i
++)
322 quick_widgets
[i
].u
.button
.text
= _(quick_widgets
[i
].u
.button
.text
);
324 for (i
= 2; i
< 5; i
++)
325 quick_widgets
[i
].u
.checkbox
.text
= _(quick_widgets
[i
].u
.checkbox
.text
);
326 #endif /* ENABLE_NlS */
329 cancel_len
= str_term_width1 (quick_widgets
[0].u
.button
.text
) + 4;
330 ok_len
= str_term_width1 (quick_widgets
[1].u
.button
.text
) + 6;
332 for (i
= 2; i
< 5; i
++)
333 max_check
= max (max_check
, str_term_width1 (quick_widgets
[i
].u
.checkbox
.text
) + 4);
335 for (i
= 0; i
< SORT_TYPES
; i
++)
336 max_radio
= max (max_radio
, str_term_width1 (sort_orders_names
[i
]) + 4);
339 dlg_width
= max (dlg_width
, str_term_width1 (quick_dlg
.title
) + 8);
340 dlg_width
= max (dlg_width
, ok_len
+ cancel_len
+ 8);
341 dlg_width
= max (dlg_width
, 2 * max (max_radio
, max_check
) + 8);
343 /* fix widget and dialog parameters */
345 quick_dlg
.xlen
= dlg_width
;
347 for (i
= 0; (size_t) i
< sizeof (quick_widgets
)/sizeof (quick_widgets
[0]) - 1; i
++)
348 quick_widgets
[i
].x_divisions
= dlg_width
;
350 quick_widgets
[0].relative_x
= dlg_width
* 2/3 - cancel_len
/2;
351 quick_widgets
[1].relative_x
= dlg_width
/3 - ok_len
/2;
353 for (i
= 2; i
< 5; i
++)
354 quick_widgets
[i
].relative_x
= dlg_width
/2 + 2;
356 if (quick_dialog (&quick_dlg
) != B_CANCEL
)
357 result
= panel_get_field_by_title_hotkey(sort_orders_names
[sort_idx
]);
360 result
= sort_format
;
362 g_strfreev((gchar
**)sort_orders_names
);
376 const char *title
= _(" Confirmation ");
378 QuickWidget conf_widgets
[] =
380 /* 0 */ QUICK_BUTTON (29, dlg_width
, 9, dlg_height
, N_("&Cancel"), B_CANCEL
, NULL
),
381 /* 1 */ QUICK_BUTTON (12, dlg_width
, 9, dlg_height
, N_("&OK"), B_ENTER
, NULL
),
382 /* 2 */ QUICK_CHECKBOX (3, dlg_width
, 7, dlg_height
, N_(" confirm di&Rectory hotlist delete "), &confirm_directory_hotlist_delete
),
383 /* 3 */ QUICK_CHECKBOX (3, dlg_width
, 6, dlg_height
, N_(" confirm &Exit "), &confirm_exit
),
384 /* 4 */ QUICK_CHECKBOX (3, dlg_width
, 5, dlg_height
, N_(" confirm e&Xecute "), &confirm_execute
),
385 /* 5 */ QUICK_CHECKBOX (3, dlg_width
, 4, dlg_height
, N_(" confirm o&Verwrite "), &confirm_overwrite
),
386 /* 6 */ QUICK_CHECKBOX (3, dlg_width
, 3, dlg_height
, N_(" confirm &Delete "), &confirm_delete
),
392 int cancel_len
, ok_len
, blen
;
397 for (i
= 0; i
< 2; i
++)
398 conf_widgets
[i
].u
.button
.text
= _(conf_widgets
[i
].u
.button
.text
);
400 for (i
= 2; i
< w_num
; i
++)
401 conf_widgets
[i
].u
.checkbox
.text
= _(conf_widgets
[i
].u
.checkbox
.text
);
402 #endif /* ENABLE_NLS */
404 /* maximumr length of checkboxes */
405 for (i
= 2; i
< w_num
; i
++)
406 maxlen
= max (maxlen
, str_term_width1 (conf_widgets
[i
].u
.checkbox
.text
) + 3);
408 /* length of buttons */
409 cancel_len
= str_term_width1 (conf_widgets
[0].u
.button
.text
) + 2;
410 ok_len
= str_term_width1 (conf_widgets
[0].u
.button
.text
) + 4; /* default button */
412 blen
= cancel_len
+ ok_len
+ 2;
414 dlg_width
= max (maxlen
, blen
) + 6;
415 dlg_width
= max (dlg_width
, str_term_width1 (title
) + 4);
417 /* correct widget parameters */
418 for (i
= 0; i
< w_num
; i
++)
419 conf_widgets
[i
].x_divisions
= dlg_width
;
421 conf_widgets
[0].relative_x
= dlg_width
* 2/3 - cancel_len
/2;
422 conf_widgets
[1].relative_x
= dlg_width
/3 - ok_len
/2;
425 QuickDialog confirmation
=
427 dlg_width
, dlg_height
, -1, -1, title
,
428 "[Confirmation]", conf_widgets
, 1
431 (void) quick_dialog (&confirmation
);
438 display_bits_box (void) /* AB:FIXME: test dialog */
441 const int DISPY
= 13;
442 const int DISPX
= 46;
447 const char *display_bits_str
[] =
450 N_("Full 8 bits output"),
455 QuickWidget display_widgets
[] =
457 /* 0 */ QUICK_BUTTON (15, DISPX
, DISPY
- 3, DISPY
, N_("&Cancel"), B_CANCEL
, NULL
),
458 /* 1 */ QUICK_BUTTON (29, DISPX
, DISPY
- 3, DISPY
, N_("&OK"), B_ENTER
, NULL
),
459 /* 2 */ QUICK_CHECKBOX (3, DISPX
, 8, DISPY
, N_("F&ull 8 bits input"), &new_meta
),
460 /* 3 */ QUICK_RADIO (3, DISPX
, 3, DISPY
, 4, display_bits_str
, ¤t_mode
),
464 QuickDialog display_bits
=
466 DISPX
, DISPY
, -1, -1, _(" Display bits "),
467 "[Display bits]", display_widgets
, TRUE
472 int ok_len
, cancel_len
;
475 static gboolean i18n_flag
= FALSE
;
478 for (i
= 0; i
< 3; i
++) {
479 display_bits_str
[i
] = _(display_bits_str
[i
]);
482 display_widgets
[0].u
.button
.text
= _(display_widgets
[0].u
.button
.text
);
483 display_widgets
[1].u
.button
.text
= _(display_widgets
[1].u
.button
.text
);
484 display_widgets
[2].u
.checkbox
.text
= _(display_widgets
[2].u
.checkbox
.text
);
488 #endif /* ENABLE_NLS */
491 for (i
= 0; i
< 3; i
++)
492 maxlen
= max (maxlen
, str_term_width1 (display_bits_str
[i
]));
495 cancel_len
= str_term_width1 (display_widgets
[0].u
.button
.text
) + 2;
496 ok_len
= str_term_width1 (display_widgets
[1].u
.button
.text
) + 4; /* default button */
498 l1
= max (cancel_len
, ok_len
);
500 display_bits
.xlen
= max (maxlen
, l1
) + 20;
502 for (i
= 0; i
< 4; i
++)
503 display_widgets
[i
].x_divisions
= display_bits
.xlen
;
505 display_widgets
[0].relative_x
= display_bits
.xlen
* 2/3 - cancel_len
/2;
506 display_widgets
[1].relative_x
= display_bits
.xlen
/3 - ok_len
/2;
510 else if (eight_bit_clean
)
515 new_meta
= !use_8th_bit_as_meta
;
517 if (quick_dialog (&display_bits
) != B_CANCEL
) {
518 eight_bit_clean
= current_mode
< 3;
519 full_eight_bits
= current_mode
< 2;
521 meta (stdscr
, eight_bit_clean
);
523 SLsmg_Display_Eight_Bit
= full_eight_bits
? 128 : 160;
525 use_8th_bit_as_meta
= !new_meta
;
529 #else /* HAVE_CHARSET */
531 static int new_display_codepage
;
533 static WLabel
*cplabel
;
534 static WCheck
*inpcheck
;
537 sel_charset_button (int action
)
543 new_dcp
= select_charset (0, 0, new_display_codepage
, TRUE
);
545 if (new_dcp
!= SELECT_CHARSET_CANCEL
) {
549 new_display_codepage
= new_dcp
;
550 cpname
= (new_display_codepage
== SELECT_CHARSET_OTHER_8BIT
) ?
551 _("Other 8 bit") : codepages
[new_display_codepage
].name
;
553 utf8_display
= str_isutf8 (cpname
);
554 /* avoid strange bug with label repainting */
555 g_snprintf (buf
, sizeof (buf
), "%-27s", cpname
);
556 label_set_text (cplabel
, buf
);
563 init_disp_bits_box (void)
566 const int DISPY
= 11;
567 const int DISPX
= 46;
575 create_dlg (0, 0, DISPY
, DISPX
, dialog_colors
, NULL
,
576 "[Display bits]", _(" Display bits "), DLG_CENTER
| DLG_REVERSE
);
578 add_widget (dbits_dlg
,
579 label_new (3, 4, _("Input / display codepage:")));
581 cpname
= (new_display_codepage
< 0)
583 : codepages
[new_display_codepage
].name
;
584 cplabel
= label_new (4, 4, cpname
);
585 add_widget (dbits_dlg
, cplabel
);
587 add_widget (dbits_dlg
,
588 button_new (DISPY
- 3, DISPX
/ 2 + 3, B_CANCEL
,
589 NORMAL_BUTTON
, _("&Cancel"), 0));
590 add_widget (dbits_dlg
,
591 button_new (DISPY
- 3, 7, B_ENTER
, NORMAL_BUTTON
, _("&OK"),
595 check_new (6, 4, !use_8th_bit_as_meta
, _("F&ull 8 bits input"));
596 add_widget (dbits_dlg
, inpcheck
);
598 cpname
= _("&Select");
599 add_widget (dbits_dlg
,
600 button_new (4, DISPX
- 7 - str_term_width1 (cpname
), B_USER
,
601 NORMAL_BUTTON
, cpname
, sel_charset_button
));
607 display_bits_box (void)
610 new_display_codepage
= display_codepage
;
612 application_keypad_mode ();
613 dbits_dlg
= init_disp_bits_box ();
617 if (dbits_dlg
->ret_value
== B_ENTER
) {
619 display_codepage
= new_display_codepage
;
621 init_translation_table (source_codepage
, display_codepage
);
623 message (D_ERROR
, MSG_ERROR
, "%s", errmsg
);
625 tty_display_8bit (display_codepage
!= 0 && display_codepage
!= 1);
627 tty_display_8bit (display_codepage
!= 0);
629 use_8th_bit_as_meta
= !(inpcheck
->state
& C_BOOL
);
631 destroy_dlg (dbits_dlg
);
635 #endif /* HAVE_CHARSET */
642 tree_callback (struct Dlg_head
*h
, dlg_msg_t msg
, int parm
)
647 /* The enter key will be processed by the tree widget */
649 h
->ret_value
= B_ENTER
;
655 return default_dlg_callback (h
, msg
, parm
);
659 /* Show tree in a box, not on a panel */
661 tree_box (const char *current_dir
)
669 /* Create the components */
670 dlg
= create_dlg (0, 0, TREE_Y
, TREE_X
, dialog_colors
,
671 tree_callback
, "[Directory Tree]", NULL
, DLG_CENTER
| DLG_REVERSE
);
672 mytree
= tree_new (0, 2, 2, TREE_Y
- 6, TREE_X
- 5);
673 add_widget (dlg
, mytree
);
674 bar
= buttonbar_new(1);
675 add_widget (dlg
, bar
);
676 ((Widget
*) bar
)->x
= 0;
677 ((Widget
*) bar
)->y
= LINES
- 1;
679 if (run_dlg (dlg
) == B_ENTER
)
680 val
= g_strdup (tree_selected_name (mytree
));
688 static char *ret_timeout
;
691 static char *ret_passwd
;
692 static char *ret_directory_timeout
;
693 static char *ret_ftp_proxy
;
707 char buffer2
[BUF_TINY
];
709 char buffer3
[BUF_TINY
];
712 QuickWidget confvfs_widgets
[] =
714 /* 0 */ QUICK_BUTTON (30, VFSX
, VFSY
- 3, VFSY
, N_("&Cancel"), B_CANCEL
, NULL
),
715 /* 1 */ QUICK_BUTTON (12, VFSX
, VFSY
- 3, VFSY
, N_("&OK"), B_ENTER
, NULL
),
717 /* 2 */ QUICK_CHECKBOX (4, VFSX
, 12, VFSY
, N_("Use passive mode over pro&xy"), &ftpfs_use_passive_connections_over_proxy
),
718 /* 3 */ QUICK_CHECKBOX (4, VFSX
, 11, VFSY
, N_("Use &passive mode"), &ftpfs_use_passive_connections
),
719 /* 4 */ QUICK_CHECKBOX (4, VFSX
, 10, VFSY
, N_("&Use ~/.netrc"), &use_netrc
),
720 /* 5 */ QUICK_INPUT (4, VFSX
, 9, VFSY
, ftpfs_proxy_host
, 48, 0, "input-ftp-proxy", &ret_ftp_proxy
),
721 /* 6 */ QUICK_CHECKBOX (4, VFSX
, 8, VFSY
, N_("&Always use ftp proxy"), &ftpfs_always_use_proxy
),
722 /* 7 */ QUICK_LABEL (49, VFSX
, 7, VFSY
, N_("sec")),
723 /* 8 */ QUICK_INPUT (38, VFSX
, 7, VFSY
, buffer3
, 10, 0, "input-timeout", &ret_directory_timeout
),
724 /* 9 */ QUICK_LABEL (4, VFSX
, 7, VFSY
, N_("ftpfs directory cache timeout:")),
725 /* 10 */ QUICK_INPUT (4, VFSX
, 6, VFSY
, ftpfs_anonymous_passwd
, 48, 0, "input-passwd", &ret_passwd
),
726 /* 11 */ QUICK_LABEL (4, VFSX
, 5, VFSY
, N_("ftp anonymous password:")),
728 /* 12 */ QUICK_LABEL (49, VFSX
, 3, VFSY
, N_("sec")),
729 /* 13 */ QUICK_INPUT (38, VFSX
, 3, VFSY
, buffer2
, 10, 0, "input-timo-vfs", &ret_timeout
),
730 /* 14 */ QUICK_LABEL (4, VFSX
, 3, VFSY
, N_("Timeout for freeing VFSs:")),
734 QuickDialog confvfs_dlg
=
736 VFSX
, VFSY
, -1, -1, N_(" Virtual File System Setting "),
737 "[Virtual FS]", confvfs_widgets
, FALSE
741 g_snprintf (buffer3
, sizeof (buffer3
), "%i", ftpfs_directory_timeout
);
743 g_snprintf (buffer2
, sizeof (buffer2
), "%i", vfs_timeout
);
745 if (quick_dialog (&confvfs_dlg
) != B_CANCEL
) {
746 vfs_timeout
= atoi (ret_timeout
);
747 g_free (ret_timeout
);
749 if (vfs_timeout
< 0 || vfs_timeout
> 10000)
752 g_free (ftpfs_anonymous_passwd
);
753 ftpfs_anonymous_passwd
= ret_passwd
;
754 g_free (ftpfs_proxy_host
);
755 ftpfs_proxy_host
= ret_ftp_proxy
;
756 ftpfs_directory_timeout
= atoi(ret_directory_timeout
);
757 g_free (ret_directory_timeout
);
770 const char *label
= N_("cd");
780 len
= str_term_width1 (label
);
785 QuickWidget quick_widgets
[] =
787 /* 0 */ QUICK_INPUT (4 + len
, xlen
, 2, ylen
, "", xlen
- 7 - len
, 2, "input" , &my_str
),
788 /* 1 */ QUICK_LABEL (3, xlen
, 2, ylen
, label
),
792 QuickDialog Quick_input
=
794 xlen
, ylen
, 2, LINES
- 2 - ylen
, _("Quick cd"),
795 "[Quick cd]", quick_widgets
, TRUE
798 return (quick_dialog (&Quick_input
) != B_CANCEL
) ? my_str
: NULL
;
803 symlink_dialog (const char *existing
, const char *new, char **ret_existing
,
806 QuickWidget quick_widgets
[] =
808 /* 0 */ QUICK_BUTTON (50, 80, 6, 8, N_("&Cancel"), B_CANCEL
, NULL
),
809 /* 1 */ QUICK_BUTTON (16, 80, 6, 8, N_("&OK"), B_ENTER
, NULL
),
810 /* 2 */ QUICK_INPUT (4, 80, 5, 8, new, 58, 0, "input-1", ret_new
),
811 /* 3 */ QUICK_LABEL (4, 80, 4, 8, N_("Symbolic link filename:")),
812 /* 4 */ QUICK_INPUT (4, 80, 3, 8, existing
, 58, 0, "input-2", ret_existing
),
813 /* 5 */ QUICK_LABEL (4, 80, 2, 8, N_("Existing filename (filename symlink will point to):")),
817 QuickDialog Quick_input
=
819 64, 12, -1, -1, N_("Symbolic link"),
820 "[File Menu]", quick_widgets
, FALSE
823 if (quick_dialog (&Quick_input
) == B_CANCEL
) {
825 *ret_existing
= NULL
;
829 #ifdef WITH_BACKGROUND
830 #define B_STOP (B_USER+1)
831 #define B_RESUME (B_USER+2)
832 #define B_KILL (B_USER+3)
834 static int JOBS_X
= 60;
836 static WListbox
*bg_list
;
837 static Dlg_head
*jobs_dlg
;
840 jobs_fill_listbox (void)
842 static const char *state_str
[2];
843 TaskList
*tl
= task_list
;
846 state_str
[0] = _("Running ");
847 state_str
[1] = _("Stopped");
853 s
= g_strconcat (state_str
[tl
->state
], " ", tl
->info
, (char *) NULL
);
854 listbox_add_item (bg_list
, LISTBOX_APPEND_AT_END
, 0, s
, (void *) tl
);
869 /* Get this instance information */
870 tl
= (TaskList
*) bg_list
->current
->data
;
873 if (action
== B_STOP
){
875 tl
->state
= Task_Stopped
;
876 } else if (action
== B_RESUME
){
878 tl
->state
= Task_Running
;
881 if (action
== B_KILL
){
886 unregister_task_running (tl
->pid
, tl
->fd
);
889 listbox_remove_list (bg_list
);
890 jobs_fill_listbox ();
892 /* This can be optimized to just redraw this widget :-) */
893 dlg_redraw (jobs_dlg
);
903 int (*callback
)(int);
907 {N_("&Stop"), 3, B_STOP
, task_cb
},
908 {N_("&Resume"), 12, B_RESUME
, task_cb
},
909 {N_("&Kill"), 23, B_KILL
, task_cb
},
910 {N_("&OK"), 35, B_CANCEL
, NULL
}
917 int n_buttons
= sizeof (job_buttons
) / sizeof (job_buttons
[0]);
920 static int i18n_flag
= 0;
923 int startx
= job_buttons
[0].xpos
;
926 for (i
= 0; i
< n_buttons
; i
++)
928 job_buttons
[i
].name
= _(job_buttons
[i
].name
);
930 len
= str_term_width1 (job_buttons
[i
].name
) + 4;
931 JOBS_X
= max (JOBS_X
, startx
+ len
+ 3);
933 job_buttons
[i
].xpos
= startx
;
937 /* Last button - Ok a.k.a. Cancel :) */
938 job_buttons
[n_buttons
- 1].xpos
=
939 JOBS_X
- str_term_width1 (job_buttons
[n_buttons
- 1].name
) - 7;
943 #endif /* ENABLE_NLS */
945 jobs_dlg
= create_dlg (0, 0, JOBS_Y
, JOBS_X
, dialog_colors
, NULL
,
946 "[Background jobs]", _("Background Jobs"),
947 DLG_CENTER
| DLG_REVERSE
);
949 bg_list
= listbox_new (2, 3, JOBS_Y
- 9, JOBS_X
- 7, NULL
);
950 add_widget (jobs_dlg
, bg_list
);
955 add_widget (jobs_dlg
, button_new (JOBS_Y
-4,
956 job_buttons
[i
].xpos
, job_buttons
[i
].value
,
957 NORMAL_BUTTON
, job_buttons
[i
].name
,
958 job_buttons
[i
].callback
));
961 /* Insert all of task information in the list */
962 jobs_fill_listbox ();
965 destroy_dlg (jobs_dlg
);
967 #endif /* WITH_BACKGROUND */
970 struct smb_authinfo
*
971 vfs_smb_get_authinfo (const char *host
, const char *share
, const char *domain
,
974 static int dialog_x
= 44;
975 enum { b0
= 3, dialog_y
= 12};
976 struct smb_authinfo
*return_value
;
977 static const char* labs
[] = {N_("Domain:"), N_("Username:"), N_("Password:")};
978 static const char* buts
[] = {N_("&OK"), N_("&Cancel")};
979 static int ilen
= 30, istart
= 14;
988 static int i18n_flag
= 0;
992 register int i
= sizeof(labs
)/sizeof(labs
[0]);
997 l1
= str_term_width1 (labs
[i
] = _(labs
[i
]));
1001 i
= maxlen
+ ilen
+ 7;
1005 for (i
= sizeof(buts
)/sizeof(buts
[0]), l1
= 0; i
--; )
1007 l1
+= str_term_width1 (buts
[i
] = _(buts
[i
]));
1013 ilen
= dialog_x
- 7 - maxlen
; /* for the case of very long buttons :) */
1014 istart
= dialog_x
- 3 - ilen
;
1016 b2
= dialog_x
- (str_term_width1 (buts
[1]) + 6);
1021 #endif /* ENABLE_NLS */
1028 title
= g_strdup_printf (_("Password for \\\\%s\\%s"), host
, share
);
1030 auth_dlg
= create_dlg (0, 0, dialog_y
, dialog_x
, dialog_colors
, NULL
,
1031 "[Smb Authinfo]", title
, DLG_CENTER
| DLG_REVERSE
);
1035 in_user
= input_new (5, istart
, INPUT_COLOR
, ilen
, user
, "auth_name", INPUT_COMPLETE_DEFAULT
);
1036 add_widget (auth_dlg
, in_user
);
1038 in_domain
= input_new (3, istart
, INPUT_COLOR
, ilen
, domain
, "auth_domain", INPUT_COMPLETE_DEFAULT
);
1039 add_widget (auth_dlg
, in_domain
);
1040 add_widget (auth_dlg
, button_new (9, b2
, B_CANCEL
, NORMAL_BUTTON
,
1042 add_widget (auth_dlg
, button_new (9, b0
, B_ENTER
, DEFPUSH_BUTTON
,
1045 in_password
= input_new (7, istart
, INPUT_COLOR
, ilen
, "", "auth_password", INPUT_COMPLETE_DEFAULT
);
1046 in_password
->completion_flags
= 0;
1047 in_password
->is_password
= 1;
1048 add_widget (auth_dlg
, in_password
);
1050 add_widget (auth_dlg
, label_new (7, 3, labs
[2]));
1051 add_widget (auth_dlg
, label_new (5, 3, labs
[1]));
1052 add_widget (auth_dlg
, label_new (3, 3, labs
[0]));
1056 switch (auth_dlg
->ret_value
) {
1061 return_value
= g_new (struct smb_authinfo
, 1);
1063 return_value
->host
= g_strdup (host
);
1064 return_value
->share
= g_strdup (share
);
1065 return_value
->domain
= g_strdup (in_domain
->buffer
);
1066 return_value
->user
= g_strdup (in_user
->buffer
);
1067 return_value
->password
= g_strdup (in_password
->buffer
);
1071 destroy_dlg (auth_dlg
);
1073 return return_value
;
1075 #endif /* WITH_SMBFS */