/** Load panels options from [Panels] section. */ void panels_load_options (void) { if (mc_config_has_group (mc_main_config, CONFIG_PANELS_SECTION)) { size_t i; int qmode; for (i = 0; panels_ini_options[i].opt_name != NULL; i++) *panels_ini_options[i].opt_addr = mc_config_get_bool (mc_main_config, CONFIG_PANELS_SECTION, panels_ini_options[i].opt_name, *panels_ini_options[i].opt_addr); qmode = mc_config_get_int (mc_main_config, CONFIG_PANELS_SECTION, "quick_search_mode", (int) panels_options.qsearch_mode); if (qmode < 0) panels_options.qsearch_mode = QSEARCH_CASE_INSENSITIVE; else if (qmode >= QSEARCH_NUM) panels_options.qsearch_mode = QSEARCH_PANEL_CASE; else panels_options.qsearch_mode = (qsearch_mode_t) qmode; panels_options.select_flags = mc_config_get_int (mc_main_config, CONFIG_PANELS_SECTION, "select_flags", (int) panels_options.select_flags); } }
/* return list type */ int display_box (WPanel * panel, char **userp, char **minip, int *use_msformat, int num) { int result = -1; Dlg_head *dd; char *section = NULL; size_t i; if (panel == NULL) { const char *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); } dd = display_init (panel->list_type, panel->user_format, panel->user_mini_status, panel->user_status_format); if (run_dlg (dd) != B_CANCEL) { result = display_radio->sel; *userp = g_strdup (display_user_format->buffer); *minip = g_strdup (display_mini_status->buffer); *use_msformat = display_check_status->state & C_BOOL; } if (section != NULL) { g_free (panel->user_format); for (i = 0; i < LIST_TYPES; i++) g_free (panel->user_status_format[i]); g_free (panel); } destroy_dlg (dd); return result; }
/* 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; }