2 Some misc dialog boxes for the program.
4 Copyright (C) 1994, 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
5 2005, 2006, 2009, 2010, 2011
6 The Free Software Foundation, Inc.
9 Miguel de Icaza, 1994, 1995
12 This file is part of the Midnight Commander.
14 The Midnight Commander is free software: you can redistribute it
15 and/or modify it under the terms of the GNU General Public License as
16 published by the Free Software Foundation, either version 3 of the License,
17 or (at your option) any later version.
19 The Midnight Commander is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with this program. If not, see <http://www.gnu.org/licenses/>.
29 * \brief Source: Some misc dialog boxes for the program
39 #include <sys/types.h>
42 #include "lib/global.h"
44 #include "lib/tty/tty.h"
45 #include "lib/tty/key.h" /* XCTRL and ALT macros */
46 #include "lib/skin.h" /* INPUT_COLOR */
47 #include "lib/mcconfig.h" /* Load/save user formats */
48 #include "lib/strutil.h"
50 #include "lib/vfs/vfs.h"
52 #include "src/vfs/ftpfs/ftpfs.h"
53 #endif /* ENABLE_VFS_FTP */
55 #include "src/vfs/smbfs/smbfs.h"
56 #endif /* ENABLE_VFS_SMB */
58 #include "lib/util.h" /* Q_() */
59 #include "lib/widget.h"
61 #include "src/setup.h" /* For profile_name */
62 #include "src/background.h" /* task_list */
65 #include "lib/charsets.h"
66 #include "src/selcodepage.h"
69 #include "command.h" /* For cmdline */
71 #include "panel.h" /* LIST_TYPES */
73 #include "layout.h" /* for get_nth_panel_name proto */
77 /*** global variables ****************************************************************************/
79 /*** file scope macro definitions ****************************************************************/
88 #endif /* ENABLE_VFS_FTP */
89 #endif /* ENABLE_VFS */
91 #ifdef WITH_BACKGROUND
92 #define B_STOP (B_USER+1)
93 #define B_RESUME (B_USER+2)
94 #define B_KILL (B_USER+3)
96 #endif /* WITH_BACKGROUND */
98 /*** file scope type declarations ****************************************************************/
100 /*** file scope variables ************************************************************************/
102 static WRadio
*display_radio
;
103 static WInput
*display_user_format
;
104 static WInput
*display_mini_status
;
105 static WCheck
*display_check_status
;
106 static char **displays_status
;
107 static int display_user_hotkey
= 'u';
110 static int new_display_codepage
;
111 static WLabel
*cplabel
;
112 static WCheck
*inpcheck
;
113 #endif /* HAVE_CHARSET */
116 static char *ret_timeout
;
117 #ifdef ENABLE_VFS_FTP
118 static char *ret_ftp_proxy
;
119 static char *ret_passwd
;
120 static char *ret_directory_timeout
;
121 #endif /* ENABLE_VFS_FTP */
122 #endif /* ENABLE_VFS */
124 #ifdef WITH_BACKGROUND
125 static int JOBS_X
= 60;
126 static WListbox
*bg_list
;
127 static Dlg_head
*jobs_dlg
;
129 static int task_cb (WButton
* button
, int action
);
141 { N_("&Stop"), 3, B_STOP
, task_cb
},
142 { N_("&Resume"), 12, B_RESUME
, task_cb
},
143 { N_("&Kill"), 23, B_KILL
, task_cb
},
144 { N_("&OK"), 35, B_CANCEL
, NULL
}
148 #endif /* WITH_BACKGROUND */
150 /*** file scope functions ************************************************************************/
151 /* --------------------------------------------------------------------------------------------- */
154 display_callback (Dlg_head
* h
, Widget
* sender
, dlg_msg_t msg
, int parm
, void *data
)
161 if (dlg_widget_active (display_radio
))
163 input_assign_text (display_mini_status
, displays_status
[display_radio
->sel
]);
168 if (dlg_widget_active (display_user_format
))
170 h
->ret_value
= B_USER
+ 6;
175 if (dlg_widget_active (display_mini_status
))
177 h
->ret_value
= B_USER
+ 7;
183 if ((g_ascii_tolower (parm
) == display_user_hotkey
)
184 && dlg_widget_active (display_user_format
) && dlg_widget_active (display_mini_status
))
186 display_radio
->pos
= display_radio
->sel
= 3;
187 dlg_select_widget (display_radio
); /* force redraw */
188 h
->callback (h
, (Widget
*) display_radio
, DLG_ACTION
, 0, NULL
);
191 return MSG_NOT_HANDLED
;
194 if (sender
== (Widget
*) display_radio
)
196 if (!(display_check_status
->state
& C_BOOL
))
197 input_assign_text (display_mini_status
, displays_status
[display_radio
->sel
]);
198 input_update (display_mini_status
, FALSE
);
199 input_update (display_user_format
, FALSE
);
200 widget_disable (display_user_format
->widget
, display_radio
->sel
!= 3);
204 if (sender
== (Widget
*) display_check_status
)
206 if (display_check_status
->state
& C_BOOL
)
208 widget_disable (display_mini_status
->widget
, FALSE
);
209 input_assign_text (display_mini_status
, displays_status
[3]);
213 widget_disable (display_mini_status
->widget
, TRUE
);
214 input_assign_text (display_mini_status
, displays_status
[display_radio
->sel
]);
216 input_update (display_mini_status
, FALSE
);
220 return MSG_NOT_HANDLED
;
223 return default_dlg_callback (h
, sender
, msg
, parm
, data
);
227 /* --------------------------------------------------------------------------------------------- */
230 display_init (int radio_sel
, char *init_text
, int _check_status
, char **_status
)
232 int dlg_width
= 48, dlg_height
= 15;
235 /* Controls whether the array strings have been translated */
236 const char *displays
[LIST_TYPES
] = {
237 N_("&Full file list"),
238 N_("&Brief file list"),
239 N_("&Long file list"),
243 /* Index in displays[] for "user defined" */
244 const int user_type_idx
= 3;
246 const char *display_title
= N_("Listing mode");
247 const char *user_mini_status
= N_("User &mini status");
248 const char *ok_name
= N_("&OK");
249 const char *cancel_name
= N_("&Cancel");
251 WButton
*ok_button
, *cancel_button
;
256 int ok_len
, cancel_len
, b_len
, gap
;
259 display_title
= _(display_title
);
260 user_mini_status
= _(user_mini_status
);
261 ok_name
= _(ok_name
);
262 cancel_name
= _(cancel_name
);
264 for (i
= 0; i
< LIST_TYPES
; i
++)
265 displays
[i
] = _(displays
[i
]);
268 /* get hotkey of user-defined format string */
269 cp
= strchr (displays
[user_type_idx
], '&');
270 if (cp
!= NULL
&& *++cp
!= '\0')
271 display_user_hotkey
= g_ascii_tolower (*cp
);
273 /* xpos will be fixed later */
274 ok_button
= button_new (dlg_height
- 3, 0, B_ENTER
, DEFPUSH_BUTTON
, ok_name
, 0);
275 ok_len
= button_get_len (ok_button
);
276 cancel_button
= button_new (dlg_height
- 3, 0, B_CANCEL
, NORMAL_BUTTON
, cancel_name
, 0);
277 cancel_len
= button_get_len (cancel_button
);
278 b_len
= ok_len
+ cancel_len
+ 2;
280 dlg_width
= max (dlg_width
, str_term_width1 (display_title
) + 10);
281 /* calculate max width of radiobutons */
282 for (i
= 0; i
< LIST_TYPES
; i
++)
283 maxlen
= max (maxlen
, str_term_width1 (displays
[i
]));
284 dlg_width
= max (dlg_width
, maxlen
);
285 dlg_width
= max (dlg_width
, str_term_width1 (user_mini_status
) + 13);
288 dlg_width
= max (dlg_width
, b_len
+ 6);
289 gap
= (dlg_width
- 6 - b_len
) / 3;
290 ok_button
->widget
.x
= 3 + gap
;
291 cancel_button
->widget
.x
= ok_button
->widget
.x
+ ok_len
+ gap
+ 2;
294 displays_status
= _status
;
296 dd
= create_dlg (TRUE
, 0, 0, dlg_height
, dlg_width
, dialog_colors
,
297 display_callback
, "[Listing Mode...]", display_title
,
298 DLG_CENTER
| DLG_REVERSE
);
300 add_widget (dd
, cancel_button
);
301 add_widget (dd
, ok_button
);
303 display_mini_status
=
304 input_new (10, 8, input_get_default_colors (), dlg_width
- 12, _status
[radio_sel
],
305 "mini-input", INPUT_COMPLETE_DEFAULT
);
306 add_widget (dd
, display_mini_status
);
308 display_check_status
= check_new (9, 4, _check_status
, user_mini_status
);
309 add_widget (dd
, display_check_status
);
311 display_user_format
= input_new (7, 8, input_get_default_colors (), dlg_width
- 12, init_text
,
312 "user-fmt-input", INPUT_COMPLETE_DEFAULT
);
313 add_widget (dd
, display_user_format
);
315 display_radio
= radio_new (3, 4, LIST_TYPES
, displays
);
316 display_radio
->sel
= display_radio
->pos
= radio_sel
;
317 add_widget (dd
, display_radio
);
322 /* --------------------------------------------------------------------------------------------- */
326 sel_charset_button (WButton
* button
, int action
)
333 new_dcp
= select_charset (-1, -1, new_display_codepage
, TRUE
);
335 if (new_dcp
!= SELECT_CHARSET_CANCEL
)
340 new_display_codepage
= new_dcp
;
341 cpname
= (new_display_codepage
== SELECT_CHARSET_OTHER_8BIT
) ?
343 ((codepage_desc
*) g_ptr_array_index (codepages
, new_display_codepage
))->name
;
345 mc_global
.utf8_display
= str_isutf8 (cpname
);
346 /* avoid strange bug with label repainting */
347 g_snprintf (buf
, sizeof (buf
), "%-27s", cpname
);
348 label_set_text (cplabel
, buf
);
354 /* --------------------------------------------------------------------------------------------- */
357 init_disp_bits_box (void)
360 const int DISPY
= 11;
361 const int DISPX
= 46;
369 create_dlg (TRUE
, 0, 0, DISPY
, DISPX
, dialog_colors
, NULL
,
370 "[Display bits]", _("Display bits"), DLG_CENTER
| DLG_REVERSE
);
372 add_widget (dbits_dlg
, label_new (3, 4, _("Input / display codepage:")));
374 cpname
= (new_display_codepage
< 0) ? _("Other 8 bit")
375 : ((codepage_desc
*) g_ptr_array_index (codepages
, new_display_codepage
))->name
;
376 cplabel
= label_new (4, 4, cpname
);
377 add_widget (dbits_dlg
, cplabel
);
379 add_widget (dbits_dlg
,
380 button_new (DISPY
- 3, DISPX
/ 2 + 3, B_CANCEL
, NORMAL_BUTTON
, _("&Cancel"), 0));
381 add_widget (dbits_dlg
, button_new (DISPY
- 3, 7, B_ENTER
, NORMAL_BUTTON
, _("&OK"), 0));
383 inpcheck
= check_new (6, 4, !use_8th_bit_as_meta
, _("F&ull 8 bits input"));
384 add_widget (dbits_dlg
, inpcheck
);
386 cpname
= _("&Select");
387 add_widget (dbits_dlg
,
388 button_new (4, DISPX
- 7 - str_term_width1 (cpname
), B_USER
,
389 NORMAL_BUTTON
, cpname
, sel_charset_button
));
393 #endif /* HAVE_CHARSET */
395 /* --------------------------------------------------------------------------------------------- */
398 tree_callback (Dlg_head
* h
, Widget
* sender
, dlg_msg_t msg
, int parm
, void *data
)
403 /* The enter key will be processed by the tree widget */
406 h
->ret_value
= B_ENTER
;
412 return send_message ((Widget
*) find_tree (h
), WIDGET_COMMAND
, parm
);
415 return default_dlg_callback (h
, sender
, msg
, parm
, data
);
419 /* --------------------------------------------------------------------------------------------- */
422 #ifdef ENABLE_VFS_FTP
425 confvfs_callback (Dlg_head
* h
, Widget
* sender
, dlg_msg_t msg
, int parm
, void *data
)
430 /* message from "Always use ftp proxy" checkbutton */
431 if (sender
!= NULL
&& sender
->id
== 6)
433 const gboolean not_use
= !(((WCheck
*) sender
)->state
& C_BOOL
);
437 w
= dlg_find_by_id (h
, sender
->id
- 1);
438 widget_disable (*w
, not_use
);
439 send_message (w
, WIDGET_DRAW
, 0);
443 return MSG_NOT_HANDLED
;
446 return default_dlg_callback (h
, sender
, msg
, parm
, data
);
449 #endif /* ENABLE_VFS_FTP */
450 #endif /* ENABLE_VFS */
452 #ifdef WITH_BACKGROUND
454 jobs_fill_listbox (void)
456 static const char *state_str
[2];
457 TaskList
*tl
= task_list
;
461 state_str
[0] = _("Running");
462 state_str
[1] = _("Stopped");
469 s
= g_strconcat (state_str
[tl
->state
], " ", tl
->info
, (char *) NULL
);
470 listbox_add_item (bg_list
, LISTBOX_APPEND_AT_END
, 0, s
, (void *) tl
);
476 /* --------------------------------------------------------------------------------------------- */
479 task_cb (WButton
* button
, int action
)
486 if (bg_list
->list
== NULL
)
489 /* Get this instance information */
490 listbox_get_current (bg_list
, NULL
, (void **) &tl
);
493 if (action
== B_STOP
)
496 tl
->state
= Task_Stopped
;
498 else if (action
== B_RESUME
)
501 tl
->state
= Task_Running
;
505 if (action
== B_KILL
)
511 unregister_task_running (tl
->pid
, tl
->fd
);
514 listbox_remove_list (bg_list
);
515 jobs_fill_listbox ();
517 /* This can be optimized to just redraw this widget :-) */
518 dlg_redraw (jobs_dlg
);
522 #endif /* WITH_BACKGROUND */
524 /* --------------------------------------------------------------------------------------------- */
525 /*** public functions ****************************************************************************/
526 /* --------------------------------------------------------------------------------------------- */
528 /* return list type */
530 display_box (WPanel
* panel
, char **userp
, char **minip
, int *use_msformat
, int num
)
534 char *section
= NULL
;
539 const char *p
= get_nth_panel_name (num
);
540 panel
= g_new (WPanel
, 1);
541 panel
->list_type
= list_full
;
542 panel
->user_format
= g_strdup (DEFAULT_USER_FORMAT
);
543 panel
->user_mini_status
= 0;
544 for (i
= 0; i
< LIST_TYPES
; i
++)
545 panel
->user_status_format
[i
] = g_strdup (DEFAULT_USER_FORMAT
);
546 section
= g_strconcat ("Temporal:", p
, (char *) NULL
);
547 if (!mc_config_has_group (mc_main_config
, section
))
550 section
= g_strdup (p
);
552 panel_load_setup (panel
, section
);
556 dd
= display_init (panel
->list_type
, panel
->user_format
,
557 panel
->user_mini_status
, panel
->user_status_format
);
559 if (run_dlg (dd
) != B_CANCEL
)
561 result
= display_radio
->sel
;
562 *userp
= g_strdup (display_user_format
->buffer
);
563 *minip
= g_strdup (display_mini_status
->buffer
);
564 *use_msformat
= display_check_status
->state
& C_BOOL
;
569 g_free (panel
->user_format
);
570 for (i
= 0; i
< LIST_TYPES
; i
++)
571 g_free (panel
->user_status_format
[i
]);
580 /* --------------------------------------------------------------------------------------------- */
582 const panel_field_t
*
583 sort_box (panel_sort_info_t
* info
)
585 int dlg_width
= 40, dlg_height
= 7;
587 const char **sort_orders_names
;
588 gsize sort_names_num
;
592 const panel_field_t
*result
= info
->sort_field
;
594 sort_orders_names
= panel_get_sortable_fields (&sort_names_num
);
595 dlg_height
+= sort_names_num
;
598 int max_radio
= 0, max_check
= 0;
599 int ok_len
, cancel_len
;
602 QuickWidget quick_widgets
[] = {
604 QUICK_BUTTON (0, dlg_width
, dlg_height
- 3, dlg_height
, N_("&Cancel"), B_CANCEL
, NULL
),
606 QUICK_BUTTON (0, dlg_width
, dlg_height
- 3, dlg_height
, N_("&OK"), B_ENTER
, NULL
),
608 QUICK_CHECKBOX (0, dlg_width
, 5, dlg_height
, N_("&Reverse"), &info
->reverse
),
610 QUICK_CHECKBOX (0, dlg_width
, 4, dlg_height
, N_("Case sensi&tive"),
611 &info
->case_sensitive
),
613 QUICK_CHECKBOX (0, dlg_width
, 3, dlg_height
, N_("Executable &first"),
616 QUICK_RADIO (4, dlg_width
, 3, dlg_height
, 0, NULL
, &sort_idx
),
620 QuickDialog quick_dlg
= {
621 dlg_width
, dlg_height
, -1, -1,
622 N_("Sort order"), "[Sort Order...]",
623 quick_widgets
, NULL
, TRUE
626 quick_widgets
[5].u
.radio
.items
= sort_orders_names
;
627 quick_widgets
[5].u
.radio
.count
= sort_names_num
;
629 for (i
= 0; i
< sort_names_num
; i
++)
630 if (strcmp (sort_orders_names
[i
], _(info
->sort_field
->title_hotkey
)) == 0)
637 quick_dlg
.title
= _(quick_dlg
.title
);
639 for (i
= 0; i
< 2; i
++)
640 quick_widgets
[i
].u
.button
.text
= _(quick_widgets
[i
].u
.button
.text
);
642 for (i
= 2; i
< 5; i
++)
643 quick_widgets
[i
].u
.checkbox
.text
= _(quick_widgets
[i
].u
.checkbox
.text
);
644 #endif /* ENABLE_NlS */
647 cancel_len
= str_term_width1 (quick_widgets
[0].u
.button
.text
) + 4;
648 ok_len
= str_term_width1 (quick_widgets
[1].u
.button
.text
) + 6;
650 for (i
= 2; i
< 5; i
++)
651 max_check
= max (max_check
, str_term_width1 (quick_widgets
[i
].u
.checkbox
.text
) + 4);
653 for (i
= 0; i
< sort_names_num
; i
++)
654 max_radio
= max (max_radio
, str_term_width1 (sort_orders_names
[i
]) + 4);
657 dlg_width
= max (dlg_width
, str_term_width1 (quick_dlg
.title
) + 8);
658 dlg_width
= max (dlg_width
, ok_len
+ cancel_len
+ 8);
659 dlg_width
= max (dlg_width
, 2 * max (max_radio
, max_check
) + 8);
661 /* fix widget and dialog parameters */
663 quick_dlg
.xlen
= dlg_width
;
665 for (i
= 0; (size_t) i
< sizeof (quick_widgets
) / sizeof (quick_widgets
[0]) - 1; i
++)
666 quick_widgets
[i
].x_divisions
= dlg_width
;
668 quick_widgets
[0].relative_x
= dlg_width
* 2 / 3 - cancel_len
/ 2;
669 quick_widgets
[1].relative_x
= dlg_width
/ 3 - ok_len
/ 2;
671 for (i
= 2; i
< 5; i
++)
672 quick_widgets
[i
].relative_x
= dlg_width
/ 2 + 2;
674 if (quick_dialog (&quick_dlg
) != B_CANCEL
)
675 result
= panel_get_field_by_title_hotkey (sort_orders_names
[sort_idx
]);
678 result
= info
->sort_field
;
680 g_strfreev ((gchar
**) sort_orders_names
);
684 /* --------------------------------------------------------------------------------------------- */
689 const char *title
= _("Confirmation");
691 QuickWidget conf_widgets
[] = {
692 /* 0 */ QUICK_BUTTON (29, 46, 10, 13, N_("&Cancel"), B_CANCEL
, NULL
),
693 /* 1 */ QUICK_BUTTON (12, 46, 10, 13, N_("&OK"), B_ENTER
, NULL
),
694 /* TRANSLATORS: no need to translate 'Confirmation', it's just a context prefix */
695 /* 2 */ QUICK_CHECKBOX (3, 46, 8, 13, N_("Confirmation|&History cleanup"),
696 &mc_global
.widget
.confirm_history_cleanup
),
697 /* 3 */ QUICK_CHECKBOX (3, 46, 7, 13, N_("Confirmation|Di&rectory hotlist delete"),
698 &confirm_directory_hotlist_delete
),
699 /* 4 */ QUICK_CHECKBOX (3, 46, 6, 13, N_("Confirmation|E&xit"), &confirm_exit
),
700 /* 5 */ QUICK_CHECKBOX (3, 46, 5, 13, N_("Confirmation|&Execute"), &confirm_execute
),
701 /* 6 */ QUICK_CHECKBOX (3, 46, 4, 13, N_("Confirmation|O&verwrite"), &confirm_overwrite
),
702 /* 7 */ QUICK_CHECKBOX (3, 46, 3, 13, N_("Confirmation|&Delete"), &confirm_delete
),
706 const size_t w_num
= sizeof (conf_widgets
) / sizeof (conf_widgets
[0]) - 1;
710 int dlg_height
= w_num
+ 5;
714 int cancel_len
, ok_len
, blen
;
719 for (i
= 0; i
< 2; i
++)
720 conf_widgets
[i
].u
.button
.text
= _(conf_widgets
[i
].u
.button
.text
);
721 #endif /* ENABLE_NLS */
723 for (i
= 2; i
< w_num
; i
++)
724 conf_widgets
[i
].u
.checkbox
.text
= Q_ (conf_widgets
[i
].u
.checkbox
.text
);
726 /* maximum length of checkboxes */
727 for (i
= 2; i
< w_num
; i
++)
728 maxlen
= max (maxlen
, str_term_width1 (conf_widgets
[i
].u
.checkbox
.text
) + 4);
730 /* length of buttons */
731 cancel_len
= str_term_width1 (conf_widgets
[0].u
.button
.text
) + 3;
732 ok_len
= str_term_width1 (conf_widgets
[1].u
.button
.text
) + 5; /* default button */
734 blen
= cancel_len
+ ok_len
+ 2;
736 dlg_width
= max (maxlen
, blen
) + 6;
737 dlg_width
= max (dlg_width
, str_term_width1 (title
) + 4);
739 /* correct widget parameters */
740 for (i
= 0; i
< w_num
; i
++)
742 conf_widgets
[i
].x_divisions
= dlg_width
;
743 conf_widgets
[i
].y_divisions
= dlg_height
;
746 conf_widgets
[1].relative_x
= dlg_width
/ 2 - blen
/ 2;
747 conf_widgets
[0].relative_x
= conf_widgets
[1].relative_x
+ ok_len
+ 2;
750 QuickDialog confirmation
= {
751 dlg_width
, dlg_height
, -1, -1, title
,
752 "[Confirmation]", conf_widgets
, NULL
, TRUE
755 (void) quick_dialog (&confirmation
);
759 /* --------------------------------------------------------------------------------------------- */
763 display_bits_box (void) /* AB:FIXME: test dialog */
766 const int DISPY
= 13;
767 const int DISPX
= 46;
772 const char *display_bits_str
[] = {
774 N_("Full 8 bits output"),
779 QuickWidget display_widgets
[] = {
780 /* 0 */ QUICK_BUTTON (15, DISPX
, DISPY
- 3, DISPY
, N_("&Cancel"), B_CANCEL
, NULL
),
781 /* 1 */ QUICK_BUTTON (29, DISPX
, DISPY
- 3, DISPY
, N_("&OK"), B_ENTER
, NULL
),
782 /* 2 */ QUICK_CHECKBOX (3, DISPX
, 8, DISPY
, N_("F&ull 8 bits input"), &new_meta
),
783 /* 3 */ QUICK_RADIO (3, DISPX
, 3, DISPY
, 4, display_bits_str
, ¤t_mode
),
787 QuickDialog display_bits
= {
788 DISPX
, DISPY
, -1, -1, _("Display bits"),
789 "[Display bits]", display_widgets
, NULL
, TRUE
794 int ok_len
, cancel_len
;
797 static gboolean i18n_flag
= FALSE
;
801 for (i
= 0; i
< 3; i
++)
803 display_bits_str
[i
] = _(display_bits_str
[i
]);
806 display_widgets
[0].u
.button
.text
= _(display_widgets
[0].u
.button
.text
);
807 display_widgets
[1].u
.button
.text
= _(display_widgets
[1].u
.button
.text
);
808 display_widgets
[2].u
.checkbox
.text
= _(display_widgets
[2].u
.checkbox
.text
);
812 #endif /* ENABLE_NLS */
815 for (i
= 0; i
< 3; i
++)
816 maxlen
= max (maxlen
, str_term_width1 (display_bits_str
[i
]));
819 cancel_len
= str_term_width1 (display_widgets
[0].u
.button
.text
) + 2;
820 ok_len
= str_term_width1 (display_widgets
[1].u
.button
.text
) + 4; /* default button */
822 l1
= max (cancel_len
, ok_len
);
824 display_bits
.xlen
= max (maxlen
, l1
) + 20;
826 for (i
= 0; i
< 4; i
++)
827 display_widgets
[i
].x_divisions
= display_bits
.xlen
;
829 display_widgets
[0].relative_x
= display_bits
.xlen
* 2 / 3 - cancel_len
/ 2;
830 display_widgets
[1].relative_x
= display_bits
.xlen
/ 3 - ok_len
/ 2;
832 if (mc_global
.full_eight_bits
)
834 else if (mc_global
.eight_bit_clean
)
839 new_meta
= !use_8th_bit_as_meta
;
841 if (quick_dialog (&display_bits
) != B_CANCEL
)
843 mc_global
.eight_bit_clean
= current_mode
< 3;
844 mc_global
.full_eight_bits
= current_mode
< 2;
846 meta (stdscr
, mc_global
.eight_bit_clean
);
848 SLsmg_Display_Eight_Bit
= mc_global
.full_eight_bits
? 128 : 160;
850 use_8th_bit_as_meta
= !new_meta
;
854 /* --------------------------------------------------------------------------------------------- */
855 #else /* HAVE_CHARSET */
858 display_bits_box (void)
861 new_display_codepage
= mc_global
.display_codepage
;
863 application_keypad_mode ();
864 dbits_dlg
= init_disp_bits_box ();
868 if (dbits_dlg
->ret_value
== B_ENTER
)
872 mc_global
.display_codepage
= new_display_codepage
;
873 errmsg
= init_translation_table (mc_global
.source_codepage
, mc_global
.display_codepage
);
876 message (D_ERROR
, MSG_ERROR
, "%s", errmsg
);
880 tty_display_8bit (mc_global
.display_codepage
!= 0 && mc_global
.display_codepage
!= 1);
882 tty_display_8bit (mc_global
.display_codepage
!= 0);
884 use_8th_bit_as_meta
= !(inpcheck
->state
& C_BOOL
);
886 destroy_dlg (dbits_dlg
);
889 #endif /* HAVE_CHARSET */
891 /* --------------------------------------------------------------------------------------------- */
892 /** Show tree in a box, not on a panel */
895 tree_box (const char *current_dir
)
904 /* Create the components */
905 dlg
= create_dlg (TRUE
, 0, 0, LINES
- 9, COLS
- 20, dialog_colors
,
906 tree_callback
, "[Directory Tree]",
907 _("Directory tree"), DLG_CENTER
| DLG_REVERSE
);
909 mytree
= tree_new (2, 2, dlg
->lines
- 6, dlg
->cols
- 5, FALSE
);
910 add_widget (dlg
, mytree
);
911 add_widget (dlg
, hline_new (dlg
->lines
- 4, 1, -1));
912 bar
= buttonbar_new (TRUE
);
913 add_widget (dlg
, bar
);
914 /* restore ButtonBar coordinates after add_widget() */
915 ((Widget
*) bar
)->x
= 0;
916 ((Widget
*) bar
)->y
= LINES
- 1;
918 if (run_dlg (dlg
) == B_ENTER
)
919 val
= vfs_path_to_str (tree_selected_name (mytree
));
925 /* --------------------------------------------------------------------------------------------- */
931 char buffer2
[BUF_TINY
];
932 #ifdef ENABLE_VFS_FTP
933 char buffer3
[BUF_TINY
];
936 QuickWidget confvfs_widgets
[] = {
937 /* 0 */ QUICK_BUTTON (30, VFSX
, VFSY
- 3, VFSY
, N_("&Cancel"), B_CANCEL
, NULL
),
938 /* 1 */ QUICK_BUTTON (12, VFSX
, VFSY
- 3, VFSY
, N_("&OK"), B_ENTER
, NULL
),
939 #ifdef ENABLE_VFS_FTP
940 /* 2 */ QUICK_CHECKBOX (4, VFSX
, 12, VFSY
, N_("Use passive mode over pro&xy"),
941 &ftpfs_use_passive_connections_over_proxy
),
942 /* 3 */ QUICK_CHECKBOX (4, VFSX
, 11, VFSY
, N_("Use &passive mode"),
943 &ftpfs_use_passive_connections
),
944 /* 4 */ QUICK_CHECKBOX (4, VFSX
, 10, VFSY
, N_("&Use ~/.netrc"), &ftpfs_use_netrc
),
945 /* 5 */ QUICK_INPUT (4, VFSX
, 9, VFSY
, ftpfs_proxy_host
, 48, 0, "input-ftp-proxy",
947 /* 6 */ QUICK_CHECKBOX (4, VFSX
, 8, VFSY
, N_("&Always use ftp proxy"),
948 &ftpfs_always_use_proxy
),
949 /* 7 */ QUICK_LABEL (49, VFSX
, 7, VFSY
, N_("sec")),
950 /* 8 */ QUICK_INPUT (38, VFSX
, 7, VFSY
, buffer3
, 10, 0, "input-timeout",
951 &ret_directory_timeout
),
952 /* 9 */ QUICK_LABEL (4, VFSX
, 7, VFSY
, N_("ftpfs directory cache timeout:")),
953 /* 10 */ QUICK_INPUT (4, VFSX
, 6, VFSY
, ftpfs_anonymous_passwd
, 48, 0, "input-passwd",
955 /* 11 */ QUICK_LABEL (4, VFSX
, 5, VFSY
, N_("ftp anonymous password:")),
956 #endif /* ENABLE_VFS_FTP */
957 /* 12 */ QUICK_LABEL (49, VFSX
, 3, VFSY
, N_("sec")),
958 /* 13 */ QUICK_INPUT (38, VFSX
, 3, VFSY
, buffer2
, 10, 0, "input-timo-vfs", &ret_timeout
),
959 /* 14 */ QUICK_LABEL (4, VFSX
, 3, VFSY
, N_("Timeout for freeing VFSs:")),
963 QuickDialog confvfs_dlg
= {
964 VFSX
, VFSY
, -1, -1, N_("Virtual File System Setting"),
965 "[Virtual FS]", confvfs_widgets
,
966 #ifdef ENABLE_VFS_FTP
974 #ifdef ENABLE_VFS_FTP
975 g_snprintf (buffer3
, sizeof (buffer3
), "%i", ftpfs_directory_timeout
);
977 if (!ftpfs_always_use_proxy
)
978 confvfs_widgets
[5].options
= W_DISABLED
;
981 g_snprintf (buffer2
, sizeof (buffer2
), "%i", vfs_timeout
);
983 if (quick_dialog (&confvfs_dlg
) != B_CANCEL
)
985 vfs_timeout
= atoi (ret_timeout
);
986 g_free (ret_timeout
);
988 if (vfs_timeout
< 0 || vfs_timeout
> 10000)
990 #ifdef ENABLE_VFS_FTP
991 g_free (ftpfs_anonymous_passwd
);
992 ftpfs_anonymous_passwd
= ret_passwd
;
993 g_free (ftpfs_proxy_host
);
994 ftpfs_proxy_host
= ret_ftp_proxy
;
995 ftpfs_directory_timeout
= atoi (ret_directory_timeout
);
996 g_free (ret_directory_timeout
);
1004 #endif /* ENABLE_VFS */
1006 /* --------------------------------------------------------------------------------------------- */
1011 const char *label
= N_("cd");
1013 const int xlen
= 57;
1021 len
= str_term_width1 (label
);
1026 QuickWidget quick_widgets
[] = {
1027 /* 0 */ QUICK_INPUT (4 + len
, xlen
, 2, ylen
, "", xlen
- 7 - len
, 2, "input", &my_str
),
1028 /* 1 */ QUICK_LABEL (3, xlen
, 2, ylen
, label
),
1032 QuickDialog Quick_input
= {
1033 xlen
, ylen
, 2, LINES
- 2 - ylen
, _("Quick cd"),
1034 "[Quick cd]", quick_widgets
, NULL
, TRUE
1037 return (quick_dialog (&Quick_input
) != B_CANCEL
) ? my_str
: NULL
;
1041 /* --------------------------------------------------------------------------------------------- */
1044 symlink_dialog (const vfs_path_t
* existing_vpath
, const vfs_path_t
* new_vpath
,
1045 char **ret_existing
, char **ret_new
)
1047 char *existing
= vfs_path_to_str (existing_vpath
);
1048 char *new = vfs_path_to_str (new_vpath
);
1050 QuickWidget quick_widgets
[] = {
1051 /* 0 */ QUICK_BUTTON (50, 80, 6, 8, N_("&Cancel"), B_CANCEL
, NULL
),
1052 /* 1 */ QUICK_BUTTON (16, 80, 6, 8, N_("&OK"), B_ENTER
, NULL
),
1053 /* 2 */ QUICK_INPUT (4, 80, 5, 8, new, 58, 0, "input-1", ret_new
),
1054 /* 3 */ QUICK_LABEL (4, 80, 4, 8, N_("Symbolic link filename:")),
1055 /* 4 */ QUICK_INPUT (4, 80, 3, 8, existing
, 58, 0, "input-2", ret_existing
),
1056 /* 5 */ QUICK_LABEL (4, 80, 2, 8,
1057 N_("Existing filename (filename symlink will point to):")),
1061 QuickDialog Quick_input
= {
1062 64, 12, -1, -1, N_("Symbolic link"),
1063 "[File Menu]", quick_widgets
, NULL
, FALSE
1066 if (quick_dialog (&Quick_input
) == B_CANCEL
)
1069 *ret_existing
= NULL
;
1075 /* --------------------------------------------------------------------------------------------- */
1077 #ifdef WITH_BACKGROUND
1082 int n_buttons
= sizeof (job_buttons
) / sizeof (job_buttons
[0]);
1085 static int i18n_flag
= 0;
1088 int startx
= job_buttons
[0].xpos
;
1091 for (i
= 0; i
< n_buttons
; i
++)
1093 job_buttons
[i
].name
= _(job_buttons
[i
].name
);
1095 len
= str_term_width1 (job_buttons
[i
].name
) + 4;
1096 JOBS_X
= max (JOBS_X
, startx
+ len
+ 3);
1098 job_buttons
[i
].xpos
= startx
;
1102 /* Last button - Ok a.k.a. Cancel :) */
1103 job_buttons
[n_buttons
- 1].xpos
=
1104 JOBS_X
- str_term_width1 (job_buttons
[n_buttons
- 1].name
) - 7;
1108 #endif /* ENABLE_NLS */
1110 jobs_dlg
= create_dlg (TRUE
, 0, 0, JOBS_Y
, JOBS_X
, dialog_colors
, NULL
,
1111 "[Background jobs]", _("Background Jobs"), DLG_CENTER
| DLG_REVERSE
);
1113 bg_list
= listbox_new (2, 3, JOBS_Y
- 9, JOBS_X
- 7, FALSE
, NULL
);
1114 add_widget (jobs_dlg
, bg_list
);
1119 add_widget (jobs_dlg
, button_new (JOBS_Y
- 4,
1120 job_buttons
[i
].xpos
, job_buttons
[i
].value
,
1121 NORMAL_BUTTON
, job_buttons
[i
].name
,
1122 job_buttons
[i
].callback
));
1125 /* Insert all of task information in the list */
1126 jobs_fill_listbox ();
1129 destroy_dlg (jobs_dlg
);
1131 #endif /* WITH_BACKGROUND */
1133 /* --------------------------------------------------------------------------------------------- */
1135 #ifdef ENABLE_VFS_SMB
1136 struct smb_authinfo
*
1137 vfs_smb_get_authinfo (const char *host
, const char *share
, const char *domain
, const char *user
)
1139 static int dialog_x
= 44;
1140 int b0
= 3, dialog_y
= 12;
1141 static const char *lc_labs
[] = { N_("Domain:"), N_("Username:"), N_("Password:") };
1142 static const char *buts
[] = { N_("&OK"), N_("&Cancel") };
1143 static int ilen
= 30, istart
= 14;
1146 WInput
*in_password
;
1150 struct smb_authinfo
*return_value
= NULL
;
1153 static int i18n_flag
= 0;
1157 register int i
= sizeof (lc_labs
) / sizeof (lc_labs
[0]);
1162 l1
= str_term_width1 (lc_labs
[i
] = _(lc_labs
[i
]));
1166 i
= maxlen
+ ilen
+ 7;
1170 for (i
= sizeof (buts
) / sizeof (buts
[0]), l1
= 0; i
--;)
1172 l1
+= str_term_width1 (buts
[i
] = _(buts
[i
]));
1178 ilen
= dialog_x
- 7 - maxlen
; /* for the case of very long buttons :) */
1179 istart
= dialog_x
- 3 - ilen
;
1181 b2
= dialog_x
- (str_term_width1 (buts
[1]) + 6);
1186 #endif /* ENABLE_NLS */
1193 title
= g_strdup_printf (_("Password for \\\\%s\\%s"), host
, share
);
1195 auth_dlg
= create_dlg (TRUE
, 0, 0, dialog_y
, dialog_x
, dialog_colors
, NULL
,
1196 "[Smb Authinfo]", title
, DLG_CENTER
| DLG_REVERSE
);
1201 input_new (5, istart
, input_get_default_colors (), ilen
, user
, "auth_name",
1202 INPUT_COMPLETE_DEFAULT
);
1203 add_widget (auth_dlg
, in_user
);
1206 input_new (3, istart
, input_get_default_colors (), ilen
, domain
, "auth_domain",
1207 INPUT_COMPLETE_DEFAULT
);
1209 add_widget (auth_dlg
, in_domain
);
1210 add_widget (auth_dlg
, button_new (9, b2
, B_CANCEL
, NORMAL_BUTTON
, buts
[1], 0));
1211 add_widget (auth_dlg
, button_new (9, b0
, B_ENTER
, DEFPUSH_BUTTON
, buts
[0], 0));
1214 input_new (7, istart
, input_get_default_colors (), ilen
, "", "auth_password",
1215 INPUT_COMPLETE_DEFAULT
);
1217 in_password
->completion_flags
= 0;
1218 in_password
->is_password
= 1;
1219 add_widget (auth_dlg
, in_password
);
1221 add_widget (auth_dlg
, label_new (7, 3, lc_labs
[2]));
1222 add_widget (auth_dlg
, label_new (5, 3, lc_labs
[1]));
1223 add_widget (auth_dlg
, label_new (3, 3, lc_labs
[0]));
1225 if (run_dlg (auth_dlg
) != B_CANCEL
)
1226 return_value
= vfs_smb_authinfo_new (host
, share
, in_domain
->buffer
, in_user
->buffer
,
1227 in_password
->buffer
);
1229 destroy_dlg (auth_dlg
);
1231 return return_value
;
1233 #endif /* ENABLE_VFS_SMB */
1235 /* --------------------------------------------------------------------------------------------- */