2 Some misc dialog boxes for the program.
4 Copyright (C) 1994, 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
5 2005, 2006, 2009, 2010, 2011, 2012
6 The Free Software Foundation, Inc.
9 Miguel de Icaza, 1994, 1995
11 Andrew Borodin <aborodin@vmail.ru>, 2009, 2010, 2011, 2012
13 This file is part of the Midnight Commander.
15 The Midnight Commander is free software: you can redistribute it
16 and/or modify it under the terms of the GNU General Public License as
17 published by the Free Software Foundation, either version 3 of the License,
18 or (at your option) any later version.
20 The Midnight Commander is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
25 You should have received a copy of the GNU General Public License
26 along with this program. If not, see <http://www.gnu.org/licenses/>.
30 * \brief Source: Some misc dialog boxes for the program
40 #include <sys/types.h>
43 #include "lib/global.h"
45 #include "lib/tty/tty.h"
46 #include "lib/tty/key.h" /* XCTRL and ALT macros */
47 #include "lib/skin.h" /* INPUT_COLOR */
48 #include "lib/mcconfig.h" /* Load/save user formats */
49 #include "lib/strutil.h"
51 #include "lib/vfs/vfs.h"
53 #include "src/vfs/ftpfs/ftpfs.h"
54 #endif /* ENABLE_VFS_FTP */
56 #include "src/vfs/smbfs/smbfs.h"
57 #endif /* ENABLE_VFS_SMB */
59 #include "lib/util.h" /* Q_() */
60 #include "lib/widget.h"
62 #include "src/setup.h" /* For profile_name */
63 #ifdef ENABLE_BACKGROUND
64 #include "src/background.h" /* task_list */
68 #include "lib/charsets.h"
69 #include "src/selcodepage.h"
72 #include "command.h" /* For cmdline */
74 #include "panel.h" /* LIST_TYPES */
76 #include "layout.h" /* for get_nth_panel_name proto */
77 #include "midnight.h" /* current_panel */
81 /*** global variables ****************************************************************************/
83 /*** file scope macro definitions ****************************************************************/
85 #ifdef ENABLE_BACKGROUND
86 #define B_STOP (B_USER+1)
87 #define B_RESUME (B_USER+2)
88 #define B_KILL (B_USER+3)
89 #endif /* ENABLE_BACKGROUND */
91 /*** file scope type declarations ****************************************************************/
93 /*** file scope variables ************************************************************************/
95 /* Index in list_types[] for "user defined" */
96 static const int panel_listing_user_idx
= 3;
98 static char **status_format
;
99 static int listing_user_hotkey
= 'u';
100 static unsigned long panel_listing_types_id
, panel_user_format_id
;
101 static unsigned long mini_user_status_id
, mini_user_format_id
;
104 static int new_display_codepage
;
105 static unsigned long disp_bits_name_id
;
106 #endif /* HAVE_CHARSET */
108 #if defined(ENABLE_VFS) && defined(ENABLE_VFS_FTP)
109 static unsigned long ftpfs_always_use_proxy_id
, ftpfs_proxy_host_id
;
110 #endif /* ENABLE_VFS && ENABLE_VFS_FTP */
112 #ifdef ENABLE_BACKGROUND
113 static WListbox
*bg_list
= NULL
;
114 #endif /* ENABLE_BACKGROUND */
116 /* --------------------------------------------------------------------------------------------- */
117 /*** file scope functions ************************************************************************/
118 /* --------------------------------------------------------------------------------------------- */
121 panel_listing_callback (Widget
* w
, Widget
* sender
, widget_msg_t msg
, int parm
, void *data
)
123 WDialog
*h
= DIALOG (w
);
132 wi
= dlg_find_by_id (h
, panel_listing_types_id
);
133 if (dlg_widget_active (wi
))
137 in
= INPUT (dlg_find_by_id (h
, mini_user_format_id
));
138 input_assign_text (in
, status_format
[RADIO (wi
)->sel
]);
143 wi
= dlg_find_by_id (h
, panel_user_format_id
);
144 if (dlg_widget_active (wi
))
146 h
->ret_value
= B_USER
+ 6;
151 wi
= dlg_find_by_id (h
, mini_user_format_id
);
152 if (dlg_widget_active (wi
))
154 h
->ret_value
= B_USER
+ 7;
160 if (g_ascii_tolower (parm
) == listing_user_hotkey
)
164 wi
= dlg_find_by_id (h
, panel_user_format_id
);
165 if (dlg_widget_active (wi
))
167 wi
= dlg_find_by_id (h
, mini_user_format_id
);
168 if (dlg_widget_active (wi
))
172 r
= RADIO (dlg_find_by_id (h
, panel_listing_types_id
));
173 r
->pos
= r
->sel
= panel_listing_user_idx
;
174 dlg_select_widget (WIDGET (r
)); /* force redraw */
175 send_message (h
, r
, MSG_ACTION
, 0, NULL
);
180 return MSG_NOT_HANDLED
;
183 if (sender
!= NULL
&& sender
->id
== panel_listing_types_id
)
188 in1
= INPUT (dlg_find_by_id (h
, panel_user_format_id
));
189 ch
= CHECK (dlg_find_by_id (h
, mini_user_status_id
));
190 in2
= INPUT (dlg_find_by_id (h
, mini_user_format_id
));
192 if (!(ch
->state
& C_BOOL
))
193 input_assign_text (in2
, status_format
[RADIO (sender
)->sel
]);
194 input_update (in2
, FALSE
);
195 input_update (in1
, FALSE
);
196 widget_disable (WIDGET (in1
), RADIO (sender
)->sel
!= panel_listing_user_idx
);
200 if (sender
!= NULL
&& sender
->id
== mini_user_status_id
)
204 in
= INPUT (dlg_find_by_id (h
, mini_user_format_id
));
206 if (CHECK (sender
)->state
& C_BOOL
)
208 widget_disable (WIDGET (in
), FALSE
);
209 input_assign_text (in
, status_format
[3]);
215 r
= RADIO (dlg_find_by_id (h
, panel_listing_types_id
));
216 widget_disable (WIDGET (in
), TRUE
);
217 input_assign_text (in
, status_format
[r
->sel
]);
219 /* input_update (in, FALSE); */
223 return MSG_NOT_HANDLED
;
226 return dlg_default_callback (w
, sender
, msg
, parm
, data
);
230 /* --------------------------------------------------------------------------------------------- */
234 sel_charset_button (WButton
* button
, int action
)
240 new_dcp
= select_charset (-1, -1, new_display_codepage
, TRUE
);
242 if (new_dcp
!= SELECT_CHARSET_CANCEL
)
248 new_display_codepage
= new_dcp
;
249 cpname
= (new_display_codepage
== SELECT_CHARSET_OTHER_8BIT
) ?
251 ((codepage_desc
*) g_ptr_array_index (codepages
, new_display_codepage
))->name
;
253 mc_global
.utf8_display
= str_isutf8 (cpname
);
254 /* avoid strange bug with label repainting */
255 g_snprintf (buf
, sizeof (buf
), "%-27s", cpname
);
256 w
= dlg_find_by_id (WIDGET (button
)->owner
, disp_bits_name_id
);
257 label_set_text (LABEL (w
), buf
);
262 #endif /* HAVE_CHARSET */
264 /* --------------------------------------------------------------------------------------------- */
267 tree_callback (Widget
* w
, Widget
* sender
, widget_msg_t msg
, int parm
, void *data
)
269 WDialog
*h
= DIALOG (w
);
274 /* The enter key will be processed by the tree widget */
277 h
->ret_value
= B_ENTER
;
286 /* simply call dlg_set_size() with new size */
287 dlg_set_size (h
, LINES
- 9, COLS
- 20);
288 bar
= WIDGET (find_buttonbar (h
));
295 return send_message (find_tree (h
), NULL
, MSG_ACTION
, parm
, NULL
);
298 return dlg_default_callback (w
, sender
, msg
, parm
, data
);
302 /* --------------------------------------------------------------------------------------------- */
304 #if defined(ENABLE_VFS) && defined (ENABLE_VFS_FTP)
306 confvfs_callback (Widget
* w
, Widget
* sender
, widget_msg_t msg
, int parm
, void *data
)
311 /* message from "Always use ftp proxy" checkbutton */
312 if (sender
!= NULL
&& sender
->id
== ftpfs_always_use_proxy_id
)
314 const gboolean not_use
= !(CHECK (sender
)->state
& C_BOOL
);
318 wi
= dlg_find_by_id (DIALOG (w
), ftpfs_proxy_host_id
);
319 widget_disable (wi
, not_use
);
322 return MSG_NOT_HANDLED
;
325 return dlg_default_callback (w
, sender
, msg
, parm
, data
);
328 #endif /* ENABLE_VFS && ENABLE_VFS_FTP */
330 /* --------------------------------------------------------------------------------------------- */
332 #ifdef ENABLE_BACKGROUND
334 jobs_fill_listbox (WListbox
* list
)
336 static const char *state_str
[2] = { "", "" };
339 if (state_str
[0] == '\0')
341 state_str
[0] = _("Running");
342 state_str
[1] = _("Stopped");
345 for (tl
= task_list
; tl
!= NULL
; tl
= tl
->next
)
349 s
= g_strconcat (state_str
[tl
->state
], " ", tl
->info
, (char *) NULL
);
350 listbox_add_item (list
, LISTBOX_APPEND_AT_END
, 0, s
, (void *) tl
);
355 /* --------------------------------------------------------------------------------------------- */
358 task_cb (WButton
* button
, int action
)
365 if (bg_list
->list
== NULL
)
368 /* Get this instance information */
369 listbox_get_current (bg_list
, NULL
, (void **) &tl
);
372 if (action
== B_STOP
)
375 tl
->state
= Task_Stopped
;
377 else if (action
== B_RESUME
)
380 tl
->state
= Task_Running
;
384 if (action
== B_KILL
)
388 unregister_task_running (tl
->pid
, tl
->fd
);
391 listbox_remove_list (bg_list
);
392 jobs_fill_listbox (bg_list
);
394 /* This can be optimized to just redraw this widget :-) */
395 dlg_redraw (WIDGET (button
)->owner
);
399 #endif /* ENABLE_BACKGROUND */
401 /* --------------------------------------------------------------------------------------------- */
402 /*** public functions ****************************************************************************/
403 /* --------------------------------------------------------------------------------------------- */
405 /* return list type */
407 panel_listing_box (WPanel
* panel
, char **userp
, char **minip
, int *use_msformat
, int num
)
410 char *section
= NULL
;
417 p
= get_nth_panel_name (num
);
418 panel
= g_new (WPanel
, 1);
419 panel
->list_type
= list_full
;
420 panel
->user_format
= g_strdup (DEFAULT_USER_FORMAT
);
421 panel
->user_mini_status
= 0;
422 for (i
= 0; i
< LIST_TYPES
; i
++)
423 panel
->user_status_format
[i
] = g_strdup (DEFAULT_USER_FORMAT
);
424 section
= g_strconcat ("Temporal:", p
, (char *) NULL
);
425 if (!mc_config_has_group (mc_main_config
, section
))
428 section
= g_strdup (p
);
430 panel_load_setup (panel
, section
);
435 int mini_user_status
;
436 char *panel_user_format
;
437 char *mini_user_format
;
440 /* Controls whether the array strings have been translated */
441 const char *list_types
[LIST_TYPES
] = {
442 N_("&Full file list"),
443 N_("&Brief file list"),
444 N_("&Long file list"),
448 quick_widget_t quick_widgets
[] = {
450 QUICK_RADIO (LIST_TYPES
, list_types
, &result
, &panel_listing_types_id
),
451 QUICK_INPUT (panel
->user_format
, INPUT_COMPLETE_DEFAULT
, "user-fmt-input",
452 &panel_user_format
, &panel_user_format_id
),
453 QUICK_SEPARATOR (TRUE
),
454 QUICK_CHECKBOX (N_("User &mini status"), &mini_user_status
, &mini_user_status_id
),
455 QUICK_INPUT (panel
->user_status_format
[panel
->list_type
], INPUT_COMPLETE_DEFAULT
,
456 "mini_input", &mini_user_format
, &mini_user_format_id
),
457 QUICK_BUTTONS_OK_CANCEL
,
462 quick_dialog_t qdlg
= {
464 N_("Listing mode"), "[Listing Mode...]",
465 quick_widgets
, panel_listing_callback
, NULL
468 /* get hotkey of user-defined format string */
469 cp
= strchr (_(list_types
[panel_listing_user_idx
]), '&');
470 if (cp
!= NULL
&& *++cp
!= '\0')
471 listing_user_hotkey
= g_ascii_tolower (*cp
);
473 mini_user_status
= panel
->user_mini_status
;
474 result
= panel
->list_type
;
475 status_format
= panel
->user_status_format
;
477 if (panel
->list_type
!= panel_listing_user_idx
)
478 quick_widgets
[1].options
= W_DISABLED
;
480 if (!mini_user_status
)
481 quick_widgets
[4].options
= W_DISABLED
;
483 if (quick_dialog (&qdlg
) == B_CANCEL
)
487 *userp
= panel_user_format
;
488 *minip
= mini_user_format
;
489 *use_msformat
= mini_user_status
;
497 g_free (panel
->user_format
);
498 for (i
= 0; i
< LIST_TYPES
; i
++)
499 g_free (panel
->user_status_format
[i
]);
506 /* --------------------------------------------------------------------------------------------- */
508 const panel_field_t
*
509 sort_box (panel_sort_info_t
* info
)
511 const char **sort_orders_names
;
512 gsize sort_names_num
, i
;
514 const panel_field_t
*result
= info
->sort_field
;
516 sort_orders_names
= panel_get_sortable_fields (&sort_names_num
);
518 for (i
= 0; i
< sort_names_num
; i
++)
519 if (strcmp (sort_orders_names
[i
], _(info
->sort_field
->title_hotkey
)) == 0)
526 quick_widget_t quick_widgets
[] = {
529 QUICK_RADIO (sort_names_num
, sort_orders_names
, &sort_idx
, NULL
),
531 QUICK_CHECKBOX (N_("Executable &first"), &info
->exec_first
, NULL
),
532 QUICK_CHECKBOX (N_("Cas&e sensitive"), &info
->case_sensitive
, NULL
),
533 QUICK_CHECKBOX (N_("&Reverse"), &info
->reverse
, NULL
),
535 QUICK_BUTTONS_OK_CANCEL
,
540 quick_dialog_t qdlg
= {
542 N_("Sort order"), "[Sort Order...]",
543 quick_widgets
, NULL
, NULL
546 if (quick_dialog (&qdlg
) != B_CANCEL
)
547 result
= panel_get_field_by_title_hotkey (sort_orders_names
[sort_idx
]);
550 result
= info
->sort_field
;
553 g_strfreev ((gchar
**) sort_orders_names
);
558 /* --------------------------------------------------------------------------------------------- */
563 quick_widget_t quick_widgets
[] = {
565 /* TRANSLATORS: no need to translate 'Confirmation', it's just a context prefix */
566 QUICK_CHECKBOX (N_("Confirmation|&Delete"), &confirm_delete
, NULL
),
567 QUICK_CHECKBOX (N_("Confirmation|O&verwrite"), &confirm_overwrite
, NULL
),
568 QUICK_CHECKBOX (N_("Confirmation|&Execute"), &confirm_execute
, NULL
),
569 QUICK_CHECKBOX (N_("Confirmation|E&xit"), &confirm_exit
, NULL
),
570 QUICK_CHECKBOX (N_("Confirmation|Di&rectory hotlist delete"),
571 &confirm_directory_hotlist_delete
, NULL
),
572 QUICK_CHECKBOX (N_("Confirmation|&History cleanup"),
573 &mc_global
.widget
.confirm_history_cleanup
, NULL
),
574 QUICK_BUTTONS_OK_CANCEL
,
579 quick_dialog_t qdlg
= {
581 N_("Confirmation"), "[Confirmation]",
582 quick_widgets
, NULL
, NULL
585 (void) quick_dialog (&qdlg
);
588 /* --------------------------------------------------------------------------------------------- */
592 display_bits_box (void)
597 const char *display_bits_str
[] = {
599 N_("&Full 8 bits output"),
604 quick_widget_t quick_widgets
[] = {
606 QUICK_RADIO (4, display_bits_str
, ¤t_mode
, NULL
),
607 QUICK_SEPARATOR (TRUE
),
608 QUICK_CHECKBOX (N_("F&ull 8 bits input"), &new_meta
, NULL
),
609 QUICK_BUTTONS_OK_CANCEL
,
614 quick_dialog_t qdlg
= {
616 _("Display bits"), "[Display bits]",
617 quick_widgets
, NULL
, NULL
620 if (mc_global
.full_eight_bits
)
622 else if (mc_global
.eight_bit_clean
)
627 new_meta
= !use_8th_bit_as_meta
;
629 if (quick_dialog (&qdlg
) != B_CANCEL
)
631 mc_global
.eight_bit_clean
= current_mode
< 3;
632 mc_global
.full_eight_bits
= current_mode
< 2;
634 meta (stdscr
, mc_global
.eight_bit_clean
);
636 SLsmg_Display_Eight_Bit
= mc_global
.full_eight_bits
? 128 : 160;
638 use_8th_bit_as_meta
= !new_meta
;
642 /* --------------------------------------------------------------------------------------------- */
643 #else /* HAVE_CHARSET */
646 display_bits_box (void)
650 cpname
= (new_display_codepage
< 0) ? _("Other 8 bit")
651 : ((codepage_desc
*) g_ptr_array_index (codepages
, new_display_codepage
))->name
;
653 new_display_codepage
= mc_global
.display_codepage
;
658 quick_widget_t quick_widgets
[] = {
661 QUICK_LABEL (N_("Input / display codepage:"), NULL
),
665 QUICK_LABEL (cpname
, &disp_bits_name_id
),
667 QUICK_BUTTON (N_("&Select"), B_USER
, sel_charset_button
, NULL
),
669 QUICK_SEPARATOR (TRUE
),
670 QUICK_CHECKBOX (N_("F&ull 8 bits input"), &new_meta
, NULL
),
671 QUICK_BUTTONS_OK_CANCEL
,
676 quick_dialog_t qdlg
= {
678 N_("Display bits"), "[Display bits]",
679 quick_widgets
, NULL
, NULL
682 new_meta
= !use_8th_bit_as_meta
;
683 application_keypad_mode ();
685 if (quick_dialog (&qdlg
) == B_ENTER
)
689 mc_global
.display_codepage
= new_display_codepage
;
691 errmsg
= init_translation_table (mc_global
.source_codepage
, mc_global
.display_codepage
);
694 message (D_ERROR
, MSG_ERROR
, "%s", errmsg
);
699 tty_display_8bit (mc_global
.display_codepage
!= 0 && mc_global
.display_codepage
!= 1);
701 tty_display_8bit (mc_global
.display_codepage
!= 0);
703 use_8th_bit_as_meta
= !new_meta
;
709 #endif /* HAVE_CHARSET */
711 /* --------------------------------------------------------------------------------------------- */
712 /** Show tree in a box, not on a panel */
715 tree_box (const char *current_dir
)
725 /* Create the components */
726 dlg
= create_dlg (TRUE
, 0, 0, LINES
- 9, COLS
- 20, dialog_colors
, tree_callback
, NULL
,
727 "[Directory Tree]", _("Directory tree"), DLG_CENTER
);
730 mytree
= tree_new (2, 2, wd
->lines
- 6, wd
->cols
- 5, FALSE
);
731 add_widget_autopos (dlg
, mytree
, WPOS_KEEP_ALL
, NULL
);
732 add_widget_autopos (dlg
, hline_new (wd
->lines
- 4, 1, -1), WPOS_KEEP_BOTTOM
, NULL
);
733 bar
= buttonbar_new (TRUE
);
734 add_widget (dlg
, bar
);
735 /* restore ButtonBar coordinates after add_widget() */
737 WIDGET (bar
)->y
= LINES
- 1;
739 if (run_dlg (dlg
) == B_ENTER
)
740 val
= vfs_path_to_str (tree_selected_name (mytree
));
746 /* --------------------------------------------------------------------------------------------- */
752 char buffer2
[BUF_TINY
];
753 #ifdef ENABLE_VFS_FTP
754 char buffer3
[BUF_TINY
];
756 g_snprintf (buffer3
, sizeof (buffer3
), "%i", ftpfs_directory_timeout
);
759 g_snprintf (buffer2
, sizeof (buffer2
), "%i", vfs_timeout
);
763 #ifdef ENABLE_VFS_FTP
766 char *ret_directory_timeout
;
767 #endif /* ENABLE_VFS_FTP */
769 quick_widget_t quick_widgets
[] = {
771 QUICK_LABELED_INPUT (N_("Timeout for freeing VFSs (sec):"), input_label_left
,
772 buffer2
, 0, "input-timo-vfs", &ret_timeout
, NULL
),
773 #ifdef ENABLE_VFS_FTP
774 QUICK_SEPARATOR (TRUE
),
775 QUICK_LABELED_INPUT (N_("FTP anonymous password:"), input_label_left
,
776 ftpfs_anonymous_passwd
, 0, "input-passwd", &ret_passwd
, NULL
),
777 QUICK_LABELED_INPUT (N_("FTP directory cache timeout (sec):"), input_label_left
,
778 buffer3
, 0, "input-timeout", &ret_directory_timeout
, NULL
),
779 QUICK_CHECKBOX (N_("&Always use ftp proxy:"), &ftpfs_always_use_proxy
,
780 &ftpfs_always_use_proxy_id
),
781 QUICK_INPUT (ftpfs_proxy_host
, 0, "input-ftp-proxy", &ret_ftp_proxy
,
782 &ftpfs_proxy_host_id
),
783 QUICK_CHECKBOX (N_("&Use ~/.netrc"), &ftpfs_use_netrc
, NULL
),
784 QUICK_CHECKBOX (N_("Use &passive mode"), &ftpfs_use_passive_connections
, NULL
),
785 QUICK_CHECKBOX (N_("Use passive mode over pro&xy"),
786 &ftpfs_use_passive_connections_over_proxy
, NULL
),
787 #endif /* ENABLE_VFS_FTP */
788 QUICK_BUTTONS_OK_CANCEL
,
793 quick_dialog_t qdlg
= {
795 N_("Virtual File System Setting"), "[Virtual FS]",
797 #ifdef ENABLE_VFS_FTP
805 #ifdef ENABLE_VFS_FTP
806 if (!ftpfs_always_use_proxy
)
807 quick_widgets
[5].options
= W_DISABLED
;
810 if (quick_dialog (&qdlg
) != B_CANCEL
)
812 vfs_timeout
= atoi (ret_timeout
);
813 g_free (ret_timeout
);
815 if (vfs_timeout
< 0 || vfs_timeout
> 10000)
817 #ifdef ENABLE_VFS_FTP
818 g_free (ftpfs_anonymous_passwd
);
819 ftpfs_anonymous_passwd
= ret_passwd
;
820 g_free (ftpfs_proxy_host
);
821 ftpfs_proxy_host
= ret_ftp_proxy
;
822 ftpfs_directory_timeout
= atoi (ret_directory_timeout
);
823 g_free (ret_directory_timeout
);
829 #endif /* ENABLE_VFS */
831 /* --------------------------------------------------------------------------------------------- */
836 const Widget
*w
= WIDGET (current_panel
);
839 quick_widget_t quick_widgets
[] = {
840 QUICK_LABELED_INPUT (N_("cd"), input_label_left
, "", 2, "input", &my_str
, NULL
),
844 quick_dialog_t qdlg
= {
845 w
->y
+ w
->lines
- 6, w
->x
, w
->cols
,
846 N_("Quick cd"), "[Quick cd]",
847 quick_widgets
, NULL
, NULL
850 return (quick_dialog (&qdlg
) != B_CANCEL
) ? my_str
: NULL
;
853 /* --------------------------------------------------------------------------------------------- */
856 symlink_dialog (const vfs_path_t
* existing_vpath
, const vfs_path_t
* new_vpath
,
857 char **ret_existing
, char **ret_new
)
862 existing
= vfs_path_to_str (existing_vpath
);
863 new = vfs_path_to_str (new_vpath
);
866 quick_widget_t quick_widgets
[] = {
868 QUICK_LABELED_INPUT (N_("Existing filename (filename symlink will point to):"),
870 existing
, 0, "input-2", ret_existing
, NULL
),
871 QUICK_SEPARATOR (FALSE
),
872 QUICK_LABELED_INPUT (N_("Symbolic link filename:"), input_label_above
,
873 new, 0, "input-1", ret_new
, NULL
),
874 QUICK_BUTTONS_OK_CANCEL
,
879 quick_dialog_t qdlg
= {
881 N_("Symbolic link"), "[File Menu]",
882 quick_widgets
, NULL
, NULL
885 if (quick_dialog (&qdlg
) == B_CANCEL
)
888 *ret_existing
= NULL
;
896 /* --------------------------------------------------------------------------------------------- */
898 #ifdef ENABLE_BACKGROUND
913 { N_("&Stop"), NORMAL_BUTTON
, B_STOP
, 0, task_cb
},
914 { N_("&Resume"), NORMAL_BUTTON
, B_RESUME
, 0, task_cb
},
915 { N_("&Kill"), NORMAL_BUTTON
, B_KILL
, 0, task_cb
},
916 { N_("&OK"), DEFPUSH_BUTTON
, B_CANCEL
, 0, NULL
}
921 const size_t n_but
= G_N_ELEMENTS (job_but
);
928 for (i
= 0; i
< n_but
; i
++)
931 job_but
[i
].name
= _(job_but
[i
].name
);
932 #endif /* ENABLE_NLS */
934 job_but
[i
].len
= str_term_width1 (job_but
[i
].name
) + 3;
935 if (job_but
[i
].flags
== DEFPUSH_BUTTON
)
940 x
+= (int) n_but
- 1;
941 cols
= max (cols
, x
+ 6);
943 jobs_dlg
= create_dlg (TRUE
, 0, 0, lines
, cols
, dialog_colors
, NULL
, NULL
,
944 "[Background jobs]", _("Background jobs"), DLG_CENTER
);
946 bg_list
= listbox_new (2, 2, lines
- 6, cols
- 6, FALSE
, NULL
);
947 jobs_fill_listbox (bg_list
);
948 add_widget (jobs_dlg
, bg_list
);
950 add_widget (jobs_dlg
, hline_new (lines
- 4, -1, -1));
953 for (i
= 0; i
< n_but
; i
++)
955 add_widget (jobs_dlg
,
956 button_new (lines
- 3, x
, job_but
[i
].value
, job_but
[i
].flags
, job_but
[i
].name
,
957 job_but
[i
].callback
));
958 x
+= job_but
[i
].len
+ 1;
961 (void) run_dlg (jobs_dlg
);
962 destroy_dlg (jobs_dlg
);
964 #endif /* ENABLE_BACKGROUND */
966 /* --------------------------------------------------------------------------------------------- */
968 #ifdef ENABLE_VFS_SMB
969 struct smb_authinfo
*
970 vfs_smb_get_authinfo (const char *host
, const char *share
, const char *domain
, const char *user
)
973 struct smb_authinfo
*return_value
= NULL
;
980 label
= g_strdup_printf (_("Password for \\\\%s\\%s"), host
, share
);
983 char *ret_domain
, *ret_user
, *ret_password
;
985 quick_widget_t quick_widgets
[] = {
987 QUICK_LABEL (label
, NULL
),
988 QUICK_SEPARATOR (TRUE
),
990 QUICK_LABEL (N_("Domain:"), NULL
),
991 QUICK_SEPARATOR (FALSE
),
992 QUICK_LABEL (N_("Username:"), NULL
),
993 QUICK_SEPARATOR (FALSE
),
994 QUICK_LABEL (N_("Password:"), NULL
),
996 QUICK_INPUT (domain
, 0, "auth_domain", &ret_domain
, NULL
),
997 QUICK_SEPARATOR (FALSE
),
998 QUICK_INPUT (user
, 0, "auth_name", &ret_user
, NULL
),
999 QUICK_SEPARATOR (FALSE
),
1000 QUICK_INPUT ("", 1, "auth_password", &ret_password
, NULL
),
1002 QUICK_BUTTONS_OK_CANCEL
,
1007 quick_dialog_t qdlg
= {
1009 N_("SMB authentication"), "[Smb Authinfo]",
1010 quick_widgets
, NULL
, NULL
1013 if (quick_dialog (&qdlg
) != B_CANCEL
)
1015 return_value
= vfs_smb_authinfo_new (host
, share
, ret_domain
, ret_user
, ret_password
);
1017 g_free (ret_domain
);
1019 g_free (ret_password
);
1025 return return_value
;
1027 #endif /* ENABLE_VFS_SMB */
1029 /* --------------------------------------------------------------------------------------------- */