public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>,
	linux-kernel-list <linux-kernel@vger.kernel.org>
Subject: Re: PROBLEM: "Make nenuconfig" does not save parameters.
Date: Sun, 11 Mar 2007 20:50:33 +0100	[thread overview]
Message-ID: <20070311195033.GA3302@uranus.ravnborg.org> (raw)
In-Reply-To: <20070311100723.GA10359@cvg>

On Sun, Mar 11, 2007 at 01:07:23PM +0300, Cyrill Gorcunov wrote:
> [Sam Ravnborg - Sat, Mar 10, 2007 at 11:45:34PM +0100]
> | On Sat, Mar 10, 2007 at 10:34:41PM +0100, Jan Engelhardt wrote:
> | > 
> | > On Mar 10 2007 22:27, Sam Ravnborg wrote:
> | > >On Sat, Mar 10, 2007 at 07:23:41PM +0100, Jan Engelhardt wrote:
> | > >> 
> | > >> Whether the 'working config file path' should change when you do
> | > >> 'Save as Alternate' or not, is a menuconfig axiom. Ask Sam Ravnborg
> | > >> if you want it changed :-)
> | > >
> | > >Current behaviour is not logical but on the other hand I do not
> | > >see a big need to make it so.
> | > >It seems that people very seldom uses "save alternate" anyway.
> | > >
> | > >But patches are welcome.
> | > 
> | > ^_^ The patch has already been posted, has not it?
> | No.
> | Either we keep current behaviour or we change to the "normal"
> | behaviour with a "Save as..." as know from all other programs.
> | 
> | 	Sam
> | 
> 
> Hi Sam,
> 
> here is a patch for menuconfig that shows current configuration
> file. So I think menuconfig does its work well but the only
> thing we need is to show location of an _active_ configuration.
> 
> Any comments are welcome (and you may swear at me too :)
I would rather avoid adding the extra lines. In the
'office-suite' fashion I have cooked up a patch that specify
the filename as part of the windows title.

To make the conversion we should consider renaming from
current "Load alternate" to "Open config file..."
and likewise "Save alternate" to "Save config file as..."

Comments?

	Sam

diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h
index fd695e1..7e17eba 100644
--- a/scripts/kconfig/lxdialog/dialog.h
+++ b/scripts/kconfig/lxdialog/dialog.h
@@ -188,6 +188,7 @@ int on_key_esc(WINDOW *win);
 int on_key_resize(void);
 
 void init_dialog(const char *backtitle);
+void set_dialog_backtitle(const char *backtitle);
 void reset_dialog(void);
 void end_dialog(void);
 void attr_clear(WINDOW * win, int height, int width, chtype attr);
diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c
index d54440f..549373b 100644
--- a/scripts/kconfig/lxdialog/util.c
+++ b/scripts/kconfig/lxdialog/util.c
@@ -272,6 +272,11 @@ void init_dialog(const char *backtitle)
 	color_setup(getenv("MENUCONFIG_COLOR"));
 }
 
