2 Some misc dialog boxes for the program.
4 Copyright (C) 1994-2015
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 int listing_user_hotkey
= 'u';
105 static unsigned long panel_listing_types_id
, panel_user_format_id
, panel_brief_cols_id
;
106 static unsigned long mini_user_status_id
, mini_user_format_id
;
109 static int new_display_codepage
;
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 static GPtrArray
*skin_names
;
117 static gchar
*current_skin_name
;
119 #ifdef ENABLE_BACKGROUND
120 static WListbox
*bg_list
= NULL
;
121 #endif /* ENABLE_BACKGROUND */
123 /* --------------------------------------------------------------------------------------------- */
124 /*** file scope functions ************************************************************************/
125 /* --------------------------------------------------------------------------------------------- */
128 configure_callback (Widget
* w
, Widget
* sender
, widget_msg_t msg
, int parm
, void *data
)
133 /* message from "Single press" checkbutton */
134 if (sender
!= NULL
&& sender
->id
== configure_old_esc_mode_id
)
136 const gboolean not_single
= !(CHECK (sender
)->state
& C_BOOL
);
140 ww
= dlg_find_by_id (DIALOG (w
), configure_time_out_id
);
141 widget_disable (ww
, not_single
);
145 return MSG_NOT_HANDLED
;
148 return dlg_default_callback (w
, sender
, msg
, parm
, data
);
152 /* --------------------------------------------------------------------------------------------- */
155 skin_apply (const gchar
* skin_override
)
157 GError
*mcerror
= NULL
;
160 mc_skin_init (skin_override
, &mcerror
);
161 mc_fhl_free (&mc_filehighlight
);
162 mc_filehighlight
= mc_fhl_new (TRUE
);
163 dlg_set_default_colors ();
164 input_set_default_colors ();
165 if (mc_global
.mc_run_mode
== MC_RUN_FULL
)
166 command_set_default_colors ();
171 mc_error_message (&mcerror
, NULL
);
174 /* --------------------------------------------------------------------------------------------- */
177 skin_name_to_label (const gchar
* name
)
179 if (strcmp (name
, "default") == 0)
180 return _("< Default >");
184 /* --------------------------------------------------------------------------------------------- */
187 sel_skin_button (WButton
* button
, int action
)
192 const gchar
*skin_name
;
195 unsigned int pos
= 1;
200 lyy
= (LINES
- 13) / 2;
202 dlg_create (TRUE
, lyy
, lxx
, 13, 24, dialog_colors
, NULL
, NULL
, "[Appearance]", _("Skins"),
205 skin_list
= listbox_new (1, 1, 11, 22, FALSE
, NULL
);
206 skin_name
= "default";
207 listbox_add_item (skin_list
, LISTBOX_APPEND_AT_END
, 0, skin_name_to_label (skin_name
),
210 if (strcmp (skin_name
, current_skin_name
) == 0)
211 listbox_select_entry (skin_list
, 0);
213 for (i
= 0; i
< skin_names
->len
; i
++)
215 skin_name
= g_ptr_array_index (skin_names
, i
);
216 if (strcmp (skin_name
, "default") != 0)
218 listbox_add_item (skin_list
, LISTBOX_APPEND_AT_END
, 0, skin_name_to_label (skin_name
),
220 if (strcmp (skin_name
, current_skin_name
) == 0)
221 listbox_select_entry (skin_list
, pos
);
226 add_widget (skin_dlg
, skin_list
);
228 result
= dlg_run (skin_dlg
);
229 if (result
== B_ENTER
)
233 listbox_get_current (skin_list
, &skin_label
, (void **) &skin_name
);
234 g_free (current_skin_name
);
235 current_skin_name
= g_strdup (skin_name
);
236 skin_apply (skin_name
);
238 button_set_text (button
, str_fit_to_term (skin_label
, 20, J_LEFT_FIT
));
240 dlg_destroy (skin_dlg
);
245 /* --------------------------------------------------------------------------------------------- */
248 panel_listing_callback (Widget
* w
, Widget
* sender
, widget_msg_t msg
, int parm
, void *data
)
250 WDialog
*h
= DIALOG (w
);
259 wi
= dlg_find_by_id (h
, panel_listing_types_id
);
260 if (widget_is_active (wi
))
264 in
= INPUT (dlg_find_by_id (h
, mini_user_format_id
));
265 input_assign_text (in
, status_format
[RADIO (wi
)->sel
]);
270 wi
= dlg_find_by_id (h
, panel_user_format_id
);
271 if (widget_is_active (wi
))
273 h
->ret_value
= B_USER
+ 6;
278 wi
= dlg_find_by_id (h
, mini_user_format_id
);
279 if (widget_is_active (wi
))
281 h
->ret_value
= B_USER
+ 7;
287 if (g_ascii_tolower (parm
) == listing_user_hotkey
)
291 wi
= dlg_find_by_id (h
, panel_user_format_id
);
292 if (widget_is_active (wi
))
294 wi
= dlg_find_by_id (h
, mini_user_format_id
);
295 if (widget_is_active (wi
))
299 r
= RADIO (dlg_find_by_id (h
, panel_listing_types_id
));
300 r
->pos
= r
->sel
= panel_listing_user_idx
;
301 dlg_select_widget (WIDGET (r
)); /* force redraw */
302 send_message (h
, r
, MSG_ACTION
, 0, NULL
);
307 return MSG_NOT_HANDLED
;
310 if (sender
!= NULL
&& sender
->id
== panel_listing_types_id
)
313 WInput
*in1
, *in2
, *in3
;
315 in1
= INPUT (dlg_find_by_id (h
, panel_user_format_id
));
316 in2
= INPUT (dlg_find_by_id (h
, panel_brief_cols_id
));
317 ch
= CHECK (dlg_find_by_id (h
, mini_user_status_id
));
318 in3
= INPUT (dlg_find_by_id (h
, mini_user_format_id
));
320 if (!(ch
->state
& C_BOOL
))
321 input_assign_text (in3
, status_format
[RADIO (sender
)->sel
]);
322 input_update (in1
, FALSE
);
323 input_update (in2
, FALSE
);
324 input_update (in3
, FALSE
);
325 widget_disable (WIDGET (in1
), RADIO (sender
)->sel
!= panel_listing_user_idx
);
326 widget_disable (WIDGET (in2
), RADIO (sender
)->sel
!= panel_listing_brief_idx
);
330 if (sender
!= NULL
&& sender
->id
== mini_user_status_id
)
334 in
= INPUT (dlg_find_by_id (h
, mini_user_format_id
));
336 if (CHECK (sender
)->state
& C_BOOL
)
338 widget_disable (WIDGET (in
), FALSE
);
339 input_assign_text (in
, status_format
[3]);
345 r
= RADIO (dlg_find_by_id (h
, panel_listing_types_id
));
346 widget_disable (WIDGET (in
), TRUE
);
347 input_assign_text (in
, status_format
[r
->sel
]);
349 /* input_update (in, FALSE); */
353 return MSG_NOT_HANDLED
;
356 return dlg_default_callback (w
, sender
, msg
, parm
, data
);
360 /* --------------------------------------------------------------------------------------------- */
364 sel_charset_button (WButton
* button
, int action
)
370 new_dcp
= select_charset (-1, -1, new_display_codepage
, TRUE
);
372 if (new_dcp
!= SELECT_CHARSET_CANCEL
)
376 new_display_codepage
= new_dcp
;
377 cpname
= (new_display_codepage
== SELECT_CHARSET_OTHER_8BIT
) ?
379 ((codepage_desc
*) g_ptr_array_index (codepages
, new_display_codepage
))->name
;
381 mc_global
.utf8_display
= str_isutf8 (cpname
);
383 cpname
= _("7-bit ASCII"); /* FIXME */
385 button_set_text (button
, cpname
);
386 dlg_redraw (WIDGET (button
)->owner
);
391 #endif /* HAVE_CHARSET */
393 /* --------------------------------------------------------------------------------------------- */
396 tree_callback (Widget
* w
, Widget
* sender
, widget_msg_t msg
, int parm
, void *data
)
398 WDialog
*h
= DIALOG (w
);
406 /* simply call dlg_set_size() with new size */
407 dlg_set_size (h
, LINES
- 9, COLS
- 20);
408 bar
= WIDGET (find_buttonbar (h
));
415 return send_message (find_tree (h
), NULL
, MSG_ACTION
, parm
, NULL
);
418 return dlg_default_callback (w
, sender
, msg
, parm
, data
);
422 /* --------------------------------------------------------------------------------------------- */
424 #if defined(ENABLE_VFS) && defined (ENABLE_VFS_FTP)
426 confvfs_callback (Widget
* w
, Widget
* sender
, widget_msg_t msg
, int parm
, void *data
)
431 /* message from "Always use ftp proxy" checkbutton */
432 if (sender
!= NULL
&& sender
->id
== ftpfs_always_use_proxy_id
)
434 const gboolean not_use
= !(CHECK (sender
)->state
& C_BOOL
);
438 wi
= dlg_find_by_id (DIALOG (w
), ftpfs_proxy_host_id
);
439 widget_disable (wi
, not_use
);
442 return MSG_NOT_HANDLED
;
445 return dlg_default_callback (w
, sender
, msg
, parm
, data
);
448 #endif /* ENABLE_VFS && ENABLE_VFS_FTP */
450 /* --------------------------------------------------------------------------------------------- */
452 #ifdef ENABLE_BACKGROUND
454 jobs_fill_listbox (WListbox
* list
)
456 static const char *state_str
[2] = { "", "" };
459 if (state_str
[0] == '\0')
461 state_str
[0] = _("Running");
462 state_str
[1] = _("Stopped");
465 for (tl
= task_list
; tl
!= NULL
; tl
= tl
->next
)
469 s
= g_strconcat (state_str
[tl
->state
], " ", tl
->info
, (char *) NULL
);
470 listbox_add_item (list
, LISTBOX_APPEND_AT_END
, 0, s
, (void *) tl
);
475 /* --------------------------------------------------------------------------------------------- */
478 task_cb (WButton
* button
, int action
)
485 if (bg_list
->list
== NULL
)
488 /* Get this instance information */
489 listbox_get_current (bg_list
, NULL
, (void **) &tl
);
492 if (action
== B_STOP
)
495 tl
->state
= Task_Stopped
;
497 else if (action
== B_RESUME
)
500 tl
->state
= Task_Running
;
504 if (action
== B_KILL
)
508 unregister_task_running (tl
->pid
, tl
->fd
);
511 listbox_remove_list (bg_list
);
512 jobs_fill_listbox (bg_list
);
514 /* This can be optimized to just redraw this widget :-) */
515 dlg_redraw (WIDGET (button
)->owner
);
519 #endif /* ENABLE_BACKGROUND */
521 /* --------------------------------------------------------------------------------------------- */
522 /*** public functions ****************************************************************************/
523 /* --------------------------------------------------------------------------------------------- */
528 const char *pause_options
[] = {
530 N_("On dum&b terminals"),
534 int pause_options_num
;
536 pause_options_num
= G_N_ELEMENTS (pause_options
);
539 char time_out
[BUF_TINY
] = "";
542 quick_widget_t quick_widgets
[] = {
545 QUICK_START_GROUPBOX (N_("File operations")),
546 QUICK_CHECKBOX (N_("&Verbose operation"), &verbose
, NULL
),
547 QUICK_CHECKBOX (N_("Compute tota&ls"), &file_op_compute_totals
, NULL
),
548 QUICK_CHECKBOX (N_("Classic pro&gressbar"), &classic_progressbar
, NULL
),
549 QUICK_CHECKBOX (N_("Mkdi&r autoname"), &auto_fill_mkdir_name
, NULL
),
550 QUICK_CHECKBOX (N_("&Preallocate space"), &mc_global
.vfs
.preallocate_space
,
553 QUICK_START_GROUPBOX (N_("Esc key mode")),
554 QUICK_CHECKBOX (N_("S&ingle press"), &old_esc_mode
, &configure_old_esc_mode_id
),
555 QUICK_LABELED_INPUT (N_("Timeout:"), input_label_left
,
556 (const char *) time_out
, MC_HISTORY_ESC_TIMEOUT
,
557 &time_out_new
, &configure_time_out_id
, FALSE
, FALSE
,
558 INPUT_COMPLETE_NONE
),
560 QUICK_START_GROUPBOX (N_("Pause after run")),
561 QUICK_RADIO (pause_options_num
, pause_options
, &pause_after_run
, NULL
),
564 QUICK_START_GROUPBOX (N_("Other options")),
565 QUICK_CHECKBOX (N_("Use internal edi&t"), &use_internal_edit
, NULL
),
566 QUICK_CHECKBOX (N_("Use internal vie&w"), &use_internal_view
, NULL
),
567 QUICK_CHECKBOX (N_("A&sk new file name"),
568 &editor_ask_filename_before_edit
, NULL
),
569 QUICK_CHECKBOX (N_("Auto m&enus"), &auto_menu
, NULL
),
570 QUICK_CHECKBOX (N_("&Drop down menus"), &drop_menus
, NULL
),
571 QUICK_CHECKBOX (N_("S&hell patterns"), &easy_patterns
, NULL
),
572 QUICK_CHECKBOX (N_("Co&mplete: show all"),
573 &mc_global
.widget
.show_all_if_ambiguous
, NULL
),
574 QUICK_CHECKBOX (N_("Rotating d&ash"), &nice_rotating_dash
, NULL
),
575 QUICK_CHECKBOX (N_("Cd follows lin&ks"), &mc_global
.vfs
.cd_symlinks
, NULL
),
576 QUICK_CHECKBOX (N_("Sa&fe delete"), &safe_delete
, NULL
),
577 QUICK_CHECKBOX (N_("A&uto save setup"), &auto_save_setup
, NULL
),
578 QUICK_SEPARATOR (FALSE
),
579 QUICK_SEPARATOR (FALSE
),
580 QUICK_SEPARATOR (FALSE
),
583 QUICK_BUTTONS_OK_CANCEL
,
588 quick_dialog_t qdlg
= {
590 N_("Configure options"), "[Configuration]",
591 quick_widgets
, configure_callback
, NULL
594 g_snprintf (time_out
, sizeof (time_out
), "%d", old_esc_mode_timeout
);
596 #ifndef USE_INTERNAL_EDIT
597 quick_widgets
[17].options
= W_DISABLED
;
601 quick_widgets
[10].options
= quick_widgets
[11].options
= W_DISABLED
;
603 #ifndef HAVE_POSIX_FALLOCATE
604 mc_global
.vfs
.preallocate_space
= FALSE
;
605 quick_widgets
[7].options
= W_DISABLED
;
608 if (quick_dialog (&qdlg
) == B_ENTER
)
609 old_esc_mode_timeout
= atoi (time_out_new
);
611 g_free (time_out_new
);
615 /* --------------------------------------------------------------------------------------------- */
618 appearance_box (void)
620 current_skin_name
= g_strdup (mc_skin__default
.name
);
621 skin_names
= mc_skin_list ();
624 quick_widget_t quick_widgets
[] = {
627 QUICK_LABEL (N_("Skin:"), NULL
),
629 QUICK_BUTTON (str_fit_to_term (skin_name_to_label (current_skin_name
), 20, J_LEFT_FIT
),
630 B_USER
, sel_skin_button
, NULL
),
632 QUICK_BUTTONS_OK_CANCEL
,
637 quick_dialog_t qdlg
= {
639 N_("Appearance"), "[Appearance]",
640 quick_widgets
, dlg_default_callback
, NULL
643 if (quick_dialog (&qdlg
) == B_ENTER
)
644 mc_config_set_string (mc_main_config
, CONFIG_APP_SECTION
, "skin", current_skin_name
);
649 g_free (current_skin_name
);
650 g_ptr_array_foreach (skin_names
, (GFunc
) g_free
, NULL
);
651 g_ptr_array_free (skin_names
, TRUE
);
654 /* --------------------------------------------------------------------------------------------- */
657 panel_options_box (void)
661 simple_swap
= mc_config_get_bool (mc_main_config
, CONFIG_PANELS_SECTION
,
662 "simple_swap", FALSE
) ? 1 : 0;
664 const char *qsearch_options
[] = {
665 N_("Case &insensitive"),
666 N_("Cas&e sensitive"),
667 N_("Use panel sort mo&de")
670 quick_widget_t quick_widgets
[] = {
673 QUICK_START_GROUPBOX (N_("Main options")),
674 QUICK_CHECKBOX (N_("Show mi&ni-status"), &panels_options
.show_mini_info
, NULL
),
675 QUICK_CHECKBOX (N_("Use SI si&ze units"), &panels_options
.kilobyte_si
, NULL
),
676 QUICK_CHECKBOX (N_("Mi&x all files"), &panels_options
.mix_all_files
, NULL
),
677 QUICK_CHECKBOX (N_("Show &backup files"), &panels_options
.show_backups
, NULL
),
678 QUICK_CHECKBOX (N_("Show &hidden files"), &panels_options
.show_dot_files
, NULL
),
679 QUICK_CHECKBOX (N_("&Fast dir reload"), &panels_options
.fast_reload
, NULL
),
680 QUICK_CHECKBOX (N_("Ma&rk moves down"), &panels_options
.mark_moves_down
, NULL
),
681 QUICK_CHECKBOX (N_("Re&verse files only"), &panels_options
.reverse_files_only
,
683 QUICK_CHECKBOX (N_("Simple s&wap"), &simple_swap
, NULL
),
684 QUICK_CHECKBOX (N_("A&uto save panels setup"), &panels_options
.auto_save_setup
,
686 QUICK_SEPARATOR (FALSE
),
687 QUICK_SEPARATOR (FALSE
),
690 QUICK_START_GROUPBOX (N_("Navigation")),
691 QUICK_CHECKBOX (N_("L&ynx-like motion"), &panels_options
.navigate_with_arrows
,
693 QUICK_CHECKBOX (N_("Pa&ge scrolling"), &panels_options
.scroll_pages
, NULL
),
694 QUICK_CHECKBOX (N_("&Mouse page scrolling"), &panels_options
.mouse_move_pages
,
697 QUICK_START_GROUPBOX (N_("File highlight")),
698 QUICK_CHECKBOX (N_("File &types"), &panels_options
.filetype_mode
, NULL
),
699 QUICK_CHECKBOX (N_("&Permissions"), &panels_options
.permission_mode
, NULL
),
701 QUICK_START_GROUPBOX (N_("Quick search")),
702 QUICK_RADIO (QSEARCH_NUM
, qsearch_options
, (int *) &panels_options
.qsearch_mode
,
706 QUICK_BUTTONS_OK_CANCEL
,
711 quick_dialog_t qdlg
= {
713 N_("Panel options"), "[Panel options]",
714 quick_widgets
, NULL
, NULL
717 if (quick_dialog (&qdlg
) != B_ENTER
)
721 mc_config_set_bool (mc_main_config
, CONFIG_PANELS_SECTION
,
722 "simple_swap", (gboolean
) (simple_swap
& C_BOOL
));
724 if (!panels_options
.fast_reload_msg_shown
&& panels_options
.fast_reload
)
726 message (D_NORMAL
, _("Information"),
727 _("Using the fast reload option may not reflect the exact\n"
728 "directory contents. In this case you'll need to do a\n"
729 "manual reload of the directory. See the man page for\n" "the details."));
730 panels_options
.fast_reload_msg_shown
= TRUE
;
733 update_panels (UP_RELOAD
, UP_KEEPSEL
);
736 /* --------------------------------------------------------------------------------------------- */
738 /* return list type */
740 panel_listing_box (WPanel
* panel
, int num
, char **userp
, char **minip
, int *use_msformat
,
744 char *section
= NULL
;
751 p
= get_nth_panel_name (num
);
752 panel
= g_new (WPanel
, 1);
753 panel
->list_type
= list_full
;
754 panel
->user_format
= g_strdup (DEFAULT_USER_FORMAT
);
755 panel
->user_mini_status
= 0;
756 for (i
= 0; i
< LIST_TYPES
; i
++)
757 panel
->user_status_format
[i
] = g_strdup (DEFAULT_USER_FORMAT
);
758 section
= g_strconcat ("Temporal:", p
, (char *) NULL
);
759 if (!mc_config_has_group (mc_main_config
, section
))
762 section
= g_strdup (p
);
764 panel_load_setup (panel
, section
);
769 int mini_user_status
;
770 char panel_brief_cols_in
[BUF_TINY
];
771 char *panel_brief_cols_out
= NULL
;
772 char *panel_user_format
= NULL
;
773 char *mini_user_format
= NULL
;
776 /* Controls whether the array strings have been translated */
777 const char *list_types
[LIST_TYPES
] = {
778 N_("&Full file list"),
779 N_("&Brief file list:"),
780 N_("&Long file list"),
784 quick_widget_t quick_widgets
[] = {
787 QUICK_RADIO (LIST_TYPES
, list_types
, &result
, &panel_listing_types_id
),
789 QUICK_SEPARATOR (FALSE
),
790 QUICK_LABELED_INPUT (_ ("columns"), input_label_right
, panel_brief_cols_in
,
791 "panel-brief-cols-input", &panel_brief_cols_out
,
792 &panel_brief_cols_id
, FALSE
, FALSE
, INPUT_COMPLETE_NONE
),
794 QUICK_INPUT (panel
->user_format
, "user-fmt-input", &panel_user_format
,
795 &panel_user_format_id
, FALSE
, FALSE
, INPUT_COMPLETE_NONE
),
796 QUICK_SEPARATOR (TRUE
),
797 QUICK_CHECKBOX (N_("User &mini status"), &mini_user_status
, &mini_user_status_id
),
798 QUICK_INPUT (panel
->user_status_format
[panel
->list_type
], "mini_input",
799 &mini_user_format
, &mini_user_format_id
, FALSE
, FALSE
, INPUT_COMPLETE_NONE
),
800 QUICK_BUTTONS_OK_CANCEL
,
805 quick_dialog_t qdlg
= {
807 N_("Listing mode"), "[Listing Mode...]",
808 quick_widgets
, panel_listing_callback
, NULL
811 /* get hotkey of user-defined format string */
812 cp
= strchr (_(list_types
[panel_listing_user_idx
]), '&');
813 if (cp
!= NULL
&& *++cp
!= '\0')
814 listing_user_hotkey
= g_ascii_tolower (*cp
);
816 mini_user_status
= panel
->user_mini_status
;
817 result
= panel
->list_type
;
818 status_format
= panel
->user_status_format
;
820 g_snprintf (panel_brief_cols_in
, sizeof (panel_brief_cols_in
), "%d", panel
->brief_cols
);
822 if ((int) panel
->list_type
!= panel_listing_brief_idx
)
823 quick_widgets
[4].options
= W_DISABLED
;
825 if ((int) panel
->list_type
!= panel_listing_user_idx
)
826 quick_widgets
[6].options
= W_DISABLED
;
828 if (!mini_user_status
)
829 quick_widgets
[9].options
= W_DISABLED
;
831 if (quick_dialog (&qdlg
) == B_CANCEL
)
838 *userp
= panel_user_format
;
839 *minip
= mini_user_format
;
840 *use_msformat
= mini_user_status
;
842 cols
= strtol (panel_brief_cols_out
, &error
, 10);
846 *brief_cols
= panel
->brief_cols
;
848 g_free (panel_brief_cols_out
);
856 g_free (panel
->user_format
);
857 for (i
= 0; i
< LIST_TYPES
; i
++)
858 g_free (panel
->user_status_format
[i
]);
865 /* --------------------------------------------------------------------------------------------- */
867 const panel_field_t
*
868 sort_box (dir_sort_options_t
* op
, const panel_field_t
* sort_field
)
870 const char **sort_orders_names
;
871 gsize sort_names_num
, i
;
873 const panel_field_t
*result
= NULL
;
875 sort_orders_names
= panel_get_sortable_fields (&sort_names_num
);
877 for (i
= 0; i
< sort_names_num
; i
++)
878 if (strcmp (sort_orders_names
[i
], _(sort_field
->title_hotkey
)) == 0)
885 quick_widget_t quick_widgets
[] = {
888 QUICK_RADIO (sort_names_num
, sort_orders_names
, &sort_idx
, NULL
),
890 QUICK_CHECKBOX (N_("Executable &first"), &op
->exec_first
, NULL
),
891 QUICK_CHECKBOX (N_("Cas&e sensitive"), &op
->case_sensitive
, NULL
),
892 QUICK_CHECKBOX (N_("&Reverse"), &op
->reverse
, NULL
),
894 QUICK_BUTTONS_OK_CANCEL
,
899 quick_dialog_t qdlg
= {
901 N_("Sort order"), "[Sort Order...]",
902 quick_widgets
, NULL
, NULL
905 if (quick_dialog (&qdlg
) != B_CANCEL
)
906 result
= panel_get_field_by_title_hotkey (sort_orders_names
[sort_idx
]);
912 g_strfreev ((gchar
**) sort_orders_names
);
917 /* --------------------------------------------------------------------------------------------- */
922 quick_widget_t quick_widgets
[] = {
924 /* TRANSLATORS: no need to translate 'Confirmation', it's just a context prefix */
925 QUICK_CHECKBOX (Q_("Confirmation|&Delete"), &confirm_delete
, NULL
),
926 QUICK_CHECKBOX (Q_("Confirmation|O&verwrite"), &confirm_overwrite
, NULL
),
927 QUICK_CHECKBOX (Q_("Confirmation|&Execute"), &confirm_execute
, NULL
),
928 QUICK_CHECKBOX (Q_("Confirmation|E&xit"), &confirm_exit
, NULL
),
929 QUICK_CHECKBOX (Q_("Confirmation|Di&rectory hotlist delete"),
930 &confirm_directory_hotlist_delete
, NULL
),
931 QUICK_CHECKBOX (Q_("Confirmation|&History cleanup"),
932 &mc_global
.widget
.confirm_history_cleanup
, NULL
),
933 QUICK_BUTTONS_OK_CANCEL
,
938 quick_dialog_t qdlg
= {
940 N_("Confirmation"), "[Confirmation]",
941 quick_widgets
, NULL
, NULL
944 (void) quick_dialog (&qdlg
);
947 /* --------------------------------------------------------------------------------------------- */
951 display_bits_box (void)
956 const char *display_bits_str
[] = {
958 N_("&Full 8 bits output"),
963 quick_widget_t quick_widgets
[] = {
965 QUICK_RADIO (4, display_bits_str
, ¤t_mode
, 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 _("Display bits"), "[Display bits]",
976 quick_widgets
, NULL
, NULL
979 if (mc_global
.full_eight_bits
)
981 else if (mc_global
.eight_bit_clean
)
986 new_meta
= !use_8th_bit_as_meta
;
988 if (quick_dialog (&qdlg
) != B_CANCEL
)
990 mc_global
.eight_bit_clean
= current_mode
< 3;
991 mc_global
.full_eight_bits
= current_mode
< 2;
993 meta (stdscr
, mc_global
.eight_bit_clean
);
995 SLsmg_Display_Eight_Bit
= mc_global
.full_eight_bits
? 128 : 160;
997 use_8th_bit_as_meta
= !new_meta
;
1001 /* --------------------------------------------------------------------------------------------- */
1002 #else /* HAVE_CHARSET */
1005 display_bits_box (void)
1009 new_display_codepage
= mc_global
.display_codepage
;
1011 cpname
= (new_display_codepage
< 0) ? _("Other 8 bit")
1012 : ((codepage_desc
*) g_ptr_array_index (codepages
, new_display_codepage
))->name
;
1017 quick_widget_t quick_widgets
[] = {
1019 QUICK_START_COLUMNS
,
1020 QUICK_LABEL (N_("Input / display codepage:"), NULL
),
1022 QUICK_BUTTON (cpname
, B_USER
, sel_charset_button
, NULL
),
1024 QUICK_SEPARATOR (TRUE
),
1025 QUICK_CHECKBOX (N_("F&ull 8 bits input"), &new_meta
, NULL
),
1026 QUICK_BUTTONS_OK_CANCEL
,
1031 quick_dialog_t qdlg
= {
1033 N_("Display bits"), "[Display bits]",
1034 quick_widgets
, NULL
, NULL
1037 new_meta
= !use_8th_bit_as_meta
;
1038 application_keypad_mode ();
1040 if (quick_dialog (&qdlg
) == B_ENTER
)
1044 mc_global
.display_codepage
= new_display_codepage
;
1046 errmsg
= init_translation_table (mc_global
.source_codepage
, mc_global
.display_codepage
);
1049 message (D_ERROR
, MSG_ERROR
, "%s", errmsg
);
1054 tty_display_8bit (mc_global
.display_codepage
!= 0 && mc_global
.display_codepage
!= 1);
1056 tty_display_8bit (mc_global
.display_codepage
!= 0);
1058 use_8th_bit_as_meta
= !new_meta
;
1064 #endif /* HAVE_CHARSET */
1066 /* --------------------------------------------------------------------------------------------- */
1067 /** Show tree in a box, not on a panel */
1070 tree_box (const char *current_dir
)
1080 /* Create the components */
1081 dlg
= dlg_create (TRUE
, 0, 0, LINES
- 9, COLS
- 20, dialog_colors
, tree_callback
, NULL
,
1082 "[Directory Tree]", _("Directory tree"), DLG_CENTER
);
1085 mytree
= tree_new (2, 2, wd
->lines
- 6, wd
->cols
- 5, FALSE
);
1086 add_widget_autopos (dlg
, mytree
, WPOS_KEEP_ALL
, NULL
);
1087 add_widget_autopos (dlg
, hline_new (wd
->lines
- 4, 1, -1), WPOS_KEEP_BOTTOM
, NULL
);
1088 bar
= buttonbar_new (TRUE
);
1089 add_widget (dlg
, bar
);
1090 /* restore ButtonBar coordinates after add_widget() */
1091 WIDGET (bar
)->x
= 0;
1092 WIDGET (bar
)->y
= LINES
- 1;
1094 if (dlg_run (dlg
) == B_ENTER
)
1096 const vfs_path_t
*selected_name
;
1097 selected_name
= tree_selected_name (mytree
);
1098 val
= g_strdup (vfs_path_as_str (selected_name
));
1105 /* --------------------------------------------------------------------------------------------- */
1109 configure_vfs (void)
1111 char buffer2
[BUF_TINY
];
1112 #ifdef ENABLE_VFS_FTP
1113 char buffer3
[BUF_TINY
];
1115 g_snprintf (buffer3
, sizeof (buffer3
), "%i", ftpfs_directory_timeout
);
1118 g_snprintf (buffer2
, sizeof (buffer2
), "%i", vfs_timeout
);
1122 #ifdef ENABLE_VFS_FTP
1124 char *ret_ftp_proxy
;
1125 char *ret_directory_timeout
;
1126 #endif /* ENABLE_VFS_FTP */
1128 quick_widget_t quick_widgets
[] = {
1130 QUICK_LABELED_INPUT (N_("Timeout for freeing VFSs (sec):"), input_label_left
,
1131 buffer2
, "input-timo-vfs", &ret_timeout
, NULL
, FALSE
, FALSE
,
1132 INPUT_COMPLETE_NONE
),
1133 #ifdef ENABLE_VFS_FTP
1134 QUICK_SEPARATOR (TRUE
),
1135 QUICK_LABELED_INPUT (N_("FTP anonymous password:"), input_label_left
,
1136 ftpfs_anonymous_passwd
, "input-passwd", &ret_passwd
, NULL
,
1137 FALSE
, FALSE
, INPUT_COMPLETE_NONE
),
1138 QUICK_LABELED_INPUT (N_("FTP directory cache timeout (sec):"), input_label_left
,
1139 buffer3
, "input-timeout", &ret_directory_timeout
, NULL
,
1140 FALSE
, FALSE
, INPUT_COMPLETE_NONE
),
1141 QUICK_CHECKBOX (N_("&Always use ftp proxy:"), &ftpfs_always_use_proxy
,
1142 &ftpfs_always_use_proxy_id
),
1143 QUICK_INPUT (ftpfs_proxy_host
, "input-ftp-proxy", &ret_ftp_proxy
,
1144 &ftpfs_proxy_host_id
, FALSE
, FALSE
, INPUT_COMPLETE_HOSTNAMES
),
1145 QUICK_CHECKBOX (N_("&Use ~/.netrc"), &ftpfs_use_netrc
, NULL
),
1146 QUICK_CHECKBOX (N_("Use &passive mode"), &ftpfs_use_passive_connections
, NULL
),
1147 QUICK_CHECKBOX (N_("Use passive mode over pro&xy"),
1148 &ftpfs_use_passive_connections_over_proxy
, NULL
),
1149 #endif /* ENABLE_VFS_FTP */
1150 QUICK_BUTTONS_OK_CANCEL
,
1155 quick_dialog_t qdlg
= {
1157 N_("Virtual File System Setting"), "[Virtual FS]",
1159 #ifdef ENABLE_VFS_FTP
1167 #ifdef ENABLE_VFS_FTP
1168 if (!ftpfs_always_use_proxy
)
1169 quick_widgets
[5].options
= W_DISABLED
;
1172 if (quick_dialog (&qdlg
) != B_CANCEL
)
1174 /* cppcheck-suppress uninitvar */
1175 vfs_timeout
= atoi (ret_timeout
);
1176 g_free (ret_timeout
);
1178 if (vfs_timeout
< 0 || vfs_timeout
> 10000)
1180 #ifdef ENABLE_VFS_FTP
1181 g_free (ftpfs_anonymous_passwd
);
1182 /* cppcheck-suppress uninitvar */
1183 ftpfs_anonymous_passwd
= ret_passwd
;
1184 g_free (ftpfs_proxy_host
);
1185 /* cppcheck-suppress uninitvar */
1186 ftpfs_proxy_host
= ret_ftp_proxy
;
1187 /* cppcheck-suppress uninitvar */
1188 ftpfs_directory_timeout
= atoi (ret_directory_timeout
);
1189 g_free (ret_directory_timeout
);
1195 #endif /* ENABLE_VFS */
1197 /* --------------------------------------------------------------------------------------------- */
1202 const Widget
*w
= WIDGET (current_panel
);
1205 quick_widget_t quick_widgets
[] = {
1206 QUICK_LABELED_INPUT (N_("cd"), input_label_left
, "", "input", &my_str
, NULL
, FALSE
, TRUE
,
1207 INPUT_COMPLETE_FILENAMES
| INPUT_COMPLETE_CD
),
1211 quick_dialog_t qdlg
= {
1212 w
->y
+ w
->lines
- 6, w
->x
, w
->cols
,
1213 N_("Quick cd"), "[Quick cd]",
1214 quick_widgets
, NULL
, NULL
1217 return (quick_dialog (&qdlg
) != B_CANCEL
) ? my_str
: NULL
;
1220 /* --------------------------------------------------------------------------------------------- */
1223 symlink_dialog (const vfs_path_t
* existing_vpath
, const vfs_path_t
* new_vpath
,
1224 char **ret_existing
, char **ret_new
)
1226 quick_widget_t quick_widgets
[] = {
1228 QUICK_LABELED_INPUT (N_("Existing filename (filename symlink will point to):"),
1229 input_label_above
, vfs_path_as_str (existing_vpath
), "input-2",
1230 ret_existing
, NULL
, FALSE
, FALSE
, INPUT_COMPLETE_FILENAMES
),
1231 QUICK_SEPARATOR (FALSE
),
1232 QUICK_LABELED_INPUT (N_("Symbolic link filename:"), input_label_above
,
1233 vfs_path_as_str (new_vpath
), "input-1",
1234 ret_new
, NULL
, FALSE
, FALSE
, INPUT_COMPLETE_FILENAMES
),
1235 QUICK_BUTTONS_OK_CANCEL
,
1240 quick_dialog_t qdlg
= {
1242 N_("Symbolic link"), "[File Menu]",
1243 quick_widgets
, NULL
, NULL
1246 if (quick_dialog (&qdlg
) == B_CANCEL
)
1249 *ret_existing
= NULL
;
1253 /* --------------------------------------------------------------------------------------------- */
1255 #ifdef ENABLE_BACKGROUND
1270 { N_("&Stop"), NORMAL_BUTTON
, B_STOP
, 0, task_cb
},
1271 { N_("&Resume"), NORMAL_BUTTON
, B_RESUME
, 0, task_cb
},
1272 { N_("&Kill"), NORMAL_BUTTON
, B_KILL
, 0, task_cb
},
1273 { N_("&OK"), DEFPUSH_BUTTON
, B_CANCEL
, 0, NULL
}
1278 const size_t n_but
= G_N_ELEMENTS (job_but
);
1285 for (i
= 0; i
< n_but
; i
++)
1288 job_but
[i
].name
= _(job_but
[i
].name
);
1289 #endif /* ENABLE_NLS */
1291 job_but
[i
].len
= str_term_width1 (job_but
[i
].name
) + 3;
1292 if (job_but
[i
].flags
== DEFPUSH_BUTTON
)
1293 job_but
[i
].len
+= 2;
1294 x
+= job_but
[i
].len
;
1297 x
+= (int) n_but
- 1;
1298 cols
= max (cols
, x
+ 6);
1300 jobs_dlg
= dlg_create (TRUE
, 0, 0, lines
, cols
, dialog_colors
, NULL
, NULL
,
1301 "[Background jobs]", _("Background jobs"), DLG_CENTER
);
1303 bg_list
= listbox_new (2, 2, lines
- 6, cols
- 6, FALSE
, NULL
);
1304 jobs_fill_listbox (bg_list
);
1305 add_widget (jobs_dlg
, bg_list
);
1307 add_widget (jobs_dlg
, hline_new (lines
- 4, -1, -1));
1310 for (i
= 0; i
< n_but
; i
++)
1312 add_widget (jobs_dlg
,
1313 button_new (lines
- 3, x
, job_but
[i
].value
, job_but
[i
].flags
, job_but
[i
].name
,
1314 job_but
[i
].callback
));
1315 x
+= job_but
[i
].len
+ 1;
1318 (void) dlg_run (jobs_dlg
);
1319 dlg_destroy (jobs_dlg
);
1321 #endif /* ENABLE_BACKGROUND */
1323 /* --------------------------------------------------------------------------------------------- */
1325 #ifdef ENABLE_VFS_SMB
1326 struct smb_authinfo
*
1327 vfs_smb_get_authinfo (const char *host
, const char *share
, const char *domain
, const char *user
)
1330 struct smb_authinfo
*return_value
= NULL
;
1337 label
= g_strdup_printf (_("Password for \\\\%s\\%s"), host
, share
);
1340 char *ret_domain
, *ret_user
, *ret_password
;
1342 quick_widget_t quick_widgets
[] = {
1344 QUICK_LABEL (label
, NULL
),
1345 QUICK_SEPARATOR (TRUE
),
1346 QUICK_START_COLUMNS
,
1347 QUICK_LABEL (N_("Domain:"), NULL
),
1348 QUICK_SEPARATOR (FALSE
),
1349 QUICK_LABEL (N_("Username:"), NULL
),
1350 QUICK_SEPARATOR (FALSE
),
1351 QUICK_LABEL (N_("Password:"), NULL
),
1353 QUICK_INPUT (domain
, "auth_domain", &ret_domain
, NULL
, FALSE
, FALSE
, INPUT_COMPLETE_HOSTNAMES
),
1354 QUICK_SEPARATOR (FALSE
),
1355 QUICK_INPUT (user
, "auth_name", &ret_user
, NULL
, FALSE
, FALSE
, INPUT_COMPLETE_USERNAMES
),
1356 QUICK_SEPARATOR (FALSE
),
1357 QUICK_INPUT ("", "auth_password", &ret_password
, NULL
, TRUE
, FALSE
, INPUT_COMPLETE_NONE
),
1359 QUICK_BUTTONS_OK_CANCEL
,
1364 quick_dialog_t qdlg
= {
1366 N_("SMB authentication"), "[Smb Authinfo]",
1367 quick_widgets
, NULL
, NULL
1370 if (quick_dialog (&qdlg
) != B_CANCEL
)
1372 return_value
= vfs_smb_authinfo_new (host
, share
, ret_domain
, ret_user
, ret_password
);
1374 g_free (ret_domain
);
1376 g_free (ret_password
);
1382 return return_value
;
1384 #endif /* ENABLE_VFS_SMB */
1386 /* --------------------------------------------------------------------------------------------- */