1 /* Some misc dialog boxes for the program.
3 Copyright (C) 1994, 1995 the Free Software Foundation
5 Authors: 1994, 1995 Miguel de Icaza
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
30 #include <sys/types.h>
35 #include "win.h" /* Our window tools */
36 #include "color.h" /* Color definitions */
37 #include "dialog.h" /* The nice dialog manager */
38 #include "widget.h" /* The widgets for the nice dialog manager */
40 #include "setup.h" /* For profile_name */
41 #include "profile.h" /* Load/save user formats */
42 #include "key.h" /* XCTRL and ALT macros */
43 #include "command.h" /* For cmdline */
47 #include "main.h" /* For the confirm_* variables */
49 #include "layout.h" /* for get_nth_panel_name proto */
50 #include "background.h" /* task_list */
54 #include "selcodepage.h"
58 # include "../vfs/ftpfs.h"
62 #include "../vfs/gc.h"
65 static int DISPLAY_X
= 45, DISPLAY_Y
= 14;
68 static WRadio
*my_radio
;
70 static WInput
*status
;
71 static WCheck
*check_status
;
72 static int current_mode
;
74 static char **displays_status
;
76 /* Controls whether the array strings have been translated */
77 static const char *displays
[LIST_TYPES
] = {
78 N_("&Full file list"),
79 N_("&Brief file list"),
80 N_("&Long file list"),
84 /* Index in displays[] for "user defined" */
87 static int user_hotkey
= 'u';
90 display_callback (struct Dlg_head
*h
, dlg_msg_t msg
, int parm
)
94 if (dlg_widget_active (my_radio
)) {
95 assign_text (status
, displays_status
[my_radio
->sel
]);
96 input_set_point (status
, 0);
102 if (dlg_widget_active (my_radio
)) {
103 assign_text (status
, displays_status
[my_radio
->sel
]);
108 if (dlg_widget_active (user
)) {
109 h
->ret_value
= B_USER
+ 6;
114 if (dlg_widget_active (status
)) {
115 h
->ret_value
= B_USER
+ 7;
121 if (tolower (parm
) == user_hotkey
&& dlg_widget_active (user
)
122 && dlg_widget_active (status
)) {
124 dlg_select_widget (my_radio
); /* force redraw */
125 dlg_select_widget (user
);
128 return MSG_NOT_HANDLED
;
131 return default_dlg_callback (h
, msg
, parm
);
136 display_init (int radio_sel
, char *init_text
, int _check_status
,
139 static const char *display_title
= N_("Listing mode");
140 static int i18n_displays_flag
;
141 const char *user_mini_status
= _("user &Mini status");
142 const char *ok_button
= _("&OK");
143 const char *cancel_button
= _("&Cancel");
145 static int button_start
= 30;
147 displays_status
= _status
;
149 if (!i18n_displays_flag
) {
150 int i
, l
, maxlen
= 0;
153 display_title
= _(display_title
);
154 for (i
= 0; i
< LIST_TYPES
; i
++) {
155 displays
[i
] = _(displays
[i
]);
156 if ((l
= strlen (displays
[i
])) > maxlen
)
160 i
= strlen (ok_button
) + 5;
161 l
= strlen (cancel_button
) + 3;
168 i
= strlen (user_mini_status
) + 13;
172 i
= strlen (display_title
) + 10;
176 button_start
= DISPLAY_X
- l
- 5;
178 /* get hotkey of user-defined format string */
179 cp
= strchr (displays
[USER_TYPE
], '&');
180 if (cp
!= NULL
&& *++cp
!= '\0')
181 user_hotkey
= tolower ((unsigned char) *cp
);
183 i18n_displays_flag
= 1;
185 dd
= create_dlg (0, 0, DISPLAY_Y
, DISPLAY_X
, dialog_colors
,
186 display_callback
, "[Listing Mode...]", display_title
,
187 DLG_CENTER
| DLG_REVERSE
);
190 button_new (4, button_start
, B_CANCEL
, NORMAL_BUTTON
,
194 button_new (3, button_start
, B_ENTER
, DEFPUSH_BUTTON
,
198 input_new (10, 9, INPUT_COLOR
, DISPLAY_X
- 14, _status
[radio_sel
],
200 add_widget (dd
, status
);
201 input_set_point (status
, 0);
204 check_new (9, 5, _check_status
, user_mini_status
);
205 add_widget (dd
, check_status
);
208 input_new (7, 9, INPUT_COLOR
, DISPLAY_X
- 14, init_text
,
210 add_widget (dd
, user
);
211 input_set_point (user
, 0);
213 my_radio
= radio_new (3, 5, LIST_TYPES
, displays
, 1);
214 my_radio
->sel
= my_radio
->pos
= current_mode
;
215 add_widget (dd
, my_radio
);
219 display_box (WPanel
*panel
, char **userp
, char **minip
, int *use_msformat
, int num
)
222 char *section
= NULL
;
226 p
= get_nth_panel_name (num
);
227 panel
= g_new (WPanel
, 1);
228 panel
->list_type
= list_full
;
229 panel
->user_format
= g_strdup (DEFAULT_USER_FORMAT
);
230 panel
->user_mini_status
= 0;
231 for (i
= 0; i
< LIST_TYPES
; i
++)
232 panel
->user_status_format
[i
] = g_strdup (DEFAULT_USER_FORMAT
);
233 section
= g_strconcat ("Temporal:", p
, (char *) NULL
);
234 if (!profile_has_section (section
, profile_name
)) {
236 section
= g_strdup (p
);
238 panel_load_setup (panel
, section
);
242 current_mode
= panel
->list_type
;
243 display_init (current_mode
, panel
->user_format
,
244 panel
->user_mini_status
, panel
->user_status_format
);
251 g_free (panel
->user_format
);
252 for (i
= 0; i
< LIST_TYPES
; i
++)
253 g_free (panel
->user_status_format
[i
]);
257 if (dd
->ret_value
!= B_CANCEL
){
258 result
= my_radio
->sel
;
259 *userp
= g_strdup (user
->buffer
);
260 *minip
= g_strdup (status
->buffer
);
261 *use_msformat
= check_status
->state
& C_BOOL
;
268 static int SORT_X
= 40, SORT_Y
= 14;
270 static const char *sort_orders_names
[SORT_TYPES
];
273 sort_box (sortfn
*sort_fn
, int *reverse
, int *case_sensitive
)
277 WCheck
*c
, *case_sense
;
279 const char *ok_button
= _("&OK");
280 const char *cancel_button
= _("&Cancel");
281 const char *reverse_label
= _("&Reverse");
282 const char *case_label
= _("case sensi&tive");
283 const char *sort_title
= _("Sort order");
285 static int i18n_sort_flag
= 0, check_pos
= 0, button_pos
= 0;
287 if (!i18n_sort_flag
) {
289 for (i
= SORT_TYPES
- 1; i
>= 0; i
--) {
290 sort_orders_names
[i
] = _(sort_orders
[i
].sort_name
);
291 r
= strlen (sort_orders_names
[i
]);
296 check_pos
= maxlen
+ 9;
298 r
= strlen (reverse_label
) + 4;
299 i
= strlen (case_label
) + 4;
303 l
= strlen (ok_button
) + 6;
304 i
= strlen (cancel_button
) + 4;
308 i
= check_pos
+ max (r
, l
) + 2;
313 i
= strlen (sort_title
) + 6;
317 button_pos
= SORT_X
- l
- 2;
324 for (i
= 0; i
< SORT_TYPES
; i
++)
325 if ((sortfn
*) (sort_orders
[i
].sort_fn
) == sort_fn
) {
330 dd
= create_dlg (0, 0, SORT_Y
, SORT_X
, dialog_colors
, NULL
,
331 "[Sort Order...]", sort_title
, DLG_CENTER
| DLG_REVERSE
);
334 button_new (10, button_pos
, B_CANCEL
, NORMAL_BUTTON
,
338 button_new (9, button_pos
, B_ENTER
, DEFPUSH_BUTTON
,
341 case_sense
= check_new (4, check_pos
, *case_sensitive
, case_label
);
342 add_widget (dd
, case_sense
);
343 c
= check_new (3, check_pos
, *reverse
, reverse_label
);
346 my_radio
= radio_new (3, 3, SORT_TYPES
, sort_orders_names
, 1);
347 my_radio
->sel
= my_radio
->pos
= current_mode
;
349 add_widget (dd
, my_radio
);
354 result
= (sortfn
*) sort_orders
[my_radio
->sel
].sort_fn
;
355 *reverse
= c
->state
& C_BOOL
;
356 *case_sensitive
= case_sense
->state
& C_BOOL
;
367 static int my_delete
;
368 static int my_overwrite
;
369 static int my_execute
;
372 static QuickWidget conf_widgets
[] = {
373 { quick_button
, 4, 6, 4, CONFY
, N_("&Cancel"),
374 0, B_CANCEL
, 0, 0, "c" },
375 { quick_button
, 4, 6, 3, CONFY
, N_("&OK"),
376 0, B_ENTER
, 0, 0, "o" },
378 { quick_checkbox
, 1, 13, 6, CONFY
, N_(" confirm &Exit "),
379 9, 0, &my_exit
, 0, "e" },
380 { quick_checkbox
, 1, 13, 5, CONFY
, N_(" confirm e&Xecute "),
381 10, 0, &my_execute
, 0, "x" },
382 { quick_checkbox
, 1, 13, 4, CONFY
, N_(" confirm o&Verwrite "),
383 10, 0, &my_overwrite
, 0, "ov" },
384 { quick_checkbox
, 1, 13, 3, CONFY
, N_(" confirm &Delete "),
385 9, 0, &my_delete
, 0, "de" },
389 static QuickDialog confirmation
=
390 { CONFX
, CONFY
, -1, -1, N_(" Confirmation "), "[Confirmation]",
399 static int i18n_flag
= 0;
403 register int i
= sizeof(conf_widgets
)/sizeof(QuickWidget
) - 1;
407 conf_widgets
[i
].text
= _(conf_widgets
[i
].text
);
408 l1
= strlen (conf_widgets
[i
].text
) + 3;
414 * If buttons start on 4/6, checkboxes (with some add'l space)
415 * must take not more than it.
417 confirmation
.xlen
= (maxlen
+ 5) * 6 / 4;
420 * And this for the case when buttons with some space to the right
421 * do not fit within 2/6
423 l1
= strlen (conf_widgets
[0].text
) + 3;
424 i
= strlen (conf_widgets
[1].text
) + 5;
428 i
= (l1
+ 3) * 6 / 2;
429 if (i
> confirmation
.xlen
)
430 confirmation
.xlen
= i
;
432 confirmation
.title
= _(confirmation
.title
);
434 i18n_flag
= confirmation
.i18n
= 1;
437 #endif /* ENABLE_NLS */
439 my_delete
= confirm_delete
;
440 my_overwrite
= confirm_overwrite
;
441 my_execute
= confirm_execute
;
442 my_exit
= confirm_exit
;
444 if (quick_dialog (&confirmation
) != B_CANCEL
){
445 confirm_delete
= my_delete
;
446 confirm_overwrite
= my_overwrite
;
447 confirm_execute
= my_execute
;
448 confirm_exit
= my_exit
;
461 static const char *display_bits_str
[] =
462 { N_("Full 8 bits output"), N_("ISO 8859-1"), N_("7 bits") };
464 static QuickWidget display_widgets
[] = {
465 { quick_button
, 4, 6, 4, DISPY
, N_("&Cancel"),
466 0, B_CANCEL
, 0, 0, "c" },
467 { quick_button
, 4, 6, 3, DISPY
, N_("&OK"),
468 0, B_ENTER
, 0, 0, "o" },
469 { quick_checkbox
, 4, DISPX
, 7, DISPY
, N_("F&ull 8 bits input"),
470 0, 0, &new_meta
, 0, "u" },
471 { quick_radio
, 4, DISPX
, 3, DISPY
, "", 3, 0,
472 &new_mode
, const_cast(char **, display_bits_str
), "r" },
476 static QuickDialog display_bits
=
477 { DISPX
, DISPY
, -1, -1, N_(" Display bits "), "[Display bits]",
478 display_widgets
, 0 };
481 display_bits_box (void)
486 static int i18n_flag
= 0;
491 for (i
= 0; i
< 3; i
++)
493 display_widgets
[i
].text
= _(display_widgets
[i
].text
);
494 display_bits_str
[i
] = _(display_bits_str
[i
]);
495 l1
= strlen (display_bits_str
[i
]);
499 l1
= strlen (display_widgets
[2].text
);
504 display_bits
.xlen
= (maxlen
+ 5) * 6 / 4;
506 /* See above confirm_box */
507 l1
= strlen (display_widgets
[0].text
) + 3;
508 i
= strlen (display_widgets
[1].text
) + 5;
512 i
= (l1
+ 3) * 6 / 2;
513 if (i
> display_bits
.xlen
)
514 display_bits
.xlen
= i
;
516 display_bits
.title
= _(display_bits
.title
);
517 i18n_flag
= display_bits
.i18n
= 1;
520 #endif /* ENABLE_NLS */
524 else if (eight_bit_clean
)
529 display_widgets
[3].value
= current_mode
;
530 new_meta
= !use_8th_bit_as_meta
;
531 if (quick_dialog (&display_bits
) != B_ENTER
)
534 eight_bit_clean
= new_mode
< 2;
535 full_eight_bits
= new_mode
== 0;
537 meta (stdscr
, eight_bit_clean
);
539 SLsmg_Display_Eight_Bit
= full_eight_bits
? 128 : 160;
541 use_8th_bit_as_meta
= !new_meta
;
545 #else /* HAVE_CHARSET */
548 static int new_display_codepage
;
550 static WLabel
*cplabel
;
551 static WCheck
*inpcheck
;
554 sel_charset_button (int action
)
558 new_display_codepage
= select_charset (new_display_codepage
, 1);
559 cpname
= (new_display_codepage
< 0)
561 : codepages
[new_display_codepage
].name
;
563 /* avoid strange bug with label repainting */
564 g_snprintf (buf
, sizeof (buf
), "%-27s", cpname
);
565 label_set_text (cplabel
, buf
);
570 init_disp_bits_box (void)
578 create_dlg (0, 0, DISPY
, DISPX
, dialog_colors
, NULL
,
579 "[Display bits]", _(" Display bits "), DLG_CENTER
| DLG_REVERSE
);
581 add_widget (dbits_dlg
,
582 label_new (3, 4, _("Input / display codepage:")));
584 cpname
= (new_display_codepage
< 0)
586 : codepages
[new_display_codepage
].name
;
587 cplabel
= label_new (4, 4, cpname
);
588 add_widget (dbits_dlg
, cplabel
);
590 add_widget (dbits_dlg
,
591 button_new (DISPY
- 3, DISPX
/ 2 + 3, B_CANCEL
,
592 NORMAL_BUTTON
, _("&Cancel"), 0));
593 add_widget (dbits_dlg
,
594 button_new (DISPY
- 3, 7, B_ENTER
, NORMAL_BUTTON
, _("&OK"),
598 check_new (6, 4, !use_8th_bit_as_meta
, _("F&ull 8 bits input"));
599 add_widget (dbits_dlg
, inpcheck
);
601 cpname
= _("&Select");
602 add_widget (dbits_dlg
,
603 button_new (4, DISPX
- 8 - strlen (cpname
), B_USER
,
604 NORMAL_BUTTON
, cpname
, sel_charset_button
));
610 display_bits_box (void)
613 new_display_codepage
= display_codepage
;
615 application_keypad_mode ();
616 dbits_dlg
= init_disp_bits_box ();
620 if (dbits_dlg
->ret_value
== B_ENTER
) {
622 display_codepage
= new_display_codepage
;
624 init_translation_table (source_codepage
, display_codepage
);
626 message (1, MSG_ERROR
, "%s", errmsg
);
628 meta (stdscr
, display_codepage
!= 0);
630 SLsmg_Display_Eight_Bit
= (display_codepage
!= 0
631 && display_codepage
!= 1) ? 128 : 160;
633 use_8th_bit_as_meta
= !(inpcheck
->state
& C_BOOL
);
635 destroy_dlg (dbits_dlg
);
639 #endif /* HAVE_CHARSET */
646 tree_callback (struct Dlg_head
*h
, dlg_msg_t msg
, int parm
)
651 /* The enter key will be processed by the tree widget */
653 h
->ret_value
= B_ENTER
;
659 return default_dlg_callback (h
, msg
, parm
);
663 /* Show tree in a box, not on a panel */
665 tree_box (const char *current_dir
)
672 /* Create the components */
673 dlg
= create_dlg (0, 0, TREE_Y
, TREE_X
, dialog_colors
,
674 tree_callback
, "[Directory Tree]", NULL
, DLG_CENTER
| DLG_REVERSE
);
675 mytree
= tree_new (0, 2, 2, TREE_Y
- 6, TREE_X
- 5);
676 add_widget (dlg
, mytree
);
677 bar
= buttonbar_new(1);
678 add_widget (dlg
, bar
);
679 ((Widget
*) bar
)->x
= 0;
680 ((Widget
*) bar
)->y
= LINES
- 1;
683 if (dlg
->ret_value
== B_ENTER
)
684 val
= g_strdup (tree_selected_name (mytree
));
694 #if defined(USE_NETCODE)
696 #define VFS_WIDGETBASE 9
699 #define VFS_WIDGETBASE 0
704 static char *ret_timeout
;
706 #if defined(USE_NETCODE)
707 static char *ret_passwd
;
708 static char *ret_directory_timeout
;
709 static char *ret_ftp_proxy
;
710 static int ret_use_netrc
;
711 static int ret_ftpfs_use_passive_connections
;
712 static int ret_ftpfs_use_passive_connections_over_proxy
;
715 static QuickWidget confvfs_widgets
[] = {
716 { quick_button
, 30, VFSX
, VFSY
- 3, VFSY
, N_("&Cancel"),
717 0, B_CANCEL
, 0, 0, "button-cancel" },
718 { quick_button
, 12, VFSX
, VFSY
- 3, VFSY
, N_("&OK"),
719 0, B_ENTER
, 0, 0, "button-ok" },
720 #if defined(USE_NETCODE)
721 { quick_checkbox
, 4, VFSX
, 12, VFSY
, N_("Use passive mode over pro&xy"), 0, 0,
722 &ret_ftpfs_use_passive_connections_over_proxy
, 0, "check-use-passive-mode-proxy" },
723 { quick_checkbox
, 4, VFSX
, 11, VFSY
, N_("Use &passive mode"), 0, 0,
724 &ret_ftpfs_use_passive_connections
, 0, "check-use-passive-mode" },
725 { quick_checkbox
, 4, VFSX
, 10, VFSY
, N_("&Use ~/.netrc"), 0, 0,
726 &ret_use_netrc
, 0, "check-use-netrc" },
727 { quick_input
, 4, VFSX
, 9, VFSY
, "", 48, 0, 0, &ret_ftp_proxy
,
729 { quick_checkbox
, 4, VFSX
, 8, VFSY
, N_("&Always use ftp proxy"), 0, 0,
730 &ftpfs_always_use_proxy
, 0, "check-ftp-proxy" },
731 { quick_label
, 49, VFSX
, 7, VFSY
, N_("sec"),
732 0, 0, 0, 0, "label-sec" },
733 { quick_input
, 38, VFSX
, 7, VFSY
, "", 10, 0, 0, &ret_directory_timeout
,
735 { quick_label
, 4, VFSX
, 7, VFSY
, N_("ftpfs directory cache timeout:"),
736 0, 0, 0, 0, "label-cache"},
737 { quick_input
, 4, VFSX
, 6, VFSY
, "", 48, 0, 0, &ret_passwd
,
739 { quick_label
, 4, VFSX
, 5, VFSY
, N_("ftp anonymous password:"),
740 0, 0, 0, 0, "label-pass"},
742 { quick_label
, 49, VFSX
, 3, VFSY
, "sec",
743 0, 0, 0, 0, "label-sec2" },
744 { quick_input
, 38, VFSX
, 3, VFSY
, "", 10, 0, 0, &ret_timeout
,
746 { quick_label
, 4, VFSX
, 3, VFSY
, N_("Timeout for freeing VFSs:"),
747 0, 0, 0, 0, "label-vfs" },
751 static QuickDialog confvfs_dlg
=
752 { VFSX
, VFSY
, -1, -1, N_(" Virtual File System Setting "),
753 "[Virtual FS]", confvfs_widgets
, 0 };
758 char buffer2
[BUF_TINY
];
759 #if defined(USE_NETCODE)
760 char buffer3
[BUF_TINY
];
762 ret_use_netrc
= use_netrc
;
763 ret_ftpfs_use_passive_connections
= ftpfs_use_passive_connections
;
764 ret_ftpfs_use_passive_connections_over_proxy
= ftpfs_use_passive_connections_over_proxy
;
765 g_snprintf(buffer3
, sizeof (buffer3
), "%i", ftpfs_directory_timeout
);
766 confvfs_widgets
[8].text
= buffer3
;
767 confvfs_widgets
[10].text
= ftpfs_anonymous_passwd
;
768 confvfs_widgets
[5].text
= ftpfs_proxy_host
;
770 g_snprintf (buffer2
, sizeof (buffer2
), "%i", vfs_timeout
);
771 confvfs_widgets
[4 + VFS_WIDGETBASE
].text
= buffer2
;
773 if (quick_dialog (&confvfs_dlg
) != B_CANCEL
) {
774 vfs_timeout
= atoi (ret_timeout
);
775 g_free (ret_timeout
);
776 if (vfs_timeout
< 0 || vfs_timeout
> 10000)
778 #if defined(USE_NETCODE)
779 g_free (ftpfs_anonymous_passwd
);
780 ftpfs_anonymous_passwd
= ret_passwd
;
781 g_free (ftpfs_proxy_host
);
782 ftpfs_proxy_host
= ret_ftp_proxy
;
783 ftpfs_directory_timeout
= atoi(ret_directory_timeout
);
784 use_netrc
= ret_use_netrc
;
785 ftpfs_use_passive_connections
= ret_ftpfs_use_passive_connections
;
786 ftpfs_use_passive_connections_over_proxy
= ret_ftpfs_use_passive_connections_over_proxy
;
787 g_free (ret_directory_timeout
);
797 QuickDialog Quick_input
;
798 QuickWidget quick_widgets
[] = {
799 { quick_input
, 6, 57, 2, 0, "", 50, 0, 0, 0, "input" },
800 { quick_label
, 3, 57, 2, 0, "", 0, 0, 0, 0, "label" },
806 Quick_input
.xlen
= 57;
807 Quick_input
.title
= _("Quick cd");
808 Quick_input
.help
= "[Quick cd]";
809 quick_widgets
[0].value
= 2; /* want cd like completion */
810 quick_widgets
[1].text
= _("cd");
811 quick_widgets
[1].y_divisions
=
812 quick_widgets
[0].y_divisions
= Quick_input
.ylen
= 5;
814 len
= strlen (quick_widgets
[1].text
);
816 quick_widgets
[0].relative_x
=
817 quick_widgets
[1].relative_x
+ len
+ 1;
819 Quick_input
.xlen
= len
+ quick_widgets
[0].hotkey_pos
+ 7;
820 quick_widgets
[0].x_divisions
=
821 quick_widgets
[1].x_divisions
= Quick_input
.xlen
;
823 Quick_input
.i18n
= 1;
824 Quick_input
.xpos
= 2;
825 Quick_input
.ypos
= LINES
- 2 - Quick_input
.ylen
;
826 quick_widgets
[0].str_result
= &my_str
;
828 Quick_input
.widgets
= quick_widgets
;
829 if (quick_dialog (&Quick_input
) != B_CANCEL
){
836 symlink_dialog (const char *existing
, const char *new, char **ret_existing
,
839 QuickDialog Quick_input
;
840 QuickWidget quick_widgets
[] = {
841 {quick_button
, 50, 80, 6, 8, N_("&Cancel"), 0, B_CANCEL
, 0, 0,
843 {quick_button
, 16, 80, 6, 8, N_("&OK"), 0, B_ENTER
, 0, 0, NULL
},
844 {quick_input
, 4, 80, 5, 8, "", 58, 0, 0, 0, "input-1"},
845 {quick_label
, 4, 80, 4, 8, N_("Symbolic link filename:"), 0, 0, 0,
847 {quick_input
, 4, 80, 3, 8, "", 58, 0, 0, 0, "input-2"},
848 {quick_label
, 4, 80, 2, 8,
849 N_("Existing filename (filename symlink will point to):"), 0, 0,
854 Quick_input
.xlen
= 64;
855 Quick_input
.ylen
= 12;
856 Quick_input
.title
= N_("Symbolic link");
857 Quick_input
.help
= "[File Menu]";
858 Quick_input
.i18n
= 0;
859 quick_widgets
[2].text
= new;
860 quick_widgets
[4].text
= existing
;
861 Quick_input
.xpos
= -1;
862 quick_widgets
[2].str_result
= ret_new
;
863 quick_widgets
[4].str_result
= ret_existing
;
865 Quick_input
.widgets
= quick_widgets
;
866 if (quick_dialog (&Quick_input
) == B_CANCEL
) {
868 *ret_existing
= NULL
;
872 #ifdef WITH_BACKGROUND
873 #define B_STOP (B_USER+1)
874 #define B_RESUME (B_USER+2)
875 #define B_KILL (B_USER+3)
877 static int JOBS_X
= 60;
879 static WListbox
*bg_list
;
880 static Dlg_head
*jobs_dlg
;
883 jobs_fill_listbox (void)
885 static const char *state_str
[2];
886 TaskList
*tl
= task_list
;
889 state_str
[0] = _("Running ");
890 state_str
[1] = _("Stopped");
896 s
= g_strconcat (state_str
[tl
->state
], " ", tl
->info
, (char *) NULL
);
897 listbox_add_item (bg_list
, LISTBOX_APPEND_AT_END
, 0, s
, (void *) tl
);
912 /* Get this instance information */
913 tl
= (TaskList
*) bg_list
->current
->data
;
916 if (action
== B_STOP
){
918 tl
->state
= Task_Stopped
;
919 } else if (action
== B_RESUME
){
921 tl
->state
= Task_Running
;
924 if (action
== B_KILL
){
929 unregister_task_running (tl
->pid
, tl
->fd
);
932 listbox_remove_list (bg_list
);
933 jobs_fill_listbox ();
935 /* This can be optimized to just redraw this widget :-) */
936 dlg_redraw (jobs_dlg
);
946 int (*callback
)(int);
950 {N_("&Stop"), 3, B_STOP
, task_cb
},
951 {N_("&Resume"), 12, B_RESUME
, task_cb
},
952 {N_("&Kill"), 23, B_KILL
, task_cb
},
953 {N_("&OK"), 35, B_CANCEL
, NULL
}
960 int n_buttons
= sizeof (job_buttons
) / sizeof (job_buttons
[0]);
963 static int i18n_flag
= 0;
966 int startx
= job_buttons
[0].xpos
;
969 for (i
= 0; i
< n_buttons
; i
++)
971 job_buttons
[i
].name
= _(job_buttons
[i
].name
);
973 len
= strlen (job_buttons
[i
].name
) + 4;
974 JOBS_X
= max (JOBS_X
, startx
+ len
+ 3);
976 job_buttons
[i
].xpos
= startx
;
980 /* Last button - Ok a.k.a. Cancel :) */
981 job_buttons
[n_buttons
- 1].xpos
=
982 JOBS_X
- strlen (job_buttons
[n_buttons
- 1].name
) - 7;
986 #endif /* ENABLE_NLS */
988 jobs_dlg
= create_dlg (0, 0, JOBS_Y
, JOBS_X
, dialog_colors
, NULL
,
989 "[Background jobs]", _("Background Jobs"),
990 DLG_CENTER
| DLG_REVERSE
);
992 bg_list
= listbox_new (2, 3, JOBS_X
-7, JOBS_Y
-9, 0);
993 add_widget (jobs_dlg
, bg_list
);
998 add_widget (jobs_dlg
, button_new (JOBS_Y
-4,
999 job_buttons
[i
].xpos
, job_buttons
[i
].value
,
1000 NORMAL_BUTTON
, job_buttons
[i
].name
,
1001 job_buttons
[i
].callback
));
1004 /* Insert all of task information in the list */
1005 jobs_fill_listbox ();
1008 destroy_dlg (jobs_dlg
);
1010 #endif /* WITH_BACKGROUND */
1013 struct smb_authinfo
*
1014 vfs_smb_get_authinfo (const char *host
, const char *share
, const char *domain
,
1017 static int dialog_x
= 44;
1018 enum { b0
= 3, dialog_y
= 12};
1019 struct smb_authinfo
*return_value
;
1020 static const char* labs
[] = {N_("Domain:"), N_("Username:"), N_("Password:")};
1021 static const char* buts
[] = {N_("&OK"), N_("&Cancel")};
1022 static int ilen
= 30, istart
= 14;
1025 WInput
*in_password
;
1031 static int i18n_flag
= 0;
1035 register int i
= sizeof(labs
)/sizeof(labs
[0]);
1040 l1
= strlen (labs
[i
] = _(labs
[i
]));
1044 i
= maxlen
+ ilen
+ 7;
1048 for (i
= sizeof(buts
)/sizeof(buts
[0]), l1
= 0; i
--; )
1050 l1
+= strlen (buts
[i
] = _(buts
[i
]));
1056 ilen
= dialog_x
- 7 - maxlen
; /* for the case of very long buttons :) */
1057 istart
= dialog_x
- 3 - ilen
;
1059 b2
= dialog_x
- (strlen(buts
[1]) + 6);
1064 #endif /* ENABLE_NLS */
1071 title
= g_strdup_printf (_("Password for \\\\%s\\%s"), host
, share
);
1073 auth_dlg
= create_dlg (0, 0, dialog_y
, dialog_x
, dialog_colors
, NULL
,
1074 "[Smb Authinfo]", title
, DLG_CENTER
| DLG_REVERSE
);
1078 in_user
= input_new (5, istart
, INPUT_COLOR
, ilen
, user
, "auth_name");
1079 add_widget (auth_dlg
, in_user
);
1081 in_domain
= input_new (3, istart
, INPUT_COLOR
, ilen
, domain
, "auth_domain");
1082 add_widget (auth_dlg
, in_domain
);
1083 add_widget (auth_dlg
, button_new (9, b2
, B_CANCEL
, NORMAL_BUTTON
,
1085 add_widget (auth_dlg
, button_new (9, b0
, B_ENTER
, DEFPUSH_BUTTON
,
1088 in_password
= input_new (7, istart
, INPUT_COLOR
, ilen
, "", "auth_password");
1089 in_password
->completion_flags
= 0;
1090 in_password
->is_password
= 1;
1091 add_widget (auth_dlg
, in_password
);
1093 add_widget (auth_dlg
, label_new (7, 3, labs
[2]));
1094 add_widget (auth_dlg
, label_new (5, 3, labs
[1]));
1095 add_widget (auth_dlg
, label_new (3, 3, labs
[0]));
1099 switch (auth_dlg
->ret_value
) {
1104 return_value
= g_new (struct smb_authinfo
, 1);
1106 return_value
->host
= g_strdup (host
);
1107 return_value
->share
= g_strdup (share
);
1108 return_value
->domain
= g_strdup (in_domain
->buffer
);
1109 return_value
->user
= g_strdup (in_user
->buffer
);
1110 return_value
->password
= g_strdup (in_password
->buffer
);
1114 destroy_dlg (auth_dlg
);
1116 return return_value
;
1118 #endif /* WITH_SMBFS */