gboolean editcmd_dialog_search_show (WEdit * edit) { char *search_text; size_t num_of_types; gchar **list_of_types; int dialog_result; list_of_types = mc_search_get_types_strings_array (&num_of_types); { quick_widget_t quick_widgets[] = { /* *INDENT-OFF* */ QUICK_LABELED_INPUT (N_("Enter search string:"), input_label_above, INPUT_LAST_TEXT, MC_HISTORY_SHARED_SEARCH, &search_text, NULL, FALSE, FALSE, INPUT_COMPLETE_NONE), QUICK_SEPARATOR (TRUE), QUICK_START_COLUMNS, QUICK_RADIO (num_of_types, (const char **) list_of_types, (int *) &edit_search_options.type, NULL), QUICK_NEXT_COLUMN, QUICK_CHECKBOX (N_("Cas&e sensitive"), &edit_search_options.case_sens, NULL), QUICK_CHECKBOX (N_("&Backwards"), &edit_search_options.backwards, NULL), QUICK_CHECKBOX (N_("In se&lection"), &edit_search_options.only_in_selection, NULL), QUICK_CHECKBOX (N_("&Whole words"), &edit_search_options.whole_words, NULL), #ifdef HAVE_CHARSET QUICK_CHECKBOX (N_("&All charsets"), &edit_search_options.all_codepages, NULL), #endif QUICK_STOP_COLUMNS, QUICK_START_BUTTONS (TRUE, TRUE), QUICK_BUTTON (N_("&OK"), B_ENTER, NULL, NULL), QUICK_BUTTON (N_("&Find all"), B_USER, NULL, NULL), QUICK_BUTTON (N_("&Cancel"), B_CANCEL, NULL, NULL), QUICK_END /* *INDENT-ON* */ }; quick_dialog_t qdlg = { -1, -1, 58, N_("Search"), "[Input Line Keys]", quick_widgets, NULL, NULL }; dialog_result = quick_dialog (&qdlg); } g_strfreev (list_of_types); if ((dialog_result == B_CANCEL) || (search_text == NULL) || (search_text[0] == '\0')) { g_free (search_text); return FALSE; } if (dialog_result == B_USER) search_create_bookmark = TRUE; #ifdef HAVE_CHARSET { GString *tmp; tmp = str_convert_to_input (search_text); if (tmp != NULL) { g_free (search_text); search_text = g_string_free (tmp, FALSE); } } #endif g_free (edit->last_search_string); edit->last_search_string = search_text; mc_search_free (edit->search); #ifdef HAVE_CHARSET edit->search = mc_search_new (edit->last_search_string, cp_source); #else edit->search = mc_search_new (edit->last_search_string, NULL); #endif if (edit->search != NULL) { edit->search->search_type = edit_search_options.type; #ifdef HAVE_CHARSET edit->search->is_all_charsets = edit_search_options.all_codepages; #endif edit->search->is_case_sensitive = edit_search_options.case_sens; edit->search->whole_words = edit_search_options.whole_words; edit->search->search_fn = edit_search_cmd_callback; edit->search->update_fn = edit_search_update_callback; } return (edit->search != NULL); }
const panel_field_t * sort_box (panel_sort_info_t *info) { int dlg_width = 40, dlg_height = 7; const char **sort_orders_names; gsize sort_names_num; int sort_idx = 0; const panel_field_t *result = info->sort_field; sort_orders_names = panel_get_sortable_fields (&sort_names_num); dlg_height += sort_names_num; { int max_radio = 0, max_check = 0; int ok_len, cancel_len; gsize i; QuickWidget quick_widgets[] = { /* 0 */ QUICK_BUTTON (0, dlg_width, dlg_height - 3, dlg_height, N_("&Cancel"), B_CANCEL, NULL), /* 1 */ QUICK_BUTTON (0, dlg_width, dlg_height - 3, dlg_height, N_("&OK"), B_ENTER, NULL), /* 2 */ QUICK_CHECKBOX (0, dlg_width, 5, dlg_height, N_("&Reverse"), &info->reverse), /* 3 */ QUICK_CHECKBOX (0, dlg_width, 4, dlg_height, N_("Case sensi&tive"), &info->case_sensitive), /* 4 */ QUICK_CHECKBOX (0, dlg_width, 3, dlg_height, N_("Executable &first"), &info->exec_first), /* 5 */ QUICK_RADIO (4, dlg_width, 3, dlg_height, 0, NULL, &sort_idx), QUICK_END }; QuickDialog quick_dlg = { dlg_width, dlg_height, -1, -1, N_("Sort order"), "[Sort Order...]", quick_widgets, NULL, TRUE }; quick_widgets[5].u.radio.items = sort_orders_names; quick_widgets[5].u.radio.count = sort_names_num; for (i = 0; i < sort_names_num; i++) if (strcmp (sort_orders_names[i], _(info->sort_field->title_hotkey)) == 0) { sort_idx = i; break; } #ifdef ENABLE_NLS quick_dlg.title = _(quick_dlg.title); /* buttons */ for (i = 0; i < 2; i++) quick_widgets[i].u.button.text = _(quick_widgets[i].u.button.text); /* checkboxes */ for (i = 2; i < 5; i++) quick_widgets[i].u.checkbox.text = _(quick_widgets[i].u.checkbox.text); #endif /* ENABLE_NlS */ /* buttons */ cancel_len = str_term_width1 (quick_widgets[0].u.button.text) + 4; ok_len = str_term_width1 (quick_widgets[1].u.button.text) + 6; /* checkboxes */ for (i = 2; i < 5; i++) max_check = max (max_check, str_term_width1 (quick_widgets[i].u.checkbox.text) + 4); /* radiobuttons */ for (i = 0; i < sort_names_num; i++) max_radio = max (max_radio, str_term_width1 (sort_orders_names[i]) + 4); /* dialog width */ dlg_width = max (dlg_width, str_term_width1 (quick_dlg.title) + 8); dlg_width = max (dlg_width, ok_len + cancel_len + 8); dlg_width = max (dlg_width, 2 * max (max_radio, max_check) + 8); /* fix widget and dialog parameters */ /* dialog */ quick_dlg.xlen = dlg_width; /* widgets */ for (i = 0; (size_t) i < sizeof (quick_widgets) / sizeof (quick_widgets[0]) - 1; i++) quick_widgets[i].x_divisions = dlg_width; /* buttons */ quick_widgets[0].relative_x = dlg_width * 2 / 3 - cancel_len / 2; quick_widgets[1].relative_x = dlg_width / 3 - ok_len / 2; /* checkboxes */ for (i = 2; i < 5; i++) quick_widgets[i].relative_x = dlg_width / 2 + 2; if (quick_dialog (&quick_dlg) != B_CANCEL) result = panel_get_field_by_title_hotkey (sort_orders_names[sort_idx]); if (result == NULL) result = info->sort_field; } g_strfreev ((gchar **) sort_orders_names); return result; }
gboolean mcview_dialog_search (mcview_t * view) { int SEARCH_DLG_MIN_HEIGHT = 12; int SEARCH_DLG_HEIGHT_SUPPLY = 3; int SEARCH_DLG_WIDTH = 58; char *exp = NULL; int qd_result; size_t num_of_types; gchar **list_of_types = mc_search_get_types_strings_array (&num_of_types); int SEARCH_DLG_HEIGHT = SEARCH_DLG_MIN_HEIGHT + num_of_types - SEARCH_DLG_HEIGHT_SUPPLY; QuickWidget quick_widgets[] = { QUICK_BUTTON (6, 10, SEARCH_DLG_HEIGHT - 3, SEARCH_DLG_HEIGHT, N_("&Cancel"), B_CANCEL, NULL), QUICK_BUTTON (2, 10, SEARCH_DLG_HEIGHT - 3, SEARCH_DLG_HEIGHT, N_("&OK"), B_ENTER, NULL), #ifdef HAVE_CHARSET QUICK_CHECKBOX (SEARCH_DLG_WIDTH / 2 + 3, SEARCH_DLG_WIDTH, 8, SEARCH_DLG_HEIGHT, N_("&All charsets"), &mcview_search_options.all_codepages), #endif QUICK_CHECKBOX (SEARCH_DLG_WIDTH / 2 + 3, SEARCH_DLG_WIDTH, 7, SEARCH_DLG_HEIGHT, N_("&Whole words"), &mcview_search_options.whole_words), QUICK_CHECKBOX (SEARCH_DLG_WIDTH / 2 + 3, SEARCH_DLG_WIDTH, 6, SEARCH_DLG_HEIGHT, N_("&Backwards"), &mcview_search_options.backwards), QUICK_CHECKBOX (SEARCH_DLG_WIDTH / 2 + 3, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT, N_("Cas&e sensitive"), &mcview_search_options.case_sens), QUICK_RADIO (3, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT, num_of_types, (const char **) list_of_types, (int *) &mcview_search_options.type), QUICK_INPUT (3, SEARCH_DLG_WIDTH, 3, SEARCH_DLG_HEIGHT, INPUT_LAST_TEXT, SEARCH_DLG_WIDTH - 6, 0, MC_HISTORY_SHARED_SEARCH, &exp), QUICK_LABEL (3, SEARCH_DLG_WIDTH, 2, SEARCH_DLG_HEIGHT, N_("Enter search string:")), QUICK_END }; QuickDialog Quick_input = { SEARCH_DLG_WIDTH, SEARCH_DLG_HEIGHT, -1, -1, N_("Search"), "[Input Line Keys]", quick_widgets, NULL, NULL, FALSE }; qd_result = quick_dialog (&Quick_input); g_strfreev (list_of_types); if ((qd_result == B_CANCEL) || (exp == NULL) || (exp[0] == '\0')) { g_free (exp); return FALSE; } #ifdef HAVE_CHARSET { GString *tmp = str_convert_to_input (exp); if (tmp) { g_free (exp); exp = g_string_free (tmp, FALSE); } } #endif g_free (view->last_search_string); view->last_search_string = exp; mcview_nroff_seq_free (&view->search_nroff_seq); mc_search_free (view->search); view->search = mc_search_new (view->last_search_string, -1); view->search_nroff_seq = mcview_nroff_seq_new (view); if (view->search != NULL) { view->search->search_type = mcview_search_options.type; view->search->is_all_charsets = mcview_search_options.all_codepages; view->search->is_case_sensitive = mcview_search_options.case_sens; view->search->whole_words = mcview_search_options.whole_words; view->search->search_fn = mcview_search_cmd_callback; view->search->update_fn = mcview_search_update_cmd_callback; } return (view->search != NULL); }
char * file_mask_dialog (file_op_context_t * ctx, FileOperation operation, gboolean only_one, const char *format, const void *text, const char *def_text, gboolean * do_bg) { size_t fmd_xlen; vfs_path_t *vpath; int source_easy_patterns = easy_patterns; char fmd_buf[BUF_MEDIUM]; char *dest_dir, *tmp; char *def_text_secure; if (ctx == NULL) return NULL; /* unselect checkbox if target filesystem don't support attributes */ ctx->op_preserve = filegui__check_attrs_on_fs (def_text); ctx->stable_symlinks = FALSE; *do_bg = FALSE; /* filter out a possible password from def_text */ vpath = vfs_path_from_str_flags (def_text, only_one ? VPF_NO_CANON : VPF_NONE); tmp = vfs_path_to_str_flags (vpath, 0, VPF_STRIP_PASSWORD); vfs_path_free (vpath); if (source_easy_patterns) def_text_secure = strutils_glob_escape (tmp); else def_text_secure = strutils_regex_escape (tmp); g_free (tmp); if (only_one) { int format_len, text_len; int max_len; format_len = str_term_width1 (format); text_len = str_term_width1 (text); max_len = COLS - 2 - 6; if (format_len + text_len <= max_len) { fmd_xlen = format_len + text_len + 6; fmd_xlen = max (fmd_xlen, 68); } else { text = str_trunc ((const char *) text, max_len - format_len); fmd_xlen = max_len + 6; } g_snprintf (fmd_buf, sizeof (fmd_buf), format, (const char *) text); } else { fmd_xlen = COLS * 2 / 3; fmd_xlen = max (fmd_xlen, 68); g_snprintf (fmd_buf, sizeof (fmd_buf), format, *(const int *) text); } { char *source_mask, *orig_mask; int val; struct stat buf; quick_widget_t quick_widgets[] = { /* *INDENT-OFF* */ QUICK_LABELED_INPUT (fmd_buf, input_label_above, easy_patterns ? "*" : "^(.*)$", "input-def", &source_mask, NULL, FALSE, FALSE, INPUT_COMPLETE_FILENAMES), QUICK_START_COLUMNS, QUICK_SEPARATOR (FALSE), QUICK_NEXT_COLUMN, QUICK_CHECKBOX (N_("&Using shell patterns"), &source_easy_patterns, NULL), QUICK_STOP_COLUMNS, QUICK_LABELED_INPUT (N_("to:"), input_label_above, def_text_secure, "input2", &dest_dir, NULL, FALSE, FALSE, INPUT_COMPLETE_FILENAMES), QUICK_SEPARATOR (TRUE), QUICK_START_COLUMNS, QUICK_CHECKBOX (N_("Follow &links"), &ctx->follow_links, NULL), QUICK_CHECKBOX (N_("Preserve &attributes"), &ctx->op_preserve, NULL), QUICK_NEXT_COLUMN, QUICK_CHECKBOX (N_("Di&ve into subdir if exists"), &ctx->dive_into_subdirs, NULL), QUICK_CHECKBOX (N_("&Stable symlinks"), &ctx->stable_symlinks, NULL), QUICK_STOP_COLUMNS, QUICK_START_BUTTONS (TRUE, TRUE), QUICK_BUTTON (N_("&OK"), B_ENTER, NULL, NULL), #ifdef ENABLE_BACKGROUND QUICK_BUTTON (N_("&Background"), B_USER, NULL, NULL), #endif /* ENABLE_BACKGROUND */ QUICK_BUTTON (N_("&Cancel"), B_CANCEL, NULL, NULL), QUICK_END /* *INDENT-ON* */ }; quick_dialog_t qdlg = { -1, -1, fmd_xlen, op_names[operation], "[Mask Copy/Rename]", quick_widgets, NULL, NULL }; ask_file_mask: val = quick_dialog_skip (&qdlg, 4); if (val == B_CANCEL) { g_free (def_text_secure); return NULL; } if (ctx->follow_links) ctx->stat_func = mc_stat; else ctx->stat_func = mc_lstat; if (ctx->op_preserve) { ctx->preserve = TRUE; ctx->umask_kill = 0777777; ctx->preserve_uidgid = (geteuid () == 0); } else { int i2; ctx->preserve = ctx->preserve_uidgid = FALSE; i2 = umask (0); umask (i2); ctx->umask_kill = i2 ^ 0777777; } if ((dest_dir == NULL) || (*dest_dir == '\0')) { g_free (def_text_secure); g_free (source_mask); return dest_dir; } ctx->search_handle = mc_search_new (source_mask, -1, NULL); if (ctx->search_handle == NULL) { message (D_ERROR, MSG_ERROR, _("Invalid source pattern '%s'"), source_mask); g_free (dest_dir); g_free (source_mask); goto ask_file_mask; } g_free (def_text_secure); g_free (source_mask); ctx->search_handle->is_case_sensitive = TRUE; if (source_easy_patterns) ctx->search_handle->search_type = MC_SEARCH_T_GLOB; else ctx->search_handle->search_type = MC_SEARCH_T_REGEX; vpath = vfs_path_from_str (dest_dir); ctx->dest_mask = strrchr (dest_dir, PATH_SEP); if (ctx->dest_mask == NULL) ctx->dest_mask = dest_dir; else ctx->dest_mask++; orig_mask = ctx->dest_mask; if (*ctx->dest_mask == '\0' || (!ctx->dive_into_subdirs && !is_wildcarded (ctx->dest_mask) && (!only_one || (mc_stat (vpath, &buf) == 0 && S_ISDIR (buf.st_mode)))) || (ctx->dive_into_subdirs && ((!only_one && !is_wildcarded (ctx->dest_mask)) || (only_one && mc_stat (vpath, &buf) == 0 && S_ISDIR (buf.st_mode))))) ctx->dest_mask = g_strdup ("\\0"); else { ctx->dest_mask = g_strdup (ctx->dest_mask); *orig_mask = '\0'; } if (*dest_dir == '\0') { g_free (dest_dir); dest_dir = g_strdup ("./"); } vfs_path_free (vpath); if (val == B_USER) *do_bg = TRUE; } return dest_dir; }
void confirm_box (void) { const int w_num = 7; /* dialog sizes */ int dlg_width = 46; int dlg_height = 12; const char *title = _(" Confirmation "); QuickWidget conf_widgets [] = { /* 0 */ QUICK_BUTTON (29, dlg_width, 9, dlg_height, N_("&Cancel"), B_CANCEL, NULL), /* 1 */ QUICK_BUTTON (12, dlg_width, 9, dlg_height, N_("&OK"), B_ENTER, NULL), /* 2 */ QUICK_CHECKBOX (3, dlg_width, 7, dlg_height, N_(" confirm di&Rectory hotlist delete "), &confirm_directory_hotlist_delete), /* 3 */ QUICK_CHECKBOX (3, dlg_width, 6, dlg_height, N_(" confirm &Exit "), &confirm_exit), /* 4 */ QUICK_CHECKBOX (3, dlg_width, 5, dlg_height, N_(" confirm e&Xecute "), &confirm_execute), /* 5 */ QUICK_CHECKBOX (3, dlg_width, 4, dlg_height, N_(" confirm o&Verwrite "), &confirm_overwrite), /* 6 */ QUICK_CHECKBOX (3, dlg_width, 3, dlg_height, N_(" confirm &Delete "), &confirm_delete), QUICK_END }; int i; int maxlen = 0; int cancel_len, ok_len, blen; #ifdef ENABLE_NLS title = _(title); for (i = 0; i < 2; i++) conf_widgets [i].u.button.text = _(conf_widgets [i].u.button.text); for (i = 2; i < w_num; i++) conf_widgets [i].u.checkbox.text = _(conf_widgets [i].u.checkbox.text); #endif /* ENABLE_NLS */ /* maximumr length of checkboxes */ for (i = 2; i < w_num; i++) maxlen = max (maxlen, str_term_width1 (conf_widgets [i].u.checkbox.text) + 3); /* length of buttons */ cancel_len = str_term_width1 (conf_widgets [0].u.button.text) + 2; ok_len = str_term_width1 (conf_widgets [0].u.button.text) + 4; /* default button */ blen = cancel_len + ok_len + 2; dlg_width = max (maxlen, blen) + 6; dlg_width = max (dlg_width, str_term_width1 (title) + 4); /* correct widget parameters */ for (i = 0; i < w_num; i++) conf_widgets[i].x_divisions = dlg_width; conf_widgets[0].relative_x = dlg_width * 2/3 - cancel_len/2; conf_widgets[1].relative_x = dlg_width/3 - ok_len/2; { QuickDialog confirmation = { dlg_width, dlg_height, -1, -1, title, "[Confirmation]", conf_widgets, 1 }; (void) quick_dialog (&confirmation); } }
/* return list type */ int panel_listing_box (WPanel * panel, int num, char **userp, char **minip, int *use_msformat, int *brief_cols) { int result = -1; char *section = NULL; if (panel == NULL) { const char *p; size_t i; p = get_nth_panel_name (num); panel = g_new (WPanel, 1); panel->list_type = list_full; panel->user_format = g_strdup (DEFAULT_USER_FORMAT); panel->user_mini_status = 0; for (i = 0; i < LIST_TYPES; i++) panel->user_status_format[i] = g_strdup (DEFAULT_USER_FORMAT); section = g_strconcat ("Temporal:", p, (char *) NULL); if (!mc_config_has_group (mc_main_config, section)) { g_free (section); section = g_strdup (p); } panel_load_setup (panel, section); g_free (section); } { int mini_user_status; char panel_brief_cols_in[BUF_TINY]; char *panel_brief_cols_out = NULL; char *panel_user_format = NULL; char *mini_user_format = NULL; const char *cp; /* Controls whether the array strings have been translated */ const char *list_types[LIST_TYPES] = { N_("&Full file list"), N_("&Brief file list:"), N_("&Long file list"), N_("&User defined:") }; quick_widget_t quick_widgets[] = { /* *INDENT-OFF* */ QUICK_START_COLUMNS, QUICK_RADIO (LIST_TYPES, list_types, &result, &panel_listing_types_id), QUICK_NEXT_COLUMN, QUICK_SEPARATOR (FALSE), QUICK_LABELED_INPUT (_ ("columns"), input_label_right, panel_brief_cols_in, "panel-brief-cols-input", &panel_brief_cols_out, &panel_brief_cols_id, FALSE, FALSE, INPUT_COMPLETE_NONE), QUICK_STOP_COLUMNS, QUICK_INPUT (panel->user_format, "user-fmt-input", &panel_user_format, &panel_user_format_id, FALSE, FALSE, INPUT_COMPLETE_NONE), QUICK_SEPARATOR (TRUE), QUICK_CHECKBOX (N_("User &mini status"), &mini_user_status, &mini_user_status_id), QUICK_INPUT (panel->user_status_format[panel->list_type], "mini_input", &mini_user_format, &mini_user_format_id, FALSE, FALSE, INPUT_COMPLETE_NONE), QUICK_BUTTONS_OK_CANCEL, QUICK_END /* *INDENT-ON* */ }; quick_dialog_t qdlg = { -1, -1, 48, N_("Listing mode"), "[Listing Mode...]", quick_widgets, panel_listing_callback, NULL }; /* get hotkey of user-defined format string */ cp = strchr (_(list_types[panel_listing_user_idx]), '&'); if (cp != NULL && *++cp != '\0') listing_user_hotkey = g_ascii_tolower (*cp); mini_user_status = panel->user_mini_status; result = panel->list_type; status_format = panel->user_status_format; g_snprintf (panel_brief_cols_in, sizeof (panel_brief_cols_in), "%d", panel->brief_cols); if ((int) panel->list_type != panel_listing_brief_idx) quick_widgets[4].options = W_DISABLED; if ((int) panel->list_type != panel_listing_user_idx) quick_widgets[6].options = W_DISABLED; if (!mini_user_status) quick_widgets[9].options = W_DISABLED; if (quick_dialog (&qdlg) == B_CANCEL) result = -1; else { int cols; char *error = NULL; *userp = panel_user_format; *minip = mini_user_format; *use_msformat = mini_user_status; cols = strtol (panel_brief_cols_out, &error, 10); if (*error == '\0') *brief_cols = cols; else *brief_cols = panel->brief_cols; g_free (panel_brief_cols_out); } } if (section != NULL) { int i; g_free (panel->user_format); for (i = 0; i < LIST_TYPES; i++) g_free (panel->user_status_format[i]); g_free (panel); } return result; }
void configure_vfs (void) { char buffer2[BUF_TINY]; #ifdef ENABLE_VFS_FTP char buffer3[BUF_TINY]; g_snprintf (buffer3, sizeof (buffer3), "%i", ftpfs_directory_timeout); #endif g_snprintf (buffer2, sizeof (buffer2), "%i", vfs_timeout); { char *ret_timeout; #ifdef ENABLE_VFS_FTP char *ret_passwd; char *ret_ftp_proxy; char *ret_directory_timeout; #endif /* ENABLE_VFS_FTP */ quick_widget_t quick_widgets[] = { /* *INDENT-OFF* */ QUICK_LABELED_INPUT (N_("Timeout for freeing VFSs (sec):"), input_label_left, buffer2, "input-timo-vfs", &ret_timeout, NULL, FALSE, FALSE, INPUT_COMPLETE_NONE), #ifdef ENABLE_VFS_FTP QUICK_SEPARATOR (TRUE), QUICK_LABELED_INPUT (N_("FTP anonymous password:"******"input-passwd", &ret_passwd, NULL, FALSE, FALSE, INPUT_COMPLETE_NONE), QUICK_LABELED_INPUT (N_("FTP directory cache timeout (sec):"), input_label_left, buffer3, "input-timeout", &ret_directory_timeout, NULL, FALSE, FALSE, INPUT_COMPLETE_NONE), QUICK_CHECKBOX (N_("&Always use ftp proxy:"), &ftpfs_always_use_proxy, &ftpfs_always_use_proxy_id), QUICK_INPUT (ftpfs_proxy_host, "input-ftp-proxy", &ret_ftp_proxy, &ftpfs_proxy_host_id, FALSE, FALSE, INPUT_COMPLETE_HOSTNAMES), QUICK_CHECKBOX (N_("&Use ~/.netrc"), &ftpfs_use_netrc, NULL), QUICK_CHECKBOX (N_("Use &passive mode"), &ftpfs_use_passive_connections, NULL), QUICK_CHECKBOX (N_("Use passive mode over pro&xy"), &ftpfs_use_passive_connections_over_proxy, NULL), #endif /* ENABLE_VFS_FTP */ QUICK_BUTTONS_OK_CANCEL, QUICK_END /* *INDENT-ON* */ }; quick_dialog_t qdlg = { -1, -1, 56, N_("Virtual File System Setting"), "[Virtual FS]", quick_widgets, #ifdef ENABLE_VFS_FTP confvfs_callback, #else NULL, #endif NULL, }; #ifdef ENABLE_VFS_FTP if (!ftpfs_always_use_proxy) quick_widgets[5].options = W_DISABLED; #endif if (quick_dialog (&qdlg) != B_CANCEL) { /* cppcheck-suppress uninitvar */ vfs_timeout = atoi (ret_timeout); g_free (ret_timeout); if (vfs_timeout < 0 || vfs_timeout > 10000) vfs_timeout = 10; #ifdef ENABLE_VFS_FTP g_free (ftpfs_anonymous_passwd); /* cppcheck-suppress uninitvar */ ftpfs_anonymous_passwd = ret_passwd; g_free (ftpfs_proxy_host); /* cppcheck-suppress uninitvar */ ftpfs_proxy_host = ret_ftp_proxy; /* cppcheck-suppress uninitvar */ ftpfs_directory_timeout = atoi (ret_directory_timeout); g_free (ret_directory_timeout); #endif } } }
void configure_vfs (void) { char buffer2[BUF_TINY]; #ifdef ENABLE_VFS_FTP char buffer3[BUF_TINY]; #endif QuickWidget confvfs_widgets[] = { /* 0 */ QUICK_BUTTON (30, VFSX, VFSY - 3, VFSY, N_("&Cancel"), B_CANCEL, NULL), /* 1 */ QUICK_BUTTON (12, VFSX, VFSY - 3, VFSY, N_("&OK"), B_ENTER, NULL), #ifdef ENABLE_VFS_FTP /* 2 */ QUICK_CHECKBOX (4, VFSX, 12, VFSY, N_("Use passive mode over pro&xy"), &ftpfs_use_passive_connections_over_proxy), /* 3 */ QUICK_CHECKBOX (4, VFSX, 11, VFSY, N_("Use &passive mode"), &ftpfs_use_passive_connections), /* 4 */ QUICK_CHECKBOX (4, VFSX, 10, VFSY, N_("&Use ~/.netrc"), &ftpfs_use_netrc), /* 5 */ QUICK_INPUT (4, VFSX, 9, VFSY, ftpfs_proxy_host, 48, 0, "input-ftp-proxy", &ret_ftp_proxy), /* 6 */ QUICK_CHECKBOX (4, VFSX, 8, VFSY, N_("&Always use ftp proxy"), &ftpfs_always_use_proxy), /* 7 */ QUICK_LABEL (49, VFSX, 7, VFSY, N_("sec")), /* 8 */ QUICK_INPUT (38, VFSX, 7, VFSY, buffer3, 10, 0, "input-timeout", &ret_directory_timeout), /* 9 */ QUICK_LABEL (4, VFSX, 7, VFSY, N_("ftpfs directory cache timeout:")), /* 10 */ QUICK_INPUT (4, VFSX, 6, VFSY, ftpfs_anonymous_passwd, 48, 0, "input-passwd", &ret_passwd), /* 11 */ QUICK_LABEL (4, VFSX, 5, VFSY, N_("ftp anonymous password:"******"sec")), /* 13 */ QUICK_INPUT (38, VFSX, 3, VFSY, buffer2, 10, 0, "input-timo-vfs", &ret_timeout), /* 14 */ QUICK_LABEL (4, VFSX, 3, VFSY, N_("Timeout for freeing VFSs:")), QUICK_END }; QuickDialog confvfs_dlg = { VFSX, VFSY, -1, -1, N_("Virtual File System Setting"), "[Virtual FS]", confvfs_widgets, #ifdef ENABLE_VFS_FTP confvfs_callback, #else NULL, #endif FALSE }; #ifdef ENABLE_VFS_FTP g_snprintf (buffer3, sizeof (buffer3), "%i", ftpfs_directory_timeout); if (!ftpfs_always_use_proxy) confvfs_widgets[5].options = W_DISABLED; #endif g_snprintf (buffer2, sizeof (buffer2), "%i", vfs_timeout); if (quick_dialog (&confvfs_dlg) != B_CANCEL) { vfs_timeout = atoi (ret_timeout); g_free (ret_timeout); if (vfs_timeout < 0 || vfs_timeout > 10000) vfs_timeout = 10; #ifdef ENABLE_VFS_FTP g_free (ftpfs_anonymous_passwd); ftpfs_anonymous_passwd = ret_passwd; g_free (ftpfs_proxy_host); ftpfs_proxy_host = ret_ftp_proxy; ftpfs_directory_timeout = atoi (ret_directory_timeout); g_free (ret_directory_timeout); #endif } #undef VFSX #undef VFSY }
void panel_options_box (void) { int dlg_width = 60; int dlg_height = 19; int simple_swap = mc_config_get_bool (mc_main_config, CONFIG_PANELS_SECTION, "simple_swap", FALSE) ? 1 : 0; const char *qsearch_options[] = { N_("Case &insensitive"), N_("Case s&ensitive"), N_("Use panel sort mo&de") }; QuickWidget quick_widgets[] = { /* buttons */ QUICK_BUTTON (38, dlg_width, dlg_height - 3, dlg_height, N_("&Cancel"), B_CANCEL, NULL), QUICK_BUTTON (14, dlg_width, dlg_height - 3, dlg_height, N_("&OK"), B_ENTER, NULL), /* quick search */ QUICK_RADIO (dlg_width / 2 + 2, dlg_width, 12, dlg_height, QSEARCH_NUM, qsearch_options, (int *) &panels_options.qsearch_mode), QUICK_GROUPBOX (dlg_width / 2, dlg_width, 11, dlg_height, dlg_width / 2 - 4, QSEARCH_NUM + 2, N_("Quick search")), /* file highlighting */ QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 9, dlg_height, N_("&Permissions"), &panels_options.permission_mode), QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 8, dlg_height, N_("File &types"), &panels_options.filetype_mode), QUICK_GROUPBOX (dlg_width / 2, dlg_width, 7, dlg_height, dlg_width / 2 - 4, 4, N_("File highlight")), /* navigation */ QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 5, dlg_height, N_("&Mouse page scrolling"), &panels_options.mouse_move_pages), QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 4, dlg_height, N_("Pa&ge scrolling"), &panels_options.scroll_pages), QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 3, dlg_height, N_("L&ynx-like motion"), &panels_options.navigate_with_arrows), QUICK_GROUPBOX (dlg_width / 2, dlg_width, 2, dlg_height, dlg_width / 2 - 4, 5, N_("Navigation")), /* main panel options */ QUICK_CHECKBOX (5, dlg_width, 12, dlg_height, N_("A&uto save panels setup"), &panels_options.auto_save_setup), QUICK_CHECKBOX (5, dlg_width, 11, dlg_height, N_("Simple s&wap"), &simple_swap), QUICK_CHECKBOX (5, dlg_width, 10, dlg_height, N_("Re&verse files only"), &panels_options.reverse_files_only), QUICK_CHECKBOX (5, dlg_width, 9, dlg_height, N_("Ma&rk moves down"), &panels_options.mark_moves_down), QUICK_CHECKBOX (5, dlg_width, 8, dlg_height, N_("&Fast dir reload"), &panels_options.fast_reload), QUICK_CHECKBOX (5, dlg_width, 7, dlg_height, N_("Show &hidden files"), &panels_options.show_dot_files), QUICK_CHECKBOX (5, dlg_width, 6, dlg_height, N_("Show &backup files"), &panels_options.show_backups), QUICK_CHECKBOX (5, dlg_width, 5, dlg_height, N_("Mi&x all files"), &panels_options.mix_all_files), QUICK_CHECKBOX (5, dlg_width, 4, dlg_height, N_("Use SI si&ze units"), &panels_options.kilobyte_si), QUICK_CHECKBOX (5, dlg_width, 3, dlg_height, N_("Show mi&ni-status"), &panels_options.show_mini_info), QUICK_GROUPBOX (3, dlg_width, 2, dlg_height, dlg_width / 2 - 4, 14, N_("Main options")), QUICK_END }; const size_t qw_num = G_N_ELEMENTS (quick_widgets) - 1; QuickDialog Quick_input = { dlg_width, dlg_height, -1, -1, N_("Panel options"), "[Panel options]", quick_widgets, NULL, TRUE }; int b0_len, b1_len; int b_len, c_len, g_len; size_t i; #ifdef ENABLE_NLS for (i = 0; i < qw_num; i++) switch (i) { case 0: case 1: /* buttons */ quick_widgets[i].u.button.text = _(quick_widgets[i].u.button.text); break; case 2: { /* radio button */ size_t j; for (j = 0; j < QSEARCH_NUM; j++) qsearch_options[j] = _(qsearch_options[j]); } break; case 3: case 6: case 10: case 21: /* groupboxes */ quick_widgets[i].u.groupbox.title = _(quick_widgets[i].u.groupbox.title); break; default: /* checkboxes */ quick_widgets[i].u.checkbox.text = _(quick_widgets[i].u.checkbox.text); break; } Quick_input.title = _(Quick_input.title); #endif /* ENABLE_NLS */ /* calculate widget and dialog widths */ /* dialog title */ dlg_width = max (dlg_width, str_term_width1 (Quick_input.title) + 4); /* buttons */ b0_len = str_term_width1 (quick_widgets[0].u.button.text) + 3; b1_len = str_term_width1 (quick_widgets[1].u.button.text) + 5; b_len = b0_len + b1_len + 1; /* checkboxes within groupboxes */ c_len = 0; for (i = 4; i < 21; i++) if ((i != 6) && (i != 10)) c_len = max (c_len, str_term_width1 (quick_widgets[i].u.checkbox.text) + 4); /* radiobuttons */ for (i = 0; i < QSEARCH_NUM; i++) c_len = max (c_len, str_term_width1 (qsearch_options[i]) + 3); /* groupboxes */ g_len = max (c_len + 2, str_term_width1 (quick_widgets[3].u.groupbox.title) + 4); g_len = max (g_len, str_term_width1 (quick_widgets[6].u.groupbox.title) + 4); g_len = max (g_len, str_term_width1 (quick_widgets[10].u.groupbox.title) + 4); g_len = max (g_len, str_term_width1 (quick_widgets[21].u.groupbox.title) + 4); /* dialog width */ Quick_input.xlen = max (dlg_width, g_len * 2 + 9); Quick_input.xlen = max (Quick_input.xlen, b_len + 2); if ((Quick_input.xlen & 1) != 0) Quick_input.xlen++; /* fix widget parameters */ for (i = 0; i < qw_num; i++) quick_widgets[i].x_divisions = Quick_input.xlen; /* groupboxes */ quick_widgets[3].u.groupbox.width = quick_widgets[6].u.groupbox.width = quick_widgets[10].u.groupbox.width = Quick_input.xlen / 2 - 3; quick_widgets[21].u.groupbox.width = Quick_input.xlen / 2 - 4; /* right column */ quick_widgets[3].relative_x = quick_widgets[6].relative_x = quick_widgets[10].relative_x = Quick_input.xlen / 2; for (i = 2; i < 10; i++) if ((i != 3) && (i != 6)) quick_widgets[i].relative_x = quick_widgets[3].relative_x + 2; /* buttons */ quick_widgets[1].relative_x = (Quick_input.xlen - b_len) / 3; quick_widgets[0].relative_x = 2 * quick_widgets[1].relative_x + b1_len + 1; if (quick_dialog (&Quick_input) != B_ENTER) return; mc_config_set_bool (mc_main_config, CONFIG_PANELS_SECTION, "simple_swap", (gboolean) (simple_swap & C_BOOL)); if (!panels_options.fast_reload_msg_shown && panels_options.fast_reload) { message (D_NORMAL, _("Information"), _("Using the fast reload option may not reflect the exact\n" "directory contents. In this case you'll need to do a\n" "manual reload of the directory. See the man page for\n" "the details.")); panels_options.fast_reload_msg_shown = TRUE; } update_panels (UP_RELOAD, UP_KEEPSEL); }
gboolean mcview_dialog_search (mcview_t * view) { char *exp = NULL; int qd_result; size_t num_of_types; gchar **list_of_types; list_of_types = mc_search_get_types_strings_array (&num_of_types); { quick_widget_t quick_widgets[] = { /* *INDENT-OFF* */ QUICK_LABELED_INPUT (N_("Enter search string:"), input_label_above, INPUT_LAST_TEXT, MC_HISTORY_SHARED_SEARCH, &exp, NULL, FALSE, FALSE, INPUT_COMPLETE_NONE), QUICK_SEPARATOR (TRUE), QUICK_START_COLUMNS, QUICK_RADIO (num_of_types, (const char **) list_of_types, (int *) &mcview_search_options.type, NULL), QUICK_NEXT_COLUMN, QUICK_CHECKBOX (N_("Cas&e sensitive"), &mcview_search_options.case_sens, NULL), QUICK_CHECKBOX (N_("&Backwards"), &mcview_search_options.backwards, NULL), QUICK_CHECKBOX (N_("&Whole words"), &mcview_search_options.whole_words, NULL), #ifdef HAVE_CHARSET QUICK_CHECKBOX (N_("&All charsets"), &mcview_search_options.all_codepages, NULL), #endif QUICK_STOP_COLUMNS, QUICK_BUTTONS_OK_CANCEL, QUICK_END /* *INDENT-ON* */ }; quick_dialog_t qdlg = { -1, -1, 58, N_("Search"), "[Input Line Keys]", quick_widgets, NULL, NULL }; qd_result = quick_dialog (&qdlg); } g_strfreev (list_of_types); if ((qd_result == B_CANCEL) || (exp == NULL) || (exp[0] == '\0')) { g_free (exp); return FALSE; } #ifdef HAVE_CHARSET { GString *tmp; tmp = str_convert_to_input (exp); if (tmp != NULL) { g_free (exp); exp = g_string_free (tmp, FALSE); } } #endif g_free (view->last_search_string); view->last_search_string = exp; mcview_nroff_seq_free (&view->search_nroff_seq); mc_search_free (view->search); #ifdef HAVE_CHARSET view->search = mc_search_new (view->last_search_string, -1, cp_source); #else view->search = mc_search_new (view->last_search_string, -1, NULL); #endif view->search_nroff_seq = mcview_nroff_seq_new (view); if (view->search != NULL) { view->search->search_type = mcview_search_options.type; #ifdef HAVE_CHARSET view->search->is_all_charsets = mcview_search_options.all_codepages; #endif view->search->is_case_sensitive = mcview_search_options.case_sens; view->search->whole_words = mcview_search_options.whole_words; view->search->search_fn = mcview_search_cmd_callback; view->search->update_fn = mcview_search_update_cmd_callback; } return (view->search != NULL); }
void configure_box (void) { int dlg_width = 60; int dlg_height = 21; char time_out[BUF_TINY] = ""; char *time_out_new; const char *pause_options[] = { N_("&Never"), N_("On dum&b terminals"), N_("Alwa&ys") }; int pause_options_num = G_N_ELEMENTS (pause_options); QuickWidget quick_widgets[] = { /* buttons */ QUICK_BUTTON (38, dlg_width, dlg_height - 3, dlg_height, N_("&Cancel"), B_CANCEL, NULL), QUICK_BUTTON (14, dlg_width, dlg_height - 3, dlg_height, N_("&OK"), B_ENTER, NULL), /* other options */ QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 12, dlg_height, N_("A&uto save setup"), &auto_save_setup), QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 11, dlg_height, N_("Sa&fe delete"), &safe_delete), QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 10, dlg_height, N_("Cd follows lin&ks"), &mc_global.vfs.cd_symlinks), QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 9, dlg_height, N_("Rotating d&ash"), &nice_rotating_dash), QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 8, dlg_height, N_("Co&mplete: show all"), &mc_global.widget.show_all_if_ambiguous), QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 7, dlg_height, N_("Shell &patterns"), &easy_patterns), QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 6, dlg_height, N_("&Drop down menus"), &drop_menus), QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 5, dlg_height, N_("Auto m&enus"), &auto_menu), QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 4, dlg_height, N_("Use internal vie&w"), &use_internal_view), QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 3, dlg_height, N_("Use internal edi&t"), &use_internal_edit), QUICK_GROUPBOX (dlg_width / 2, dlg_width, 2, dlg_height, dlg_width / 2 - 4, 16, N_("Other options")), /* pause options */ QUICK_RADIO (5, dlg_width, 14, dlg_height, pause_options_num, pause_options, &pause_after_run), QUICK_GROUPBOX (3, dlg_width, 13, dlg_height, dlg_width / 2 - 4, 5, N_("Pause after run")), /* Esc key mode */ QUICK_INPUT (10, dlg_width, 11, dlg_height, (const char *) time_out, 8, 0, MC_HISTORY_ESC_TIMEOUT, &time_out_new), QUICK_LABEL (5, dlg_width, 11, dlg_height, N_("Timeout:")), QUICK_CHECKBOX (5, dlg_width, 10, dlg_height, N_("S&ingle press"), &old_esc_mode), QUICK_GROUPBOX (3, dlg_width, 9, dlg_height, dlg_width / 2 - 4, 4, N_("Esc key mode")), /* file operation options */ QUICK_CHECKBOX (5, dlg_width, 7, dlg_height, N_("Preallocate &space"), &mc_global.vfs.preallocate_space), QUICK_CHECKBOX (5, dlg_width, 6, dlg_height, N_("Mkdi&r autoname"), &auto_fill_mkdir_name), QUICK_CHECKBOX (5, dlg_width, 5, dlg_height, N_("Classic pro&gressbar"), &classic_progressbar), QUICK_CHECKBOX (5, dlg_width, 4, dlg_height, N_("Compute tota&ls"), &file_op_compute_totals), QUICK_CHECKBOX (5, dlg_width, 3, dlg_height, N_("&Verbose operation"), &verbose), QUICK_GROUPBOX (3, dlg_width, 2, dlg_height, dlg_width / 2 - 4, 7, N_("File operation options")), QUICK_END }; const size_t qw_num = G_N_ELEMENTS (quick_widgets) - 1; QuickDialog Quick_input = { dlg_width, dlg_height, -1, -1, N_("Configure options"), "[Configuration]", quick_widgets, configure_callback, TRUE }; int b0_len, b1_len; int b_len, c_len, g_len, l_len; size_t i; #ifdef ENABLE_NLS for (i = 0; i < qw_num; i++) switch (i) { case 0: case 1: /* buttons */ quick_widgets[i].u.button.text = _(quick_widgets[i].u.button.text); break; case 12: case 14: case 18: case 24: /* groupboxes */ quick_widgets[i].u.groupbox.title = _(quick_widgets[i].u.groupbox.title); break; case 13: { /* radio button */ size_t j; for (j = 0; j < (size_t) pause_options_num; j++) pause_options[j] = _(pause_options[j]); } break; case 15: /* input line */ break; case 16: /* label */ quick_widgets[i].u.label.text = _(quick_widgets[i].u.label.text); break; default: /* checkboxes */ quick_widgets[i].u.checkbox.text = _(quick_widgets[i].u.checkbox.text); break; } Quick_input.title = _(Quick_input.title); #endif /* ENABLE_NLS */ /* calculate widget and dialog widths */ /* dialog title */ dlg_width = max (dlg_width, str_term_width1 (Quick_input.title) + 4); /* buttons */ b0_len = str_term_width1 (quick_widgets[0].u.button.text) + 3; b1_len = str_term_width1 (quick_widgets[1].u.button.text) + 5; b_len = b0_len + b1_len + 1; /* checkboxes within groupboxes */ c_len = 0; for (i = 2; i < 24; i++) if ((i < 12) || (i == 17) || (i > 18)) c_len = max (c_len, str_term_width1 (quick_widgets[i].u.checkbox.text) + 3); /* radiobuttons */ for (i = 0; i < (size_t) pause_options_num; i++) c_len = max (c_len, str_term_width1 (pause_options[i]) + 3); /* label + input */ l_len = str_term_width1 (quick_widgets[16].u.label.text); c_len = max (c_len, l_len + 1 + 8); /* groupboxes */ g_len = max (c_len + 2, str_term_width1 (quick_widgets[24].u.groupbox.title) + 4); g_len = max (g_len, str_term_width1 (quick_widgets[18].u.groupbox.title) + 4); g_len = max (g_len, str_term_width1 (quick_widgets[14].u.groupbox.title) + 4); g_len = max (g_len, str_term_width1 (quick_widgets[12].u.groupbox.title) + 4); /* dialog width */ Quick_input.xlen = max (dlg_width, g_len * 2 + 9); Quick_input.xlen = max (Quick_input.xlen, b_len + 2); if ((Quick_input.xlen & 1) != 0) Quick_input.xlen++; /* fix widget parameters */ for (i = 0; i < qw_num; i++) quick_widgets[i].x_divisions = Quick_input.xlen; /* groupboxes */ quick_widgets[14].u.groupbox.width = quick_widgets[18].u.groupbox.width = quick_widgets[24].u.groupbox.width = Quick_input.xlen / 2 - 4; quick_widgets[12].u.groupbox.width = Quick_input.xlen / 2 - 3; /* input */ quick_widgets[15].relative_x = quick_widgets[16].relative_x + l_len + 1; quick_widgets[15].u.input.len = quick_widgets[18].u.groupbox.width - l_len - 4; /* right column */ quick_widgets[12].relative_x = Quick_input.xlen / 2; for (i = 2; i < 12; i++) quick_widgets[i].relative_x = quick_widgets[12].relative_x + 2; /* buttons */ quick_widgets[1].relative_x = (Quick_input.xlen - b_len) / 3; quick_widgets[0].relative_x = 2 * quick_widgets[1].relative_x + b1_len + 1; g_snprintf (time_out, sizeof (time_out), "%d", old_esc_mode_timeout); if (!old_esc_mode) quick_widgets[15].options = quick_widgets[16].options = W_DISABLED; #ifndef HAVE_POSIX_FALLOCATE mc_global.vfs.preallocate_space = FALSE; quick_widgets[19].options = W_DISABLED; #endif if (quick_dialog (&Quick_input) == B_ENTER) old_esc_mode_timeout = atoi (time_out_new); g_free (time_out_new); }
void editcmd_dialog_search_show (WEdit * edit, char **search_text) { if (*search_text == '\0') *search_text = INPUT_LAST_TEXT; { size_t num_of_types; gchar **list_of_types = mc_search_get_types_strings_array (&num_of_types); int SEARCH_DLG_HEIGHT = SEARCH_DLG_MIN_HEIGHT + num_of_types - SEARCH_DLG_HEIGHT_SUPPLY; size_t i; int dialog_result; QuickWidget quick_widgets[] = { /* 0 */ QUICK_BUTTON (6, 10, 11, SEARCH_DLG_HEIGHT, N_("&Cancel"), B_CANCEL, NULL), /* 1 */ QUICK_BUTTON (4, 10, 11, SEARCH_DLG_HEIGHT, N_("&Find all"), B_USER, NULL), /* 2 */ QUICK_BUTTON (2, 10, 11, SEARCH_DLG_HEIGHT, N_("&OK"), B_ENTER, NULL), #ifdef HAVE_CHARSET /* 3 */ QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 9, SEARCH_DLG_HEIGHT, N_("All charsets"), &edit->all_codepages), #endif /* 4 */ QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 8, SEARCH_DLG_HEIGHT, N_("&Whole words"), &edit->whole_words), /* 5 */ QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 7, SEARCH_DLG_HEIGHT, N_("In se&lection"), &edit->only_in_selection), /* 6 */ QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 6, SEARCH_DLG_HEIGHT, N_("&Backwards"), &edit->replace_backwards), /* 7 */ QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT, N_("case &Sensitive"), &edit->replace_case), /* 8 */ QUICK_RADIO ( 3, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT, num_of_types, (const char **) list_of_types, (int *) &edit->search_type), /* 9 */ QUICK_INPUT (3, SEARCH_DLG_WIDTH, 3, SEARCH_DLG_HEIGHT, *search_text, SEARCH_DLG_WIDTH - 6, 0, MC_HISTORY_SHARED_SEARCH, search_text), /* 10 */ QUICK_LABEL (2, SEARCH_DLG_WIDTH, 2, SEARCH_DLG_HEIGHT, N_(" Enter search string:")), QUICK_END }; #ifdef HAVE_CHARSET size_t last_checkbox = 7; #else size_t last_checkbox = 6; #endif QuickDialog Quick_input = { SEARCH_DLG_WIDTH, SEARCH_DLG_HEIGHT, -1, -1, N_("Search"), "[Input Line Keys]", quick_widgets, TRUE }; #ifdef ENABLE_NLS char **list_of_types_nls; /* header title */ Quick_input.title = _(Quick_input.title); /* buttons */ for (i = 0; i < 3; i++) quick_widgets[i].u.button.text = _(quick_widgets[i].u.button.text); /* checkboxes */ for (i = 3; i <= last_checkbox; i++) quick_widgets[i].u.checkbox.text = _(quick_widgets[i].u.checkbox.text); /* label */ quick_widgets[10].u.label.text = _(quick_widgets[10].u.label.text); /* radiobuttons */ /* create copy of radio items to avoid memory leak */ list_of_types_nls = g_new0 (char *, num_of_types + 1); for (i = 0; i < num_of_types; i++) list_of_types_nls[i] = g_strdup (_(list_of_types[i])); g_strfreev (list_of_types); list_of_types = list_of_types_nls; quick_widgets[last_checkbox + 1].u.radio.items = (const char **) list_of_types; #endif /* calculate widget coordinates */ { int len = 0; int dlg_width; gchar **radio = list_of_types; int b0_len, b1_len, b2_len; const int button_gap = 2; /* length of radiobuttons */ while (*radio != NULL) { len = max (len, str_term_width1 (*radio)); radio++; } /* length of checkboxes */ for (i = 3; i <= last_checkbox; i++) len = max (len, str_term_width1 (quick_widgets[i].u.checkbox.text) + 4); /* preliminary dialog width */ dlg_width = max (len * 2, str_term_width1 (Quick_input.title)) + 4; /* length of buttons */ b0_len = str_term_width1 (quick_widgets[0].u.button.text) + 3; b1_len = str_term_width1 (quick_widgets[1].u.button.text) + 3; b2_len = str_term_width1 (quick_widgets[2].u.button.text) + 5; /* default button */ len = b0_len + b1_len + b2_len + button_gap * 2; /* dialog width */ Quick_input.xlen = max (SEARCH_DLG_WIDTH, max (dlg_width, len + 6)); /* correct widget coordinates */ for (i = 0; i < sizeof (quick_widgets)/sizeof (quick_widgets[0]); i++) quick_widgets[i].x_divisions = Quick_input.xlen; /* checkbox positions */ for (i = 3; i <= last_checkbox; i++) quick_widgets[i].relative_x = Quick_input.xlen/2 + 2; /* input length */ quick_widgets[last_checkbox + 2].u.input.len = Quick_input.xlen - 6; /* button positions */ quick_widgets[2].relative_x = Quick_input.xlen/2 - len/2; quick_widgets[1].relative_x = quick_widgets[2].relative_x + b2_len + button_gap; quick_widgets[0].relative_x = quick_widgets[1].relative_x + b1_len + button_gap; } dialog_result = quick_dialog (&Quick_input); g_strfreev (list_of_types); if (dialog_result == B_CANCEL) *search_text = NULL; else if (dialog_result == B_USER) search_create_bookmark = 1; } }
static void select_unselect_cmd (const char *title, const char *history_name, gboolean do_select) { /* dialog sizes */ const int DX = 50; const int DY = 7; int files_only = (select_flags & SELECT_FILES_ONLY) != 0; int case_sens = (select_flags & SELECT_MATCH_CASE) != 0; int shell_patterns = (select_flags & SELECT_SHELL_PATTERNS) != 0; char *reg_exp; mc_search_t *search; int i; QuickWidget quick_widgets[] = { QUICK_CHECKBOX (3, DX, DY - 3, DY, N_("&Using shell patterns"), &shell_patterns), QUICK_CHECKBOX (DX / 2 + 1, DX, DY - 4, DY, N_("&Case sensitive"), &case_sens), QUICK_CHECKBOX (3, DX, DY - 4, DY, N_("&Files only"), &files_only), QUICK_INPUT (3, DX, DY - 5, DY, INPUT_LAST_TEXT, DX - 6, 0, history_name, ®_exp), QUICK_END }; QuickDialog quick_dlg = { DX, DY, -1, -1, title, "[Select/Unselect Files]", quick_widgets, NULL, FALSE }; if (quick_dialog (&quick_dlg) == B_CANCEL) return; if (!reg_exp) return; if (!*reg_exp) { g_free (reg_exp); return; } search = mc_search_new (reg_exp, -1); search->search_type = (shell_patterns != 0) ? MC_SEARCH_T_GLOB : MC_SEARCH_T_REGEX; search->is_entire_line = TRUE; search->is_case_sensitive = case_sens != 0; for (i = 0; i < current_panel->count; i++) { if (strcmp (current_panel->dir.list[i].fname, "..") == 0) continue; if (S_ISDIR (current_panel->dir.list[i].st.st_mode) && files_only != 0) continue; if (mc_search_run (search, current_panel->dir.list[i].fname, 0, current_panel->dir.list[i].fnamelen, NULL)) do_file_mark (current_panel, i, do_select); } mc_search_free (search); g_free (reg_exp); /* result flags */ select_flags = 0; if (case_sens != 0) select_flags |= SELECT_MATCH_CASE; if (files_only != 0) select_flags |= SELECT_FILES_ONLY; if (shell_patterns != 0) select_flags |= SELECT_SHELL_PATTERNS; }
void confirm_box (void) { const char *title = _("Confirmation"); QuickWidget conf_widgets[] = { /* 0 */ QUICK_BUTTON (29, 46, 10, 13, N_("&Cancel"), B_CANCEL, NULL), /* 1 */ QUICK_BUTTON (12, 46, 10, 13, N_("&OK"), B_ENTER, NULL), /* TRANSLATORS: no need to translate 'Confirmation', it's just a context prefix */ /* 2 */ QUICK_CHECKBOX (3, 46, 8, 13, N_("Confirmation|&History cleanup"), &confirm_history_cleanup), /* 3 */ QUICK_CHECKBOX (3, 46, 7, 13, N_("Confirmation|Di&rectory hotlist delete"), &confirm_directory_hotlist_delete), /* 4 */ QUICK_CHECKBOX (3, 46, 6, 13, N_("Confirmation|E&xit"), &confirm_exit), /* 5 */ QUICK_CHECKBOX (3, 46, 5, 13, N_("Confirmation|&Execute"), &confirm_execute), /* 6 */ QUICK_CHECKBOX (3, 46, 4, 13, N_("Confirmation|O&verwrite"), &confirm_overwrite), /* 7 */ QUICK_CHECKBOX (3, 46, 3, 13, N_("Confirmation|&Delete"), &confirm_delete), QUICK_END }; const size_t w_num = sizeof (conf_widgets) / sizeof (conf_widgets[0]) - 1; /* dialog sizes */ int dlg_width = 46; int dlg_height = w_num + 5; size_t i; int maxlen = 0; int cancel_len, ok_len, blen; #ifdef ENABLE_NLS title = _(title); for (i = 0; i < 2; i++) conf_widgets[i].u.button.text = _(conf_widgets[i].u.button.text); #endif /* ENABLE_NLS */ for (i = 2; i < w_num; i++) conf_widgets[i].u.checkbox.text = Q_ (conf_widgets[i].u.checkbox.text); /* maximum length of checkboxes */ for (i = 2; i < w_num; i++) maxlen = max (maxlen, str_term_width1 (conf_widgets[i].u.checkbox.text) + 4); /* length of buttons */ cancel_len = str_term_width1 (conf_widgets[0].u.button.text) + 3; ok_len = str_term_width1 (conf_widgets[1].u.button.text) + 5; /* default button */ blen = cancel_len + ok_len + 2; dlg_width = max (maxlen, blen) + 6; dlg_width = max (dlg_width, str_term_width1 (title) + 4); /* correct widget parameters */ for (i = 0; i < w_num; i++) { conf_widgets[i].x_divisions = dlg_width; conf_widgets[i].y_divisions = dlg_height; } conf_widgets[1].relative_x = dlg_width / 2 - blen / 2; conf_widgets[0].relative_x = conf_widgets[1].relative_x + ok_len + 2; { QuickDialog confirmation = { dlg_width, dlg_height, -1, -1, title, "[Confirmation]", conf_widgets, NULL, TRUE }; (void) quick_dialog (&confirmation); } }
void configure_box (void) { const char *pause_options[] = { N_("&Never"), N_("On dum&b terminals"), N_("Alwa&ys") }; int pause_options_num; pause_options_num = G_N_ELEMENTS (pause_options); { char time_out[BUF_TINY] = ""; char *time_out_new; quick_widget_t quick_widgets[] = { /* *INDENT-OFF* */ QUICK_START_COLUMNS, QUICK_START_GROUPBOX (N_("File operations")), QUICK_CHECKBOX (N_("&Verbose operation"), &verbose, NULL), QUICK_CHECKBOX (N_("Compute tota&ls"), &file_op_compute_totals, NULL), QUICK_CHECKBOX (N_("Classic pro&gressbar"), &classic_progressbar, NULL), QUICK_CHECKBOX (N_("Mkdi&r autoname"), &auto_fill_mkdir_name, NULL), QUICK_CHECKBOX (N_("&Preallocate space"), &mc_global.vfs.preallocate_space, NULL), QUICK_STOP_GROUPBOX, QUICK_START_GROUPBOX (N_("Esc key mode")), QUICK_CHECKBOX (N_("S&ingle press"), &old_esc_mode, &configure_old_esc_mode_id), QUICK_LABELED_INPUT (N_("Timeout:"), input_label_left, (const char *) time_out, MC_HISTORY_ESC_TIMEOUT, &time_out_new, &configure_time_out_id, FALSE, FALSE, INPUT_COMPLETE_NONE), QUICK_STOP_GROUPBOX, QUICK_START_GROUPBOX (N_("Pause after run")), QUICK_RADIO (pause_options_num, pause_options, &pause_after_run, NULL), QUICK_STOP_GROUPBOX, QUICK_NEXT_COLUMN, QUICK_START_GROUPBOX (N_("Other options")), QUICK_CHECKBOX (N_("Use internal edi&t"), &use_internal_edit, NULL), QUICK_CHECKBOX (N_("Use internal vie&w"), &use_internal_view, NULL), QUICK_CHECKBOX (N_("A&sk new file name"), &editor_ask_filename_before_edit, NULL), QUICK_CHECKBOX (N_("Auto m&enus"), &auto_menu, NULL), QUICK_CHECKBOX (N_("&Drop down menus"), &drop_menus, NULL), QUICK_CHECKBOX (N_("S&hell patterns"), &easy_patterns, NULL), QUICK_CHECKBOX (N_("Co&mplete: show all"), &mc_global.widget.show_all_if_ambiguous, NULL), QUICK_CHECKBOX (N_("Rotating d&ash"), &nice_rotating_dash, NULL), QUICK_CHECKBOX (N_("Cd follows lin&ks"), &mc_global.vfs.cd_symlinks, NULL), QUICK_CHECKBOX (N_("Sa&fe delete"), &safe_delete, NULL), QUICK_CHECKBOX (N_("A&uto save setup"), &auto_save_setup, NULL), QUICK_SEPARATOR (FALSE), QUICK_SEPARATOR (FALSE), QUICK_SEPARATOR (FALSE), QUICK_STOP_GROUPBOX, QUICK_STOP_COLUMNS, QUICK_BUTTONS_OK_CANCEL, QUICK_END /* *INDENT-ON* */ }; quick_dialog_t qdlg = { -1, -1, 60, N_("Configure options"), "[Configuration]", quick_widgets, configure_callback, NULL }; g_snprintf (time_out, sizeof (time_out), "%d", old_esc_mode_timeout); #ifndef USE_INTERNAL_EDIT quick_widgets[17].options = W_DISABLED; #endif if (!old_esc_mode) quick_widgets[10].options = quick_widgets[11].options = W_DISABLED; #ifndef HAVE_POSIX_FALLOCATE mc_global.vfs.preallocate_space = FALSE; quick_widgets[7].options = W_DISABLED; #endif if (quick_dialog (&qdlg) == B_ENTER) old_esc_mode_timeout = atoi (time_out_new); g_free (time_out_new); } }
void display_bits_box (void) /* AB:FIXME: test dialog */ { /* dialog sizes */ const int DISPY = 13; const int DISPX = 46; int new_meta = 0; int current_mode; const char *display_bits_str[] = { N_("UTF-8 output"), N_("Full 8 bits output"), N_("ISO 8859-1"), N_("7 bits") }; QuickWidget display_widgets[] = { /* 0 */ QUICK_BUTTON (15, DISPX, DISPY - 3, DISPY, N_("&Cancel"), B_CANCEL, NULL), /* 1 */ QUICK_BUTTON (29, DISPX, DISPY - 3, DISPY, N_("&OK"), B_ENTER, NULL), /* 2 */ QUICK_CHECKBOX (3, DISPX, 8, DISPY, N_("F&ull 8 bits input"), &new_meta), /* 3 */ QUICK_RADIO (3, DISPX, 3, DISPY, 4, display_bits_str, ¤t_mode), QUICK_END }; QuickDialog display_bits = { DISPX, DISPY, -1, -1, _("Display bits"), "[Display bits]", display_widgets, NULL, TRUE }; int i; int l1, maxlen = 0; int ok_len, cancel_len; #ifdef ENABLE_NLS static gboolean i18n_flag = FALSE; if (!i18n_flag) { for (i = 0; i < 3; i++) { display_bits_str[i] = _(display_bits_str[i]); } display_widgets[0].u.button.text = _(display_widgets[0].u.button.text); display_widgets[1].u.button.text = _(display_widgets[1].u.button.text); display_widgets[2].u.checkbox.text = _(display_widgets[2].u.checkbox.text); i18n_flag = TRUE; } #endif /* ENABLE_NLS */ /* radiobuttons */ for (i = 0; i < 3; i++) maxlen = max (maxlen, str_term_width1 (display_bits_str[i])); /* buttons */ cancel_len = str_term_width1 (display_widgets[0].u.button.text) + 2; ok_len = str_term_width1 (display_widgets[1].u.button.text) + 4; /* default button */ l1 = max (cancel_len, ok_len); display_bits.xlen = max (maxlen, l1) + 20; for (i = 0; i < 4; i++) display_widgets[i].x_divisions = display_bits.xlen; display_widgets[0].relative_x = display_bits.xlen * 2 / 3 - cancel_len / 2; display_widgets[1].relative_x = display_bits.xlen / 3 - ok_len / 2; if (full_eight_bits) current_mode = 0; else if (eight_bit_clean) current_mode = 1; else current_mode = 2; new_meta = !use_8th_bit_as_meta; if (quick_dialog (&display_bits) != B_CANCEL) { eight_bit_clean = current_mode < 3; full_eight_bits = current_mode < 2; #ifndef HAVE_SLANG meta (stdscr, eight_bit_clean); #else SLsmg_Display_Eight_Bit = full_eight_bits ? 128 : 160; #endif use_8th_bit_as_meta = !new_meta; } }
void panel_options_box (void) { int simple_swap; simple_swap = mc_config_get_bool (mc_main_config, CONFIG_PANELS_SECTION, "simple_swap", FALSE) ? 1 : 0; { const char *qsearch_options[] = { N_("Case &insensitive"), N_("Cas&e sensitive"), N_("Use panel sort mo&de") }; quick_widget_t quick_widgets[] = { /* *INDENT-OFF* */ QUICK_START_COLUMNS, QUICK_START_GROUPBOX (N_("Main options")), QUICK_CHECKBOX (N_("Show mi&ni-status"), &panels_options.show_mini_info, NULL), QUICK_CHECKBOX (N_("Use SI si&ze units"), &panels_options.kilobyte_si, NULL), QUICK_CHECKBOX (N_("Mi&x all files"), &panels_options.mix_all_files, NULL), QUICK_CHECKBOX (N_("Show &backup files"), &panels_options.show_backups, NULL), QUICK_CHECKBOX (N_("Show &hidden files"), &panels_options.show_dot_files, NULL), QUICK_CHECKBOX (N_("&Fast dir reload"), &panels_options.fast_reload, NULL), QUICK_CHECKBOX (N_("Ma&rk moves down"), &panels_options.mark_moves_down, NULL), QUICK_CHECKBOX (N_("Re&verse files only"), &panels_options.reverse_files_only, NULL), QUICK_CHECKBOX (N_("Simple s&wap"), &simple_swap, NULL), QUICK_CHECKBOX (N_("A&uto save panels setup"), &panels_options.auto_save_setup, NULL), QUICK_SEPARATOR (FALSE), QUICK_SEPARATOR (FALSE), QUICK_STOP_GROUPBOX, QUICK_NEXT_COLUMN, QUICK_START_GROUPBOX (N_("Navigation")), QUICK_CHECKBOX (N_("L&ynx-like motion"), &panels_options.navigate_with_arrows, NULL), QUICK_CHECKBOX (N_("Pa&ge scrolling"), &panels_options.scroll_pages, NULL), QUICK_CHECKBOX (N_("&Mouse page scrolling"), &panels_options.mouse_move_pages, NULL), QUICK_STOP_GROUPBOX, QUICK_START_GROUPBOX (N_("File highlight")), QUICK_CHECKBOX (N_("File &types"), &panels_options.filetype_mode, NULL), QUICK_CHECKBOX (N_("&Permissions"), &panels_options.permission_mode, NULL), QUICK_STOP_GROUPBOX, QUICK_START_GROUPBOX (N_("Quick search")), QUICK_RADIO (QSEARCH_NUM, qsearch_options, (int *) &panels_options.qsearch_mode, NULL), QUICK_STOP_GROUPBOX, QUICK_STOP_COLUMNS, QUICK_BUTTONS_OK_CANCEL, QUICK_END /* *INDENT-ON* */ }; quick_dialog_t qdlg = { -1, -1, 60, N_("Panel options"), "[Panel options]", quick_widgets, NULL, NULL }; if (quick_dialog (&qdlg) != B_ENTER) return; } mc_config_set_bool (mc_main_config, CONFIG_PANELS_SECTION, "simple_swap", (gboolean) (simple_swap & C_BOOL)); if (!panels_options.fast_reload_msg_shown && panels_options.fast_reload) { message (D_NORMAL, _("Information"), _("Using the fast reload option may not reflect the exact\n" "directory contents. In this case you'll need to do a\n" "manual reload of the directory. See the man page for\n" "the details.")); panels_options.fast_reload_msg_shown = TRUE; } update_panels (UP_RELOAD, UP_KEEPSEL); }
char * file_mask_dialog (FileOpContext * ctx, FileOperation operation, gboolean only_one, const char *format, const void *text, const char *def_text, gboolean * do_bg) { const size_t FMDY = 13; const size_t FMDX = 68; size_t fmd_xlen; /* buttons */ const size_t gap = 1; size_t b0_len, b2_len; size_t b1_len = 0; int source_easy_patterns = easy_patterns; size_t i, len; char fmd_buf[BUF_MEDIUM]; char *source_mask, *orig_mask, *dest_dir, *tmp; char *def_text_secure; int val; QuickWidget fmd_widgets[] = { /* 0 */ QUICK_BUTTON (42, 64, 10, FMDY, N_("&Cancel"), B_CANCEL, NULL), #ifdef WITH_BACKGROUND /* 1 */ QUICK_BUTTON (25, 64, 10, FMDY, N_("&Background"), B_USER, NULL), #define OFFSET 0 #else #define OFFSET 1 #endif /* WITH_BACKGROUND */ /* 2 - OFFSET */ QUICK_BUTTON (14, FMDX, 10, FMDY, N_("&OK"), B_ENTER, NULL), /* 3 - OFFSET */ QUICK_CHECKBOX (42, FMDX, 8, FMDY, N_("&Stable Symlinks"), &ctx->stable_symlinks), /* 4 - OFFSET */ QUICK_CHECKBOX (31, FMDX, 7, FMDY, N_("Di&ve into subdir if exists"), &ctx->dive_into_subdirs), /* 5 - OFFSET */ QUICK_CHECKBOX (3, FMDX, 8, FMDY, N_("Preserve &attributes"), &ctx->op_preserve), /* 6 - OFFSET */ QUICK_CHECKBOX (3, FMDX, 7, FMDY, N_("Follow &links"), &ctx->follow_links), /* 7 - OFFSET */ QUICK_INPUT (3, FMDX, 6, FMDY, "", 58, 0, "input2", &dest_dir), /* 8 - OFFSET */ QUICK_LABEL (3, FMDX, 5, FMDY, N_("to:")), /* 9 - OFFSET */ QUICK_CHECKBOX (37, FMDX, 4, FMDY, N_("&Using shell patterns"), &source_easy_patterns), /* 10 - OFFSET */ QUICK_INPUT (3, FMDX, 3, FMDY, easy_patterns ? "*" : "^(.*)$", 58, 0, "input-def", &source_mask), /* 11 - OFFSET */ QUICK_LABEL (3, FMDX, 2, FMDY, fmd_buf), QUICK_END }; g_return_val_if_fail (ctx != NULL, NULL); #ifdef ENABLE_NLS /* buttons */ for (i = 0; i <= 2 - OFFSET; i++) fmd_widgets[i].u.button.text = _(fmd_widgets[i].u.button.text); /* checkboxes */ for (i = 3 - OFFSET; i <= 9 - OFFSET; i++) if (i != 7 - OFFSET) fmd_widgets[i].u.checkbox.text = _(fmd_widgets[i].u.checkbox.text); #endif /* !ENABLE_NLS */ fmd_xlen = max (FMDX, (size_t) COLS * 2 / 3); len = str_term_width1 (fmd_widgets[6 - OFFSET].u.checkbox.text) + str_term_width1 (fmd_widgets[4 - OFFSET].u.checkbox.text) + 15; fmd_xlen = max (fmd_xlen, len); len = str_term_width1 (fmd_widgets[5 - OFFSET].u.checkbox.text) + str_term_width1 (fmd_widgets[3 - OFFSET].u.checkbox.text) + 15; fmd_xlen = max (fmd_xlen, len); /* buttons */ b2_len = str_term_width1 (fmd_widgets[2 - OFFSET].u.button.text) + 6 + gap; /* OK */ #ifdef WITH_BACKGROUND b1_len = str_term_width1 (fmd_widgets[1].u.button.text) + 4 + gap; /* Background */ #endif b0_len = str_term_width1 (fmd_widgets[0].u.button.text) + 4; /* Cancel */ len = b0_len + b1_len + b2_len; fmd_xlen = min (max (fmd_xlen, len + 6), (size_t) COLS); if (only_one) { int flen; flen = str_term_width1 (format); i = fmd_xlen - flen - 4; /* FIXME */ g_snprintf (fmd_buf, sizeof (fmd_buf), format, str_trunc ((const char *) text, i)); } else { g_snprintf (fmd_buf, sizeof (fmd_buf), format, *(const int *) text); fmd_xlen = max (fmd_xlen, (size_t) str_term_width1 (fmd_buf) + 6); } for (i = sizeof (fmd_widgets) / sizeof (fmd_widgets[0]); i > 0;) fmd_widgets[--i].x_divisions = fmd_xlen; i = (fmd_xlen - len) / 2; /* OK button */ fmd_widgets[2 - OFFSET].relative_x = i; i += b2_len; #ifdef WITH_BACKGROUND /* Background button */ fmd_widgets[1].relative_x = i; i += b1_len; #endif /* Cancel button */ fmd_widgets[0].relative_x = i; #define chkbox_xpos(i) \ fmd_widgets [i].relative_x = fmd_xlen - str_term_width1 (fmd_widgets [i].u.checkbox.text) - 6 chkbox_xpos (3 - OFFSET); chkbox_xpos (4 - OFFSET); chkbox_xpos (9 - OFFSET); #undef chkbox_xpos /* inputs */ fmd_widgets[7 - OFFSET].u.input.len = fmd_widgets[10 - OFFSET].u.input.len = fmd_xlen - 6; /* unselect checkbox if target filesystem don't support attributes */ ctx->op_preserve = filegui__check_attrs_on_fs (def_text); /* filter out a possible password from def_text */ tmp = strip_password (g_strdup (def_text), 1); if (source_easy_patterns) def_text_secure = strutils_glob_escape (tmp); else def_text_secure = strutils_regex_escape (tmp); g_free (tmp); /* destination */ fmd_widgets[7 - OFFSET].u.input.text = def_text_secure; ctx->stable_symlinks = FALSE; *do_bg = FALSE; { struct stat buf; QuickDialog Quick_input = { fmd_xlen, FMDY, -1, -1, op_names[operation], "[Mask Copy/Rename]", fmd_widgets, NULL, TRUE }; ask_file_mask: val = quick_dialog_skip (&Quick_input, 4); if (val == B_CANCEL) { g_free (def_text_secure); return NULL; } if (ctx->follow_links) ctx->stat_func = mc_stat; else ctx->stat_func = mc_lstat; if (ctx->op_preserve) { ctx->preserve = TRUE; ctx->umask_kill = 0777777; ctx->preserve_uidgid = (geteuid () == 0); } else { int i2; ctx->preserve = ctx->preserve_uidgid = FALSE; i2 = umask (0); umask (i2); ctx->umask_kill = i2 ^ 0777777; } if ((dest_dir == NULL) || (*dest_dir == '\0')) { g_free (def_text_secure); g_free (source_mask); return dest_dir; } ctx->search_handle = mc_search_new (source_mask, -1); if (ctx->search_handle == NULL) { message (D_ERROR, MSG_ERROR, _("Invalid source pattern `%s'"), source_mask); g_free (dest_dir); g_free (source_mask); goto ask_file_mask; } g_free (def_text_secure); g_free (source_mask); ctx->search_handle->is_case_sensitive = TRUE; if (source_easy_patterns) ctx->search_handle->search_type = MC_SEARCH_T_GLOB; else ctx->search_handle->search_type = MC_SEARCH_T_REGEX; tmp = dest_dir; dest_dir = tilde_expand (tmp); g_free (tmp); ctx->dest_mask = strrchr (dest_dir, PATH_SEP); if (ctx->dest_mask == NULL) ctx->dest_mask = dest_dir; else ctx->dest_mask++; orig_mask = ctx->dest_mask; if (!*ctx->dest_mask || (!ctx->dive_into_subdirs && !is_wildcarded (ctx->dest_mask) && (!only_one || (!mc_stat (dest_dir, &buf) && S_ISDIR (buf.st_mode)))) || (ctx->dive_into_subdirs && ((!only_one && !is_wildcarded (ctx->dest_mask)) || (only_one && !mc_stat (dest_dir, &buf) && S_ISDIR (buf.st_mode))))) ctx->dest_mask = g_strdup ("\\0"); else { ctx->dest_mask = g_strdup (ctx->dest_mask); *orig_mask = '\0'; } if (!*dest_dir) { g_free (dest_dir); dest_dir = g_strdup ("./"); } if (val == B_USER) *do_bg = TRUE; } return dest_dir; }
void edit_options_dialog (WDialog * h) { char wrap_length[16], tab_spacing[16]; char *p, *q; int wrap_mode = 0; int old_syntax_hl; #ifdef ENABLE_NLS static gboolean i18n_flag = FALSE; if (!i18n_flag) { i18n_translate_array (wrap_str); i18n_flag = TRUE; } #endif /* ENABLE_NLS */ g_snprintf (wrap_length, sizeof (wrap_length), "%d", option_word_wrap_line_length); g_snprintf (tab_spacing, sizeof (tab_spacing), "%d", option_tab_spacing); if (option_auto_para_formatting) wrap_mode = 1; else if (option_typewriter_wrap) wrap_mode = 2; else wrap_mode = 0; { quick_widget_t quick_widgets[] = { /* *INDENT-OFF* */ QUICK_START_COLUMNS, QUICK_START_GROUPBOX (N_("Wrap mode")), QUICK_RADIO (3, wrap_str, &wrap_mode, NULL), QUICK_STOP_GROUPBOX, QUICK_SEPARATOR (FALSE), QUICK_SEPARATOR (FALSE), QUICK_START_GROUPBOX (N_("Tabulation")), QUICK_CHECKBOX (N_("&Fake half tabs"), &option_fake_half_tabs, NULL), QUICK_CHECKBOX (N_("&Backspace through tabs"), &option_backspace_through_tabs, NULL), QUICK_CHECKBOX (N_("Fill tabs with &spaces"), &option_fill_tabs_with_spaces, NULL), QUICK_LABELED_INPUT (N_("Tab spacing:"), input_label_left, tab_spacing, "edit-tab-spacing", &q, NULL, FALSE, FALSE, INPUT_COMPLETE_NONE), QUICK_STOP_GROUPBOX, QUICK_NEXT_COLUMN, QUICK_START_GROUPBOX (N_("Other options")), QUICK_CHECKBOX (N_("&Return does autoindent"), &option_return_does_auto_indent, NULL), QUICK_CHECKBOX (N_("Confir&m before saving"), &edit_confirm_save, NULL), QUICK_CHECKBOX (N_("Save file &position"), &option_save_position, NULL), QUICK_CHECKBOX (N_("&Visible trailing spaces"), &visible_tws, NULL), QUICK_CHECKBOX (N_("Visible &tabs"), &visible_tabs, NULL), QUICK_CHECKBOX (N_("Synta&x highlighting"), &option_syntax_highlighting, NULL), QUICK_CHECKBOX (N_("C&ursor after inserted block"), &option_cursor_after_inserted_block, NULL), QUICK_CHECKBOX (N_("Pers&istent selection"), &option_persistent_selections, NULL), QUICK_CHECKBOX (N_("Cursor be&yond end of line"), &option_cursor_beyond_eol, NULL), QUICK_CHECKBOX (N_("&Group undo"), &option_group_undo, NULL), QUICK_LABELED_INPUT (N_("Word wrap line length:"), input_label_left, wrap_length, "edit-word-wrap", &p, NULL, FALSE, FALSE, INPUT_COMPLETE_NONE), QUICK_STOP_GROUPBOX, QUICK_STOP_COLUMNS, QUICK_BUTTONS_OK_CANCEL, QUICK_END /* *INDENT-ON* */ }; quick_dialog_t qdlg = { -1, -1, 74, N_("Editor options"), "[Editor options]", quick_widgets, NULL, NULL }; if (quick_dialog (&qdlg) == B_CANCEL) return; } old_syntax_hl = option_syntax_highlighting; if (!option_cursor_beyond_eol) g_list_foreach (h->widgets, edit_reset_over_col, NULL); if (p != NULL) { option_word_wrap_line_length = atoi (p); if (option_word_wrap_line_length <= 0) option_word_wrap_line_length = DEFAULT_WRAP_LINE_LENGTH; g_free (p); } if (q != NULL) { option_tab_spacing = atoi (q); if (option_tab_spacing <= 0) option_tab_spacing = DEFAULT_TAB_SPACING; g_free (q); } if (wrap_mode == 1) { option_auto_para_formatting = 1; option_typewriter_wrap = 0; } else if (wrap_mode == 2) { option_auto_para_formatting = 0; option_typewriter_wrap = 1; } else { option_auto_para_formatting = 0; option_typewriter_wrap = 0; } /* Load or unload syntax rules if the option has changed */ if (option_syntax_highlighting != old_syntax_hl) g_list_foreach (h->widgets, edit_reload_syntax, NULL); }