Commit 95e30f95 authored by Sam Ravnborg's avatar Sam Ravnborg

menuconfig: remember alternate config filename

When loading an alternate configuration use that file as
current configuration filename.
Make the filename visible in the dialog.
Default continue to be .config.

Inspired by patch from: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
Cc:  Cyrill Gorcunov <gorcunov@gmail.com>
parent dd7e54ad
...@@ -188,6 +188,7 @@ int on_key_esc(WINDOW *win); ...@@ -188,6 +188,7 @@ int on_key_esc(WINDOW *win);
int on_key_resize(void); int on_key_resize(void);
void init_dialog(const char *backtitle); void init_dialog(const char *backtitle);
void set_dialog_backtitle(const char *backtitle);
void reset_dialog(void); void reset_dialog(void);
void end_dialog(void); void end_dialog(void);
void attr_clear(WINDOW * win, int height, int width, chtype attr); void attr_clear(WINDOW * win, int height, int width, chtype attr);
......
...@@ -272,6 +272,11 @@ void init_dialog(const char *backtitle) ...@@ -272,6 +272,11 @@ void init_dialog(const char *backtitle)
color_setup(getenv("MENUCONFIG_COLOR")); color_setup(getenv("MENUCONFIG_COLOR"));
} }
void set_dialog_backtitle(const char *backtitle)
{
dlg.backtitle = backtitle;
}
void reset_dialog(void) void reset_dialog(void)
{ {
initscr(); /* Init curses */ initscr(); /* Init curses */
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "lkc.h" #include "lkc.h"
#include "lxdialog/dialog.h" #include "lxdialog/dialog.h"
static char menu_backtitle[128];
static const char mconf_readme[] = N_( static const char mconf_readme[] = N_(
"Overview\n" "Overview\n"
"--------\n" "--------\n"
...@@ -271,7 +270,6 @@ search_help[] = N_( ...@@ -271,7 +270,6 @@ search_help[] = N_(
" USB$ => find all CONFIG_ symbols ending with USB\n" " USB$ => find all CONFIG_ symbols ending with USB\n"
"\n"); "\n");
static char filename[PATH_MAX+1] = ".config";
static int indent; static int indent;
static struct termios ios_org; static struct termios ios_org;
static int rows = 0, cols = 0; static int rows = 0, cols = 0;
...@@ -395,6 +393,28 @@ static struct gstr get_relations_str(struct symbol **sym_arr) ...@@ -395,6 +393,28 @@ static struct gstr get_relations_str(struct symbol **sym_arr)
return res; return res;
} }
static char filename[PATH_MAX+1];
static void set_config_filename(const char *config_filename)
{
static char menu_backtitle[PATH_MAX+128];
int size;
struct symbol *sym;
sym = sym_lookup("KERNELVERSION", 0);
sym_calc_value(sym);
size = snprintf(menu_backtitle, sizeof(menu_backtitle),
_("%s - Linux Kernel v%s Configuration"),
config_filename, sym_get_string_value(sym));
if (size >= sizeof(menu_backtitle))
menu_backtitle[sizeof(menu_backtitle)-1] = '\0';
set_dialog_backtitle(menu_backtitle);
size = snprintf(filename, sizeof(filename), "%s", config_filename);
if (size >= sizeof(filename))
filename[sizeof(filename)-1] = '\0';
}
static void search_conf(void) static void search_conf(void)
{ {
struct symbol **sym_arr; struct symbol **sym_arr;
...@@ -816,8 +836,10 @@ static void conf_load(void) ...@@ -816,8 +836,10 @@ static void conf_load(void)
case 0: case 0:
if (!dialog_input_result[0]) if (!dialog_input_result[0])
return; return;
if (!conf_read(dialog_input_result)) if (!conf_read(dialog_input_result)) {
set_config_filename(dialog_input_result);
return; return;
}
show_textbox(NULL, _("File does not exist!"), 5, 38); show_textbox(NULL, _("File does not exist!"), 5, 38);
break; break;
case 1: case 1:
...@@ -840,8 +862,10 @@ static void conf_save(void) ...@@ -840,8 +862,10 @@ static void conf_save(void)
case 0: case 0:
if (!dialog_input_result[0]) if (!dialog_input_result[0])
return; return;
if (!conf_write(dialog_input_result)) if (!conf_write(dialog_input_result)) {
set_config_filename(dialog_input_result);
return; return;
}
show_textbox(NULL, _("Can't create file! Probably a nonexistent directory."), 5, 60); show_textbox(NULL, _("Can't create file! Probably a nonexistent directory."), 5, 60);
break; break;
case 1: case 1:
...@@ -860,7 +884,6 @@ static void conf_cleanup(void) ...@@ -860,7 +884,6 @@ static void conf_cleanup(void)
int main(int ac, char **av) int main(int ac, char **av)
{ {
struct symbol *sym;
char *mode; char *mode;
int res; int res;
...@@ -871,11 +894,6 @@ int main(int ac, char **av) ...@@ -871,11 +894,6 @@ int main(int ac, char **av)
conf_parse(av[1]); conf_parse(av[1]);
conf_read(NULL); conf_read(NULL);
sym = sym_lookup("KERNELVERSION", 0);
sym_calc_value(sym);
sprintf(menu_backtitle, _("Linux Kernel v%s Configuration"),
sym_get_string_value(sym));
mode = getenv("MENUCONFIG_MODE"); mode = getenv("MENUCONFIG_MODE");
if (mode) { if (mode) {
if (!strcasecmp(mode, "single_menu")) if (!strcasecmp(mode, "single_menu"))
...@@ -886,7 +904,8 @@ int main(int ac, char **av) ...@@ -886,7 +904,8 @@ int main(int ac, char **av)
atexit(conf_cleanup); atexit(conf_cleanup);
init_wsize(); init_wsize();
reset_dialog(); reset_dialog();
init_dialog(menu_backtitle); init_dialog(NULL);
set_config_filename(".config");
do { do {
conf(&rootmenu); conf(&rootmenu);
dialog_clear(); dialog_clear();
...@@ -903,7 +922,7 @@ int main(int ac, char **av) ...@@ -903,7 +922,7 @@ int main(int ac, char **av)
switch (res) { switch (res) {
case 0: case 0:
if (conf_write(NULL)) { if (conf_write(filename)) {
fprintf(stderr, _("\n\n" fprintf(stderr, _("\n\n"
"Error during writing of the kernel configuration.\n" "Error during writing of the kernel configuration.\n"
"Your kernel configuration changes were NOT saved." "Your kernel configuration changes were NOT saved."
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment