2 Some misc dialog boxes for the program.
4 Copyright (C) 1994-2016
5 Free Software Foundation, Inc.
8 Miguel de Icaza, 1994, 1995
10 Andrew Borodin <aborodin@vmail.ru>, 2009-2015
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"
62 #include "src/history.h" /* MC_HISTORY_ESC_TIMEOUT */
63 #include "src/execute.h" /* pause_after_run */
64 #ifdef ENABLE_BACKGROUND
65 #include "src/background.h" /* task_list */
69 #include "lib/charsets.h"
70 #include "src/selcodepage.h"
73 #include "command.h" /* For cmdline */
75 #include "panel.h" /* LIST_TYPES */
77 #include "layout.h" /* for get_nth_panel_name proto */
78 #include "midnight.h" /* current_panel */
82 /*** global variables ****************************************************************************/
84 /*** file scope macro definitions ****************************************************************/
86 #ifdef ENABLE_BACKGROUND
87 #define B_STOP (B_USER+1)
88 #define B_RESUME (B_USER+2)
89 #define B_KILL (B_USER+3)
90 #endif /* ENABLE_BACKGROUND */
92 /*** file scope type declarations ****************************************************************/
94 /*** file scope variables ************************************************************************/
96 static unsigned long configure_old_esc_mode_id
, configure_time_out_id
;
98 /* Index in list_types[] for "brief" */
99 static const int panel_listing_brief_idx
= 1;
100 /* Index in list_types[] for "user defined" */
101 static const int panel_listing_user_idx
= 3;
103 static char **status_format
;
104 static unsigned long panel_listing_types_id
, panel_user_format_id
, panel_brief_cols_id
;
105 static unsigned long mini_user_status_id
, mini_user_format_id
;
108 static int new_display_codepage
;
109 #endif /* HAVE_CHARSET */
111 #if defined(ENABLE_VFS) && defined(ENABLE_VFS_FTP)
112 static unsigned long ftpfs_always_use_proxy_id
, ftpfs_proxy_host_id
;
113 #endif /* ENABLE_VFS && ENABLE_VFS_FTP */
115 static GPtrArray
*skin_names
;
116 static gchar
*current_skin_name
;
118 #ifdef ENABLE_BACKGROUND
119 static WListbox
*bg_list
= NULL
;
120 #endif /* ENABLE_BACKGROUND */
122 /* --------------------------------------------------------------------------------------------- */
123 /*** file scope functions ************************************************************************/
124 /* --------------------------------------------------------------------------------------------- */
127 configure_callback (Widget
* w
, Widget
* sender
, widget_msg_t msg
, int parm
, void *data
)
132 /* message from "Single press" checkbutton */
133 if (sender
!= NULL
&& sender
->id
== configure_old_esc_mode_id
)
135 const gboolean not_single
= !(CHECK (sender
)->state
& C_BOOL
);
139 ww
= dlg_find_by_id (DIALOG (w
), configure_time_out_id
);
140 widget_disable (ww
, not_single
);
144 return MSG_NOT_HANDLED
;
147 return dlg_default_callback (w
, sender
, msg
, parm
, data
);
151 /* --------------------------------------------------------------------------------------------- */
154 skin_apply (const gchar
* skin_override
)
156 GError
*mcerror
= NULL
;
159 mc_skin_init (skin_override
, &mcerror
);
160 mc_fhl_free (&mc_filehighlight
);
161 mc_filehighlight
= mc_fhl_new (TRUE
);
162 dlg_set_default_colors ();
163 input_set_default_colors ();
164 if (mc_global
.mc_run_mode
== MC_RUN_FULL
)
165 command_set_default_colors ();
170 mc_error_message (&mcerror
, NULL
);
173 /* --------------------------------------------------------------------------------------------- */
176 skin_name_to_label (const gchar
* name
)
178 if (strcmp (name
, "default") == 0)
179 return _("< Default >");
183 /* --------------------------------------------------------------------------------------------- */
186 sel_skin_button (WButton
* button
, int action
)
191 const gchar
*skin_name
;
194 unsigned int pos
= 1;
199 lyy
= (LINES
- 13) / 2;
201 dlg_create (TRUE
, lyy
, lxx
, 13, 24, dialog_colors
, NULL
, NULL
, "[Appearance]", _("Skins"),
204 skin_list
= listbox_new (1, 1, 11, 22, FALSE
, NULL
);
205 skin_name
= "default";
206 listbox_add_item (skin_list
, LISTBOX_APPEND_AT_END
, 0, skin_name_to_label (skin_name
),
207 (void *) skin_name
, FALSE
);
209 if (strcmp (skin_name
, current_skin_name
) == 0)
210 listbox_select_entry (skin_list
, 0);
212 for (i
= 0; i
< skin_names
->len
; i
++)
214 skin_name
= g_ptr_array_index (skin_names
, i
);
215 if (strcmp (skin_name
, "default") != 0)
217 listbox_add_item (skin_list
, LISTBOX_APPEND_AT_END
, 0, skin_name_to_label (skin_name
),
218 (void *) skin_name
, FALSE
);
219 if (strcmp (skin_name
, current_skin_name
) == 0)
220 listbox_select_entry (skin_list
, pos
);
225 add_widget (skin_dlg
, skin_list
);
227 result
= dlg_run (skin_dlg
);
228 if (result
== B_ENTER
)
232 listbox_get_current (skin_list
, &skin_label
, (void **) &skin_name
);
233 g_free (current_skin_name
);
234 current_skin_name
= g_strdup (skin_name
);
235 skin_apply (skin_name
);
237 button_set_text (button
, str_fit_to_term (skin_label
, 20, J_LEFT_FIT
));
239 dlg_destroy (skin_dlg
);
244 /* --------------------------------------------------------------------------------------------- */
247 panel_listing_callback (Widget
* w
, Widget
* sender
, widget_msg_t msg
, int parm
, void *data
)
249 WDialog
*h
= DIALOG (w
);
254 if (sender
!= NULL
&& sender
->id
== panel_listing_types_id
)
257 WInput
*in1
, *in2
, *in3
;
259 in1
= INPUT (dlg_find_by_id (h
, panel_user_format_id
));
260 in2
= INPUT (dlg_find_by_id (h
, panel_brief_cols_id
));
261 ch
= CHECK (dlg_find_by_id (h
, mini_user_status_id
));
262 in3
= INPUT (dlg_find_by_id (h
, mini_user_format_id
));
264 if (!(ch
->state
& C_BOOL
))
265 input_assign_text (in3
, status_format
[RADIO (sender
)->sel
]);
266 input_update (in1
, FALSE
);
267 input_update (in2
, FALSE
);
268 input_update (in3
, FALSE
);
269 widget_disable (WIDGET (in1
), RADIO (sender
)->sel
!= panel_listing_user_idx
);
270 widget_disable (WIDGET (in2
), RADIO (sender
)->sel
!= panel_listing_brief_idx
);
274 if (sender
!= NULL
&& sender
->id
== mini_user_status_id
)
278 in
= INPUT (dlg_find_by_id (h
, mini_user_format_id
));
280 if (CHECK (sender
)->state
& C_BOOL
)
282 widget_disable (WIDGET (in
), FALSE
);
283 input_assign_text (in
, status_format
[3]);
289 r
= RADIO (dlg_find_by_id (h
, panel_listing_types_id
));
290 widget_disable (WIDGET (in
), TRUE
);
291 input_assign_text (in
, status_format
[r
->sel
]);
293 /* input_update (in, FALSE); */
297 return MSG_NOT_HANDLED
;
300 return dlg_default_callback (w
, sender
, msg
, parm
, data
);
304 /* --------------------------------------------------------------------------------------------- */
308 sel_charset_button (WButton
* button
, int action
)
314 new_dcp
= select_charset (-1, -1, new_display_codepage
, TRUE
);
316 if (new_dcp
!= SELECT_CHARSET_CANCEL
)
320 new_display_codepage
= new_dcp
;
321 cpname
= (new_display_codepage
== SELECT_CHARSET_OTHER_8BIT
) ?
323 ((codepage_desc
*) g_ptr_array_index (codepages
, new_display_codepage
))->name
;
325 mc_global
.utf8_display
= str_isutf8 (cpname
);
327 cpname
= _("7-bit ASCII"); /* FIXME */
329 button_set_text (button
, cpname
);
330 dlg_redraw (WIDGET (button
)->owner
);
335 #endif /* HAVE_CHARSET */
337 /* --------------------------------------------------------------------------------------------- */
340 tree_callback (Widget
* w
, Widget
* sender
, widget_msg_t msg
, int parm
, void *data
)
342 WDialog
*h
= DIALOG (w
);
350 /* simply call dlg_set_size() with new size */
351 dlg_set_size (h
, LINES
- 9, COLS
- 20);
352 bar
= WIDGET (find_buttonbar (h
));
359 return send_message (find_tree (h
), NULL
, MSG_ACTION
, parm
, NULL
);
362 return dlg_default_callback (w
, sender
, msg
, parm
, data
);
366 /* --------------------------------------------------------------------------------------------- */
368 #if defined(ENABLE_VFS) && defined (ENABLE_VFS_FTP)
370 confvfs_callback (Widget
* w
, Widget
* sender
, widget_msg_t msg
, int parm
, void *data
)
375 /* message from "Always use ftp proxy" checkbutton */
376 if (sender
!= NULL
&& sender
->id
== ftpfs_always_use_proxy_id
)
378 const gboolean not_use
= !(CHECK (sender
)->state
& C_BOOL
);
382 wi
= dlg_find_by_id (DIALOG (w
), ftpfs_proxy_host_id
);
383 widget_disable (wi
, not_use
);
386 return MSG_NOT_HANDLED
;
389 return dlg_default_callback (w
, sender
, msg
, parm
, data
);
392 #endif /* ENABLE_VFS && ENABLE_VFS_FTP */
394 /* --------------------------------------------------------------------------------------------- */
396 #ifdef ENABLE_BACKGROUND
398 jobs_fill_listbox (WListbox
* list
)
400 static const char *state_str
[2] = { "", "" };
403 if (state_str
[0] == '\0')
405 state_str
[0] = _("Running");
406 state_str
[1] = _("Stopped");
409 for (tl
= task_list
; tl
!= NULL
; tl
= tl
->next
)
413 s
= g_strconcat (state_str
[tl
->state
], " ", tl
->info
, (char *) NULL
);
414 listbox_add_item (list
, LISTBOX_APPEND_AT_END
, 0, s
, (void *) tl
, FALSE
);
419 /* --------------------------------------------------------------------------------------------- */
422 task_cb (WButton
* button
, int action
)
429 if (bg_list
->list
== NULL
)
432 /* Get this instance information */
433 listbox_get_current (bg_list
, NULL
, (void **) &tl
);
436 if (action
== B_STOP
)
439 tl
->state
= Task_Stopped
;
441 else if (action
== B_RESUME
)
444 tl
->state
= Task_Running
;
448 if (action
== B_KILL
)
452 unregister_task_running (tl
->pid
, tl
->fd
);
455 listbox_remove_list (bg_list
);
456 jobs_fill_listbox (bg_list
);
458 /* This can be optimized to just redraw this widget :-) */
459 dlg_redraw (WIDGET (button
)->owner
);
463 #endif /* ENABLE_BACKGROUND */
465 /* --------------------------------------------------------------------------------------------- */
466 /*** public functions ****************************************************************************/
467 /* --------------------------------------------------------------------------------------------- */
472 const char *pause_options
[] = {
474 N_("On dum&b terminals"),
478 int pause_options_num
;
480 pause_options_num
= G_N_ELEMENTS (pause_options
);
483 char time_out
[BUF_TINY
] = "";
486 quick_widget_t quick_widgets
[] = {
489 QUICK_START_GROUPBOX (N_("File operations")),
490 QUICK_CHECKBOX (N_("&Verbose operation"), &verbose
, NULL
),
491 QUICK_CHECKBOX (N_("Compute tota&ls"), &file_op_compute_totals
, NULL
),
492 QUICK_CHECKBOX (N_("Classic pro&gressbar"), &classic_progressbar
, NULL
),
493 QUICK_CHECKBOX (N_("Mkdi&r autoname"), &auto_fill_mkdir_name
, NULL
),
494 QUICK_CHECKBOX (N_("&Preallocate space"), &mc_global
.vfs
.preallocate_space
,
497 QUICK_START_GROUPBOX (N_("Esc key mode")),
498 QUICK_CHECKBOX (N_("S&ingle press"), &old_esc_mode
, &configure_old_esc_mode_id
),
499 QUICK_LABELED_INPUT (N_("Timeout:"), input_label_left
,
500 (const char *) time_out
, MC_HISTORY_ESC_TIMEOUT
,
501 &time_out_new
, &configure_time_out_id
, FALSE
, FALSE
,
502 INPUT_COMPLETE_NONE
),
504 QUICK_START_GROUPBOX (N_("Pause after run")),
505 QUICK_RADIO (pause_options_num
, pause_options
, &pause_after_run
, NULL
),
508 QUICK_START_GROUPBOX (N_("Other options")),
509 QUICK_CHECKBOX (N_("Use internal edi&t"), &use_internal_edit
, NULL
),
510 QUICK_CHECKBOX (N_("Use internal vie&w"), &use_internal_view
, NULL
),
511 QUICK_CHECKBOX (N_("A&sk new file name"),
512 &editor_ask_filename_before_edit
, NULL
),
513 QUICK_CHECKBOX (N_("Auto m&enus"), &auto_menu
, NULL
),
514 QUICK_CHECKBOX (N_("&Drop down menus"), &drop_menus
, NULL
),
515 QUICK_CHECKBOX (N_("S&hell patterns"), &easy_patterns
, NULL
),
516 QUICK_CHECKBOX (N_("Co&mplete: show all"),
517 &mc_global
.widget
.show_all_if_ambiguous
, NULL
),
518 QUICK_CHECKBOX (N_("Rotating d&ash"), &nice_rotating_dash
, NULL
),
519 QUICK_CHECKBOX (N_("Cd follows lin&ks"), &mc_global
.vfs
.cd_symlinks
, NULL
),
520 QUICK_CHECKBOX (N_("Sa&fe delete"), &safe_delete
, NULL
),
521 QUICK_CHECKBOX (N_("A&uto save setup"), &auto_save_setup
, NULL
),
522 QUICK_SEPARATOR (FALSE
),
523 QUICK_SEPARATOR (FALSE
),
524 QUICK_SEPARATOR (FALSE
),
527 QUICK_BUTTONS_OK_CANCEL
,
532 quick_dialog_t qdlg
= {
534 N_("Configure options"), "[Configuration]",
535 quick_widgets
, configure_callback
, NULL
538 g_snprintf (time_out
, sizeof (time_out
), "%d", old_esc_mode_timeout
);
540 #ifndef USE_INTERNAL_EDIT
541 quick_widgets
[17].options
= W_DISABLED
;
545 quick_widgets
[10].options
= quick_widgets
[11].options
= W_DISABLED
;
547 #ifndef HAVE_POSIX_FALLOCATE
548 mc_global
.vfs
.preallocate_space
= FALSE
;
549 quick_widgets
[7].options
= W_DISABLED
;
552 if (quick_dialog (&qdlg
) == B_ENTER
)
553 old_esc_mode_timeout
= atoi (time_out_new
);
555 g_free (time_out_new
);
559 /* --------------------------------------------------------------------------------------------- */
562 appearance_box (void)
564 current_skin_name
= g_strdup (mc_skin__default
.name
);
565 skin_names
= mc_skin_list ();
568 quick_widget_t quick_widgets
[] = {
571 QUICK_LABEL (N_("Skin:"), NULL
),
573 QUICK_BUTTON (str_fit_to_term (skin_name_to_label (current_skin_name
), 20, J_LEFT_FIT
),
574 B_USER
, sel_skin_button
, NULL
),
576 QUICK_BUTTONS_OK_CANCEL
,
581 quick_dialog_t qdlg
= {
583 N_("Appearance"), "[Appearance]",
584 quick_widgets
, dlg_default_callback
, NULL
587 if (quick_dialog (&qdlg
) == B_ENTER
)
588 mc_config_set_string (mc_main_config
, CONFIG_APP_SECTION
, "skin", current_skin_name
);
593 g_free (current_skin_name
);
594 g_ptr_array_foreach (skin_names
, (GFunc
) g_free
, NULL
);
595 g_ptr_array_free (skin_names
, TRUE
);
598 /* --------------------------------------------------------------------------------------------- */
601 panel_options_box (void)
605 simple_swap
= mc_config_get_bool (mc_main_config
, CONFIG_PANELS_SECTION
,
606 "simple_swap", FALSE
) ? 1 : 0;
608 const char *qsearch_options
[] = {
609 N_("Case &insensitive"),
610 N_("Cas&e sensitive"),
611 N_("Use panel sort mo&de")
614 quick_widget_t quick_widgets
[] = {
617 QUICK_START_GROUPBOX (N_("Main options")),
618 QUICK_CHECKBOX (N_("Show mi&ni-status"), &panels_options
.show_mini_info
, NULL
),
619 QUICK_CHECKBOX (N_("Use SI si&ze units"), &panels_options
.kilobyte_si
, NULL
),
620 QUICK_CHECKBOX (N_("Mi&x all files"), &panels_options
.mix_all_files
, NULL
),
621 QUICK_CHECKBOX (N_("Show &backup files"), &panels_options
.show_backups
, NULL
),
622 QUICK_CHECKBOX (N_("Show &hidden files"), &panels_options
.show_dot_files
, NULL
),
623 QUICK_CHECKBOX (N_("&Fast dir reload"), &panels_options
.fast_reload
, NULL
),
624 QUICK_CHECKBOX (N_("Ma&rk moves down"), &panels_options
.mark_moves_down
, NULL
),
625 QUICK_CHECKBOX (N_("Re&verse files only"), &panels_options
.reverse_files_only
,
627 QUICK_CHECKBOX (N_("Simple s&wap"), &simple_swap
, NULL
),
628 QUICK_CHECKBOX (N_("A&uto save panels setup"), &panels_options
.auto_save_setup
,
630 QUICK_SEPARATOR (FALSE
),
631 QUICK_SEPARATOR (FALSE
),
634 QUICK_START_GROUPBOX (N_("Navigation")),
635 QUICK_CHECKBOX (N_("L&ynx-like motion"), &panels_options
.navigate_with_arrows
,
637 QUICK_CHECKBOX (N_("Pa&ge scrolling"), &panels_options
.scroll_pages
, NULL
),
638 QUICK_CHECKBOX (N_("&Mouse page scrolling"), &panels_options
.mouse_move_pages
,
641 QUICK_START_GROUPBOX (N_("File highlight")),
642 QUICK_CHECKBOX (N_("File &types"), &panels_options
.filetype_mode
, NULL
),
643 QUICK_CHECKBOX (N_("&Permissions"), &panels_options
.permission_mode
, NULL
),
645 QUICK_START_GROUPBOX (N_("Quick search")),
646 QUICK_RADIO (QSEARCH_NUM
, qsearch_options
, (int *) &panels_options
.qsearch_mode
,
650 QUICK_BUTTONS_OK_CANCEL
,
655 quick_dialog_t qdlg
= {
657 N_("Panel options"), "[Panel options]",
658 quick_widgets
, NULL
, NULL
661 if (quick_dialog (&qdlg
) != B_ENTER
)
665 mc_config_set_bool (mc_main_config
, CONFIG_PANELS_SECTION
,
666 "simple_swap", (gboolean
) (simple_swap
& C_BOOL
));
668 if (!panels_options
.fast_reload_msg_shown
&& panels_options
.fast_reload
)
670 message (D_NORMAL
, _("Information"),
671 _("Using the fast reload option may not reflect the exact\n"
672 "directory contents. In this case you'll need to do a\n"
673 "manual reload of the directory. See the man page for\n" "the details."));
674 panels_options
.fast_reload_msg_shown
= TRUE
;
677 update_panels (UP_RELOAD
, UP_KEEPSEL
);
680 /* --------------------------------------------------------------------------------------------- */
682 /* return list type */
684 panel_listing_box (WPanel
* panel
, int num
, char **userp
, char **minip
, int *use_msformat
,
688 char *section
= NULL
;
695 p
= get_nth_panel_name (num
);
696 panel
= g_new (WPanel
, 1);
697 panel
->list_type
= list_full
;
698 panel
->user_format
= g_strdup (DEFAULT_USER_FORMAT
);
699 panel
->user_mini_status
= 0;
700 for (i
= 0; i
< LIST_TYPES
; i
++)
701 panel
->user_status_format
[i
] = g_strdup (DEFAULT_USER_FORMAT
);
702 section
= g_strconcat ("Temporal:", p
, (char *) NULL
);
703 if (!mc_config_has_group (mc_main_config
, section
))
706 section
= g_strdup (p
);
708 panel_load_setup (panel
, section
);
713 int mini_user_status
;
714 char panel_brief_cols_in
[BUF_TINY
];
715 char *panel_brief_cols_out
= NULL
;
716 char *panel_user_format
= NULL
;
717 char *mini_user_format
= NULL
;
719 /* Controls whether the array strings have been translated */
720 const char *list_types
[LIST_TYPES
] = {
721 N_("&Full file list"),
722 N_("&Brief file list:"),
723 N_("&Long file list"),
727 quick_widget_t quick_widgets
[] = {
730 QUICK_RADIO (LIST_TYPES
, list_types
, &result
, &panel_listing_types_id
),
732 QUICK_SEPARATOR (FALSE
),
733 QUICK_LABELED_INPUT (_ ("columns"), input_label_right
, panel_brief_cols_in
,
734 "panel-brief-cols-input", &panel_brief_cols_out
,
735 &panel_brief_cols_id
, FALSE
, FALSE
, INPUT_COMPLETE_NONE
),
737 QUICK_INPUT (panel
->user_format
, "user-fmt-input", &panel_user_format
,
738 &panel_user_format_id
, FALSE
, FALSE
, INPUT_COMPLETE_NONE
),
739 QUICK_SEPARATOR (TRUE
),
740 QUICK_CHECKBOX (N_("User &mini status"), &mini_user_status
, &mini_user_status_id
),
741 QUICK_INPUT (panel
->user_status_format
[panel
->list_type
], "mini_input",
742 &mini_user_format
, &mini_user_format_id
, FALSE
, FALSE
, INPUT_COMPLETE_NONE
),
743 QUICK_BUTTONS_OK_CANCEL
,
748 quick_dialog_t qdlg
= {
750 N_("Listing mode"), "[Listing Mode...]",
751 quick_widgets
, panel_listing_callback
, NULL
754 mini_user_status
= panel
->user_mini_status
;
755 result
= panel
->list_type
;
756 status_format
= panel
->user_status_format
;
758 g_snprintf (panel_brief_cols_in
, sizeof (panel_brief_cols_in
), "%d", panel
->brief_cols
);
760 if ((int) panel
->list_type
!= panel_listing_brief_idx
)
761 quick_widgets
[4].options
= W_DISABLED
;
763 if ((int) panel
->list_type
!= panel_listing_user_idx
)
764 quick_widgets
[6].options
= W_DISABLED
;
766 if (!mini_user_status
)
767 quick_widgets
[9].options
= W_DISABLED
;
769 if (quick_dialog (&qdlg
) == B_CANCEL
)
776 *userp
= panel_user_format
;
777 *minip
= mini_user_format
;
778 *use_msformat
= mini_user_status
;
780 cols
= strtol (panel_brief_cols_out
, &error
, 10);
784 *brief_cols
= panel
->brief_cols
;
786 g_free (panel_brief_cols_out
);
794 g_free (panel
->user_format
);
795 for (i
= 0; i
< LIST_TYPES
; i
++)
796 g_free (panel
->user_status_format
[i
]);
803 /* --------------------------------------------------------------------------------------------- */
805 const panel_field_t
*
806 sort_box (dir_sort_options_t
* op
, const panel_field_t
* sort_field
)
808 char **sort_orders_names
;
810 gsize sort_names_num
= 0;
812 const panel_field_t
*result
= NULL
;
814 sort_orders_names
= panel_get_sortable_fields (&sort_names_num
);
816 for (i
= 0; i
< sort_names_num
; i
++)
817 if (strcmp (sort_orders_names
[i
], _(sort_field
->title_hotkey
)) == 0)
824 quick_widget_t quick_widgets
[] = {
827 QUICK_RADIO (sort_names_num
, (const char **) sort_orders_names
, &sort_idx
, NULL
),
829 QUICK_CHECKBOX (N_("Executable &first"), &op
->exec_first
, NULL
),
830 QUICK_CHECKBOX (N_("Cas&e sensitive"), &op
->case_sensitive
, NULL
),
831 QUICK_CHECKBOX (N_("&Reverse"), &op
->reverse
, NULL
),
833 QUICK_BUTTONS_OK_CANCEL
,
838 quick_dialog_t qdlg
= {
840 N_("Sort order"), "[Sort Order...]",
841 quick_widgets
, NULL
, NULL
844 if (quick_dialog (&qdlg
) != B_CANCEL
)
845 result
= panel_get_field_by_title_hotkey (sort_orders_names
[sort_idx
]);
851 g_strfreev (sort_orders_names
);
856 /* --------------------------------------------------------------------------------------------- */
861 quick_widget_t quick_widgets
[] = {
863 /* TRANSLATORS: no need to translate 'Confirmation', it's just a context prefix */
864 QUICK_CHECKBOX (Q_("Confirmation|&Delete"), &confirm_delete
, NULL
),
865 QUICK_CHECKBOX (Q_("Confirmation|O&verwrite"), &confirm_overwrite
, NULL
),
866 QUICK_CHECKBOX (Q_("Confirmation|&Execute"), &confirm_execute
, NULL
),
867 QUICK_CHECKBOX (Q_("Confirmation|E&xit"), &confirm_exit
, NULL
),
868 QUICK_CHECKBOX (Q_("Confirmation|Di&rectory hotlist delete"),
869 &confirm_directory_hotlist_delete
, NULL
),
870 QUICK_CHECKBOX (Q_("Confirmation|&History cleanup"),
871 &mc_global
.widget
.confirm_history_cleanup
, NULL
),
872 QUICK_BUTTONS_OK_CANCEL
,
877 quick_dialog_t qdlg
= {
879 N_("Confirmation"), "[Confirmation]",
880 quick_widgets
, NULL
, NULL
883 (void) quick_dialog (&qdlg
);
886 /* --------------------------------------------------------------------------------------------- */
890 display_bits_box (void)
895 const char *display_bits_str
[] = {
897 N_("&Full 8 bits output"),
902 quick_widget_t quick_widgets
[] = {
904 QUICK_RADIO (4, display_bits_str
, ¤t_mode
, NULL
),
905 QUICK_SEPARATOR (TRUE
),
906 QUICK_CHECKBOX (N_("F&ull 8 bits input"), &new_meta
, NULL
),
907 QUICK_BUTTONS_OK_CANCEL
,
912 quick_dialog_t qdlg
= {
914 _("Display bits"), "[Display bits]",
915 quick_widgets
, NULL
, NULL
918 if (mc_global
.full_eight_bits
)
920 else if (mc_global
.eight_bit_clean
)
925 new_meta
= !use_8th_bit_as_meta
;
927 if (quick_dialog (&qdlg
) != B_CANCEL
)
929 mc_global
.eight_bit_clean
= current_mode
< 3;
930 mc_global
.full_eight_bits
= current_mode
< 2;
932 meta (stdscr
, mc_global
.eight_bit_clean
);
934 SLsmg_Display_Eight_Bit
= mc_global
.full_eight_bits
? 128 : 160;
936 use_8th_bit_as_meta
= !new_meta
;
940 /* --------------------------------------------------------------------------------------------- */
941 #else /* HAVE_CHARSET */
944 display_bits_box (void)
948 new_display_codepage
= mc_global
.display_codepage
;
950 cpname
= (new_display_codepage
< 0) ? _("Other 8 bit")
951 : ((codepage_desc
*) g_ptr_array_index (codepages
, new_display_codepage
))->name
;
956 quick_widget_t quick_widgets
[] = {
959 QUICK_LABEL (N_("Input / display codepage:"), NULL
),
961 QUICK_BUTTON (cpname
, B_USER
, sel_charset_button
, NULL
),
963 QUICK_SEPARATOR (TRUE
),
964 QUICK_CHECKBOX (N_("F&ull 8 bits input"), &new_meta
, NULL
),
965 QUICK_BUTTONS_OK_CANCEL
,
970 quick_dialog_t qdlg
= {
972 N_("Display bits"), "[Display bits]",
973 quick_widgets
, NULL
, NULL
976 new_meta
= !use_8th_bit_as_meta
;
977 application_keypad_mode ();
979 if (quick_dialog (&qdlg
) == B_ENTER
)
983 mc_global
.display_codepage
= new_display_codepage
;
985 errmsg
= init_translation_table (mc_global
.source_codepage
, mc_global
.display_codepage
);
988 message (D_ERROR
, MSG_ERROR
, "%s", errmsg
);
993 tty_display_8bit (mc_global
.display_codepage
!= 0 && mc_global
.display_codepage
!= 1);
995 tty_display_8bit (mc_global
.display_codepage
!= 0);
997 use_8th_bit_as_meta
= !new_meta
;
1003 #endif /* HAVE_CHARSET */
1005 /* --------------------------------------------------------------------------------------------- */
1006 /** Show tree in a box, not on a panel */
1009 tree_box (const char *current_dir
)
1019 /* Create the components */
1020 dlg
= dlg_create (TRUE
, 0, 0, LINES
- 9, COLS
- 20, dialog_colors
, tree_callback
, NULL
,
1021 "[Directory Tree]", _("Directory tree"), DLG_CENTER
);
1024 mytree
= tree_new (2, 2, wd
->lines
- 6, wd
->cols
- 5, FALSE
);
1025 add_widget_autopos (dlg
, mytree
, WPOS_KEEP_ALL
, NULL
);
1026 add_widget_autopos (dlg
, hline_new (wd
->lines
- 4, 1, -1), WPOS_KEEP_BOTTOM
, NULL
);
1027 bar
= buttonbar_new (TRUE
);
1028 add_widget (dlg
, bar
);
1029 /* restore ButtonBar coordinates after add_widget() */
1030 WIDGET (bar
)->x
= 0;
1031 WIDGET (bar
)->y
= LINES
- 1;
1033 if (dlg_run (dlg
) == B_ENTER
)
1035 const vfs_path_t
*selected_name
;
1037 selected_name
= tree_selected_name (mytree
);
1038 val
= g_strdup (vfs_path_as_str (selected_name
));
1045 /* --------------------------------------------------------------------------------------------- */
1049 configure_vfs (void)
1051 char buffer2
[BUF_TINY
];
1052 #ifdef ENABLE_VFS_FTP
1053 char buffer3
[BUF_TINY
];
1055 g_snprintf (buffer3
, sizeof (buffer3
), "%i", ftpfs_directory_timeout
);
1058 g_snprintf (buffer2
, sizeof (buffer2
), "%i", vfs_timeout
);
1062 #ifdef ENABLE_VFS_FTP
1064 char *ret_ftp_proxy
;
1065 char *ret_directory_timeout
;
1066 #endif /* ENABLE_VFS_FTP */
1068 quick_widget_t quick_widgets
[] = {
1070 QUICK_LABELED_INPUT (N_("Timeout for freeing VFSs (sec):"), input_label_left
,
1071 buffer2
, "input-timo-vfs", &ret_timeout
, NULL
, FALSE
, FALSE
,
1072 INPUT_COMPLETE_NONE
),
1073 #ifdef ENABLE_VFS_FTP
1074 QUICK_SEPARATOR (TRUE
),
1075 QUICK_LABELED_INPUT (N_("FTP anonymous password:"), input_label_left
,
1076 ftpfs_anonymous_passwd
, "input-passwd", &ret_passwd
, NULL
,
1077 FALSE
, FALSE
, INPUT_COMPLETE_NONE
),
1078 QUICK_LABELED_INPUT (N_("FTP directory cache timeout (sec):"), input_label_left
,
1079 buffer3
, "input-timeout", &ret_directory_timeout
, NULL
,
1080 FALSE
, FALSE
, INPUT_COMPLETE_NONE
),
1081 QUICK_CHECKBOX (N_("&Always use ftp proxy:"), &ftpfs_always_use_proxy
,
1082 &ftpfs_always_use_proxy_id
),
1083 QUICK_INPUT (ftpfs_proxy_host
, "input-ftp-proxy", &ret_ftp_proxy
,
1084 &ftpfs_proxy_host_id
, FALSE
, FALSE
, INPUT_COMPLETE_HOSTNAMES
),
1085 QUICK_CHECKBOX (N_("&Use ~/.netrc"), &ftpfs_use_netrc
, NULL
),
1086 QUICK_CHECKBOX (N_("Use &passive mode"), &ftpfs_use_passive_connections
, NULL
),
1087 QUICK_CHECKBOX (N_("Use passive mode over pro&xy"),
1088 &ftpfs_use_passive_connections_over_proxy
, NULL
),
1089 #endif /* ENABLE_VFS_FTP */
1090 QUICK_BUTTONS_OK_CANCEL
,
1095 quick_dialog_t qdlg
= {
1097 N_("Virtual File System Setting"), "[Virtual FS]",
1099 #ifdef ENABLE_VFS_FTP
1107 #ifdef ENABLE_VFS_FTP
1108 if (!ftpfs_always_use_proxy
)
1109 quick_widgets
[5].options
= W_DISABLED
;
1112 if (quick_dialog (&qdlg
) != B_CANCEL
)
1114 /* cppcheck-suppress uninitvar */
1115 vfs_timeout
= atoi (ret_timeout
);
1116 g_free (ret_timeout
);
1118 if (vfs_timeout
< 0 || vfs_timeout
> 10000)
1120 #ifdef ENABLE_VFS_FTP
1121 g_free (ftpfs_anonymous_passwd
);
1122 /* cppcheck-suppress uninitvar */
1123 ftpfs_anonymous_passwd
= ret_passwd
;
1124 g_free (ftpfs_proxy_host
);
1125 /* cppcheck-suppress uninitvar */
1126 ftpfs_proxy_host
= ret_ftp_proxy
;
1127 /* cppcheck-suppress uninitvar */
1128 ftpfs_directory_timeout
= atoi (ret_directory_timeout
);
1129 g_free (ret_directory_timeout
);
1135 #endif /* ENABLE_VFS */
1137 /* --------------------------------------------------------------------------------------------- */
1142 const Widget
*w
= CONST_WIDGET (current_panel
);
1145 quick_widget_t quick_widgets
[] = {
1146 QUICK_LABELED_INPUT (N_("cd"), input_label_left
, "", "input", &my_str
, NULL
, FALSE
, TRUE
,
1147 INPUT_COMPLETE_FILENAMES
| INPUT_COMPLETE_CD
),
1151 quick_dialog_t qdlg
= {
1152 w
->y
+ w
->lines
- 6, w
->x
, w
->cols
,
1153 N_("Quick cd"), "[Quick cd]",
1154 quick_widgets
, NULL
, NULL
1157 return (quick_dialog (&qdlg
) != B_CANCEL
) ? my_str
: NULL
;
1160 /* --------------------------------------------------------------------------------------------- */
1163 symlink_dialog (const vfs_path_t
* existing_vpath
, const vfs_path_t
* new_vpath
,
1164 char **ret_existing
, char **ret_new
)
1166 quick_widget_t quick_widgets
[] = {
1168 QUICK_LABELED_INPUT (N_("Existing filename (filename symlink will point to):"),
1169 input_label_above
, vfs_path_as_str (existing_vpath
), "input-2",
1170 ret_existing
, NULL
, FALSE
, FALSE
, INPUT_COMPLETE_FILENAMES
),
1171 QUICK_SEPARATOR (FALSE
),
1172 QUICK_LABELED_INPUT (N_("Symbolic link filename:"), input_label_above
,
1173 vfs_path_as_str (new_vpath
), "input-1",
1174 ret_new
, NULL
, FALSE
, FALSE
, INPUT_COMPLETE_FILENAMES
),
1175 QUICK_BUTTONS_OK_CANCEL
,
1180 quick_dialog_t qdlg
= {
1182 N_("Symbolic link"), "[File Menu]",
1183 quick_widgets
, NULL
, NULL
1186 if (quick_dialog (&qdlg
) == B_CANCEL
)
1189 *ret_existing
= NULL
;
1193 /* --------------------------------------------------------------------------------------------- */
1195 #ifdef ENABLE_BACKGROUND
1210 { N_("&Stop"), NORMAL_BUTTON
, B_STOP
, 0, task_cb
},
1211 { N_("&Resume"), NORMAL_BUTTON
, B_RESUME
, 0, task_cb
},
1212 { N_("&Kill"), NORMAL_BUTTON
, B_KILL
, 0, task_cb
},
1213 { N_("&OK"), DEFPUSH_BUTTON
, B_CANCEL
, 0, NULL
}
1218 const size_t n_but
= G_N_ELEMENTS (job_but
);
1225 for (i
= 0; i
< n_but
; i
++)
1228 job_but
[i
].name
= _(job_but
[i
].name
);
1229 #endif /* ENABLE_NLS */
1231 job_but
[i
].len
= str_term_width1 (job_but
[i
].name
) + 3;
1232 if (job_but
[i
].flags
== DEFPUSH_BUTTON
)
1233 job_but
[i
].len
+= 2;
1234 x
+= job_but
[i
].len
;
1237 x
+= (int) n_but
- 1;
1238 cols
= MAX (cols
, x
+ 6);
1240 jobs_dlg
= dlg_create (TRUE
, 0, 0, lines
, cols
, dialog_colors
, NULL
, NULL
,
1241 "[Background jobs]", _("Background jobs"), DLG_CENTER
);
1243 bg_list
= listbox_new (2, 2, lines
- 6, cols
- 6, FALSE
, NULL
);
1244 jobs_fill_listbox (bg_list
);
1245 add_widget (jobs_dlg
, bg_list
);
1247 add_widget (jobs_dlg
, hline_new (lines
- 4, -1, -1));
1250 for (i
= 0; i
< n_but
; i
++)
1252 add_widget (jobs_dlg
,
1253 button_new (lines
- 3, x
, job_but
[i
].value
, job_but
[i
].flags
, job_but
[i
].name
,
1254 job_but
[i
].callback
));
1255 x
+= job_but
[i
].len
+ 1;
1258 (void) dlg_run (jobs_dlg
);
1259 dlg_destroy (jobs_dlg
);
1261 #endif /* ENABLE_BACKGROUND */
1263 /* --------------------------------------------------------------------------------------------- */
1265 #ifdef ENABLE_VFS_SMB
1266 struct smb_authinfo
*
1267 vfs_smb_get_authinfo (const char *host
, const char *share
, const char *domain
, const char *user
)
1270 struct smb_authinfo
*return_value
= NULL
;
1277 label
= g_strdup_printf (_("Password for \\\\%s\\%s"), host
, share
);
1280 char *ret_domain
, *ret_user
, *ret_password
;
1282 quick_widget_t quick_widgets
[] = {
1284 QUICK_LABEL (label
, NULL
),
1285 QUICK_SEPARATOR (TRUE
),
1286 QUICK_START_COLUMNS
,
1287 QUICK_LABEL (N_("Domain:"), NULL
),
1288 QUICK_SEPARATOR (FALSE
),
1289 QUICK_LABEL (N_("Username:"), NULL
),
1290 QUICK_SEPARATOR (FALSE
),
1291 QUICK_LABEL (N_("Password:"), NULL
),
1293 QUICK_INPUT (domain
, "auth_domain", &ret_domain
, NULL
, FALSE
, FALSE
, INPUT_COMPLETE_HOSTNAMES
),
1294 QUICK_SEPARATOR (FALSE
),
1295 QUICK_INPUT (user
, "auth_name", &ret_user
, NULL
, FALSE
, FALSE
, INPUT_COMPLETE_USERNAMES
),
1296 QUICK_SEPARATOR (FALSE
),
1297 QUICK_INPUT ("", "auth_password", &ret_password
, NULL
, TRUE
, FALSE
, INPUT_COMPLETE_NONE
),
1299 QUICK_BUTTONS_OK_CANCEL
,
1304 quick_dialog_t qdlg
= {
1306 N_("SMB authentication"), "[Smb Authinfo]",
1307 quick_widgets
, NULL
, NULL
1310 if (quick_dialog (&qdlg
) != B_CANCEL
)
1312 return_value
= vfs_smb_authinfo_new (host
, share
, ret_domain
, ret_user
, ret_password
);
1314 g_free (ret_domain
);
1316 g_free (ret_password
);
1322 return return_value
;
1324 #endif /* ENABLE_VFS_SMB */
1326 /* --------------------------------------------------------------------------------------------- */