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 (Dlg_head
* h
, Widget
* sender
, dlg_msg_t msg
, int parm
, void *data
)
130 wi
= dlg_find_by_id (h
, panel_listing_types_id
);
131 if (dlg_widget_active (wi
))
135 in
= (WInput
*) dlg_find_by_id (h
, mini_user_format_id
);
136 input_assign_text (in
, status_format
[((WRadio
*) wi
)->sel
]);
141 wi
= dlg_find_by_id (h
, panel_user_format_id
);
142 if (dlg_widget_active (wi
))
144 h
->ret_value
= B_USER
+ 6;
149 wi
= dlg_find_by_id (h
, mini_user_format_id
);
150 if (dlg_widget_active (wi
))
152 h
->ret_value
= B_USER
+ 7;
158 if (g_ascii_tolower (parm
) == listing_user_hotkey
)
162 wi
= dlg_find_by_id (h
, panel_user_format_id
);
163 if (dlg_widget_active (wi
))
165 wi
= dlg_find_by_id (h
, mini_user_format_id
);
166 if (dlg_widget_active (wi
))
170 r
= (WRadio
*) dlg_find_by_id (h
, panel_listing_types_id
);
171 r
->pos
= r
->sel
= panel_listing_user_idx
;
172 dlg_select_widget (WIDGET (r
)); /* force redraw */
173 h
->callback (h
, WIDGET (r
), DLG_ACTION
, 0, NULL
);
178 return MSG_NOT_HANDLED
;
181 if (sender
!= NULL
&& sender
->id
== panel_listing_types_id
)
186 in1
= (WInput
*) dlg_find_by_id (h
, panel_user_format_id
);
187 ch
= (WCheck
*) dlg_find_by_id (h
, mini_user_status_id
);
188 in2
= (WInput
*) dlg_find_by_id (h
, mini_user_format_id
);
190 if (!(ch
->state
& C_BOOL
))
191 input_assign_text (in2
, status_format
[((WRadio
*) sender
)->sel
]);
192 input_update (in2
, FALSE
);
193 input_update (in1
, FALSE
);
194 widget_disable (WIDGET (in1
), ((WRadio
*) sender
)->sel
!= panel_listing_user_idx
);
198 if (sender
!= NULL
&& sender
->id
== mini_user_status_id
)
202 in
= (WInput
*) dlg_find_by_id (h
, mini_user_format_id
);
204 if (((WCheck
*) sender
)->state
& C_BOOL
)
206 widget_disable (WIDGET (in
), FALSE
);
207 input_assign_text (in
, status_format
[3]);
213 r
= (WRadio
*) dlg_find_by_id (h
, panel_listing_types_id
);
214 widget_disable (WIDGET (in
), TRUE
);
215 input_assign_text (in
, status_format
[r
->sel
]);
217 /* input_update (in, FALSE); */
221 return MSG_NOT_HANDLED
;
224 return default_dlg_callback (h
, sender
, msg
, parm
, data
);
228 /* --------------------------------------------------------------------------------------------- */
232 sel_charset_button (WButton
* button
, int action
)
238 new_dcp
= select_charset (-1, -1, new_display_codepage
, TRUE
);
240 if (new_dcp
!= SELECT_CHARSET_CANCEL
)
246 new_display_codepage
= new_dcp
;
247 cpname
= (new_display_codepage
== SELECT_CHARSET_OTHER_8BIT
) ?
249 ((codepage_desc
*) g_ptr_array_index (codepages
, new_display_codepage
))->name
;
251 mc_global
.utf8_display
= str_isutf8 (cpname
);
252 /* avoid strange bug with label repainting */
253 g_snprintf (buf
, sizeof (buf
), "%-27s", cpname
);
254 w
= dlg_find_by_id (WIDGET (button
)->owner
, disp_bits_name_id
);
255 label_set_text ((WLabel
*) w
, buf
);
260 #endif /* HAVE_CHARSET */
262 /* --------------------------------------------------------------------------------------------- */
265 tree_callback (Dlg_head
* h
, Widget
* sender
, dlg_msg_t msg
, int parm
, void *data
)
270 /* The enter key will be processed by the tree widget */
273 h
->ret_value
= B_ENTER
;
282 /* simply call dlg_set_size() with new size */
283 dlg_set_size (h
, LINES
- 9, COLS
- 20);
284 bar
= WIDGET (find_buttonbar (h
));
291 return send_message (WIDGET (find_tree (h
)), NULL
, WIDGET_COMMAND
, parm
, NULL
);
294 return default_dlg_callback (h
, sender
, msg
, parm
, data
);
298 /* --------------------------------------------------------------------------------------------- */
300 #if defined(ENABLE_VFS) && defined (ENABLE_VFS_FTP)
302 confvfs_callback (Dlg_head
* h
, Widget
* sender
, dlg_msg_t msg
, int parm
, void *data
)
307 /* message from "Always use ftp proxy" checkbutton */
308 if (sender
!= NULL
&& sender
->id
== ftpfs_always_use_proxy_id
)
310 const gboolean not_use
= !(((WCheck
*) sender
)->state
& C_BOOL
);
314 w
= dlg_find_by_id (h
, ftpfs_proxy_host_id
);
315 widget_disable (w
, not_use
);
318 return MSG_NOT_HANDLED
;
321 return default_dlg_callback (h
, sender
, msg
, parm
, data
);
324 #endif /* ENABLE_VFS && ENABLE_VFS_FTP */
326 /* --------------------------------------------------------------------------------------------- */
328 #ifdef ENABLE_BACKGROUND
330 jobs_fill_listbox (WListbox
* list
)
332 static const char *state_str
[2] = { "", "" };
335 if (state_str
[0] == '\0')
337 state_str
[0] = _("Running");
338 state_str
[1] = _("Stopped");
341 for (tl
= task_list
; tl
!= NULL
; tl
= tl
->next
)
345 s
= g_strconcat (state_str
[tl
->state
], " ", tl
->info
, (char *) NULL
);
346 listbox_add_item (list
, LISTBOX_APPEND_AT_END
, 0, s
, (void *) tl
);
351 /* --------------------------------------------------------------------------------------------- */
354 task_cb (WButton
* button
, int action
)
361 if (bg_list
->list
== NULL
)
364 /* Get this instance information */
365 listbox_get_current (bg_list
, NULL
, (void **) &tl
);
368 if (action
== B_STOP
)
371 tl
->state
= Task_Stopped
;
373 else if (action
== B_RESUME
)
376 tl
->state
= Task_Running
;
380 if (action
== B_KILL
)
384 unregister_task_running (tl
->pid
, tl
->fd
);
387 listbox_remove_list (bg_list
);
388 jobs_fill_listbox (bg_list
);
390 /* This can be optimized to just redraw this widget :-) */
391 dlg_redraw (WIDGET (button
)->owner
);
395 #endif /* ENABLE_BACKGROUND */
397 /* --------------------------------------------------------------------------------------------- */
398 /*** public functions ****************************************************************************/
399 /* --------------------------------------------------------------------------------------------- */
401 /* return list type */
403 panel_listing_box (WPanel
* panel
, char **userp
, char **minip
, int *use_msformat
, int num
)
406 char *section
= NULL
;
413 p
= get_nth_panel_name (num
);
414 panel
= g_new (WPanel
, 1);
415 panel
->list_type
= list_full
;
416 panel
->user_format
= g_strdup (DEFAULT_USER_FORMAT
);
417 panel
->user_mini_status
= 0;
418 for (i
= 0; i
< LIST_TYPES
; i
++)
419 panel
->user_status_format
[i
] = g_strdup (DEFAULT_USER_FORMAT
);
420 section
= g_strconcat ("Temporal:", p
, (char *) NULL
);
421 if (!mc_config_has_group (mc_main_config
, section
))
424 section
= g_strdup (p
);
426 panel_load_setup (panel
, section
);
431 int mini_user_status
;
432 char *panel_user_format
;
433 char *mini_user_format
;
436 /* Controls whether the array strings have been translated */
437 const char *list_types
[LIST_TYPES
] = {
438 N_("&Full file list"),
439 N_("&Brief file list"),
440 N_("&Long file list"),
444 quick_widget_t quick_widgets
[] = {
446 QUICK_RADIO (LIST_TYPES
, list_types
, &result
, &panel_listing_types_id
),
447 QUICK_INPUT (panel
->user_format
, INPUT_COMPLETE_DEFAULT
, "user-fmt-input",
448 &panel_user_format
, &panel_user_format_id
),
449 QUICK_SEPARATOR (TRUE
),
450 QUICK_CHECKBOX (N_("User &mini status"), &mini_user_status
, &mini_user_status_id
),
451 QUICK_INPUT (panel
->user_status_format
[panel
->list_type
], INPUT_COMPLETE_DEFAULT
,
452 "mini_input", &mini_user_format
, &mini_user_format_id
),
453 QUICK_BUTTONS_OK_CANCEL
,
458 quick_dialog_t qdlg
= {
460 N_("Listing mode"), "[Listing Mode...]",
461 quick_widgets
, panel_listing_callback
, NULL
464 /* get hotkey of user-defined format string */
465 cp
= strchr (_(list_types
[panel_listing_user_idx
]), '&');
466 if (cp
!= NULL
&& *++cp
!= '\0')
467 listing_user_hotkey
= g_ascii_tolower (*cp
);
469 mini_user_status
= panel
->user_mini_status
;
470 result
= panel
->list_type
;
471 status_format
= panel
->user_status_format
;
473 if (panel
->list_type
!= panel_listing_user_idx
)
474 quick_widgets
[1].options
= W_DISABLED
;
476 if (!mini_user_status
)
477 quick_widgets
[4].options
= W_DISABLED
;
479 if (quick_dialog (&qdlg
) == B_CANCEL
)
483 *userp
= panel_user_format
;
484 *minip
= mini_user_format
;
485 *use_msformat
= mini_user_status
;
493 g_free (panel
->user_format
);
494 for (i
= 0; i
< LIST_TYPES
; i
++)
495 g_free (panel
->user_status_format
[i
]);
502 /* --------------------------------------------------------------------------------------------- */
504 const panel_field_t
*
505 sort_box (panel_sort_info_t
* info
)
507 const char **sort_orders_names
;
508 gsize sort_names_num
, i
;
510 const panel_field_t
*result
= info
->sort_field
;
512 sort_orders_names
= panel_get_sortable_fields (&sort_names_num
);
514 for (i
= 0; i
< sort_names_num
; i
++)
515 if (strcmp (sort_orders_names
[i
], _(info
->sort_field
->title_hotkey
)) == 0)
522 quick_widget_t quick_widgets
[] = {
525 QUICK_RADIO (sort_names_num
, sort_orders_names
, &sort_idx
, NULL
),
527 QUICK_CHECKBOX (N_("Executable &first"), &info
->exec_first
, NULL
),
528 QUICK_CHECKBOX (N_("Case sensi&tive"), &info
->case_sensitive
, NULL
),
529 QUICK_CHECKBOX (N_("&Reverse"), &info
->reverse
, NULL
),
531 QUICK_BUTTONS_OK_CANCEL
,
536 quick_dialog_t qdlg
= {
538 N_("Sort order"), "[Sort Order...]",
539 quick_widgets
, NULL
, NULL
542 if (quick_dialog (&qdlg
) != B_CANCEL
)
543 result
= panel_get_field_by_title_hotkey (sort_orders_names
[sort_idx
]);
546 result
= info
->sort_field
;
549 g_strfreev ((gchar
**) sort_orders_names
);
554 /* --------------------------------------------------------------------------------------------- */
559 quick_widget_t quick_widgets
[] = {
561 /* TRANSLATORS: no need to translate 'Confirmation', it's just a context prefix */
562 QUICK_CHECKBOX (N_("Confirmation|&Delete"), &confirm_delete
, NULL
),
563 QUICK_CHECKBOX (N_("Confirmation|O&verwrite"), &confirm_overwrite
, NULL
),
564 QUICK_CHECKBOX (N_("Confirmation|&Execute"), &confirm_execute
, NULL
),
565 QUICK_CHECKBOX (N_("Confirmation|E&xit"), &confirm_exit
, NULL
),
566 QUICK_CHECKBOX (N_("Confirmation|Di&rectory hotlist delete"),
567 &confirm_directory_hotlist_delete
, NULL
),
568 QUICK_CHECKBOX (N_("Confirmation|&History cleanup"),
569 &mc_global
.widget
.confirm_history_cleanup
, NULL
),
570 QUICK_BUTTONS_OK_CANCEL
,
575 quick_dialog_t qdlg
= {
577 N_("Confirmation"), "[Confirmation]",
578 quick_widgets
, NULL
, NULL
581 (void) quick_dialog (&qdlg
);
584 /* --------------------------------------------------------------------------------------------- */
588 display_bits_box (void)
593 const char *display_bits_str
[] = {
595 N_("&Full 8 bits output"),
600 quick_widget_t quick_widgets
[] = {
602 QUICK_RADIO (4, display_bits_str
, ¤t_mode
, NULL
),
603 QUICK_SEPARATOR (TRUE
),
604 QUICK_CHECKBOX (N_("F&ull 8 bits input"), &new_meta
, NULL
),
605 QUICK_BUTTONS_OK_CANCEL
,
610 quick_dialog_t qdlg
= {
612 _("Display bits"), "[Display bits]",
613 quick_widgets
, NULL
, NULL
616 if (mc_global
.full_eight_bits
)
618 else if (mc_global
.eight_bit_clean
)
623 new_meta
= !use_8th_bit_as_meta
;
625 if (quick_dialog (&qdlg
) != B_CANCEL
)
627 mc_global
.eight_bit_clean
= current_mode
< 3;
628 mc_global
.full_eight_bits
= current_mode
< 2;
630 meta (stdscr
, mc_global
.eight_bit_clean
);
632 SLsmg_Display_Eight_Bit
= mc_global
.full_eight_bits
? 128 : 160;
634 use_8th_bit_as_meta
= !new_meta
;
638 /* --------------------------------------------------------------------------------------------- */
639 #else /* HAVE_CHARSET */
642 display_bits_box (void)
646 cpname
= (new_display_codepage
< 0) ? _("Other 8 bit")
647 : ((codepage_desc
*) g_ptr_array_index (codepages
, new_display_codepage
))->name
;
649 new_display_codepage
= mc_global
.display_codepage
;
654 quick_widget_t quick_widgets
[] = {
657 QUICK_LABEL (N_("Input / display codepage:"), NULL
),
661 QUICK_LABEL (cpname
, &disp_bits_name_id
),
663 QUICK_BUTTON (N_("&Select"), B_USER
, sel_charset_button
, NULL
),
665 QUICK_SEPARATOR (TRUE
),
666 QUICK_CHECKBOX (N_("F&ull 8 bits input"), &new_meta
, NULL
),
667 QUICK_BUTTONS_OK_CANCEL
,
672 quick_dialog_t qdlg
= {
674 N_("Display bits"), "[Display bits]",
675 quick_widgets
, NULL
, NULL
678 new_meta
= !use_8th_bit_as_meta
;
679 application_keypad_mode ();
681 if (quick_dialog (&qdlg
) == B_ENTER
)
685 mc_global
.display_codepage
= new_display_codepage
;
687 errmsg
= init_translation_table (mc_global
.source_codepage
, mc_global
.display_codepage
);
690 message (D_ERROR
, MSG_ERROR
, "%s", errmsg
);
695 tty_display_8bit (mc_global
.display_codepage
!= 0 && mc_global
.display_codepage
!= 1);
697 tty_display_8bit (mc_global
.display_codepage
!= 0);
699 use_8th_bit_as_meta
= !new_meta
;
705 #endif /* HAVE_CHARSET */
707 /* --------------------------------------------------------------------------------------------- */
708 /** Show tree in a box, not on a panel */
711 tree_box (const char *current_dir
)
721 /* Create the components */
722 dlg
= create_dlg (TRUE
, 0, 0, LINES
- 9, COLS
- 20, dialog_colors
, tree_callback
, NULL
,
723 "[Directory Tree]", _("Directory tree"), DLG_CENTER
);
726 mytree
= tree_new (2, 2, wd
->lines
- 6, wd
->cols
- 5, FALSE
);
727 add_widget_autopos (dlg
, mytree
, WPOS_KEEP_ALL
, NULL
);
728 add_widget_autopos (dlg
, hline_new (wd
->lines
- 4, 1, -1), WPOS_KEEP_BOTTOM
, NULL
);
729 bar
= buttonbar_new (TRUE
);
730 add_widget (dlg
, bar
);
731 /* restore ButtonBar coordinates after add_widget() */
733 WIDGET (bar
)->y
= LINES
- 1;
735 if (run_dlg (dlg
) == B_ENTER
)
736 val
= vfs_path_to_str (tree_selected_name (mytree
));
742 /* --------------------------------------------------------------------------------------------- */
748 char buffer2
[BUF_TINY
];
749 #ifdef ENABLE_VFS_FTP
750 char buffer3
[BUF_TINY
];
752 g_snprintf (buffer3
, sizeof (buffer3
), "%i", ftpfs_directory_timeout
);
755 g_snprintf (buffer2
, sizeof (buffer2
), "%i", vfs_timeout
);
759 #ifdef ENABLE_VFS_FTP
762 char *ret_directory_timeout
;
763 #endif /* ENABLE_VFS_FTP */
765 quick_widget_t quick_widgets
[] = {
767 QUICK_LABELED_INPUT (N_("Timeout for freeing VFSs (sec):"), input_label_left
,
768 buffer2
, 0, "input-timo-vfs", &ret_timeout
, NULL
),
769 #ifdef ENABLE_VFS_FTP
770 QUICK_SEPARATOR (TRUE
),
771 QUICK_LABELED_INPUT (N_("FTP anonymous password:"), input_label_left
,
772 ftpfs_anonymous_passwd
, 0, "input-passwd", &ret_passwd
, NULL
),
773 QUICK_LABELED_INPUT (N_("FTP directory cache timeout (sec):"), input_label_left
,
774 buffer3
, 0, "input-timeout", &ret_directory_timeout
, NULL
),
775 QUICK_CHECKBOX (N_("&Always use ftp proxy:"), &ftpfs_always_use_proxy
,
776 &ftpfs_always_use_proxy_id
),
777 QUICK_INPUT (ftpfs_proxy_host
, 0, "input-ftp-proxy", &ret_ftp_proxy
,
778 &ftpfs_proxy_host_id
),
779 QUICK_CHECKBOX (N_("&Use ~/.netrc"), &ftpfs_use_netrc
, NULL
),
780 QUICK_CHECKBOX (N_("Use &passive mode"), &ftpfs_use_passive_connections
, NULL
),
781 QUICK_CHECKBOX (N_("Use passive mode over pro&xy"),
782 &ftpfs_use_passive_connections_over_proxy
, NULL
),
783 #endif /* ENABLE_VFS_FTP */
784 QUICK_BUTTONS_OK_CANCEL
,
789 quick_dialog_t qdlg
= {
791 N_("Virtual File System Setting"), "[Virtual FS]",
793 #ifdef ENABLE_VFS_FTP
801 #ifdef ENABLE_VFS_FTP
802 if (!ftpfs_always_use_proxy
)
803 quick_widgets
[5].options
= W_DISABLED
;
806 if (quick_dialog (&qdlg
) != B_CANCEL
)
808 vfs_timeout
= atoi (ret_timeout
);
809 g_free (ret_timeout
);
811 if (vfs_timeout
< 0 || vfs_timeout
> 10000)
813 #ifdef ENABLE_VFS_FTP
814 g_free (ftpfs_anonymous_passwd
);
815 ftpfs_anonymous_passwd
= ret_passwd
;
816 g_free (ftpfs_proxy_host
);
817 ftpfs_proxy_host
= ret_ftp_proxy
;
818 ftpfs_directory_timeout
= atoi (ret_directory_timeout
);
819 g_free (ret_directory_timeout
);
825 #endif /* ENABLE_VFS */
827 /* --------------------------------------------------------------------------------------------- */
832 const Widget
*w
= WIDGET (current_panel
);
835 quick_widget_t quick_widgets
[] = {
836 QUICK_LABELED_INPUT (N_("cd"), input_label_left
, "", 2, "input", &my_str
, NULL
),
840 quick_dialog_t qdlg
= {
841 w
->y
+ w
->lines
- 6, w
->x
, w
->cols
,
842 N_("Quick cd"), "[Quick cd]",
843 quick_widgets
, NULL
, NULL
846 return (quick_dialog (&qdlg
) != B_CANCEL
) ? my_str
: NULL
;
849 /* --------------------------------------------------------------------------------------------- */
852 symlink_dialog (const vfs_path_t
* existing_vpath
, const vfs_path_t
* new_vpath
,
853 char **ret_existing
, char **ret_new
)
858 existing
= vfs_path_to_str (existing_vpath
);
859 new = vfs_path_to_str (new_vpath
);
862 quick_widget_t quick_widgets
[] = {
864 QUICK_LABELED_INPUT (N_("Existing filename (filename symlink will point to):"),
866 existing
, 0, "input-2", ret_existing
, NULL
),
867 QUICK_SEPARATOR (FALSE
),
868 QUICK_LABELED_INPUT (N_("Symbolic link filename:"), input_label_above
,
869 new, 0, "input-1", ret_new
, NULL
),
870 QUICK_BUTTONS_OK_CANCEL
,
875 quick_dialog_t qdlg
= {
877 N_("Symbolic link"), "[File Menu]",
878 quick_widgets
, NULL
, NULL
881 if (quick_dialog (&qdlg
) == B_CANCEL
)
884 *ret_existing
= NULL
;
892 /* --------------------------------------------------------------------------------------------- */
894 #ifdef ENABLE_BACKGROUND
909 { N_("&Stop"), NORMAL_BUTTON
, B_STOP
, 0, task_cb
},
910 { N_("&Resume"), NORMAL_BUTTON
, B_RESUME
, 0, task_cb
},
911 { N_("&Kill"), NORMAL_BUTTON
, B_KILL
, 0, task_cb
},
912 { N_("&OK"), DEFPUSH_BUTTON
, B_CANCEL
, 0, NULL
}
917 const size_t n_but
= G_N_ELEMENTS (job_but
);
924 for (i
= 0; i
< n_but
; i
++)
927 job_but
[i
].name
= _(job_but
[i
].name
);
928 #endif /* ENABLE_NLS */
930 job_but
[i
].len
= str_term_width1 (job_but
[i
].name
) + 3;
931 if (job_but
[i
].flags
== DEFPUSH_BUTTON
)
936 x
+= (int) n_but
- 1;
937 cols
= max (cols
, x
+ 6);
939 jobs_dlg
= create_dlg (TRUE
, 0, 0, lines
, cols
, dialog_colors
, NULL
, NULL
,
940 "[Background jobs]", _("Background jobs"), DLG_CENTER
);
942 bg_list
= listbox_new (2, 2, lines
- 6, cols
- 6, FALSE
, NULL
);
943 jobs_fill_listbox (bg_list
);
944 add_widget (jobs_dlg
, bg_list
);
946 add_widget (jobs_dlg
, hline_new (lines
- 4, -1, -1));
949 for (i
= 0; i
< n_but
; i
++)
951 add_widget (jobs_dlg
,
952 button_new (lines
- 3, x
, job_but
[i
].value
, job_but
[i
].flags
, job_but
[i
].name
,
953 job_but
[i
].callback
));
954 x
+= job_but
[i
].len
+ 1;
957 (void) run_dlg (jobs_dlg
);
958 destroy_dlg (jobs_dlg
);
960 #endif /* ENABLE_BACKGROUND */
962 /* --------------------------------------------------------------------------------------------- */
964 #ifdef ENABLE_VFS_SMB
965 struct smb_authinfo
*
966 vfs_smb_get_authinfo (const char *host
, const char *share
, const char *domain
, const char *user
)
969 struct smb_authinfo
*return_value
= NULL
;
976 label
= g_strdup_printf (_("Password for \\\\%s\\%s"), host
, share
);
979 char *ret_domain
, *ret_user
, *ret_password
;
981 quick_widget_t quick_widgets
[] = {
983 QUICK_LABEL (label
, NULL
),
984 QUICK_SEPARATOR (TRUE
),
986 QUICK_LABEL (N_("Domain:"), NULL
),
987 QUICK_SEPARATOR (FALSE
),
988 QUICK_LABEL (N_("Username:"), NULL
),
989 QUICK_SEPARATOR (FALSE
),
990 QUICK_LABEL (N_("Password:"), NULL
),
992 QUICK_INPUT (domain
, 0, "auth_domain", &ret_domain
, NULL
),
993 QUICK_SEPARATOR (FALSE
),
994 QUICK_INPUT (user
, 0, "auth_name", &ret_user
, NULL
),
995 QUICK_SEPARATOR (FALSE
),
996 QUICK_INPUT ("", 1, "auth_password", &ret_password
, NULL
),
998 QUICK_BUTTONS_OK_CANCEL
,
1003 quick_dialog_t qdlg
= {
1005 N_("SMB authentication"), "[Smb Authinfo]",
1006 quick_widgets
, NULL
, NULL
1009 if (quick_dialog (&qdlg
) != B_CANCEL
)
1011 return_value
= vfs_smb_authinfo_new (host
, share
, ret_domain
, ret_user
, ret_password
);
1013 g_free (ret_domain
);
1015 g_free (ret_password
);
1021 return return_value
;
1023 #endif /* ENABLE_VFS_SMB */
1025 /* --------------------------------------------------------------------------------------------- */