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, 2012, 2013
6 The Free Software Foundation, Inc.
9 Miguel de Icaza, 1994, 1995
11 Andrew Borodin <aborodin@vmail.ru>, 2009, 2010, 2011, 2012, 2013
13 This file is part of the Midnight Commander.
15 The Midnight Commander is free software: you can redistribute it
16 and/or modify it under the terms of the GNU General Public License as
17 published by the Free Software Foundation, either version 3 of the License,
18 or (at your option) any later version.
20 The Midnight Commander is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
25 You should have received a copy of the GNU General Public License
26 along with this program. If not, see <http://www.gnu.org/licenses/>.
30 * \brief Source: Some misc dialog boxes for the program
40 #include <sys/types.h>
43 #include "lib/global.h"
45 #include "lib/tty/tty.h"
46 #include "lib/tty/key.h" /* XCTRL and ALT macros */
47 #include "lib/skin.h" /* INPUT_COLOR */
48 #include "lib/mcconfig.h" /* Load/save user formats */
49 #include "lib/strutil.h"
51 #include "lib/vfs/vfs.h"
53 #include "src/vfs/ftpfs/ftpfs.h"
54 #endif /* ENABLE_VFS_FTP */
56 #include "src/vfs/smbfs/smbfs.h"
57 #endif /* ENABLE_VFS_SMB */
59 #include "lib/util.h" /* Q_() */
60 #include "lib/widget.h"
62 #include "src/setup.h" /* For profile_name */
63 #include "src/history.h" /* MC_HISTORY_ESC_TIMEOUT */
64 #include "src/execute.h" /* pause_after_run */
65 #ifdef ENABLE_BACKGROUND
66 #include "src/background.h" /* task_list */
70 #include "lib/charsets.h"
71 #include "src/selcodepage.h"
74 #include "command.h" /* For cmdline */
76 #include "panel.h" /* LIST_TYPES */
78 #include "layout.h" /* for get_nth_panel_name proto */
79 #include "midnight.h" /* current_panel */
83 /*** global variables ****************************************************************************/
85 /*** file scope macro definitions ****************************************************************/
87 #ifdef ENABLE_BACKGROUND
88 #define B_STOP (B_USER+1)
89 #define B_RESUME (B_USER+2)
90 #define B_KILL (B_USER+3)
91 #endif /* ENABLE_BACKGROUND */
93 /*** file scope type declarations ****************************************************************/
95 /*** file scope variables ************************************************************************/
97 unsigned long configure_old_esc_mode_id
, configure_time_out_id
;
99 /* Index in list_types[] for "user defined" */
100 static const int panel_listing_user_idx
= 3;
102 static char **status_format
;
103 static int listing_user_hotkey
= 'u';
104 static unsigned long panel_listing_types_id
, panel_user_format_id
;
105 static unsigned long mini_user_status_id
, mini_user_format_id
;
108 static int new_display_codepage
;
109 static unsigned long disp_bits_name_id
;
110 #endif /* HAVE_CHARSET */
112 #if defined(ENABLE_VFS) && defined(ENABLE_VFS_FTP)
113 static unsigned long ftpfs_always_use_proxy_id
, ftpfs_proxy_host_id
;
114 #endif /* ENABLE_VFS && ENABLE_VFS_FTP */
116 #ifdef ENABLE_BACKGROUND
117 static WListbox
*bg_list
= NULL
;
118 #endif /* ENABLE_BACKGROUND */
120 /* --------------------------------------------------------------------------------------------- */
121 /*** file scope functions ************************************************************************/
122 /* --------------------------------------------------------------------------------------------- */
125 configure_callback (Widget
* w
, Widget
* sender
, widget_msg_t msg
, int parm
, void *data
)
130 /* message from "Single press" checkbutton */
131 if (sender
!= NULL
&& sender
->id
== configure_old_esc_mode_id
)
133 const gboolean not_single
= !(CHECK (sender
)->state
& C_BOOL
);
137 ww
= dlg_find_by_id (DIALOG (w
), configure_time_out_id
);
138 widget_disable (ww
, not_single
);
142 return MSG_NOT_HANDLED
;
145 return dlg_default_callback (w
, sender
, msg
, parm
, data
);
149 /* --------------------------------------------------------------------------------------------- */
152 panel_listing_callback (Widget
* w
, Widget
* sender
, widget_msg_t msg
, int parm
, void *data
)
154 WDialog
*h
= DIALOG (w
);
163 wi
= dlg_find_by_id (h
, panel_listing_types_id
);
164 if (dlg_widget_active (wi
))
168 in
= INPUT (dlg_find_by_id (h
, mini_user_format_id
));
169 input_assign_text (in
, status_format
[RADIO (wi
)->sel
]);
174 wi
= dlg_find_by_id (h
, panel_user_format_id
);
175 if (dlg_widget_active (wi
))
177 h
->ret_value
= B_USER
+ 6;
182 wi
= dlg_find_by_id (h
, mini_user_format_id
);
183 if (dlg_widget_active (wi
))
185 h
->ret_value
= B_USER
+ 7;
191 if (g_ascii_tolower (parm
) == listing_user_hotkey
)
195 wi
= dlg_find_by_id (h
, panel_user_format_id
);
196 if (dlg_widget_active (wi
))
198 wi
= dlg_find_by_id (h
, mini_user_format_id
);
199 if (dlg_widget_active (wi
))
203 r
= RADIO (dlg_find_by_id (h
, panel_listing_types_id
));
204 r
->pos
= r
->sel
= panel_listing_user_idx
;
205 dlg_select_widget (WIDGET (r
)); /* force redraw */
206 send_message (h
, r
, MSG_ACTION
, 0, NULL
);
211 return MSG_NOT_HANDLED
;
214 if (sender
!= NULL
&& sender
->id
== panel_listing_types_id
)
219 in1
= INPUT (dlg_find_by_id (h
, panel_user_format_id
));
220 ch
= CHECK (dlg_find_by_id (h
, mini_user_status_id
));
221 in2
= INPUT (dlg_find_by_id (h
, mini_user_format_id
));
223 if (!(ch
->state
& C_BOOL
))
224 input_assign_text (in2
, status_format
[RADIO (sender
)->sel
]);
225 input_update (in2
, FALSE
);
226 input_update (in1
, FALSE
);
227 widget_disable (WIDGET (in1
), RADIO (sender
)->sel
!= panel_listing_user_idx
);
231 if (sender
!= NULL
&& sender
->id
== mini_user_status_id
)
235 in
= INPUT (dlg_find_by_id (h
, mini_user_format_id
));
237 if (CHECK (sender
)->state
& C_BOOL
)
239 widget_disable (WIDGET (in
), FALSE
);
240 input_assign_text (in
, status_format
[3]);
246 r
= RADIO (dlg_find_by_id (h
, panel_listing_types_id
));
247 widget_disable (WIDGET (in
), TRUE
);
248 input_assign_text (in
, status_format
[r
->sel
]);
250 /* input_update (in, FALSE); */
254 return MSG_NOT_HANDLED
;
257 return dlg_default_callback (w
, sender
, msg
, parm
, data
);
261 /* --------------------------------------------------------------------------------------------- */
265 sel_charset_button (WButton
* button
, int action
)
271 new_dcp
= select_charset (-1, -1, new_display_codepage
, TRUE
);
273 if (new_dcp
!= SELECT_CHARSET_CANCEL
)
279 new_display_codepage
= new_dcp
;
280 cpname
= (new_display_codepage
== SELECT_CHARSET_OTHER_8BIT
) ?
282 ((codepage_desc
*) g_ptr_array_index (codepages
, new_display_codepage
))->name
;
284 mc_global
.utf8_display
= str_isutf8 (cpname
);
285 /* avoid strange bug with label repainting */
286 g_snprintf (buf
, sizeof (buf
), "%-27s", cpname
);
287 w
= dlg_find_by_id (WIDGET (button
)->owner
, disp_bits_name_id
);
288 label_set_text (LABEL (w
), buf
);
293 #endif /* HAVE_CHARSET */
295 /* --------------------------------------------------------------------------------------------- */
298 tree_callback (Widget
* w
, Widget
* sender
, widget_msg_t msg
, int parm
, void *data
)
300 WDialog
*h
= DIALOG (w
);
305 /* The enter key will be processed by the tree widget */
308 h
->ret_value
= B_ENTER
;
317 /* simply call dlg_set_size() with new size */
318 dlg_set_size (h
, LINES
- 9, COLS
- 20);
319 bar
= WIDGET (find_buttonbar (h
));
326 return send_message (find_tree (h
), NULL
, MSG_ACTION
, parm
, NULL
);
329 return dlg_default_callback (w
, sender
, msg
, parm
, data
);
333 /* --------------------------------------------------------------------------------------------- */
335 #if defined(ENABLE_VFS) && defined (ENABLE_VFS_FTP)
337 confvfs_callback (Widget
* w
, Widget
* sender
, widget_msg_t msg
, int parm
, void *data
)
342 /* message from "Always use ftp proxy" checkbutton */
343 if (sender
!= NULL
&& sender
->id
== ftpfs_always_use_proxy_id
)
345 const gboolean not_use
= !(CHECK (sender
)->state
& C_BOOL
);
349 wi
= dlg_find_by_id (DIALOG (w
), ftpfs_proxy_host_id
);
350 widget_disable (wi
, not_use
);
353 return MSG_NOT_HANDLED
;
356 return dlg_default_callback (w
, sender
, msg
, parm
, data
);
359 #endif /* ENABLE_VFS && ENABLE_VFS_FTP */
361 /* --------------------------------------------------------------------------------------------- */
363 #ifdef ENABLE_BACKGROUND
365 jobs_fill_listbox (WListbox
* list
)
367 static const char *state_str
[2] = { "", "" };
370 if (state_str
[0] == '\0')
372 state_str
[0] = _("Running");
373 state_str
[1] = _("Stopped");
376 for (tl
= task_list
; tl
!= NULL
; tl
= tl
->next
)
380 s
= g_strconcat (state_str
[tl
->state
], " ", tl
->info
, (char *) NULL
);
381 listbox_add_item (list
, LISTBOX_APPEND_AT_END
, 0, s
, (void *) tl
);
386 /* --------------------------------------------------------------------------------------------- */
389 task_cb (WButton
* button
, int action
)
396 if (bg_list
->list
== NULL
)
399 /* Get this instance information */
400 listbox_get_current (bg_list
, NULL
, (void **) &tl
);
403 if (action
== B_STOP
)
406 tl
->state
= Task_Stopped
;
408 else if (action
== B_RESUME
)
411 tl
->state
= Task_Running
;
415 if (action
== B_KILL
)
419 unregister_task_running (tl
->pid
, tl
->fd
);
422 listbox_remove_list (bg_list
);
423 jobs_fill_listbox (bg_list
);
425 /* This can be optimized to just redraw this widget :-) */
426 dlg_redraw (WIDGET (button
)->owner
);
430 #endif /* ENABLE_BACKGROUND */
432 /* --------------------------------------------------------------------------------------------- */
433 /*** public functions ****************************************************************************/
434 /* --------------------------------------------------------------------------------------------- */
439 const char *pause_options
[] = {
441 N_("On dum&b terminals"),
445 int pause_options_num
;
447 pause_options_num
= G_N_ELEMENTS (pause_options
);
450 char time_out
[BUF_TINY
] = "";
453 quick_widget_t quick_widgets
[] = {
456 QUICK_START_GROUPBOX (N_("File operations")),
457 QUICK_CHECKBOX (N_("&Verbose operation"), &verbose
, NULL
),
458 QUICK_CHECKBOX (N_("Compute tota&ls"), &file_op_compute_totals
, NULL
),
459 QUICK_CHECKBOX (N_("Classic pro&gressbar"), &classic_progressbar
, NULL
),
460 QUICK_CHECKBOX (N_("Mkdi&r autoname"), &auto_fill_mkdir_name
, NULL
),
461 QUICK_CHECKBOX (N_("Preallocate &space"), &mc_global
.vfs
.preallocate_space
,
464 QUICK_START_GROUPBOX (N_("Esc key mode")),
465 QUICK_CHECKBOX (N_("S&ingle press"), &old_esc_mode
, &configure_old_esc_mode_id
),
466 QUICK_LABELED_INPUT (N_("Timeout:"), input_label_left
,
467 (const char *) time_out
, 0, MC_HISTORY_ESC_TIMEOUT
,
468 &time_out_new
, &configure_time_out_id
),
470 QUICK_START_GROUPBOX (N_("Pause after run")),
471 QUICK_RADIO (pause_options_num
, pause_options
, &pause_after_run
, NULL
),
474 QUICK_START_GROUPBOX (N_("Other options")),
475 QUICK_CHECKBOX (N_("Use internal edi&t"), &use_internal_edit
, NULL
),
476 QUICK_CHECKBOX (N_("Use internal vie&w"), &use_internal_view
, NULL
),
477 QUICK_CHECKBOX (N_("Auto m&enus"), &auto_menu
, NULL
),
478 QUICK_CHECKBOX (N_("&Drop down menus"), &drop_menus
, NULL
),
479 QUICK_CHECKBOX (N_("Shell &patterns"), &easy_patterns
, NULL
),
480 QUICK_CHECKBOX (N_("Co&mplete: show all"),
481 &mc_global
.widget
.show_all_if_ambiguous
, NULL
),
482 QUICK_CHECKBOX (N_("Rotating d&ash"), &nice_rotating_dash
, NULL
),
483 QUICK_CHECKBOX (N_("Cd follows lin&ks"), &mc_global
.vfs
.cd_symlinks
, NULL
),
484 QUICK_CHECKBOX (N_("Sa&fe delete"), &safe_delete
, NULL
),
485 QUICK_CHECKBOX (N_("A&uto save setup"), &auto_save_setup
, NULL
),
486 QUICK_SEPARATOR (FALSE
),
487 QUICK_SEPARATOR (FALSE
),
488 QUICK_SEPARATOR (FALSE
),
489 QUICK_SEPARATOR (FALSE
),
492 QUICK_BUTTONS_OK_CANCEL
,
497 quick_dialog_t qdlg
= {
499 N_("Configure options"), "[Configuration]",
500 quick_widgets
, configure_callback
, NULL
503 g_snprintf (time_out
, sizeof (time_out
), "%d", old_esc_mode_timeout
);
506 quick_widgets
[10].options
= quick_widgets
[11].options
= W_DISABLED
;
508 #ifndef HAVE_POSIX_FALLOCATE
509 mc_global
.vfs
.preallocate_space
= FALSE
;
510 quick_widgets
[7].options
= W_DISABLED
;
513 if (quick_dialog (&qdlg
) == B_ENTER
)
514 old_esc_mode_timeout
= atoi (time_out_new
);
516 g_free (time_out_new
);
520 /* --------------------------------------------------------------------------------------------- */
523 panel_options_box (void)
525 const char *qsearch_options
[] = {
526 N_("Case &insensitive"),
527 N_("Cas&e sensitive"),
528 N_("Use panel sort mo&de")
533 simple_swap
= mc_config_get_bool (mc_main_config
, CONFIG_PANELS_SECTION
,
534 "simple_swap", FALSE
) ? 1 : 0;
537 quick_widget_t quick_widgets
[] = {
540 QUICK_START_GROUPBOX (N_("Main options")),
541 QUICK_CHECKBOX (N_("Show mi&ni-status"), &panels_options
.show_mini_info
, NULL
),
542 QUICK_CHECKBOX (N_("Use SI si&ze units"), &panels_options
.kilobyte_si
, NULL
),
543 QUICK_CHECKBOX (N_("Mi&x all files"), &panels_options
.mix_all_files
, NULL
),
544 QUICK_CHECKBOX (N_("Show &backup files"), &panels_options
.show_backups
, NULL
),
545 QUICK_CHECKBOX (N_("Show &hidden files"), &panels_options
.show_dot_files
, NULL
),
546 QUICK_CHECKBOX (N_("&Fast dir reload"), &panels_options
.fast_reload
, NULL
),
547 QUICK_CHECKBOX (N_("Ma&rk moves down"), &panels_options
.mark_moves_down
, NULL
),
548 QUICK_CHECKBOX (N_("Re&verse files only"), &panels_options
.reverse_files_only
,
550 QUICK_CHECKBOX (N_("Simple s&wap"), &simple_swap
, NULL
),
551 QUICK_CHECKBOX (N_("A&uto save panels setup"), &panels_options
.auto_save_setup
,
553 QUICK_SEPARATOR (FALSE
),
554 QUICK_SEPARATOR (FALSE
),
557 QUICK_START_GROUPBOX (N_("Navigation")),
558 QUICK_CHECKBOX (N_("L&ynx-like motion"), &panels_options
.navigate_with_arrows
,
560 QUICK_CHECKBOX (N_("Pa&ge scrolling"), &panels_options
.scroll_pages
, NULL
),
561 QUICK_CHECKBOX (N_("&Mouse page scrolling"), &panels_options
.mouse_move_pages
,
564 QUICK_START_GROUPBOX (N_("File highlight")),
565 QUICK_CHECKBOX (N_("File &types"), &panels_options
.filetype_mode
, NULL
),
566 QUICK_CHECKBOX (N_("&Permissions"), &panels_options
.permission_mode
, NULL
),
568 QUICK_START_GROUPBOX (N_("Quick search")),
569 QUICK_RADIO (QSEARCH_NUM
, qsearch_options
, (int *) &panels_options
.qsearch_mode
,
573 QUICK_BUTTONS_OK_CANCEL
,
578 quick_dialog_t qdlg
= {
580 N_("Panel options"), "[Panel options]",
581 quick_widgets
, NULL
, NULL
584 if (quick_dialog (&qdlg
) != B_ENTER
)
588 mc_config_set_bool (mc_main_config
, CONFIG_PANELS_SECTION
,
589 "simple_swap", (gboolean
) (simple_swap
& C_BOOL
));
591 if (!panels_options
.fast_reload_msg_shown
&& panels_options
.fast_reload
)
593 message (D_NORMAL
, _("Information"),
594 _("Using the fast reload option may not reflect the exact\n"
595 "directory contents. In this case you'll need to do a\n"
596 "manual reload of the directory. See the man page for\n" "the details."));
597 panels_options
.fast_reload_msg_shown
= TRUE
;
600 update_panels (UP_RELOAD
, UP_KEEPSEL
);
603 /* --------------------------------------------------------------------------------------------- */
605 /* return list type */
607 panel_listing_box (WPanel
* panel
, char **userp
, char **minip
, int *use_msformat
, int num
)
610 char *section
= NULL
;
617 p
= get_nth_panel_name (num
);
618 panel
= g_new (WPanel
, 1);
619 panel
->list_type
= list_full
;
620 panel
->user_format
= g_strdup (DEFAULT_USER_FORMAT
);
621 panel
->user_mini_status
= 0;
622 for (i
= 0; i
< LIST_TYPES
; i
++)
623 panel
->user_status_format
[i
] = g_strdup (DEFAULT_USER_FORMAT
);
624 section
= g_strconcat ("Temporal:", p
, (char *) NULL
);
625 if (!mc_config_has_group (mc_main_config
, section
))
628 section
= g_strdup (p
);
630 panel_load_setup (panel
, section
);
635 int mini_user_status
;
636 char *panel_user_format
;
637 char *mini_user_format
;
640 /* Controls whether the array strings have been translated */
641 const char *list_types
[LIST_TYPES
] = {
642 N_("&Full file list"),
643 N_("&Brief file list"),
644 N_("&Long file list"),
648 quick_widget_t quick_widgets
[] = {
650 QUICK_RADIO (LIST_TYPES
, list_types
, &result
, &panel_listing_types_id
),
651 QUICK_INPUT (panel
->user_format
, INPUT_COMPLETE_DEFAULT
, "user-fmt-input",
652 &panel_user_format
, &panel_user_format_id
),
653 QUICK_SEPARATOR (TRUE
),
654 QUICK_CHECKBOX (N_("User &mini status"), &mini_user_status
, &mini_user_status_id
),
655 QUICK_INPUT (panel
->user_status_format
[panel
->list_type
], INPUT_COMPLETE_DEFAULT
,
656 "mini_input", &mini_user_format
, &mini_user_format_id
),
657 QUICK_BUTTONS_OK_CANCEL
,
662 quick_dialog_t qdlg
= {
664 N_("Listing mode"), "[Listing Mode...]",
665 quick_widgets
, panel_listing_callback
, NULL
668 /* get hotkey of user-defined format string */
669 cp
= strchr (_(list_types
[panel_listing_user_idx
]), '&');
670 if (cp
!= NULL
&& *++cp
!= '\0')
671 listing_user_hotkey
= g_ascii_tolower (*cp
);
673 mini_user_status
= panel
->user_mini_status
;
674 result
= panel
->list_type
;
675 status_format
= panel
->user_status_format
;
677 if (panel
->list_type
!= panel_listing_user_idx
)
678 quick_widgets
[1].options
= W_DISABLED
;
680 if (!mini_user_status
)
681 quick_widgets
[4].options
= W_DISABLED
;
683 if (quick_dialog (&qdlg
) == B_CANCEL
)
687 *userp
= panel_user_format
;
688 *minip
= mini_user_format
;
689 *use_msformat
= mini_user_status
;
697 g_free (panel
->user_format
);
698 for (i
= 0; i
< LIST_TYPES
; i
++)
699 g_free (panel
->user_status_format
[i
]);
706 /* --------------------------------------------------------------------------------------------- */
708 const panel_field_t
*
709 sort_box (panel_sort_info_t
* info
)
711 const char **sort_orders_names
;
712 gsize sort_names_num
, i
;
714 const panel_field_t
*result
= info
->sort_field
;
716 sort_orders_names
= panel_get_sortable_fields (&sort_names_num
);
718 for (i
= 0; i
< sort_names_num
; i
++)
719 if (strcmp (sort_orders_names
[i
], _(info
->sort_field
->title_hotkey
)) == 0)
726 quick_widget_t quick_widgets
[] = {
729 QUICK_RADIO (sort_names_num
, sort_orders_names
, &sort_idx
, NULL
),
731 QUICK_CHECKBOX (N_("Executable &first"), &info
->exec_first
, NULL
),
732 QUICK_CHECKBOX (N_("Cas&e sensitive"), &info
->case_sensitive
, NULL
),
733 QUICK_CHECKBOX (N_("&Reverse"), &info
->reverse
, NULL
),
735 QUICK_BUTTONS_OK_CANCEL
,
740 quick_dialog_t qdlg
= {
742 N_("Sort order"), "[Sort Order...]",
743 quick_widgets
, NULL
, NULL
746 if (quick_dialog (&qdlg
) != B_CANCEL
)
747 result
= panel_get_field_by_title_hotkey (sort_orders_names
[sort_idx
]);
750 result
= info
->sort_field
;
753 g_strfreev ((gchar
**) sort_orders_names
);
758 /* --------------------------------------------------------------------------------------------- */
763 quick_widget_t quick_widgets
[] = {
765 /* TRANSLATORS: no need to translate 'Confirmation', it's just a context prefix */
766 QUICK_CHECKBOX (N_("Confirmation|&Delete"), &confirm_delete
, NULL
),
767 QUICK_CHECKBOX (N_("Confirmation|O&verwrite"), &confirm_overwrite
, NULL
),
768 QUICK_CHECKBOX (N_("Confirmation|&Execute"), &confirm_execute
, NULL
),
769 QUICK_CHECKBOX (N_("Confirmation|E&xit"), &confirm_exit
, NULL
),
770 QUICK_CHECKBOX (N_("Confirmation|Di&rectory hotlist delete"),
771 &confirm_directory_hotlist_delete
, NULL
),
772 QUICK_CHECKBOX (N_("Confirmation|&History cleanup"),
773 &mc_global
.widget
.confirm_history_cleanup
, NULL
),
774 QUICK_BUTTONS_OK_CANCEL
,
779 quick_dialog_t qdlg
= {
781 N_("Confirmation"), "[Confirmation]",
782 quick_widgets
, NULL
, NULL
785 (void) quick_dialog (&qdlg
);
788 /* --------------------------------------------------------------------------------------------- */
792 display_bits_box (void)
797 const char *display_bits_str
[] = {
799 N_("&Full 8 bits output"),
804 quick_widget_t quick_widgets
[] = {
806 QUICK_RADIO (4, display_bits_str
, ¤t_mode
, NULL
),
807 QUICK_SEPARATOR (TRUE
),
808 QUICK_CHECKBOX (N_("F&ull 8 bits input"), &new_meta
, NULL
),
809 QUICK_BUTTONS_OK_CANCEL
,
814 quick_dialog_t qdlg
= {
816 _("Display bits"), "[Display bits]",
817 quick_widgets
, NULL
, NULL
820 if (mc_global
.full_eight_bits
)
822 else if (mc_global
.eight_bit_clean
)
827 new_meta
= !use_8th_bit_as_meta
;
829 if (quick_dialog (&qdlg
) != B_CANCEL
)
831 mc_global
.eight_bit_clean
= current_mode
< 3;
832 mc_global
.full_eight_bits
= current_mode
< 2;
834 meta (stdscr
, mc_global
.eight_bit_clean
);
836 SLsmg_Display_Eight_Bit
= mc_global
.full_eight_bits
? 128 : 160;
838 use_8th_bit_as_meta
= !new_meta
;
842 /* --------------------------------------------------------------------------------------------- */
843 #else /* HAVE_CHARSET */
846 display_bits_box (void)
850 cpname
= (new_display_codepage
< 0) ? _("Other 8 bit")
851 : ((codepage_desc
*) g_ptr_array_index (codepages
, new_display_codepage
))->name
;
853 new_display_codepage
= mc_global
.display_codepage
;
858 quick_widget_t quick_widgets
[] = {
861 QUICK_LABEL (N_("Input / display codepage:"), NULL
),
865 QUICK_LABEL (cpname
, &disp_bits_name_id
),
867 QUICK_BUTTON (N_("&Select"), B_USER
, sel_charset_button
, NULL
),
869 QUICK_SEPARATOR (TRUE
),
870 QUICK_CHECKBOX (N_("F&ull 8 bits input"), &new_meta
, NULL
),
871 QUICK_BUTTONS_OK_CANCEL
,
876 quick_dialog_t qdlg
= {
878 N_("Display bits"), "[Display bits]",
879 quick_widgets
, NULL
, NULL
882 new_meta
= !use_8th_bit_as_meta
;
883 application_keypad_mode ();
885 if (quick_dialog (&qdlg
) == B_ENTER
)
889 mc_global
.display_codepage
= new_display_codepage
;
891 errmsg
= init_translation_table (mc_global
.source_codepage
, mc_global
.display_codepage
);
894 message (D_ERROR
, MSG_ERROR
, "%s", errmsg
);
899 tty_display_8bit (mc_global
.display_codepage
!= 0 && mc_global
.display_codepage
!= 1);
901 tty_display_8bit (mc_global
.display_codepage
!= 0);
903 use_8th_bit_as_meta
= !new_meta
;
909 #endif /* HAVE_CHARSET */
911 /* --------------------------------------------------------------------------------------------- */
912 /** Show tree in a box, not on a panel */
915 tree_box (const char *current_dir
)
925 /* Create the components */
926 dlg
= create_dlg (TRUE
, 0, 0, LINES
- 9, COLS
- 20, dialog_colors
, tree_callback
, NULL
,
927 "[Directory Tree]", _("Directory tree"), DLG_CENTER
);
930 mytree
= tree_new (2, 2, wd
->lines
- 6, wd
->cols
- 5, FALSE
);
931 add_widget_autopos (dlg
, mytree
, WPOS_KEEP_ALL
, NULL
);
932 add_widget_autopos (dlg
, hline_new (wd
->lines
- 4, 1, -1), WPOS_KEEP_BOTTOM
, NULL
);
933 bar
= buttonbar_new (TRUE
);
934 add_widget (dlg
, bar
);
935 /* restore ButtonBar coordinates after add_widget() */
937 WIDGET (bar
)->y
= LINES
- 1;
939 if (run_dlg (dlg
) == B_ENTER
)
940 val
= vfs_path_to_str (tree_selected_name (mytree
));
946 /* --------------------------------------------------------------------------------------------- */
952 char buffer2
[BUF_TINY
];
953 #ifdef ENABLE_VFS_FTP
954 char buffer3
[BUF_TINY
];
956 g_snprintf (buffer3
, sizeof (buffer3
), "%i", ftpfs_directory_timeout
);
959 g_snprintf (buffer2
, sizeof (buffer2
), "%i", vfs_timeout
);
963 #ifdef ENABLE_VFS_FTP
966 char *ret_directory_timeout
;
967 #endif /* ENABLE_VFS_FTP */
969 quick_widget_t quick_widgets
[] = {
971 QUICK_LABELED_INPUT (N_("Timeout for freeing VFSs (sec):"), input_label_left
,
972 buffer2
, 0, "input-timo-vfs", &ret_timeout
, NULL
),
973 #ifdef ENABLE_VFS_FTP
974 QUICK_SEPARATOR (TRUE
),
975 QUICK_LABELED_INPUT (N_("FTP anonymous password:"), input_label_left
,
976 ftpfs_anonymous_passwd
, 0, "input-passwd", &ret_passwd
, NULL
),
977 QUICK_LABELED_INPUT (N_("FTP directory cache timeout (sec):"), input_label_left
,
978 buffer3
, 0, "input-timeout", &ret_directory_timeout
, NULL
),
979 QUICK_CHECKBOX (N_("&Always use ftp proxy:"), &ftpfs_always_use_proxy
,
980 &ftpfs_always_use_proxy_id
),
981 QUICK_INPUT (ftpfs_proxy_host
, 0, "input-ftp-proxy", &ret_ftp_proxy
,
982 &ftpfs_proxy_host_id
),
983 QUICK_CHECKBOX (N_("&Use ~/.netrc"), &ftpfs_use_netrc
, NULL
),
984 QUICK_CHECKBOX (N_("Use &passive mode"), &ftpfs_use_passive_connections
, NULL
),
985 QUICK_CHECKBOX (N_("Use passive mode over pro&xy"),
986 &ftpfs_use_passive_connections_over_proxy
, NULL
),
987 #endif /* ENABLE_VFS_FTP */
988 QUICK_BUTTONS_OK_CANCEL
,
993 quick_dialog_t qdlg
= {
995 N_("Virtual File System Setting"), "[Virtual FS]",
997 #ifdef ENABLE_VFS_FTP
1005 #ifdef ENABLE_VFS_FTP
1006 if (!ftpfs_always_use_proxy
)
1007 quick_widgets
[5].options
= W_DISABLED
;
1010 if (quick_dialog (&qdlg
) != B_CANCEL
)
1012 vfs_timeout
= atoi (ret_timeout
);
1013 g_free (ret_timeout
);
1015 if (vfs_timeout
< 0 || vfs_timeout
> 10000)
1017 #ifdef ENABLE_VFS_FTP
1018 g_free (ftpfs_anonymous_passwd
);
1019 ftpfs_anonymous_passwd
= ret_passwd
;
1020 g_free (ftpfs_proxy_host
);
1021 ftpfs_proxy_host
= ret_ftp_proxy
;
1022 ftpfs_directory_timeout
= atoi (ret_directory_timeout
);
1023 g_free (ret_directory_timeout
);
1029 #endif /* ENABLE_VFS */
1031 /* --------------------------------------------------------------------------------------------- */
1036 const Widget
*w
= WIDGET (current_panel
);
1039 quick_widget_t quick_widgets
[] = {
1040 QUICK_LABELED_INPUT (N_("cd"), input_label_left
, "", 2, "input", &my_str
, NULL
),
1044 quick_dialog_t qdlg
= {
1045 w
->y
+ w
->lines
- 6, w
->x
, w
->cols
,
1046 N_("Quick cd"), "[Quick cd]",
1047 quick_widgets
, NULL
, NULL
1050 return (quick_dialog (&qdlg
) != B_CANCEL
) ? my_str
: NULL
;
1053 /* --------------------------------------------------------------------------------------------- */
1056 symlink_dialog (const vfs_path_t
* existing_vpath
, const vfs_path_t
* new_vpath
,
1057 char **ret_existing
, char **ret_new
)
1062 existing
= vfs_path_to_str (existing_vpath
);
1063 new = vfs_path_to_str (new_vpath
);
1066 quick_widget_t quick_widgets
[] = {
1068 QUICK_LABELED_INPUT (N_("Existing filename (filename symlink will point to):"),
1070 existing
, 0, "input-2", ret_existing
, NULL
),
1071 QUICK_SEPARATOR (FALSE
),
1072 QUICK_LABELED_INPUT (N_("Symbolic link filename:"), input_label_above
,
1073 new, 0, "input-1", ret_new
, NULL
),
1074 QUICK_BUTTONS_OK_CANCEL
,
1079 quick_dialog_t qdlg
= {
1081 N_("Symbolic link"), "[File Menu]",
1082 quick_widgets
, NULL
, NULL
1085 if (quick_dialog (&qdlg
) == B_CANCEL
)
1088 *ret_existing
= NULL
;
1096 /* --------------------------------------------------------------------------------------------- */
1098 #ifdef ENABLE_BACKGROUND
1113 { N_("&Stop"), NORMAL_BUTTON
, B_STOP
, 0, task_cb
},
1114 { N_("&Resume"), NORMAL_BUTTON
, B_RESUME
, 0, task_cb
},
1115 { N_("&Kill"), NORMAL_BUTTON
, B_KILL
, 0, task_cb
},
1116 { N_("&OK"), DEFPUSH_BUTTON
, B_CANCEL
, 0, NULL
}
1121 const size_t n_but
= G_N_ELEMENTS (job_but
);
1128 for (i
= 0; i
< n_but
; i
++)
1131 job_but
[i
].name
= _(job_but
[i
].name
);
1132 #endif /* ENABLE_NLS */
1134 job_but
[i
].len
= str_term_width1 (job_but
[i
].name
) + 3;
1135 if (job_but
[i
].flags
== DEFPUSH_BUTTON
)
1136 job_but
[i
].len
+= 2;
1137 x
+= job_but
[i
].len
;
1140 x
+= (int) n_but
- 1;
1141 cols
= max (cols
, x
+ 6);
1143 jobs_dlg
= create_dlg (TRUE
, 0, 0, lines
, cols
, dialog_colors
, NULL
, NULL
,
1144 "[Background jobs]", _("Background jobs"), DLG_CENTER
);
1146 bg_list
= listbox_new (2, 2, lines
- 6, cols
- 6, FALSE
, NULL
);
1147 jobs_fill_listbox (bg_list
);
1148 add_widget (jobs_dlg
, bg_list
);
1150 add_widget (jobs_dlg
, hline_new (lines
- 4, -1, -1));
1153 for (i
= 0; i
< n_but
; i
++)
1155 add_widget (jobs_dlg
,
1156 button_new (lines
- 3, x
, job_but
[i
].value
, job_but
[i
].flags
, job_but
[i
].name
,
1157 job_but
[i
].callback
));
1158 x
+= job_but
[i
].len
+ 1;
1161 (void) run_dlg (jobs_dlg
);
1162 destroy_dlg (jobs_dlg
);
1164 #endif /* ENABLE_BACKGROUND */
1166 /* --------------------------------------------------------------------------------------------- */
1168 #ifdef ENABLE_VFS_SMB
1169 struct smb_authinfo
*
1170 vfs_smb_get_authinfo (const char *host
, const char *share
, const char *domain
, const char *user
)
1173 struct smb_authinfo
*return_value
= NULL
;
1180 label
= g_strdup_printf (_("Password for \\\\%s\\%s"), host
, share
);
1183 char *ret_domain
, *ret_user
, *ret_password
;
1185 quick_widget_t quick_widgets
[] = {
1187 QUICK_LABEL (label
, NULL
),
1188 QUICK_SEPARATOR (TRUE
),
1189 QUICK_START_COLUMNS
,
1190 QUICK_LABEL (N_("Domain:"), NULL
),
1191 QUICK_SEPARATOR (FALSE
),
1192 QUICK_LABEL (N_("Username:"), NULL
),
1193 QUICK_SEPARATOR (FALSE
),
1194 QUICK_LABEL (N_("Password:"), NULL
),
1196 QUICK_INPUT (domain
, 0, "auth_domain", &ret_domain
, NULL
),
1197 QUICK_SEPARATOR (FALSE
),
1198 QUICK_INPUT (user
, 0, "auth_name", &ret_user
, NULL
),
1199 QUICK_SEPARATOR (FALSE
),
1200 QUICK_INPUT ("", 1, "auth_password", &ret_password
, NULL
),
1202 QUICK_BUTTONS_OK_CANCEL
,
1207 quick_dialog_t qdlg
= {
1209 N_("SMB authentication"), "[Smb Authinfo]",
1210 quick_widgets
, NULL
, NULL
1213 if (quick_dialog (&qdlg
) != B_CANCEL
)
1215 return_value
= vfs_smb_authinfo_new (host
, share
, ret_domain
, ret_user
, ret_password
);
1217 g_free (ret_domain
);
1219 g_free (ret_password
);
1225 return return_value
;
1227 #endif /* ENABLE_VFS_SMB */
1229 /* --------------------------------------------------------------------------------------------- */