This source file includes following definitions.
- configure_callback
- skin_apply
- skin_name_to_label
- skin_dlg_callback
- sel_skin_button
- appearance_box_callback
- panel_listing_callback
- sel_charset_button
- tree_callback
- confvfs_callback
- jobs_fill_listbox
- task_cb
- configure_box
- appearance_box
- panel_options_box
- panel_listing_box
- sort_box
- confirm_box
- display_bits_box
- display_bits_box
- tree_box
- configure_vfs_box
- cd_box
- symlink_box
- jobs_box
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 #include <config.h>
33
34 #include <ctype.h>
35 #include <signal.h>
36 #include <stdio.h>
37 #include <stdlib.h>
38 #include <string.h>
39 #include <sys/types.h>
40 #include <sys/stat.h>
41
42 #include "lib/global.h"
43
44 #include "lib/tty/tty.h"
45 #include "lib/tty/color.h"
46 #include "lib/tty/key.h"
47 #include "lib/skin.h"
48 #include "lib/mcconfig.h"
49 #include "lib/strutil.h"
50
51 #include "lib/vfs/vfs.h"
52 #ifdef ENABLE_VFS_FTP
53 #include "src/vfs/ftpfs/ftpfs.h"
54 #endif
55
56 #include "lib/util.h"
57 #include "lib/widget.h"
58
59 #include "src/setup.h"
60 #include "src/history.h"
61 #include "src/execute.h"
62 #ifdef ENABLE_BACKGROUND
63 #include "src/background.h"
64 #endif
65
66 #ifdef HAVE_CHARSET
67 #include "lib/charsets.h"
68 #include "src/selcodepage.h"
69 #endif
70
71 #include "command.h"
72 #include "dir.h"
73 #include "tree.h"
74 #include "layout.h"
75 #include "filemanager.h"
76
77 #include "boxes.h"
78
79
80
81
82
83 #ifdef ENABLE_BACKGROUND
84 #define B_STOP (B_USER+1)
85 #define B_RESUME (B_USER+2)
86 #define B_KILL (B_USER+3)
87 #endif
88
89
90
91
92
93
94
95 static unsigned long configure_old_esc_mode_id, configure_time_out_id;
96
97
98 static const int panel_list_brief_idx = 1;
99
100 static const int panel_list_user_idx = 3;
101
102 static char **status_format;
103 static unsigned long panel_list_formats_id, panel_user_format_id, panel_brief_cols_id;
104 static unsigned long user_mini_status_id, mini_user_format_id;
105
106 #ifdef HAVE_CHARSET
107 static int new_display_codepage;
108 #endif
109
110 #if defined(ENABLE_VFS) && defined(ENABLE_VFS_FTP)
111 static unsigned long ftpfs_always_use_proxy_id, ftpfs_proxy_host_id;
112 #endif
113
114 static GPtrArray *skin_names;
115 static gchar *current_skin_name;
116
117 #ifdef ENABLE_BACKGROUND
118 static WListbox *bg_list = NULL;
119 #endif
120
121 static unsigned long shadows_id;
122
123
124
125
126
127 static cb_ret_t
128 configure_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
129 {
130 switch (msg)
131 {
132 case MSG_NOTIFY:
133
134 if (sender != NULL && sender->id == configure_old_esc_mode_id)
135 {
136 const gboolean not_single = !CHECK (sender)->state;
137 Widget *ww;
138
139
140 ww = widget_find_by_id (w, configure_time_out_id);
141 widget_disable (ww, not_single);
142
143 return MSG_HANDLED;
144 }
145 return MSG_NOT_HANDLED;
146
147 default:
148 return dlg_default_callback (w, sender, msg, parm, data);
149 }
150 }
151
152
153
154 static void
155 skin_apply (const gchar * skin_override)
156 {
157 GError *mcerror = NULL;
158
159 mc_skin_deinit ();
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 ();
167 panel_deinit ();
168 panel_init ();
169 repaint_screen ();
170
171 mc_error_message (&mcerror, NULL);
172 }
173
174
175
176 static const gchar *
177 skin_name_to_label (const gchar * name)
178 {
179 if (strcmp (name, "default") == 0)
180 return _("< Default >");
181 return name;
182 }
183
184
185
186 static cb_ret_t
187 skin_dlg_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
188 {
189 switch (msg)
190 {
191 case MSG_RESIZE:
192 {
193 WDialog *d = DIALOG (w);
194 const WRect *wd = &WIDGET (d->data.p)->rect;
195 WRect r = w->rect;
196
197 r.y = wd->y + (wd->lines - r.lines) / 2;
198 r.x = wd->x + wd->cols / 2;
199
200 return dlg_default_callback (w, NULL, MSG_RESIZE, 0, &r);
201 }
202
203 default:
204 return dlg_default_callback (w, sender, msg, parm, data);
205 }
206 }
207
208
209
210 static int
211 sel_skin_button (WButton * button, int action)
212 {
213 int result;
214 WListbox *skin_list;
215 WDialog *skin_dlg;
216 const gchar *skin_name;
217 unsigned int i;
218 unsigned int pos = 1;
219
220 (void) action;
221
222 skin_dlg =
223 dlg_create (TRUE, 0, 0, 13, 24, WPOS_KEEP_DEFAULT, TRUE, dialog_colors, skin_dlg_callback,
224 NULL, "[Appearance]", _("Skins"));
225
226 skin_dlg->data.p = WIDGET (button)->owner;
227
228
229 send_message (skin_dlg, NULL, MSG_RESIZE, 0, NULL);
230
231 skin_list = listbox_new (1, 1, 11, 22, FALSE, NULL);
232 skin_name = "default";
233 listbox_add_item (skin_list, LISTBOX_APPEND_AT_END, 0, skin_name_to_label (skin_name),
234 (void *) skin_name, FALSE);
235
236 if (strcmp (skin_name, current_skin_name) == 0)
237 listbox_set_current (skin_list, 0);
238
239 for (i = 0; i < skin_names->len; i++)
240 {
241 skin_name = g_ptr_array_index (skin_names, i);
242 if (strcmp (skin_name, "default") != 0)
243 {
244 listbox_add_item (skin_list, LISTBOX_APPEND_AT_END, 0, skin_name_to_label (skin_name),
245 (void *) skin_name, FALSE);
246 if (strcmp (skin_name, current_skin_name) == 0)
247 listbox_set_current (skin_list, pos);
248 pos++;
249 }
250 }
251
252
253 group_add_widget_autopos (GROUP (skin_dlg), skin_list, WPOS_KEEP_ALL, NULL);
254
255 result = dlg_run (skin_dlg);
256 if (result == B_ENTER)
257 {
258 gchar *skin_label;
259
260 listbox_get_current (skin_list, &skin_label, (void **) &skin_name);
261 g_free (current_skin_name);
262 current_skin_name = g_strdup (skin_name);
263 skin_apply (skin_name);
264
265 button_set_text (button, str_fit_to_term (skin_label, 20, J_LEFT_FIT));
266 }
267 widget_destroy (WIDGET (skin_dlg));
268
269 return 0;
270 }
271
272
273
274 static cb_ret_t
275 appearance_box_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
276 {
277 switch (msg)
278 {
279 case MSG_INIT:
280 #ifdef ENABLE_SHADOWS
281 if (!tty_use_colors ())
282 #endif
283 {
284 Widget *shadow;
285
286 shadow = widget_find_by_id (w, shadows_id);
287 CHECK (shadow)->state = FALSE;
288 widget_disable (shadow, TRUE);
289 }
290 return MSG_HANDLED;
291
292 case MSG_NOTIFY:
293 if (sender != NULL && sender->id == shadows_id)
294 {
295 mc_global.tty.shadows = CHECK (sender)->state;
296 repaint_screen ();
297 return MSG_HANDLED;
298 }
299 return MSG_NOT_HANDLED;
300
301 default:
302 return dlg_default_callback (w, sender, msg, parm, data);
303 }
304 }
305
306
307
308 static cb_ret_t
309 panel_listing_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
310 {
311 switch (msg)
312 {
313 case MSG_NOTIFY:
314 if (sender != NULL && sender->id == panel_list_formats_id)
315 {
316 WCheck *ch;
317 WInput *in1, *in2, *in3;
318
319 in1 = INPUT (widget_find_by_id (w, panel_user_format_id));
320 in2 = INPUT (widget_find_by_id (w, panel_brief_cols_id));
321 ch = CHECK (widget_find_by_id (w, user_mini_status_id));
322 in3 = INPUT (widget_find_by_id (w, mini_user_format_id));
323
324 if (!ch->state)
325 input_assign_text (in3, status_format[RADIO (sender)->sel]);
326 input_update (in1, FALSE);
327 input_update (in2, FALSE);
328 input_update (in3, FALSE);
329 widget_disable (WIDGET (in1), RADIO (sender)->sel != panel_list_user_idx);
330 widget_disable (WIDGET (in2), RADIO (sender)->sel != panel_list_brief_idx);
331 return MSG_HANDLED;
332 }
333
334 if (sender != NULL && sender->id == user_mini_status_id)
335 {
336 WInput *in;
337
338 in = INPUT (widget_find_by_id (w, mini_user_format_id));
339
340 if (CHECK (sender)->state)
341 {
342 widget_disable (WIDGET (in), FALSE);
343 input_assign_text (in, status_format[3]);
344 }
345 else
346 {
347 WRadio *r;
348
349 r = RADIO (widget_find_by_id (w, panel_list_formats_id));
350 widget_disable (WIDGET (in), TRUE);
351 input_assign_text (in, status_format[r->sel]);
352 }
353
354 return MSG_HANDLED;
355 }
356
357 return MSG_NOT_HANDLED;
358
359 default:
360 return dlg_default_callback (w, sender, msg, parm, data);
361 }
362 }
363
364
365
366 #ifdef HAVE_CHARSET
367 static int
368 sel_charset_button (WButton * button, int action)
369 {
370 int new_dcp;
371
372 (void) action;
373
374 new_dcp = select_charset (-1, -1, new_display_codepage, TRUE);
375
376 if (new_dcp != SELECT_CHARSET_CANCEL)
377 {
378 const char *cpname;
379
380 new_display_codepage = new_dcp;
381 cpname = (new_display_codepage == SELECT_CHARSET_OTHER_8BIT) ?
382 _("Other 8 bit") :
383 ((codepage_desc *) g_ptr_array_index (codepages, new_display_codepage))->name;
384 if (cpname != NULL)
385 mc_global.utf8_display = str_isutf8 (cpname);
386 else
387 cpname = _("7-bit ASCII");
388
389 button_set_text (button, cpname);
390 widget_draw (WIDGET (WIDGET (button)->owner));
391 }
392
393 return 0;
394 }
395 #endif
396
397
398
399 static cb_ret_t
400 tree_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
401 {
402 WDialog *h = DIALOG (w);
403
404 switch (msg)
405 {
406 case MSG_RESIZE:
407 {
408 WRect r = w->rect;
409 Widget *bar;
410
411 r.lines = LINES - 9;
412 r.cols = COLS - 20;
413 dlg_default_callback (w, NULL, MSG_RESIZE, 0, &r);
414
415 bar = WIDGET (buttonbar_find (h));
416 bar->rect.x = 0;
417 bar->rect.y = LINES - 1;
418 return MSG_HANDLED;
419 }
420
421 case MSG_ACTION:
422 return send_message (find_tree (h), NULL, MSG_ACTION, parm, NULL);
423
424 default:
425 return dlg_default_callback (w, sender, msg, parm, data);
426 }
427 }
428
429
430
431 #if defined(ENABLE_VFS) && defined (ENABLE_VFS_FTP)
432 static cb_ret_t
433 confvfs_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
434 {
435 switch (msg)
436 {
437 case MSG_NOTIFY:
438
439 if (sender != NULL && sender->id == ftpfs_always_use_proxy_id)
440 {
441 const gboolean not_use = !CHECK (sender)->state;
442 Widget *wi;
443
444
445 wi = widget_find_by_id (w, ftpfs_proxy_host_id);
446 widget_disable (wi, not_use);
447 return MSG_HANDLED;
448 }
449 return MSG_NOT_HANDLED;
450
451 default:
452 return dlg_default_callback (w, sender, msg, parm, data);
453 }
454 }
455 #endif
456
457
458
459 #ifdef ENABLE_BACKGROUND
460 static void
461 jobs_fill_listbox (WListbox * list)
462 {
463 static const char *state_str[2] = { "", "" };
464 TaskList *tl;
465
466 if (state_str[0][0] == '\0')
467 {
468 state_str[0] = _("Running");
469 state_str[1] = _("Stopped");
470 }
471
472 for (tl = task_list; tl != NULL; tl = tl->next)
473 {
474 char *s;
475
476 s = g_strconcat (state_str[tl->state], " ", tl->info, (char *) NULL);
477 listbox_add_item (list, LISTBOX_APPEND_AT_END, 0, s, (void *) tl, FALSE);
478 g_free (s);
479 }
480 }
481
482
483
484 static int
485 task_cb (WButton * button, int action)
486 {
487 TaskList *tl;
488 int sig = 0;
489
490 (void) button;
491
492 if (bg_list->list == NULL)
493 return 0;
494
495
496 listbox_get_current (bg_list, NULL, (void **) &tl);
497
498 #ifdef SIGTSTP
499 if (action == B_STOP)
500 {
501 sig = SIGSTOP;
502 tl->state = Task_Stopped;
503 }
504 else if (action == B_RESUME)
505 {
506 sig = SIGCONT;
507 tl->state = Task_Running;
508 }
509 else
510 #endif
511 if (action == B_KILL)
512 sig = SIGKILL;
513
514 if (sig == SIGKILL)
515 unregister_task_running (tl->pid, tl->fd);
516
517 kill (tl->pid, sig);
518 listbox_remove_list (bg_list);
519 jobs_fill_listbox (bg_list);
520
521
522 widget_draw (WIDGET (WIDGET (button)->owner));
523
524 return 0;
525 }
526 #endif
527
528
529
530
531
532 void
533 configure_box (void)
534 {
535 const char *pause_options[] = {
536 N_("&Never"),
537 N_("On dum&b terminals"),
538 N_("Alwa&ys")
539 };
540
541 int pause_options_num;
542
543 pause_options_num = G_N_ELEMENTS (pause_options);
544
545 {
546 char time_out[BUF_TINY] = "";
547 char *time_out_new;
548
549 quick_widget_t quick_widgets[] = {
550
551 QUICK_START_COLUMNS,
552 QUICK_START_GROUPBOX (N_("File operations")),
553 QUICK_CHECKBOX (N_("&Verbose operation"), &verbose, NULL),
554 QUICK_CHECKBOX (N_("Compute tota&ls"), &file_op_compute_totals, NULL),
555 QUICK_CHECKBOX (N_("Classic pro&gressbar"), &classic_progressbar, NULL),
556 QUICK_CHECKBOX (N_("Mkdi&r autoname"), &auto_fill_mkdir_name, NULL),
557 QUICK_CHECKBOX (N_("&Preallocate space"), &mc_global.vfs.preallocate_space,
558 NULL),
559 QUICK_STOP_GROUPBOX,
560 QUICK_START_GROUPBOX (N_("Esc key mode")),
561 QUICK_CHECKBOX (N_("S&ingle press"), &old_esc_mode, &configure_old_esc_mode_id),
562 QUICK_LABELED_INPUT (N_("Timeout:"), input_label_left,
563 (const char *) time_out, MC_HISTORY_ESC_TIMEOUT,
564 &time_out_new, &configure_time_out_id, FALSE, FALSE,
565 INPUT_COMPLETE_NONE),
566 QUICK_STOP_GROUPBOX,
567 QUICK_START_GROUPBOX (N_("Pause after run")),
568 QUICK_RADIO (pause_options_num, pause_options, &pause_after_run, NULL),
569 QUICK_STOP_GROUPBOX,
570 QUICK_NEXT_COLUMN,
571 QUICK_START_GROUPBOX (N_("Other options")),
572 QUICK_CHECKBOX (N_("Use internal edi&t"), &use_internal_edit, NULL),
573 QUICK_CHECKBOX (N_("Use internal vie&w"), &use_internal_view, NULL),
574 QUICK_CHECKBOX (N_("A&sk new file name"),
575 &editor_ask_filename_before_edit, NULL),
576 QUICK_CHECKBOX (N_("Auto m&enus"), &auto_menu, NULL),
577 QUICK_CHECKBOX (N_("&Drop down menus"), &drop_menus, NULL),
578 QUICK_CHECKBOX (N_("S&hell patterns"), &easy_patterns, NULL),
579 QUICK_CHECKBOX (N_("Co&mplete: show all"),
580 &mc_global.widget.show_all_if_ambiguous, NULL),
581 QUICK_CHECKBOX (N_("Rotating d&ash"), &nice_rotating_dash, NULL),
582 QUICK_CHECKBOX (N_("Cd follows lin&ks"), &mc_global.vfs.cd_symlinks, NULL),
583 QUICK_CHECKBOX (N_("Sa&fe delete"), &safe_delete, NULL),
584 QUICK_CHECKBOX (N_("Safe overwrite"), &safe_overwrite, NULL),
585 QUICK_CHECKBOX (N_("A&uto save setup"), &auto_save_setup, NULL),
586 QUICK_SEPARATOR (FALSE),
587 QUICK_SEPARATOR (FALSE),
588 QUICK_STOP_GROUPBOX,
589 QUICK_STOP_COLUMNS,
590 QUICK_BUTTONS_OK_CANCEL,
591 QUICK_END
592
593 };
594
595 WRect r = { -1, -1, 0, 60 };
596
597 quick_dialog_t qdlg = {
598 r, N_("Configure options"), "[Configuration]",
599 quick_widgets, configure_callback, NULL
600 };
601
602 g_snprintf (time_out, sizeof (time_out), "%d", old_esc_mode_timeout);
603
604 #ifndef USE_INTERNAL_EDIT
605 quick_widgets[17].state = WST_DISABLED;
606 #endif
607
608 if (!old_esc_mode)
609 quick_widgets[10].state = quick_widgets[11].state = WST_DISABLED;
610
611 #ifndef HAVE_POSIX_FALLOCATE
612 mc_global.vfs.preallocate_space = FALSE;
613 quick_widgets[7].state = WST_DISABLED;
614 #endif
615
616 if (quick_dialog (&qdlg) == B_ENTER)
617 {
618 if (time_out_new[0] == '\0')
619 old_esc_mode_timeout = 0;
620 else
621 old_esc_mode_timeout = atoi (time_out_new);
622 }
623
624 g_free (time_out_new);
625 }
626 }
627
628
629
630 void
631 appearance_box (void)
632 {
633 gboolean shadows = mc_global.tty.shadows;
634
635 current_skin_name = g_strdup (mc_skin__default.name);
636 skin_names = mc_skin_list ();
637
638 {
639 quick_widget_t quick_widgets[] = {
640
641 QUICK_START_COLUMNS,
642 QUICK_LABEL (N_("Skin:"), NULL),
643 QUICK_NEXT_COLUMN,
644 QUICK_BUTTON (str_fit_to_term (skin_name_to_label (current_skin_name), 20, J_LEFT_FIT),
645 B_USER, sel_skin_button, NULL),
646 QUICK_STOP_COLUMNS,
647 QUICK_SEPARATOR (TRUE),
648 QUICK_CHECKBOX (N_("&Shadows"), &mc_global.tty.shadows, &shadows_id),
649 QUICK_BUTTONS_OK_CANCEL,
650 QUICK_END
651
652 };
653
654 WRect r = { -1, -1, 0, 54 };
655
656 quick_dialog_t qdlg = {
657 r, N_("Appearance"), "[Appearance]",
658 quick_widgets, appearance_box_callback, NULL
659 };
660
661 if (quick_dialog (&qdlg) == B_ENTER)
662 mc_config_set_string (mc_global.main_config, CONFIG_APP_SECTION, "skin",
663 current_skin_name);
664 else
665 {
666 skin_apply (NULL);
667 mc_global.tty.shadows = shadows;
668 }
669 }
670
671 g_free (current_skin_name);
672 g_ptr_array_free (skin_names, TRUE);
673 }
674
675
676
677 void
678 panel_options_box (void)
679 {
680 gboolean simple_swap;
681
682 simple_swap = mc_config_get_bool (mc_global.main_config, CONFIG_PANELS_SECTION,
683 "simple_swap", FALSE);
684 {
685 const char *qsearch_options[] = {
686 N_("Case &insensitive"),
687 N_("Cas&e sensitive"),
688 N_("Use panel sort mo&de")
689 };
690
691 quick_widget_t quick_widgets[] = {
692
693 QUICK_START_COLUMNS,
694 QUICK_START_GROUPBOX (N_("Main options")),
695 QUICK_CHECKBOX (N_("Show mi&ni-status"), &panels_options.show_mini_info, NULL),
696 QUICK_CHECKBOX (N_("Use SI si&ze units"), &panels_options.kilobyte_si, NULL),
697 QUICK_CHECKBOX (N_("Mi&x all files"), &panels_options.mix_all_files, NULL),
698 QUICK_CHECKBOX (N_("Show &backup files"), &panels_options.show_backups, NULL),
699 QUICK_CHECKBOX (N_("Show &hidden files"), &panels_options.show_dot_files, NULL),
700 QUICK_CHECKBOX (N_("&Fast dir reload"), &panels_options.fast_reload, NULL),
701 QUICK_CHECKBOX (N_("Ma&rk moves down"), &panels_options.mark_moves_down, NULL),
702 QUICK_CHECKBOX (N_("Re&verse files only"), &panels_options.reverse_files_only,
703 NULL),
704 QUICK_CHECKBOX (N_("Simple s&wap"), &simple_swap, NULL),
705 QUICK_CHECKBOX (N_("A&uto save panels setup"), &panels_options.auto_save_setup,
706 NULL),
707 QUICK_SEPARATOR (FALSE),
708 QUICK_SEPARATOR (FALSE),
709 QUICK_SEPARATOR (FALSE),
710 QUICK_STOP_GROUPBOX,
711 QUICK_NEXT_COLUMN,
712 QUICK_START_GROUPBOX (N_("Navigation")),
713 QUICK_CHECKBOX (N_("L&ynx-like motion"), &panels_options.navigate_with_arrows,
714 NULL),
715 QUICK_CHECKBOX (N_("Pa&ge scrolling"), &panels_options.scroll_pages, NULL),
716 QUICK_CHECKBOX (N_("Center &scrolling"), &panels_options.scroll_center, NULL),
717 QUICK_CHECKBOX (N_("&Mouse page scrolling"), &panels_options.mouse_move_pages,
718 NULL),
719 QUICK_STOP_GROUPBOX,
720 QUICK_START_GROUPBOX (N_("File highlight")),
721 QUICK_CHECKBOX (N_("File &types"), &panels_options.filetype_mode, NULL),
722 QUICK_CHECKBOX (N_("&Permissions"), &panels_options.permission_mode, NULL),
723 QUICK_STOP_GROUPBOX,
724 QUICK_START_GROUPBOX (N_("Quick search")),
725 QUICK_RADIO (QSEARCH_NUM, qsearch_options, (int *) &panels_options.qsearch_mode,
726 NULL),
727 QUICK_STOP_GROUPBOX,
728 QUICK_STOP_COLUMNS,
729 QUICK_BUTTONS_OK_CANCEL,
730 QUICK_END
731
732 };
733
734 WRect r = { -1, -1, 0, 60 };
735
736 quick_dialog_t qdlg = {
737 r, N_("Panel options"), "[Panel options]",
738 quick_widgets, NULL, NULL
739 };
740
741 if (quick_dialog (&qdlg) != B_ENTER)
742 return;
743 }
744
745 mc_config_set_bool (mc_global.main_config, CONFIG_PANELS_SECTION, "simple_swap", simple_swap);
746
747 if (!panels_options.fast_reload_msg_shown && panels_options.fast_reload)
748 {
749 message (D_NORMAL, _("Information"),
750 _("Using the fast reload option may not reflect the exact\n"
751 "directory contents. In this case you'll need to do a\n"
752 "manual reload of the directory. See the man page for\n" "the details."));
753 panels_options.fast_reload_msg_shown = TRUE;
754 }
755
756 update_panels (UP_RELOAD, UP_KEEPSEL);
757 }
758
759
760
761
762 int
763 panel_listing_box (WPanel * panel, int num, char **userp, char **minip, gboolean * use_msformat,
764 int *brief_cols)
765 {
766 int result = -1;
767 const char *p = NULL;
768
769 if (panel == NULL)
770 {
771 p = get_nth_panel_name (num);
772 panel = panel_empty_new (p);
773 }
774
775 {
776 gboolean user_mini_status;
777 char panel_brief_cols_in[BUF_TINY];
778 char *panel_brief_cols_out = NULL;
779 char *panel_user_format = NULL;
780 char *mini_user_format = NULL;
781
782
783 const char *list_formats[LIST_FORMATS] = {
784 N_("&Full file list"),
785 N_("&Brief file list:"),
786 N_("&Long file list"),
787 N_("&User defined:")
788 };
789
790 quick_widget_t quick_widgets[] = {
791
792 QUICK_START_COLUMNS,
793 QUICK_RADIO (LIST_FORMATS, list_formats, &result, &panel_list_formats_id),
794 QUICK_NEXT_COLUMN,
795 QUICK_SEPARATOR (FALSE),
796 QUICK_LABELED_INPUT (_ ("columns"), input_label_right, panel_brief_cols_in,
797 "panel-brief-cols-input", &panel_brief_cols_out,
798 &panel_brief_cols_id, FALSE, FALSE, INPUT_COMPLETE_NONE),
799 QUICK_STOP_COLUMNS,
800 QUICK_INPUT (panel->user_format, "user-fmt-input", &panel_user_format,
801 &panel_user_format_id, FALSE, FALSE, INPUT_COMPLETE_NONE),
802 QUICK_SEPARATOR (TRUE),
803 QUICK_CHECKBOX (N_("User &mini status"), &user_mini_status, &user_mini_status_id),
804 QUICK_INPUT (panel->user_status_format[panel->list_format], "mini_input",
805 &mini_user_format, &mini_user_format_id, FALSE, FALSE, INPUT_COMPLETE_NONE),
806 QUICK_BUTTONS_OK_CANCEL,
807 QUICK_END
808
809 };
810
811 WRect r = { -1, -1, 0, 48 };
812
813 quick_dialog_t qdlg = {
814 r, N_("Listing format"), "[Listing Format...]",
815 quick_widgets, panel_listing_callback, NULL
816 };
817
818 user_mini_status = panel->user_mini_status;
819 result = panel->list_format;
820 status_format = panel->user_status_format;
821
822 g_snprintf (panel_brief_cols_in, sizeof (panel_brief_cols_in), "%d", panel->brief_cols);
823
824 if ((int) panel->list_format != panel_list_brief_idx)
825 quick_widgets[4].state = WST_DISABLED;
826
827 if ((int) panel->list_format != panel_list_user_idx)
828 quick_widgets[6].state = WST_DISABLED;
829
830 if (!user_mini_status)
831 quick_widgets[9].state = WST_DISABLED;
832
833 if (quick_dialog (&qdlg) == B_CANCEL)
834 result = -1;
835 else
836 {
837 int cols;
838 char *error = NULL;
839
840 *userp = panel_user_format;
841 *minip = mini_user_format;
842 *use_msformat = user_mini_status;
843
844 cols = strtol (panel_brief_cols_out, &error, 10);
845 if (*error == '\0')
846 *brief_cols = cols;
847 else
848 *brief_cols = panel->brief_cols;
849
850 g_free (panel_brief_cols_out);
851 }
852 }
853
854 if (p != NULL)
855 {
856 int i;
857
858 g_free (panel->user_format);
859 for (i = 0; i < LIST_FORMATS; i++)
860 g_free (panel->user_status_format[i]);
861 g_free (panel);
862 }
863
864 return result;
865 }
866
867
868
869 const panel_field_t *
870 sort_box (dir_sort_options_t * op, const panel_field_t * sort_field)
871 {
872 char **sort_orders_names;
873 gsize i;
874 gsize sort_names_num = 0;
875 int sort_idx = 0;
876 const panel_field_t *result = NULL;
877
878 sort_orders_names = panel_get_sortable_fields (&sort_names_num);
879
880 for (i = 0; i < sort_names_num; i++)
881 if (strcmp (sort_orders_names[i], _(sort_field->title_hotkey)) == 0)
882 {
883 sort_idx = i;
884 break;
885 }
886
887 {
888 quick_widget_t quick_widgets[] = {
889
890 QUICK_START_COLUMNS,
891 QUICK_RADIO (sort_names_num, (const char **) sort_orders_names, &sort_idx, NULL),
892 QUICK_NEXT_COLUMN,
893 QUICK_CHECKBOX (N_("Executable &first"), &op->exec_first, NULL),
894 QUICK_CHECKBOX (N_("Cas&e sensitive"), &op->case_sensitive, NULL),
895 QUICK_CHECKBOX (N_("&Reverse"), &op->reverse, NULL),
896 QUICK_STOP_COLUMNS,
897 QUICK_BUTTONS_OK_CANCEL,
898 QUICK_END
899
900 };
901
902 WRect r = { -1, -1, 0, 40 };
903
904 quick_dialog_t qdlg = {
905 r, N_("Sort order"), "[Sort Order...]",
906 quick_widgets, NULL, NULL
907 };
908
909 if (quick_dialog (&qdlg) != B_CANCEL)
910 result = panel_get_field_by_title_hotkey (sort_orders_names[sort_idx]);
911
912 if (result == NULL)
913 result = sort_field;
914 }
915
916 g_strfreev (sort_orders_names);
917
918 return result;
919 }
920
921
922
923 void
924 confirm_box (void)
925 {
926 quick_widget_t quick_widgets[] = {
927
928
929 QUICK_CHECKBOX (Q_("Confirmation|&Delete"), &confirm_delete, NULL),
930 QUICK_CHECKBOX (Q_("Confirmation|O&verwrite"), &confirm_overwrite, NULL),
931 QUICK_CHECKBOX (Q_("Confirmation|&Execute"), &confirm_execute, NULL),
932 QUICK_CHECKBOX (Q_("Confirmation|E&xit"), &confirm_exit, NULL),
933 QUICK_CHECKBOX (Q_("Confirmation|Di&rectory hotlist delete"),
934 &confirm_directory_hotlist_delete, NULL),
935 QUICK_CHECKBOX (Q_("Confirmation|&History cleanup"),
936 &mc_global.widget.confirm_history_cleanup, NULL),
937 QUICK_BUTTONS_OK_CANCEL,
938 QUICK_END
939
940 };
941
942 WRect r = { -1, -1, 0, 46 };
943
944 quick_dialog_t qdlg = {
945 r, N_("Confirmation"), "[Confirmation]",
946 quick_widgets, NULL, NULL
947 };
948
949 (void) quick_dialog (&qdlg);
950 }
951
952
953
954 #ifndef HAVE_CHARSET
955 void
956 display_bits_box (void)
957 {
958 gboolean new_meta;
959 int current_mode;
960
961 const char *display_bits_str[] = {
962 N_("&UTF-8 output"),
963 N_("&Full 8 bits output"),
964 N_("&ISO 8859-1"),
965 N_("7 &bits")
966 };
967
968 quick_widget_t quick_widgets[] = {
969
970 QUICK_RADIO (4, display_bits_str, ¤t_mode, NULL),
971 QUICK_SEPARATOR (TRUE),
972 QUICK_CHECKBOX (N_("F&ull 8 bits input"), &new_meta, NULL),
973 QUICK_BUTTONS_OK_CANCEL,
974 QUICK_END
975
976 };
977
978 WRect r = { -1, -1, 0, 46 };
979
980 quick_dialog_t qdlg = {
981 r, _("Display bits"), "[Display bits]",
982 quick_widgets, NULL, NULL
983 };
984
985 if (mc_global.full_eight_bits)
986 current_mode = 0;
987 else if (mc_global.eight_bit_clean)
988 current_mode = 1;
989 else
990 current_mode = 2;
991
992 new_meta = !use_8th_bit_as_meta;
993
994 if (quick_dialog (&qdlg) != B_CANCEL)
995 {
996 mc_global.eight_bit_clean = current_mode < 3;
997 mc_global.full_eight_bits = current_mode < 2;
998 #ifndef HAVE_SLANG
999 tty_display_8bit (mc_global.eight_bit_clean);
1000 #else
1001 tty_display_8bit (mc_global.full_eight_bits);
1002 #endif
1003 use_8th_bit_as_meta = !new_meta;
1004 }
1005 }
1006
1007
1008 #else
1009
1010 void
1011 display_bits_box (void)
1012 {
1013 const char *cpname;
1014
1015 new_display_codepage = mc_global.display_codepage;
1016
1017 cpname = (new_display_codepage < 0) ? _("Other 8 bit")
1018 : ((codepage_desc *) g_ptr_array_index (codepages, new_display_codepage))->name;
1019
1020 {
1021 gboolean new_meta;
1022
1023 quick_widget_t quick_widgets[] = {
1024
1025 QUICK_START_COLUMNS,
1026 QUICK_LABEL (N_("Input / display codepage:"), NULL),
1027 QUICK_NEXT_COLUMN,
1028 QUICK_BUTTON (cpname, B_USER, sel_charset_button, NULL),
1029 QUICK_STOP_COLUMNS,
1030 QUICK_SEPARATOR (TRUE),
1031 QUICK_CHECKBOX (N_("F&ull 8 bits input"), &new_meta, NULL),
1032 QUICK_BUTTONS_OK_CANCEL,
1033 QUICK_END
1034
1035 };
1036
1037 WRect r = { -1, -1, 0, 46 };
1038
1039 quick_dialog_t qdlg = {
1040 r, N_("Display bits"), "[Display bits]",
1041 quick_widgets, NULL, NULL
1042 };
1043
1044 new_meta = !use_8th_bit_as_meta;
1045 application_keypad_mode ();
1046
1047 if (quick_dialog (&qdlg) == B_ENTER)
1048 {
1049 char *errmsg;
1050
1051 mc_global.display_codepage = new_display_codepage;
1052
1053 errmsg = init_translation_table (mc_global.source_codepage, mc_global.display_codepage);
1054 if (errmsg != NULL)
1055 {
1056 message (D_ERROR, MSG_ERROR, "%s", errmsg);
1057 g_free (errmsg);
1058 }
1059
1060 #ifdef HAVE_SLANG
1061 tty_display_8bit (mc_global.display_codepage != 0 && mc_global.display_codepage != 1);
1062 #else
1063 tty_display_8bit (mc_global.display_codepage != 0);
1064 #endif
1065 use_8th_bit_as_meta = !new_meta;
1066
1067 repaint_screen ();
1068 }
1069 }
1070 }
1071 #endif
1072
1073
1074
1075
1076 char *
1077 tree_box (const char *current_dir)
1078 {
1079 WTree *mytree;
1080 WDialog *dlg;
1081 WGroup *g;
1082 Widget *wd;
1083 char *val = NULL;
1084 WButtonBar *bar;
1085
1086 (void) current_dir;
1087
1088
1089 dlg = dlg_create (TRUE, 0, 0, LINES - 9, COLS - 20, WPOS_CENTER, FALSE, dialog_colors,
1090 tree_callback, NULL, "[Directory Tree]", _("Directory tree"));
1091 g = GROUP (dlg);
1092 wd = WIDGET (dlg);
1093
1094 mytree = tree_new (2, 2, wd->rect.lines - 6, wd->rect.cols - 5, FALSE);
1095 group_add_widget_autopos (g, mytree, WPOS_KEEP_ALL, NULL);
1096 group_add_widget_autopos (g, hline_new (wd->rect.lines - 4, 1, -1), WPOS_KEEP_BOTTOM, NULL);
1097 bar = buttonbar_new ();
1098 group_add_widget (g, bar);
1099
1100 WIDGET (bar)->rect.x = 0;
1101 WIDGET (bar)->rect.y = LINES - 1;
1102
1103 if (dlg_run (dlg) == B_ENTER)
1104 {
1105 const vfs_path_t *selected_name;
1106
1107 selected_name = tree_selected_name (mytree);
1108 val = g_strdup (vfs_path_as_str (selected_name));
1109 }
1110
1111 widget_destroy (wd);
1112 return val;
1113 }
1114
1115
1116
1117 #ifdef ENABLE_VFS
1118 void
1119 configure_vfs_box (void)
1120 {
1121 char buffer2[BUF_TINY];
1122 #ifdef ENABLE_VFS_FTP
1123 char buffer3[BUF_TINY];
1124
1125 g_snprintf (buffer3, sizeof (buffer3), "%i", ftpfs_directory_timeout);
1126 #endif
1127
1128 g_snprintf (buffer2, sizeof (buffer2), "%i", vfs_timeout);
1129
1130 {
1131 char *ret_timeout;
1132 #ifdef ENABLE_VFS_FTP
1133 char *ret_passwd;
1134 char *ret_ftp_proxy;
1135 char *ret_directory_timeout;
1136 #endif
1137
1138 quick_widget_t quick_widgets[] = {
1139
1140 QUICK_LABELED_INPUT (N_("Timeout for freeing VFSs (sec):"), input_label_left,
1141 buffer2, "input-timo-vfs", &ret_timeout, NULL, FALSE, FALSE,
1142 INPUT_COMPLETE_NONE),
1143 #ifdef ENABLE_VFS_FTP
1144 QUICK_SEPARATOR (TRUE),
1145 QUICK_LABELED_INPUT (N_("FTP anonymous password:"), input_label_left,
1146 ftpfs_anonymous_passwd, "input-passwd", &ret_passwd, NULL,
1147 FALSE, FALSE, INPUT_COMPLETE_NONE),
1148 QUICK_LABELED_INPUT (N_("FTP directory cache timeout (sec):"), input_label_left,
1149 buffer3, "input-timeout", &ret_directory_timeout, NULL,
1150 FALSE, FALSE, INPUT_COMPLETE_NONE),
1151 QUICK_CHECKBOX (N_("&Always use ftp proxy:"), &ftpfs_always_use_proxy,
1152 &ftpfs_always_use_proxy_id),
1153 QUICK_INPUT (ftpfs_proxy_host, "input-ftp-proxy", &ret_ftp_proxy,
1154 &ftpfs_proxy_host_id, FALSE, FALSE, INPUT_COMPLETE_HOSTNAMES),
1155 QUICK_CHECKBOX (N_("&Use ~/.netrc"), &ftpfs_use_netrc, NULL),
1156 QUICK_CHECKBOX (N_("Use &passive mode"), &ftpfs_use_passive_connections, NULL),
1157 QUICK_CHECKBOX (N_("Use passive mode over pro&xy"),
1158 &ftpfs_use_passive_connections_over_proxy, NULL),
1159 #endif
1160 QUICK_BUTTONS_OK_CANCEL,
1161 QUICK_END
1162
1163 };
1164
1165 WRect r = { -1, -1, 0, 56 };
1166
1167 quick_dialog_t qdlg = {
1168 r, N_("Virtual File System Setting"), "[Virtual FS]",
1169 quick_widgets,
1170 #ifdef ENABLE_VFS_FTP
1171 confvfs_callback,
1172 #else
1173 NULL,
1174 #endif
1175 NULL,
1176 };
1177
1178 #ifdef ENABLE_VFS_FTP
1179 if (!ftpfs_always_use_proxy)
1180 quick_widgets[5].state = WST_DISABLED;
1181 #endif
1182
1183 if (quick_dialog (&qdlg) != B_CANCEL)
1184 {
1185
1186 if (ret_timeout[0] == '\0')
1187 vfs_timeout = 0;
1188 else
1189 vfs_timeout = atoi (ret_timeout);
1190 g_free (ret_timeout);
1191
1192 if (vfs_timeout < 0 || vfs_timeout > 10000)
1193 vfs_timeout = 10;
1194 #ifdef ENABLE_VFS_FTP
1195 g_free (ftpfs_anonymous_passwd);
1196
1197 ftpfs_anonymous_passwd = ret_passwd;
1198 g_free (ftpfs_proxy_host);
1199
1200 ftpfs_proxy_host = ret_ftp_proxy;
1201
1202 if (ret_directory_timeout[0] == '\0')
1203 ftpfs_directory_timeout = 0;
1204 else
1205 ftpfs_directory_timeout = atoi (ret_directory_timeout);
1206 g_free (ret_directory_timeout);
1207 #endif
1208 }
1209 }
1210 }
1211
1212 #endif
1213
1214
1215
1216 char *
1217 cd_box (const WPanel * panel)
1218 {
1219 const Widget *w = CONST_WIDGET (panel);
1220 char *my_str;
1221
1222 quick_widget_t quick_widgets[] = {
1223 QUICK_LABELED_INPUT (N_("cd"), input_label_left, "", "input", &my_str, NULL, FALSE, TRUE,
1224 INPUT_COMPLETE_FILENAMES | INPUT_COMPLETE_CD),
1225 QUICK_END
1226 };
1227
1228 WRect r = { w->rect.y + w->rect.lines - 6, w->rect.x, 0, w->rect.cols };
1229
1230 quick_dialog_t qdlg = {
1231 r, N_("Quick cd"), "[Quick cd]",
1232 quick_widgets, NULL, NULL
1233 };
1234
1235 return (quick_dialog (&qdlg) != B_CANCEL) ? my_str : NULL;
1236 }
1237
1238
1239
1240 void
1241 symlink_box (const vfs_path_t * existing_vpath, const vfs_path_t * new_vpath,
1242 char **ret_existing, char **ret_new)
1243 {
1244 quick_widget_t quick_widgets[] = {
1245
1246 QUICK_LABELED_INPUT (N_("Existing filename (filename symlink will point to):"),
1247 input_label_above, vfs_path_as_str (existing_vpath), "input-2",
1248 ret_existing, NULL, FALSE, FALSE, INPUT_COMPLETE_FILENAMES),
1249 QUICK_SEPARATOR (FALSE),
1250 QUICK_LABELED_INPUT (N_("Symbolic link filename:"), input_label_above,
1251 vfs_path_as_str (new_vpath), "input-1",
1252 ret_new, NULL, FALSE, FALSE, INPUT_COMPLETE_FILENAMES),
1253 QUICK_BUTTONS_OK_CANCEL,
1254 QUICK_END
1255
1256 };
1257
1258 WRect r = { -1, -1, 0, 64 };
1259
1260 quick_dialog_t qdlg = {
1261 r, N_("Symbolic link"), "[File Menu]",
1262 quick_widgets, NULL, NULL
1263 };
1264
1265 if (quick_dialog (&qdlg) == B_CANCEL)
1266 {
1267 *ret_new = NULL;
1268 *ret_existing = NULL;
1269 }
1270 }
1271
1272
1273
1274 #ifdef ENABLE_BACKGROUND
1275 void
1276 jobs_box (void)
1277 {
1278 struct
1279 {
1280 const char *name;
1281 int flags;
1282 int value;
1283 int len;
1284 bcback_fn callback;
1285 }
1286 job_but[] =
1287 {
1288
1289 { N_("&Stop"), NORMAL_BUTTON, B_STOP, 0, task_cb },
1290 { N_("&Resume"), NORMAL_BUTTON, B_RESUME, 0, task_cb },
1291 { N_("&Kill"), NORMAL_BUTTON, B_KILL, 0, task_cb },
1292 { N_("&OK"), DEFPUSH_BUTTON, B_CANCEL, 0, NULL }
1293
1294 };
1295
1296 size_t i;
1297 const size_t n_but = G_N_ELEMENTS (job_but);
1298
1299 WDialog *jobs_dlg;
1300 WGroup *g;
1301 int cols = 60;
1302 int lines = 15;
1303 int x = 0;
1304
1305 for (i = 0; i < n_but; i++)
1306 {
1307 #ifdef ENABLE_NLS
1308 job_but[i].name = _(job_but[i].name);
1309 #endif
1310
1311 job_but[i].len = str_term_width1 (job_but[i].name) + 3;
1312 if (job_but[i].flags == DEFPUSH_BUTTON)
1313 job_but[i].len += 2;
1314 x += job_but[i].len;
1315 }
1316
1317 x += (int) n_but - 1;
1318 cols = MAX (cols, x + 6);
1319
1320 jobs_dlg = dlg_create (TRUE, 0, 0, lines, cols, WPOS_CENTER, FALSE, dialog_colors, NULL, NULL,
1321 "[Background jobs]", _("Background jobs"));
1322 g = GROUP (jobs_dlg);
1323
1324 bg_list = listbox_new (2, 2, lines - 6, cols - 6, FALSE, NULL);
1325 jobs_fill_listbox (bg_list);
1326 group_add_widget (g, bg_list);
1327
1328 group_add_widget (g, hline_new (lines - 4, -1, -1));
1329
1330 x = (cols - x) / 2;
1331 for (i = 0; i < n_but; i++)
1332 {
1333 group_add_widget (g, button_new (lines - 3, x, job_but[i].value, job_but[i].flags,
1334 job_but[i].name, job_but[i].callback));
1335 x += job_but[i].len + 1;
1336 }
1337
1338 (void) dlg_run (jobs_dlg);
1339 widget_destroy (WIDGET (jobs_dlg));
1340 }
1341 #endif
1342
1343