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, WPOS_KEEP_DEFAULT
, TRUE
, dialog_colors
, NULL
, NULL
,
202 "[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].state
= WST_DISABLED
;
545 quick_widgets
[10].state
= quick_widgets
[11].state
= WST_DISABLED
;
547 #ifndef HAVE_POSIX_FALLOCATE
548 mc_global
.vfs
.preallocate_space
= FALSE
;
549 quick_widgets
[7].state
= WST_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_global
.main_config
, CONFIG_APP_SECTION
, "skin",
594 g_free (current_skin_name
);
595 g_ptr_array_foreach (skin_names
, (GFunc
) g_free
, NULL
);
596 g_ptr_array_free (skin_names
, TRUE
);
599 /* --------------------------------------------------------------------------------------------- */
602 panel_options_box (void)
606 simple_swap
= mc_config_get_bool (mc_global
.main_config
, CONFIG_PANELS_SECTION
,
607 "simple_swap", FALSE
) ? 1 : 0;
609 const char *qsearch_options
[] = {
610 N_("Case &insensitive"),
611 N_("Cas&e sensitive"),
612 N_("Use panel sort mo&de")
615 quick_widget_t quick_widgets
[] = {
618 QUICK_START_GROUPBOX (N_("Main options")),
619 QUICK_CHECKBOX (N_("Show mi&ni-status"), &panels_options
.show_mini_info
, NULL
),
620 QUICK_CHECKBOX (N_("Use SI si&ze units"), &panels_options
.kilobyte_si
, NULL
),
621 QUICK_CHECKBOX (N_("Mi&x all files"), &panels_options
.mix_all_files
, NULL
),
622 QUICK_CHECKBOX (N_("Show &backup files"), &panels_options
.show_backups
, NULL
),
623 QUICK_CHECKBOX (N_("Show &hidden files"), &panels_options
.show_dot_files
, NULL
),
624 QUICK_CHECKBOX (N_("&Fast dir reload"), &panels_options
.fast_reload
, NULL
),
625 QUICK_CHECKBOX (N_("Ma&rk moves down"), &panels_options
.mark_moves_down
, NULL
),
626 QUICK_CHECKBOX (N_("Re&verse files only"), &panels_options
.reverse_files_only
,
628 QUICK_CHECKBOX (N_("Simple s&wap"), &simple_swap
, NULL
),
629 QUICK_CHECKBOX (N_("A&uto save panels setup"), &panels_options
.auto_save_setup
,
631 QUICK_SEPARATOR (FALSE
),
632 QUICK_SEPARATOR (FALSE
),
633 QUICK_SEPARATOR (FALSE
),
636 QUICK_START_GROUPBOX (N_("Navigation")),
637 QUICK_CHECKBOX (N_("L&ynx-like motion"), &panels_options
.navigate_with_arrows
,
639 QUICK_CHECKBOX (N_("Pa&ge scrolling"), &panels_options
.scroll_pages
, NULL
),
640 QUICK_CHECKBOX (N_("Center &scrolling"), &panels_options
.scroll_center
, NULL
),
641 QUICK_CHECKBOX (N_("&Mouse page scrolling"), &panels_options
.mouse_move_pages
,
644 QUICK_START_GROUPBOX (N_("File highlight")),
645 QUICK_CHECKBOX (N_("File &types"), &panels_options
.filetype_mode
, NULL
),
646 QUICK_CHECKBOX (N_("&Permissions"), &panels_options
.permission_mode
, NULL
),
648 QUICK_START_GROUPBOX (N_("Quick search")),
649 QUICK_RADIO (QSEARCH_NUM
, qsearch_options
, (int *) &panels_options
.qsearch_mode
,
653 QUICK_BUTTONS_OK_CANCEL
,
658 quick_dialog_t qdlg
= {
660 N_("Panel options"), "[Panel options]",
661 quick_widgets
, NULL
, NULL
664 if (quick_dialog (&qdlg
) != B_ENTER
)
668 mc_config_set_bool (mc_global
.main_config
, CONFIG_PANELS_SECTION
,
669 "simple_swap", (gboolean
) (simple_swap
& C_BOOL
));
671 if (!panels_options
.fast_reload_msg_shown
&& panels_options
.fast_reload
)
673 message (D_NORMAL
, _("Information"),
674 _("Using the fast reload option may not reflect the exact\n"
675 "directory contents. In this case you'll need to do a\n"
676 "manual reload of the directory. See the man page for\n" "the details."));
677 panels_options
.fast_reload_msg_shown
= TRUE
;
680 update_panels (UP_RELOAD
, UP_KEEPSEL
);
683 /* --------------------------------------------------------------------------------------------- */
685 /* return list type */
687 panel_listing_box (WPanel
* panel
, int num
, char **userp
, char **minip
, int *use_msformat
,
691 char *section
= NULL
;
698 p
= get_nth_panel_name (num
);
699 panel
= g_new (WPanel
, 1);
700 panel
->list_type
= list_full
;
701 panel
->user_format
= g_strdup (DEFAULT_USER_FORMAT
);
702 panel
->user_mini_status
= 0;
703 for (i
= 0; i
< LIST_TYPES
; i
++)
704 panel
->user_status_format
[i
] = g_strdup (DEFAULT_USER_FORMAT
);
705 section
= g_strconcat ("Temporal:", p
, (char *) NULL
);
706 if (!mc_config_has_group (mc_global
.main_config
, section
))
709 section
= g_strdup (p
);
711 panel_load_setup (panel
, section
);
716 int mini_user_status
;
717 char panel_brief_cols_in
[BUF_TINY
];
718 char *panel_brief_cols_out
= NULL
;
719 char *panel_user_format
= NULL
;
720 char *mini_user_format
= NULL
;
722 /* Controls whether the array strings have been translated */
723 const char *list_types
[LIST_TYPES
] = {
724 N_("&Full file list"),
725 N_("&Brief file list:"),
726 N_("&Long file list"),
730 quick_widget_t quick_widgets
[] = {
733 QUICK_RADIO (LIST_TYPES
, list_types
, &result
, &panel_listing_types_id
),
735 QUICK_SEPARATOR (FALSE
),
736 QUICK_LABELED_INPUT (_ ("columns"), input_label_right
, panel_brief_cols_in
,
737 "panel-brief-cols-input", &panel_brief_cols_out
,
738 &panel_brief_cols_id
, FALSE
, FALSE
, INPUT_COMPLETE_NONE
),
740 QUICK_INPUT (panel
->user_format
, "user-fmt-input", &panel_user_format
,
741 &panel_user_format_id
, FALSE
, FALSE
, INPUT_COMPLETE_NONE
),
742 QUICK_SEPARATOR (TRUE
),
743 QUICK_CHECKBOX (N_("User &mini status"), &mini_user_status
, &mini_user_status_id
),
744 QUICK_INPUT (panel
->user_status_format
[panel
->list_type
], "mini_input",
745 &mini_user_format
, &mini_user_format_id
, FALSE
, FALSE
, INPUT_COMPLETE_NONE
),
746 QUICK_BUTTONS_OK_CANCEL
,
751 quick_dialog_t qdlg
= {
753 N_("Listing mode"), "[Listing Mode...]",
754 quick_widgets
, panel_listing_callback
, NULL
757 mini_user_status
= panel
->user_mini_status
;
758 result
= panel
->list_type
;
759 status_format
= panel
->user_status_format
;
761 g_snprintf (panel_brief_cols_in
, sizeof (panel_brief_cols_in
), "%d", panel
->brief_cols
);
763 if ((int) panel
->list_type
!= panel_listing_brief_idx
)
764 quick_widgets
[4].state
= WST_DISABLED
;
766 if ((int) panel
->list_type
!= panel_listing_user_idx
)
767 quick_widgets
[6].state
= WST_DISABLED
;
769 if (!mini_user_status
)
770 quick_widgets
[9].state
= WST_DISABLED
;
772 if (quick_dialog (&qdlg
) == B_CANCEL
)
779 *userp
= panel_user_format
;
780 *minip
= mini_user_format
;
781 *use_msformat
= mini_user_status
;
783 cols
= strtol (panel_brief_cols_out
, &error
, 10);
787 *brief_cols
= panel
->brief_cols
;
789 g_free (panel_brief_cols_out
);
797 g_free (panel
->user_format
);
798 for (i
= 0; i
< LIST_TYPES
; i
++)
799 g_free (panel
->user_status_format
[i
]);
806 /* --------------------------------------------------------------------------------------------- */
808 const panel_field_t
*
809 sort_box (dir_sort_options_t
* op
, const panel_field_t
* sort_field
)
811 char **sort_orders_names
;
813 gsize sort_names_num
= 0;
815 const panel_field_t
*result
= NULL
;
817 sort_orders_names
= panel_get_sortable_fields (&sort_names_num
);
819 for (i
= 0; i
< sort_names_num
; i
++)
820 if (strcmp (sort_orders_names
[i
], _(sort_field
->title_hotkey
)) == 0)
827 quick_widget_t quick_widgets
[] = {
830 QUICK_RADIO (sort_names_num
, (const char **) sort_orders_names
, &sort_idx
, NULL
),
832 QUICK_CHECKBOX (N_("Executable &first"), &op
->exec_first
, NULL
),
833 QUICK_CHECKBOX (N_("Cas&e sensitive"), &op
->case_sensitive
, NULL
),
834 QUICK_CHECKBOX (N_("&Reverse"), &op
->reverse
, NULL
),
836 QUICK_BUTTONS_OK_CANCEL
,
841 quick_dialog_t qdlg
= {
843 N_("Sort order"), "[Sort Order...]",
844 quick_widgets
, NULL
, NULL
847 if (quick_dialog (&qdlg
) != B_CANCEL
)
848 result
= panel_get_field_by_title_hotkey (sort_orders_names
[sort_idx
]);
854 g_strfreev (sort_orders_names
);
859 /* --------------------------------------------------------------------------------------------- */
864 quick_widget_t quick_widgets
[] = {
866 /* TRANSLATORS: no need to translate 'Confirmation', it's just a context prefix */
867 QUICK_CHECKBOX (Q_("Confirmation|&Delete"), &confirm_delete
, NULL
),
868 QUICK_CHECKBOX (Q_("Confirmation|O&verwrite"), &confirm_overwrite
, NULL
),
869 QUICK_CHECKBOX (Q_("Confirmation|&Execute"), &confirm_execute
, NULL
),
870 QUICK_CHECKBOX (Q_("Confirmation|E&xit"), &confirm_exit
, NULL
),
871 QUICK_CHECKBOX (Q_("Confirmation|Di&rectory hotlist delete"),
872 &confirm_directory_hotlist_delete
, NULL
),
873 QUICK_CHECKBOX (Q_("Confirmation|&History cleanup"),
874 &mc_global
.widget
.confirm_history_cleanup
, NULL
),
875 QUICK_BUTTONS_OK_CANCEL
,
880 quick_dialog_t qdlg
= {
882 N_("Confirmation"), "[Confirmation]",
883 quick_widgets
, NULL
, NULL
886 (void) quick_dialog (&qdlg
);
889 /* --------------------------------------------------------------------------------------------- */
893 display_bits_box (void)
898 const char *display_bits_str
[] = {
900 N_("&Full 8 bits output"),
905 quick_widget_t quick_widgets
[] = {
907 QUICK_RADIO (4, display_bits_str
, ¤t_mode
, NULL
),
908 QUICK_SEPARATOR (TRUE
),
909 QUICK_CHECKBOX (N_("F&ull 8 bits input"), &new_meta
, NULL
),
910 QUICK_BUTTONS_OK_CANCEL
,
915 quick_dialog_t qdlg
= {
917 _("Display bits"), "[Display bits]",
918 quick_widgets
, NULL
, NULL
921 if (mc_global
.full_eight_bits
)
923 else if (mc_global
.eight_bit_clean
)
928 new_meta
= !use_8th_bit_as_meta
;
930 if (quick_dialog (&qdlg
) != B_CANCEL
)
932 mc_global
.eight_bit_clean
= current_mode
< 3;
933 mc_global
.full_eight_bits
= current_mode
< 2;
935 meta (stdscr
, mc_global
.eight_bit_clean
);
937 SLsmg_Display_Eight_Bit
= mc_global
.full_eight_bits
? 128 : 160;
939 use_8th_bit_as_meta
= !new_meta
;
943 /* --------------------------------------------------------------------------------------------- */
944 #else /* HAVE_CHARSET */
947 display_bits_box (void)
951 new_display_codepage
= mc_global
.display_codepage
;
953 cpname
= (new_display_codepage
< 0) ? _("Other 8 bit")
954 : ((codepage_desc
*) g_ptr_array_index (codepages
, new_display_codepage
))->name
;
959 quick_widget_t quick_widgets
[] = {
962 QUICK_LABEL (N_("Input / display codepage:"), NULL
),
964 QUICK_BUTTON (cpname
, B_USER
, sel_charset_button
, NULL
),
966 QUICK_SEPARATOR (TRUE
),
967 QUICK_CHECKBOX (N_("F&ull 8 bits input"), &new_meta
, NULL
),
968 QUICK_BUTTONS_OK_CANCEL
,
973 quick_dialog_t qdlg
= {
975 N_("Display bits"), "[Display bits]",
976 quick_widgets
, NULL
, NULL
979 new_meta
= !use_8th_bit_as_meta
;
980 application_keypad_mode ();
982 if (quick_dialog (&qdlg
) == B_ENTER
)
986 mc_global
.display_codepage
= new_display_codepage
;
988 errmsg
= init_translation_table (mc_global
.source_codepage
, mc_global
.display_codepage
);
991 message (D_ERROR
, MSG_ERROR
, "%s", errmsg
);
996 tty_display_8bit (mc_global
.display_codepage
!= 0 && mc_global
.display_codepage
!= 1);
998 tty_display_8bit (mc_global
.display_codepage
!= 0);
1000 use_8th_bit_as_meta
= !new_meta
;
1006 #endif /* HAVE_CHARSET */
1008 /* --------------------------------------------------------------------------------------------- */
1009 /** Show tree in a box, not on a panel */
1012 tree_box (const char *current_dir
)
1022 /* Create the components */
1023 dlg
= dlg_create (TRUE
, 0, 0, LINES
- 9, COLS
- 20, WPOS_CENTER
, FALSE
, dialog_colors
,
1024 tree_callback
, NULL
, "[Directory Tree]", _("Directory tree"));
1027 mytree
= tree_new (2, 2, wd
->lines
- 6, wd
->cols
- 5, FALSE
);
1028 add_widget_autopos (dlg
, mytree
, WPOS_KEEP_ALL
, NULL
);
1029 add_widget_autopos (dlg
, hline_new (wd
->lines
- 4, 1, -1), WPOS_KEEP_BOTTOM
, NULL
);
1030 bar
= buttonbar_new (TRUE
);
1031 add_widget (dlg
, bar
);
1032 /* restore ButtonBar coordinates after add_widget() */
1033 WIDGET (bar
)->x
= 0;
1034 WIDGET (bar
)->y
= LINES
- 1;
1036 if (dlg_run (dlg
) == B_ENTER
)
1038 const vfs_path_t
*selected_name
;
1040 selected_name
= tree_selected_name (mytree
);
1041 val
= g_strdup (vfs_path_as_str (selected_name
));
1048 /* --------------------------------------------------------------------------------------------- */
1052 configure_vfs (void)
1054 char buffer2
[BUF_TINY
];
1055 #ifdef ENABLE_VFS_FTP
1056 char buffer3
[BUF_TINY
];
1058 g_snprintf (buffer3
, sizeof (buffer3
), "%i", ftpfs_directory_timeout
);
1061 g_snprintf (buffer2
, sizeof (buffer2
), "%i", vfs_timeout
);
1065 #ifdef ENABLE_VFS_FTP
1067 char *ret_ftp_proxy
;
1068 char *ret_directory_timeout
;
1069 #endif /* ENABLE_VFS_FTP */
1071 quick_widget_t quick_widgets
[] = {
1073 QUICK_LABELED_INPUT (N_("Timeout for freeing VFSs (sec):"), input_label_left
,
1074 buffer2
, "input-timo-vfs", &ret_timeout
, NULL
, FALSE
, FALSE
,
1075 INPUT_COMPLETE_NONE
),
1076 #ifdef ENABLE_VFS_FTP
1077 QUICK_SEPARATOR (TRUE
),
1078 QUICK_LABELED_INPUT (N_("FTP anonymous password:"), input_label_left
,
1079 ftpfs_anonymous_passwd
, "input-passwd", &ret_passwd
, NULL
,
1080 FALSE
, FALSE
, INPUT_COMPLETE_NONE
),
1081 QUICK_LABELED_INPUT (N_("FTP directory cache timeout (sec):"), input_label_left
,
1082 buffer3
, "input-timeout", &ret_directory_timeout
, NULL
,
1083 FALSE
, FALSE
, INPUT_COMPLETE_NONE
),
1084 QUICK_CHECKBOX (N_("&Always use ftp proxy:"), &ftpfs_always_use_proxy
,
1085 &ftpfs_always_use_proxy_id
),
1086 QUICK_INPUT (ftpfs_proxy_host
, "input-ftp-proxy", &ret_ftp_proxy
,
1087 &ftpfs_proxy_host_id
, FALSE
, FALSE
, INPUT_COMPLETE_HOSTNAMES
),
1088 QUICK_CHECKBOX (N_("&Use ~/.netrc"), &ftpfs_use_netrc
, NULL
),
1089 QUICK_CHECKBOX (N_("Use &passive mode"), &ftpfs_use_passive_connections
, NULL
),
1090 QUICK_CHECKBOX (N_("Use passive mode over pro&xy"),
1091 &ftpfs_use_passive_connections_over_proxy
, NULL
),
1092 #endif /* ENABLE_VFS_FTP */
1093 QUICK_BUTTONS_OK_CANCEL
,
1098 quick_dialog_t qdlg
= {
1100 N_("Virtual File System Setting"), "[Virtual FS]",
1102 #ifdef ENABLE_VFS_FTP
1110 #ifdef ENABLE_VFS_FTP
1111 if (!ftpfs_always_use_proxy
)
1112 quick_widgets
[5].state
= WST_DISABLED
;
1115 if (quick_dialog (&qdlg
) != B_CANCEL
)
1117 /* cppcheck-suppress uninitvar */
1118 vfs_timeout
= atoi (ret_timeout
);
1119 g_free (ret_timeout
);
1121 if (vfs_timeout
< 0 || vfs_timeout
> 10000)
1123 #ifdef ENABLE_VFS_FTP
1124 g_free (ftpfs_anonymous_passwd
);
1125 /* cppcheck-suppress uninitvar */
1126 ftpfs_anonymous_passwd
= ret_passwd
;
1127 g_free (ftpfs_proxy_host
);
1128 /* cppcheck-suppress uninitvar */
1129 ftpfs_proxy_host
= ret_ftp_proxy
;
1130 /* cppcheck-suppress uninitvar */
1131 ftpfs_directory_timeout
= atoi (ret_directory_timeout
);
1132 g_free (ret_directory_timeout
);
1138 #endif /* ENABLE_VFS */
1140 /* --------------------------------------------------------------------------------------------- */
1145 const Widget
*w
= CONST_WIDGET (current_panel
);
1148 quick_widget_t quick_widgets
[] = {
1149 QUICK_LABELED_INPUT (N_("cd"), input_label_left
, "", "input", &my_str
, NULL
, FALSE
, TRUE
,
1150 INPUT_COMPLETE_FILENAMES
| INPUT_COMPLETE_CD
),
1154 quick_dialog_t qdlg
= {
1155 w
->y
+ w
->lines
- 6, w
->x
, w
->cols
,
1156 N_("Quick cd"), "[Quick cd]",
1157 quick_widgets
, NULL
, NULL
1160 return (quick_dialog (&qdlg
) != B_CANCEL
) ? my_str
: NULL
;
1163 /* --------------------------------------------------------------------------------------------- */
1166 symlink_dialog (const vfs_path_t
* existing_vpath
, const vfs_path_t
* new_vpath
,
1167 char **ret_existing
, char **ret_new
)
1169 quick_widget_t quick_widgets
[] = {
1171 QUICK_LABELED_INPUT (N_("Existing filename (filename symlink will point to):"),
1172 input_label_above
, vfs_path_as_str (existing_vpath
), "input-2",
1173 ret_existing
, NULL
, FALSE
, FALSE
, INPUT_COMPLETE_FILENAMES
),
1174 QUICK_SEPARATOR (FALSE
),
1175 QUICK_LABELED_INPUT (N_("Symbolic link filename:"), input_label_above
,
1176 vfs_path_as_str (new_vpath
), "input-1",
1177 ret_new
, NULL
, FALSE
, FALSE
, INPUT_COMPLETE_FILENAMES
),
1178 QUICK_BUTTONS_OK_CANCEL
,
1183 quick_dialog_t qdlg
= {
1185 N_("Symbolic link"), "[File Menu]",
1186 quick_widgets
, NULL
, NULL
1189 if (quick_dialog (&qdlg
) == B_CANCEL
)
1192 *ret_existing
= NULL
;
1196 /* --------------------------------------------------------------------------------------------- */
1198 #ifdef ENABLE_BACKGROUND
1213 { N_("&Stop"), NORMAL_BUTTON
, B_STOP
, 0, task_cb
},
1214 { N_("&Resume"), NORMAL_BUTTON
, B_RESUME
, 0, task_cb
},
1215 { N_("&Kill"), NORMAL_BUTTON
, B_KILL
, 0, task_cb
},
1216 { N_("&OK"), DEFPUSH_BUTTON
, B_CANCEL
, 0, NULL
}
1221 const size_t n_but
= G_N_ELEMENTS (job_but
);
1228 for (i
= 0; i
< n_but
; i
++)
1231 job_but
[i
].name
= _(job_but
[i
].name
);
1232 #endif /* ENABLE_NLS */
1234 job_but
[i
].len
= str_term_width1 (job_but
[i
].name
) + 3;
1235 if (job_but
[i
].flags
== DEFPUSH_BUTTON
)
1236 job_but
[i
].len
+= 2;
1237 x
+= job_but
[i
].len
;
1240 x
+= (int) n_but
- 1;
1241 cols
= MAX (cols
, x
+ 6);
1243 jobs_dlg
= dlg_create (TRUE
, 0, 0, lines
, cols
, WPOS_CENTER
, FALSE
, dialog_colors
, NULL
, NULL
,
1244 "[Background jobs]", _("Background jobs"));
1246 bg_list
= listbox_new (2, 2, lines
- 6, cols
- 6, FALSE
, NULL
);
1247 jobs_fill_listbox (bg_list
);
1248 add_widget (jobs_dlg
, bg_list
);
1250 add_widget (jobs_dlg
, hline_new (lines
- 4, -1, -1));
1253 for (i
= 0; i
< n_but
; i
++)
1255 add_widget (jobs_dlg
,
1256 button_new (lines
- 3, x
, job_but
[i
].value
, job_but
[i
].flags
, job_but
[i
].name
,
1257 job_but
[i
].callback
));
1258 x
+= job_but
[i
].len
+ 1;
1261 (void) dlg_run (jobs_dlg
);
1262 dlg_destroy (jobs_dlg
);
1264 #endif /* ENABLE_BACKGROUND */
1266 /* --------------------------------------------------------------------------------------------- */
1268 #ifdef ENABLE_VFS_SMB
1269 struct smb_authinfo
*
1270 vfs_smb_get_authinfo (const char *host
, const char *share
, const char *domain
, const char *user
)
1273 struct smb_authinfo
*return_value
= NULL
;
1280 label
= g_strdup_printf (_("Password for \\\\%s\\%s"), host
, share
);
1283 char *ret_domain
, *ret_user
, *ret_password
;
1285 quick_widget_t quick_widgets
[] = {
1287 QUICK_LABEL (label
, NULL
),
1288 QUICK_SEPARATOR (TRUE
),
1289 QUICK_START_COLUMNS
,
1290 QUICK_LABEL (N_("Domain:"), NULL
),
1291 QUICK_SEPARATOR (FALSE
),
1292 QUICK_LABEL (N_("Username:"), NULL
),
1293 QUICK_SEPARATOR (FALSE
),
1294 QUICK_LABEL (N_("Password:"), NULL
),
1296 QUICK_INPUT (domain
, "auth_domain", &ret_domain
, NULL
, FALSE
, FALSE
, INPUT_COMPLETE_HOSTNAMES
),
1297 QUICK_SEPARATOR (FALSE
),
1298 QUICK_INPUT (user
, "auth_name", &ret_user
, NULL
, FALSE
, FALSE
, INPUT_COMPLETE_USERNAMES
),
1299 QUICK_SEPARATOR (FALSE
),
1300 QUICK_INPUT ("", "auth_password", &ret_password
, NULL
, TRUE
, FALSE
, INPUT_COMPLETE_NONE
),
1302 QUICK_BUTTONS_OK_CANCEL
,
1307 quick_dialog_t qdlg
= {
1309 N_("SMB authentication"), "[Smb Authinfo]",
1310 quick_widgets
, NULL
, NULL
1313 if (quick_dialog (&qdlg
) != B_CANCEL
)
1315 return_value
= vfs_smb_authinfo_new (host
, share
, ret_domain
, ret_user
, ret_password
);
1317 g_free (ret_domain
);
1319 g_free (ret_password
);
1325 return return_value
;
1327 #endif /* ENABLE_VFS_SMB */
1329 /* --------------------------------------------------------------------------------------------- */