+void set_dialog_backtitle(const char *backtitle)
+{
+	dlg.backtitle = backtitle;
+}
+
 void reset_dialog(void)
 {
 	initscr();		/* Init curses */
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 3f9a132..327fc9a 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -26,7 +26,6 @@
 #include "lkc.h"
 #include "lxdialog/dialog.h"
 
-static char menu_backtitle[128];
 static const char mconf_readme[] = N_(
 "Overview\n"
 "--------\n"
@@ -271,7 +270,6 @@ search_help[] = N_(
 	"          USB$ => find all CONFIG_ symbols ending with USB\n"
 	"\n");
 
-static char filename[PATH_MAX+1] = ".config";
 static int indent;
 static struct termios ios_org;
 static int rows = 0, cols = 0;
@@ -395,6 +393,28 @@ static struct gstr get_relations_str(struct symbol **sym_arr)
 	return res;
 }
 
+static char filename[PATH_MAX+1];
+static void set_config_filename(const char *config_filename)
+{
+	static char menu_backtitle[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)
 {
 	struct symbol **sym_arr;
@@ -816,8 +836,10 @@ static void conf_load(void)
 		case 0:
 			if (!dialog_input_result[0])
 				return;
-			if (!conf_read(dialog_input_result))
+			if (!conf_read(dialog_input_result)) {
+				set_config_filename(dialog_input_result);
 				return;
+			}
 			show_textbox(NULL, _("File does not exist!"), 5, 38);
 			break;
 		case 1:
@@ -840,8 +862,10 @@ static void conf_save(void)
 		case 0:
 			if (!dialog_input_result[0])
 				return;
-			if (!conf_write(dialog_input_result))
+			if (!conf_write(dialog_input_result)) {
+				set_config_filename(dialog_input_result);
 				return;
+			}
 			show_textbox(NULL, _("Can't create file!  Probably a nonexistent directory."), 5, 60);
 			break;
 		case 1:
@@ -860,7 +884,6 @@ static void conf_cleanup(void)
 
 int main(int ac, char **av)
 {
-	struct symbol *sym;
 	char *mode;
 	int res;
 
@@ -871,11 +894,6 @@ int main(int ac, char **av)
 	conf_parse(av[1]);
 	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");
 	if (mode) {
 		if (!strcasecmp(mode, "single_menu"))
@@ -886,7 +904,8 @@ int main(int ac, char **av)
 	atexit(conf_cleanup);
 	init_wsize();
 	reset_dialog();
-	init_dialog(menu_backtitle);
+	init_dialog(NULL);
+	set_config_filename(".config");
 	do {
 		conf(&rootmenu);
 		dialog_clear();
@@ -903,7 +922,7 @@ int main(int ac, char **av)
 
 	switch (res) {
 	case 0:
-		if (conf_write(NULL)) {
+		if (conf_write(filename)) {
 			fprintf(stderr, _("\n\n"
 				"Error during writing of the kernel configuration.\n"
 				"Your kernel configuration changes were NOT saved."

  reply	other threads:[~2007-03-11 19:50 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-10 13:05 PROBLEM: "Make nenuconfig" does not save parameters Vladimir
2007-03-10 14:25 ` Cyrill Gorcunov
2007-03-10 16:06 ` Cyrill Gorcunov
2007-03-10 16:26   ` Jan Engelhardt
2007-03-10 16:35     ` Cyrill Gorcunov
2007-03-10 16:47       ` Jan Engelhardt
     [not found]     ` <20070310194617.2aef1006@localhost>
2007-03-10 16:50       ` Jan Engelhardt
2007-03-10 17:50         ` Cyrill Gorcunov
2007-03-10 18:23           ` Jan Engelhardt
2007-03-10 18:50             ` Cyrill Gorcunov
2007-03-10 19:04               ` Jan Engelhardt
2007-03-10 19:31                 ` Cyrill Gorcunov
2007-03-10 21:27             ` Sam Ravnborg
2007-03-10 21:34               ` Jan Engelhardt
2007-03-10 22:45                 ` Sam Ravnborg
2007-03-10 23:22                   ` Jan Engelhardt
2007-03-11  7:44                   ` Cyrill Gorcunov
2007-03-11 10:07                   ` Cyrill Gorcunov
2007-03-11 19:50                     ` Sam Ravnborg [this message]
2007-03-12  6:00                       ` Cyrill Gorcunov
2007-03-12 17:49                       ` Cyrill Gorcunov
2007-03-17 14:38                       ` Cyrill Gorcunov
2007-03-18 16:12                       ` Roman Zippel
     [not found] <7X9Ep-6Iu-1@gated-at.bofh.it>
     [not found] ` <7XcsC-2Iz-3@gated-at.bofh.it>
     [not found]   ` <7XcCq-2VQ-15@gated-at.bofh.it>
     [not found]     ` <7Xd5o-3wR-15@gated-at.bofh.it>
     [not found]       ` <7Xd5o-3wR-13@gated-at.bofh.it>
     [not found]         ` <7Xe1t-52k-11@gated-at.bofh.it>
     [not found]           ` <7XeE6-67b-1@gated-at.bofh.it>
     [not found]             ` <7XhiJ-1UJ-15@gated-at.bofh.it>
     [not found]               ` <7Xhsk-26S-9@gated-at.bofh.it>
     [not found]                 ` <7Xiy3-3MW-17@gated-at.bofh.it>
2007-03-11  5:21                   ` Bodo Eggert
2007-03-11  7:50                     ` Cyrill Gorcunov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070311195033.GA3302@uranus.ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=gorcunov@gmail.com \
    --cc=jengelh@linux01.gwdg.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox