1 /* Some misc dialog boxes for the program.
3 Copyright (C) 1994, 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 2005, 2006 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. */
31 #include <sys/types.h>
36 #include "win.h" /* Our window tools */
37 #include "color.h" /* Color definitions */
38 #include "dialog.h" /* The nice dialog manager */
39 #include "widget.h" /* The widgets for the nice dialog manager */
41 #include "setup.h" /* For profile_name */
42 #include "profile.h" /* Load/save user formats */
43 #include "key.h" /* XCTRL and ALT macros */
44 #include "command.h" /* For cmdline */
48 #include "main.h" /* For the confirm_* variables */
50 #include "layout.h" /* for get_nth_panel_name proto */
51 #include "background.h" /* task_list */
55 #include "selcodepage.h"
59 # include "../vfs/ftpfs.h"
63 #include "../vfs/gc.h"
66 static int DISPLAY_X
= 45, DISPLAY_Y
= 14;
69 static WRadio
*my_radio
;
71 static WInput
*status
;
72 static WCheck
*check_status
;
73 static int current_mode
;
75 static char **displays_status
;
77 /* Controls whether the array strings have been translated */
78 static const char *displays
[LIST_TYPES
] = {
79 N_("&Full file list"),
80 N_("&Brief file list"),
81 N_("&Long file list"),
85 /* Index in displays[] for "user defined" */
88 static int user_hotkey
= 'u';
91 display_callback (struct Dlg_head
*h
, dlg_msg_t msg
, int parm
)
95 if (dlg_widget_active (my_radio
)) {
96 assign_text (status
, displays_status
[my_radio
->sel
]);
97 input_set_point (status
, 0);
103 if (dlg_widget_active (my_radio
)) {
104 assign_text (status
, displays_status
[my_radio
->sel
]);
109 if (dlg_widget_active (user
)) {
110 h
->ret_value
= B_USER
+ 6;
115 if (dlg_widget_active (status
)) {
116 h
->ret_value
= B_USER
+ 7;
122 if (tolower (parm
) == user_hotkey
&& dlg_widget_active (user
)
123 && dlg_widget_active (status
)) {
125 dlg_select_widget (my_radio
); /* force redraw */
126 dlg_select_widget (user
);
129 return MSG_NOT_HANDLED
;
132 return default_dlg_callback (h
, msg
, parm
);
137 display_init (int radio_sel
, char *init_text
, int _check_status
,
140 static const char *display_title
= N_("Listing mode");
141 static int i18n_displays_flag
;
142 const char *user_mini_status
= _("user &Mini status");
143 const char *ok_button
= _("&OK");
144 const char *cancel_button
= _("&Cancel");
146 static int button_start
= 30;
148 displays_status
= _status
;
150 if (!i18n_displays_flag
) {
151 int i
, l
, maxlen
= 0;
154 display_title
= _(display_title
);
155 for (i
= 0; i
< LIST_TYPES
; i
++) {
156 displays
[i
] = _(displays
[i
]);
157 if ((l
= strlen (displays
[i
])) > maxlen
)
161 i
= strlen (ok_button
) + 5;
162 l
= strlen (cancel_button
) + 3;
169 i
= strlen (user_mini_status
) + 13;
173 i
= strlen (display_title
) + 10;
177 button_start
= DISPLAY_X
- l
- 5;
179 /* get hotkey of user-defined format string */
180 cp
= strchr (displays
[USER_TYPE
], '&');
181 if (cp
!= NULL
&& *++cp
!= '\0')
182 user_hotkey
= tolower ((unsigned char) *cp
);
184 i18n_displays_flag
= 1;
186 dd
= create_dlg (0, 0, DISPLAY_Y
, DISPLAY_X
, dialog_colors
,
187 display_callback
, "[Listing Mode...]", display_title
,
188 DLG_CENTER
| DLG_REVERSE
);
191 button_new (4, button_start
, B_CANCEL
, NORMAL_BUTTON
,
195 button_new (3, button_start
, B_ENTER
, DEFPUSH_BUTTON
,
199 input_new (10, 9, INPUT_COLOR
, DISPLAY_X
- 14, _status
[radio_sel
],
201 add_widget (dd
, status
);
202 input_set_point (status
, 0);
205 check_new (9, 5, _check_status
, user_mini_status
);
206 add_widget (dd
, check_status
);
209 input_new (7, 9, INPUT_COLOR
, DISPLAY_X
- 14, init_text
,
211 add_widget (dd
, user
);
212 input_set_point (user
, 0);
214 my_radio
= radio_new (3, 5, LIST_TYPES
, displays
);
215 my_radio
->sel
= my_radio
->pos
= current_mode
;
216 add_widget (dd
, my_radio
);
220 display_box (WPanel
*panel
, char **userp
, char **minip
, int *use_msformat
, int num
)
223 char *section
= NULL
;
227 p
= get_nth_panel_name (num
);
228 panel
= g_new (WPanel
, 1);
229 panel
->list_type
= list_full
;
230 panel
->user_format
= g_strdup (DEFAULT_USER_FORMAT
);
231 panel
->user_mini_status
= 0;
232 for (i
= 0; i
< LIST_TYPES
; i
++)
233 panel
->user_status_format
[i
] = g_strdup (DEFAULT_USER_FORMAT
);
234 section
= g_strconcat ("Temporal:", p
, (char *) NULL
);
235 if (!profile_has_section (section
, profile_name
)) {
237 section
= g_strdup (p
);
239 panel_load_setup (panel
, section
);
243 current_mode
= panel
->list_type
;
244 display_init (current_mode
, panel
->user_format
,
245 panel
->user_mini_status
, panel
->user_status_format
);
252 g_free (panel
->user_format
);
253 for (i
= 0; i
< LIST_TYPES
; i
++)
254 g_free (panel
->user_status_format
[i
]);
258 if (dd
->ret_value
!= B_CANCEL
){
259 result
= my_radio
->sel
;
260 *userp
= g_strdup (user
->buffer
);
261 *minip
= g_strdup (status
->buffer
);
262 *use_msformat
= check_status
->state
& C_BOOL
;
269 static int SORT_X
= 40, SORT_Y
= 14;
271 static const char *sort_orders_names
[SORT_TYPES
];
274 sort_box (sortfn
*sort_fn
, int *reverse
, int *case_sensitive
)
278 WCheck
*c
, *case_sense
;
280 const char *ok_button
= _("&OK");
281 const char *cancel_button
= _("&Cancel");
282 const char *reverse_label
= _("&Reverse");
283 const char *case_label
= _("case sensi&tive");
284 const char *sort_title
= _("Sort order");
286 static int i18n_sort_flag
= 0, check_pos
= 0, button_pos
= 0;
288 if (!i18n_sort_flag
) {
290 for (i
= SORT_TYPES
- 1; i
>= 0; i
--) {
291 sort_orders_names
[i
] = _(sort_orders
[i
].sort_name
);
292 r
= strlen (sort_orders_names
[i
]);
297 check_pos
= maxlen
+ 9;
299 r
= strlen (reverse_label
) + 4;
300 i
= strlen (case_label
) + 4;
304 l
= strlen (ok_button
) + 6;
305 i
= strlen (cancel_button
) + 4;
309 i
= check_pos
+ max (r
, l
) + 2;
314 i
= strlen (sort_title
) + 6;
318 button_pos
= SORT_X
- l
- 2;
325 for (i
= 0; i
< SORT_TYPES
; i
++)
326 if ((sortfn
*) (sort_orders
[i
].sort_fn
) == sort_fn
) {
331 dd
= create_dlg (0, 0, SORT_Y
, SORT_X
, dialog_colors
, NULL
,
332 "[Sort Order...]", sort_title
, DLG_CENTER
| DLG_REVERSE
);
335 button_new (10, button_pos
, B_CANCEL
, NORMAL_BUTTON
,
339 button_new (9, button_pos
, B_ENTER
, DEFPUSH_BUTTON
,
342 case_sense
= check_new (4, check_pos
, *case_sensitive
, case_label
);
343 add_widget (dd
, case_sense
);
344 c
= check_new (3, check_pos
, *reverse
, reverse_label
);
347 my_radio
= radio_new (3, 3, SORT_TYPES
, sort_orders_names
);
348 my_radio
->sel
= my_radio
->pos
= current_mode
;
350 add_widget (dd
, my_radio
);
355 result
= (sortfn
*) sort_orders
[my_radio
->sel
].sort_fn
;
356 *reverse
= c
->state
& C_BOOL
;
357 *case_sensitive
= case_sense
->state
& C_BOOL
;
368 static int my_delete
;
369 static int my_directory_hotlist_delete
;
370 static int my_overwrite
;
371 static int my_execute
;
374 static QuickWidget conf_widgets
[] = {
375 { quick_button
, 4, 6, 4, CONFY
, N_("&Cancel"),
376 0, B_CANCEL
, 0, 0, NULL
},
377 { quick_button
, 4, 6, 3, CONFY
, N_("&OK"),
378 0, B_ENTER
, 0, 0, NULL
},
380 { quick_checkbox
, 1, 13, 7, CONFY
, N_(" confirm di&Rectory hotlist delete "),
381 11, 0, &my_directory_hotlist_delete
, NULL
, NULL
},
382 { quick_checkbox
, 1, 13, 6, CONFY
, N_(" confirm &Exit "),
383 9, 0, &my_exit
, 0, NULL
},
384 { quick_checkbox
, 1, 13, 5, CONFY
, N_(" confirm e&Xecute "),
385 10, 0, &my_execute
, 0, NULL
},
386 { quick_checkbox
, 1, 13, 4, CONFY
, N_(" confirm o&Verwrite "),
387 10, 0, &my_overwrite
, 0, NULL
},
388 { quick_checkbox
, 1, 13, 3, CONFY
, N_(" confirm &Delete "),
389 9, 0, &my_delete
, 0, NULL
},
393 static QuickDialog confirmation
=
394 { CONFX
, CONFY
, -1, -1, N_(" Confirmation "), "[Confirmation]",
403 static int i18n_flag
= 0;
407 register int i
= sizeof(conf_widgets
)/sizeof(QuickWidget
) - 1;
411 conf_widgets
[i
].text
= _(conf_widgets
[i
].text
);
412 l1
= strlen (conf_widgets
[i
].text
) + 3;
418 * If buttons start on 4/6, checkboxes (with some add'l space)
419 * must take not more than it.
421 confirmation
.xlen
= (maxlen
+ 5) * 6 / 4;
424 * And this for the case when buttons with some space to the right
425 * do not fit within 2/6
427 l1
= strlen (conf_widgets
[0].text
) + 3;
428 i
= strlen (conf_widgets
[1].text
) + 5;
432 i
= (l1
+ 3) * 6 / 2;
433 if (i
> confirmation
.xlen
)
434 confirmation
.xlen
= i
;
436 confirmation
.title
= _(confirmation
.title
);
438 i18n_flag
= confirmation
.i18n
= 1;
441 #endif /* ENABLE_NLS */
443 my_delete
= confirm_delete
;
444 my_overwrite
= confirm_overwrite
;
445 my_execute
= confirm_execute
;
446 my_exit
= confirm_exit
;
447 my_directory_hotlist_delete
= confirm_directory_hotlist_delete
;
449 if (quick_dialog (&confirmation
) != B_CANCEL
){
450 confirm_delete
= my_delete
;
451 confirm_overwrite
= my_overwrite
;
452 confirm_execute
= my_execute
;
453 confirm_exit
= my_exit
;
454 confirm_directory_hotlist_delete
= my_directory_hotlist_delete
;
467 static const char *display_bits_str
[] =
468 { N_("Full 8 bits output"), N_("ISO 8859-1"), N_("7 bits") };
470 static QuickWidget display_widgets
[] = {
471 { quick_button
, 4, 6, 4, DISPY
, N_("&Cancel"),
472 0, B_CANCEL
, 0, 0, NULL
},
473 { quick_button
, 4, 6, 3, DISPY
, N_("&OK"),
474 0, B_ENTER
, 0, 0, NULL
},
475 { quick_checkbox
, 4, DISPX
, 7, DISPY
, N_("F&ull 8 bits input"),
476 0, 0, &new_meta
, 0, NULL
},
477 { quick_radio
, 4, DISPX
, 3, DISPY
, "", 3, 0,
478 &new_mode
, const_cast(char **, display_bits_str
), NULL
},
482 static QuickDialog display_bits
=
483 { DISPX
, DISPY
, -1, -1, N_(" Display bits "), "[Display bits]",
484 display_widgets
, 0 };
487 display_bits_box (void)
492 static int i18n_flag
= 0;
497 for (i
= 0; i
< 3; i
++)
499 display_widgets
[i
].text
= _(display_widgets
[i
].text
);
500 display_bits_str
[i
] = _(display_bits_str
[i
]);
501 l1
= strlen (display_bits_str
[i
]);
505 l1
= strlen (display_widgets
[2].text
);
510 display_bits
.xlen
= (maxlen
+ 5) * 6 / 4;
512 /* See above confirm_box */
513 l1
= strlen (display_widgets
[0].text
) + 3;
514 i
= strlen (display_widgets
[1].text
) + 5;
518 i
= (l1
+ 3) * 6 / 2;
519 if (i
> display_bits
.xlen
)
520 display_bits
.xlen
= i
;
522 display_bits
.title
= _(display_bits
.title
);
523 i18n_flag
= display_bits
.i18n
= 1;
526 #endif /* ENABLE_NLS */
530 else if (eight_bit_clean
)
535 display_widgets
[3].value
= current_mode
;
536 new_meta
= !use_8th_bit_as_meta
;
537 if (quick_dialog (&display_bits
) != B_ENTER
)
540 eight_bit_clean
= new_mode
< 2;
541 full_eight_bits
= new_mode
== 0;
543 meta (stdscr
, eight_bit_clean
);
545 SLsmg_Display_Eight_Bit
= full_eight_bits
? 128 : 160;
547 use_8th_bit_as_meta
= !new_meta
;
551 #else /* HAVE_CHARSET */
554 static int new_display_codepage
;
556 static WLabel
*cplabel
;
557 static WCheck
*inpcheck
;
560 sel_charset_button (int action
)
564 new_display_codepage
= select_charset (new_display_codepage
, 1);
565 cpname
= (new_display_codepage
< 0)
567 : codepages
[new_display_codepage
].name
;
569 /* avoid strange bug with label repainting */
570 g_snprintf (buf
, sizeof (buf
), "%-27s", cpname
);
571 label_set_text (cplabel
, buf
);
576 init_disp_bits_box (void)
584 create_dlg (0, 0, DISPY
, DISPX
, dialog_colors
, NULL
,
585 "[Display bits]", _(" Display bits "), DLG_CENTER
| DLG_REVERSE
);
587 add_widget (dbits_dlg
,
588 label_new (3, 4, _("Input / display codepage:")));
590 cpname
= (new_display_codepage
< 0)
592 : codepages
[new_display_codepage
].name
;
593 cplabel
= label_new (4, 4, cpname
);
594 add_widget (dbits_dlg
, cplabel
);
596 add_widget (dbits_dlg
,
597 button_new (DISPY
- 3, DISPX
/ 2 + 3, B_CANCEL
,
598 NORMAL_BUTTON
, _("&Cancel"), 0));
599 add_widget (dbits_dlg
,
600 button_new (DISPY
- 3, 7, B_ENTER
, NORMAL_BUTTON
, _("&OK"),
604 check_new (6, 4, !use_8th_bit_as_meta
, _("F&ull 8 bits input"));
605 add_widget (dbits_dlg
, inpcheck
);
607 cpname
= _("&Select");
608 add_widget (dbits_dlg
,
609 button_new (4, DISPX
- 8 - strlen (cpname
), B_USER
,
610 NORMAL_BUTTON
, cpname
, sel_charset_button
));
616 display_bits_box (void)
619 new_display_codepage
= display_codepage
;
621 application_keypad_mode ();
622 dbits_dlg
= init_disp_bits_box ();
626 if (dbits_dlg
->ret_value
== B_ENTER
) {
628 display_codepage
= new_display_codepage
;
630 init_translation_table (source_codepage
, display_codepage
);
632 message (1, MSG_ERROR
, "%s", errmsg
);
634 meta (stdscr
, display_codepage
!= 0);
636 SLsmg_Display_Eight_Bit
= (display_codepage
!= 0
637 && display_codepage
!= 1) ? 128 : 160;
639 use_8th_bit_as_meta
= !(inpcheck
->state
& C_BOOL
);
641 destroy_dlg (dbits_dlg
);
645 #endif /* HAVE_CHARSET */
652 tree_callback (struct Dlg_head
*h
, dlg_msg_t msg
, int parm
)
657 /* The enter key will be processed by the tree widget */
659 h
->ret_value
= B_ENTER
;
665 return default_dlg_callback (h
, msg
, parm
);
669 /* Show tree in a box, not on a panel */
671 tree_box (const char *current_dir
)
678 /* Create the components */
679 dlg
= create_dlg (0, 0, TREE_Y
, TREE_X
, dialog_colors
,
680 tree_callback
, "[Directory Tree]", NULL
, DLG_CENTER
| DLG_REVERSE
);
681 mytree
= tree_new (0, 2, 2, TREE_Y
- 6, TREE_X
- 5);
682 add_widget (dlg
, mytree
);
683 bar
= buttonbar_new(1);
684 add_widget (dlg
, bar
);
685 ((Widget
*) bar
)->x
= 0;
686 ((Widget
*) bar
)->y
= LINES
- 1;
689 if (dlg
->ret_value
== B_ENTER
)
690 val
= g_strdup (tree_selected_name (mytree
));
700 #if defined(USE_NETCODE)
702 #define VFS_WIDGETBASE 10
705 #define VFS_WIDGETBASE 0
710 static char *ret_timeout
;
712 #if defined(USE_NETCODE)
713 static char *ret_passwd
;
714 static char *ret_directory_timeout
;
715 static char *ret_ftp_proxy
;
716 static int ret_use_netrc
;
717 static int ret_ftpfs_use_passive_connections
;
718 static int ret_ftpfs_use_passive_connections_over_proxy
;
721 static QuickWidget confvfs_widgets
[] = {
722 { quick_button
, 30, VFSX
, VFSY
- 3, VFSY
, N_("&Cancel"),
723 0, B_CANCEL
, 0, 0, NULL
},
724 { quick_button
, 12, VFSX
, VFSY
- 3, VFSY
, N_("&OK"),
725 0, B_ENTER
, 0, 0, NULL
},
726 #if defined(USE_NETCODE)
727 { quick_checkbox
, 4, VFSX
, 12, VFSY
, N_("Use passive mode over pro&xy"), 0, 0,
728 &ret_ftpfs_use_passive_connections_over_proxy
, 0, NULL
},
729 { quick_checkbox
, 4, VFSX
, 11, VFSY
, N_("Use &passive mode"), 0, 0,
730 &ret_ftpfs_use_passive_connections
, 0, NULL
},
731 { quick_checkbox
, 4, VFSX
, 10, VFSY
, N_("&Use ~/.netrc"), 0, 0,
732 &ret_use_netrc
, 0, NULL
},
733 { quick_input
, 4, VFSX
, 9, VFSY
, "", 48, 0, 0, &ret_ftp_proxy
,
735 { quick_checkbox
, 4, VFSX
, 8, VFSY
, N_("&Always use ftp proxy"), 0, 0,
736 &ftpfs_always_use_proxy
, 0, NULL
},
737 { quick_label
, 49, VFSX
, 7, VFSY
, N_("sec"),
739 { quick_input
, 38, VFSX
, 7, VFSY
, "", 10, 0, 0, &ret_directory_timeout
,
741 { quick_label
, 4, VFSX
, 7, VFSY
, N_("ftpfs directory cache timeout:"),
743 { quick_input
, 4, VFSX
, 6, VFSY
, "", 48, 0, 0, &ret_passwd
,
745 { quick_label
, 4, VFSX
, 5, VFSY
, N_("ftp anonymous password:"),
748 { quick_label
, 49, VFSX
, 3, VFSY
, "sec",
750 { quick_input
, 38, VFSX
, 3, VFSY
, "", 10, 0, 0, &ret_timeout
,
752 { quick_label
, 4, VFSX
, 3, VFSY
, N_("Timeout for freeing VFSs:"),
757 static QuickDialog confvfs_dlg
=
758 { VFSX
, VFSY
, -1, -1, N_(" Virtual File System Setting "),
759 "[Virtual FS]", confvfs_widgets
, 0 };
764 char buffer2
[BUF_TINY
];
765 #if defined(USE_NETCODE)
766 char buffer3
[BUF_TINY
];
768 ret_use_netrc
= use_netrc
;
769 ret_ftpfs_use_passive_connections
= ftpfs_use_passive_connections
;
770 ret_ftpfs_use_passive_connections_over_proxy
= ftpfs_use_passive_connections_over_proxy
;
771 g_snprintf(buffer3
, sizeof (buffer3
), "%i", ftpfs_directory_timeout
);
772 confvfs_widgets
[8].text
= buffer3
;
773 confvfs_widgets
[10].text
= ftpfs_anonymous_passwd
;
774 confvfs_widgets
[5].text
= ftpfs_proxy_host
;
776 g_snprintf (buffer2
, sizeof (buffer2
), "%i", vfs_timeout
);
777 confvfs_widgets
[3 + VFS_WIDGETBASE
].text
= buffer2
;
779 if (quick_dialog (&confvfs_dlg
) != B_CANCEL
) {
780 vfs_timeout
= atoi (ret_timeout
);
781 g_free (ret_timeout
);
782 if (vfs_timeout
< 0 || vfs_timeout
> 10000)
784 #if defined(USE_NETCODE)
785 g_free (ftpfs_anonymous_passwd
);
786 ftpfs_anonymous_passwd
= ret_passwd
;
787 g_free (ftpfs_proxy_host
);
788 ftpfs_proxy_host
= ret_ftp_proxy
;
789 ftpfs_directory_timeout
= atoi(ret_directory_timeout
);
790 use_netrc
= ret_use_netrc
;
791 ftpfs_use_passive_connections
= ret_ftpfs_use_passive_connections
;
792 ftpfs_use_passive_connections_over_proxy
= ret_ftpfs_use_passive_connections_over_proxy
;
793 g_free (ret_directory_timeout
);
803 QuickDialog Quick_input
;
804 QuickWidget quick_widgets
[] = {
805 { quick_input
, 6, 57, 2, 0, "", 50, 0, 0, 0, "input" },
806 { quick_label
, 3, 57, 2, 0, "", 0, 0, 0, 0, NULL
},
812 Quick_input
.xlen
= 57;
813 Quick_input
.title
= _("Quick cd");
814 Quick_input
.help
= "[Quick cd]";
815 quick_widgets
[0].value
= 2; /* want cd like completion */
816 quick_widgets
[1].text
= _("cd");
817 quick_widgets
[1].y_divisions
=
818 quick_widgets
[0].y_divisions
= Quick_input
.ylen
= 5;
820 len
= strlen (quick_widgets
[1].text
);
822 quick_widgets
[0].relative_x
=
823 quick_widgets
[1].relative_x
+ len
+ 1;
825 Quick_input
.xlen
= len
+ quick_widgets
[0].hotkey_pos
+ 7;
826 quick_widgets
[0].x_divisions
=
827 quick_widgets
[1].x_divisions
= Quick_input
.xlen
;
829 Quick_input
.i18n
= 1;
830 Quick_input
.xpos
= 2;
831 Quick_input
.ypos
= LINES
- 2 - Quick_input
.ylen
;
832 quick_widgets
[0].str_result
= &my_str
;
834 Quick_input
.widgets
= quick_widgets
;
835 if (quick_dialog (&Quick_input
) != B_CANCEL
){
842 symlink_dialog (const char *existing
, const char *new, char **ret_existing
,
845 QuickDialog Quick_input
;
846 QuickWidget quick_widgets
[] = {
847 {quick_button
, 50, 80, 6, 8, N_("&Cancel"), 0, B_CANCEL
, 0, 0,
849 {quick_button
, 16, 80, 6, 8, N_("&OK"), 0, B_ENTER
, 0, 0, NULL
},
850 {quick_input
, 4, 80, 5, 8, "", 58, 0, 0, 0, "input-1"},
851 {quick_label
, 4, 80, 4, 8, N_("Symbolic link filename:"), 0, 0, 0,
853 {quick_input
, 4, 80, 3, 8, "", 58, 0, 0, 0, "input-2"},
854 {quick_label
, 4, 80, 2, 8,
855 N_("Existing filename (filename symlink will point to):"), 0, 0,
860 Quick_input
.xlen
= 64;
861 Quick_input
.ylen
= 12;
862 Quick_input
.title
= N_("Symbolic link");
863 Quick_input
.help
= "[File Menu]";
864 Quick_input
.i18n
= 0;
865 quick_widgets
[2].text
= new;
866 quick_widgets
[4].text
= existing
;
867 Quick_input
.xpos
= -1;
868 quick_widgets
[2].str_result
= ret_new
;
869 quick_widgets
[4].str_result
= ret_existing
;
871 Quick_input
.widgets
= quick_widgets
;
872 if (quick_dialog (&Quick_input
) == B_CANCEL
) {
874 *ret_existing
= NULL
;
878 #ifdef WITH_BACKGROUND
879 #define B_STOP (B_USER+1)
880 #define B_RESUME (B_USER+2)
881 #define B_KILL (B_USER+3)
883 static int JOBS_X
= 60;
885 static WListbox
*bg_list
;
886 static Dlg_head
*jobs_dlg
;
889 jobs_fill_listbox (void)
891 static const char *state_str
[2];
892 TaskList
*tl
= task_list
;
895 state_str
[0] = _("Running ");
896 state_str
[1] = _("Stopped");
902 s
= g_strconcat (state_str
[tl
->state
], " ", tl
->info
, (char *) NULL
);
903 listbox_add_item (bg_list
, LISTBOX_APPEND_AT_END
, 0, s
, (void *) tl
);
918 /* Get this instance information */
919 tl
= (TaskList
*) bg_list
->current
->data
;
922 if (action
== B_STOP
){
924 tl
->state
= Task_Stopped
;
925 } else if (action
== B_RESUME
){
927 tl
->state
= Task_Running
;
930 if (action
== B_KILL
){
935 unregister_task_running (tl
->pid
, tl
->fd
);
938 listbox_remove_list (bg_list
);
939 jobs_fill_listbox ();
941 /* This can be optimized to just redraw this widget :-) */
942 dlg_redraw (jobs_dlg
);
952 int (*callback
)(int);
956 {N_("&Stop"), 3, B_STOP
, task_cb
},
957 {N_("&Resume"), 12, B_RESUME
, task_cb
},
958 {N_("&Kill"), 23, B_KILL
, task_cb
},
959 {N_("&OK"), 35, B_CANCEL
, NULL
}
966 int n_buttons
= sizeof (job_buttons
) / sizeof (job_buttons
[0]);
969 static int i18n_flag
= 0;
972 int startx
= job_buttons
[0].xpos
;
975 for (i
= 0; i
< n_buttons
; i
++)
977 job_buttons
[i
].name
= _(job_buttons
[i
].name
);
979 len
= strlen (job_buttons
[i
].name
) + 4;
980 JOBS_X
= max (JOBS_X
, startx
+ len
+ 3);
982 job_buttons
[i
].xpos
= startx
;
986 /* Last button - Ok a.k.a. Cancel :) */
987 job_buttons
[n_buttons
- 1].xpos
=
988 JOBS_X
- strlen (job_buttons
[n_buttons
- 1].name
) - 7;
992 #endif /* ENABLE_NLS */
994 jobs_dlg
= create_dlg (0, 0, JOBS_Y
, JOBS_X
, dialog_colors
, NULL
,
995 "[Background jobs]", _("Background Jobs"),
996 DLG_CENTER
| DLG_REVERSE
);
998 bg_list
= listbox_new (2, 3, JOBS_X
-7, JOBS_Y
-9, 0);
999 add_widget (jobs_dlg
, bg_list
);
1004 add_widget (jobs_dlg
, button_new (JOBS_Y
-4,
1005 job_buttons
[i
].xpos
, job_buttons
[i
].value
,
1006 NORMAL_BUTTON
, job_buttons
[i
].name
,
1007 job_buttons
[i
].callback
));
1010 /* Insert all of task information in the list */
1011 jobs_fill_listbox ();
1014 destroy_dlg (jobs_dlg
);
1016 #endif /* WITH_BACKGROUND */
1019 struct smb_authinfo
*
1020 vfs_smb_get_authinfo (const char *host
, const char *share
, const char *domain
,
1023 static int dialog_x
= 44;
1024 enum { b0
= 3, dialog_y
= 12};
1025 struct smb_authinfo
*return_value
;
1026 static const char* labs
[] = {N_("Domain:"), N_("Username:"), N_("Password:")};
1027 static const char* buts
[] = {N_("&OK"), N_("&Cancel")};
1028 static int ilen
= 30, istart
= 14;
1031 WInput
*in_password
;
1037 static int i18n_flag
= 0;
1041 register int i
= sizeof(labs
)/sizeof(labs
[0]);
1046 l1
= strlen (labs
[i
] = _(labs
[i
]));
1050 i
= maxlen
+ ilen
+ 7;
1054 for (i
= sizeof(buts
)/sizeof(buts
[0]), l1
= 0; i
--; )
1056 l1
+= strlen (buts
[i
] = _(buts
[i
]));
1062 ilen
= dialog_x
- 7 - maxlen
; /* for the case of very long buttons :) */
1063 istart
= dialog_x
- 3 - ilen
;
1065 b2
= dialog_x
- (strlen(buts
[1]) + 6);
1070 #endif /* ENABLE_NLS */
1077 title
= g_strdup_printf (_("Password for \\\\%s\\%s"), host
, share
);
1079 auth_dlg
= create_dlg (0, 0, dialog_y
, dialog_x
, dialog_colors
, NULL
,
1080 "[Smb Authinfo]", title
, DLG_CENTER
| DLG_REVERSE
);
1084 in_user
= input_new (5, istart
, INPUT_COLOR
, ilen
, user
, "auth_name");
1085 add_widget (auth_dlg
, in_user
);
1087 in_domain
= input_new (3, istart
, INPUT_COLOR
, ilen
, domain
, "auth_domain");
1088 add_widget (auth_dlg
, in_domain
);
1089 add_widget (auth_dlg
, button_new (9, b2
, B_CANCEL
, NORMAL_BUTTON
,
1091 add_widget (auth_dlg
, button_new (9, b0
, B_ENTER
, DEFPUSH_BUTTON
,
1094 in_password
= input_new (7, istart
, INPUT_COLOR
, ilen
, "", "auth_password");
1095 in_password
->completion_flags
= 0;
1096 in_password
->is_password
= 1;
1097 add_widget (auth_dlg
, in_password
);
1099 add_widget (auth_dlg
, label_new (7, 3, labs
[2]));
1100 add_widget (auth_dlg
, label_new (5, 3, labs
[1]));
1101 add_widget (auth_dlg
, label_new (3, 3, labs
[0]));
1105 switch (auth_dlg
->ret_value
) {
1110 return_value
= g_new (struct smb_authinfo
, 1);
1112 return_value
->host
= g_strdup (host
);
1113 return_value
->share
= g_strdup (share
);
1114 return_value
->domain
= g_strdup (in_domain
->buffer
);
1115 return_value
->user
= g_strdup (in_user
->buffer
);
1116 return_value
->password
= g_strdup (in_password
->buffer
);
1120 destroy_dlg (auth_dlg
);
1122 return return_value
;
1124 #endif /* WITH_SMBFS */