kconfig: Only activate UI save widgets when .config changed; Take 3
cover kconfig: Only activate UI save widgets when .config changed; Take 3
Hi
this disables the save-widgets, as long as you haven't changed anything yet when you are in the qt/gtk -GUI after
"make xconfig" or "make gconfig".
There were no objections on kbuild-devel,
though no comments neither on "Take 3".
Should apply from 2.6.19-rc1 onwards.
Karsten
---------- Weitergeleitete Nachricht ----------
Subject: [PATCH 0/4] kconfig: Only activate UI save widgets when .config changed; Take 3
Date: Dienstag, 10. Oktober 2006 15:33
From: Karsten Wiese <[email protected]>
To: [email protected]
Cc: Sam Ravnborg <[email protected]>, Roman Zippel <[email protected]>
Hi
the patchset sent following up tries to implement
functionality for *config's UIs
to know a .config's change state.
to accordingly
set GUI's save-widgets sensitivity, remind the user to save changes.
Changes in Take 3:
Use git-format-patch instead of cg-mkpatch. No code changes.
Comments welcome.
Karsten
-------------------------------------------------------
PATCH 1/4 New function "bool conf_get_changed(void)"
Returns sym_change_count to reflect the .config's change state. All read only accesses of
sym_change_count
are replaced by calls to
conf_get_changed()
.mconfig.c is manipulated to ask for saving only when conf_get_changed() returned true.
--- scripts/kconfig/conf.c | 2 +- scripts/kconfig/confdata.c | 7 ++++++- scripts/kconfig/lkc_proto.h | 1 + scripts/kconfig/mconf.c | 21 ++++++++++++++------- scripts/kconfig/qconf.cc | 2 +- 5 files changed, 23 insertions(+), 10 deletions(-)
scripts/kconfig/conf.c +1 -1
@@ -600,7 +600,7 @@ int main(int ac, char **av) input_mode = ask_silent; valid_stdin =1 ; } - }else if (sym_change_count) { + }else if (conf_get_changed ()) { name =getenv ("KCONFIG_NOSILENTUPDATE" );if (name && *name) {fprintf (stderr,_ ("\n*** Kernel configuration requires explicit update.\n\n" ));
scripts/kconfig/confdata.c +6 -1
@@ -432,7 +432,7 @@ int conf_write(const char *name) use_timestamp ?"# " :"" , use_timestamp ? ctime(&now) : ""); -if (!sym_change_count) +if (!conf_get_changed ())sym_clear_all_valid (); menu = rootmenu.list;
@@ -765,3 +765,8 @@ int conf_write_autoconf(void)return 0 ; } + +bool conf_get_changed (void ) +{ +return sym_change_count; +}
scripts/kconfig/lkc_proto.h +1 -0
@@ -5,6 +5,7 @@ P(conf_read,int,(const char *name)); P(conf_read_simple,int,(const char *name, int)); P(conf_write,int,(const char *name)); P(conf_write_autoconf,int,(void)); +P(conf_get_changed,bool,(void));/* menu.c */ P(rootmenu,struct menu,);
scripts/kconfig/mconf.c +14 -7
@@ -890,14 +890,19 @@ int main(int ac, char **av)do {conf (&rootmenu);dialog_clear (); - res =dialog_yesno (NULL , -_ ("Do you wish to save your " -"new kernel configuration?\n" -"<ESC><ESC> to continue." ), -6 ,60 ); +if (conf_get_changed ()) + res =dialog_yesno (NULL , +_ ("Do you wish to save your " +"new kernel configuration?\n" +"<ESC><ESC> to continue." ), +6 ,60 ); +else + res =-1 ; }while (res ==KEY_ESC );end_dialog (); -if (res ==0 ) { + +switch (res) { +case 0 :if (conf_write (NULL )) { fprintf(stderr, _("\n\n" "Error during writing of the kernel configuration.\n"
@@ -905,11 +910,13 @@ int main(int ac, char **av) "\n\n"));return 1 ; } +case -1 :printf (_ ("\n\n" "*** End of Linux kernel configuration.\n" "*** Execute 'make' to build the kernel or try 'make help'." "\n\n" )); - }else { +break ; +default :fprintf (stderr,_ ("\n\n" "Your kernel configuration changes were NOT saved." "\n\n" ));
scripts/kconfig/qconf.cc +1 -1
@@ -1584,7 +1584,7 @@ void ConfigMainWindow::showFullView(void */ void ConfigMainWindow::closeEvent(QCloseEvent* e) { - if (!sym_change_count) { + if (!conf_get_changed()) { e->accept(); return; }
Signature · 1 line
1.4.2.3
PATCH 2/4 Make sym_change_count static, let it be altered by 2 functions only
Those two functions are
void sym_set_change_count(int count)
and
void sym_add_change_count(int count)
.
All write accesses to sym_change_count are replaced by calls to above functions.
Variable and changer-functions are moved to confdata.c. IMO thats ok, as sym_change_count is an attribute of the .config's change state.
--- scripts/kconfig/confdata.c | 20 ++++++++++++++++---- scripts/kconfig/lkc.h | 2 ++ scripts/kconfig/lkc_proto.h | 1 - scripts/kconfig/symbol.c | 3 +-- scripts/kconfig/zconf.tab.c_shipped | 2 +- scripts/kconfig/zconf.y | 2 +- 6 files changed, 21 insertions(+), 9 deletions(-)
scripts/kconfig/confdata.c +16 -4
@@ -100,7 +100,7 @@ int conf_read_simple(const char *name, i in =zconf_fopen (name);if (in) goto load; - sym_change_count++; +sym_add_change_count (1 );if (!sym_defconfig_list)return 1 ;
@@ -312,7 +312,7 @@ int conf_read(const char *name)struct expr *e;int i, flags; - sym_change_count =0 ; +sym_set_change_count (0 );if (conf_read_simple (name,S_DEF_USER ))return 1 ;
@@ -364,7 +364,7 @@ int conf_read(const char *name) sym->flags &= flags | ~SYMBOL_DEF_USER ; } - sym_change_count += conf_warnings || conf_unsaved; +sym_add_change_count (conf_warnings || conf_unsaved);return 0 ; }
@@ -528,7 +528,7 @@ int conf_write(const char *name)"# configuration written to %s\n" "#\n"), newname); - sym_change_count =0 ; +sym_set_change_count (0 );return 0 ; }
@@ -766,6 +766,18 @@ int conf_write_autoconf(void)return 0 ; } +static int sym_change_count; + +void sym_set_change_count (int count) +{ + sym_change_count = count; +} + +void sym_add_change_count (int count) +{ + sym_change_count += count; +} +bool conf_get_changed (void ) {return sym_change_count;
scripts/kconfig/lkc.h +2 -0
@@ -65,6 +65,8 @@ char *zconf_curname(void);/* confdata.c */ char *conf_get_default_confname (void ); +void sym_set_change_count (int count); +void sym_add_change_count (int count);/* kconfig_load.c */ void kconfig_load (void );
scripts/kconfig/lkc_proto.h +0 -1
@@ -17,7 +17,6 @@ P(menu_get_parent_menu,struct menu *,(st/* symbol.c */ P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]); -P(sym_change_count,int,); P(sym_lookup,struct symbol *,(const char *name, int isconst)); P(sym_find,struct symbol *,(const char *name));
scripts/kconfig/symbol.c +1 -2
@@ -30,7 +30,6 @@ struct symbol symbol_yes = { .flags = SYMBOL_VALID, }; -int sym_change_count;struct symbol *sym_defconfig_list;struct symbol *modules_sym;tristate modules_val;
@@ -379,7 +378,7 @@ void sym_clear_all_valid(void)for_all_symbols (i, sym) sym->flags &= ~SYMBOL_VALID; - sym_change_count++; +sym_add_change_count (1 );if (modules_sym)sym_calc_value (modules_sym); }
scripts/kconfig/zconf.tab.c_shipped +1 -1
@@ -2135,7 +2135,7 @@ #endif sym_check_deps(sym); } - sym_change_count = 1; + sym_set_change_count(1); } const char *zconf_tokenname(int token)
scripts/kconfig/zconf.y +1 -1
@@ -504,7 +504,7 @@ #endif sym_check_deps(sym); } - sym_change_count = 1; + sym_set_change_count(1); } const char *zconf_tokenname(int token)
Signature · 1 line
1.4.2.3
PATCH 3/4 Add "void conf_set_changed_callback(void (*fn)(void))", use it in qconf.cc
Added function sets "void (*conf_changed_callback)(void)". Call it, if .config's changed state changes.
Use above in qconf.cc to set gui's save-widget's sensitvity.
--- scripts/kconfig/confdata.c | 12 +++++++++++- scripts/kconfig/lkc_proto.h | 1 + scripts/kconfig/qconf.cc | 13 ++++++++++++- scripts/kconfig/qconf.h | 3 +++ 4 files changed, 27 insertions(+), 2 deletions(-)
scripts/kconfig/confdata.c +11 -1
@@ -767,18 +767,28 @@ int conf_write_autoconf(void) }static int sym_change_count; +static void (*conf_changed_callback)(void );void sym_set_change_count (int count) { +int _sym_change_count = sym_change_count; sym_change_count = count; +if (conf_changed_callback && + (bool )_sym_change_count != (bool )count) +conf_changed_callback (); }void sym_add_change_count (int count) { - sym_change_count += count; +sym_set_change_count (count + sym_change_count); }bool conf_get_changed (void ) {return sym_change_count; } + +void conf_set_changed_callback (void (*fn)(void )) +{ + conf_changed_callback = fn; +}
scripts/kconfig/lkc_proto.h +1 -0
@@ -6,6 +6,7 @@ P(conf_read_simple,int,(const char *name P(conf_write,int,(const char *name)); P(conf_write_autoconf,int,(void)); P(conf_get_changed,bool,(void)); +P(conf_set_changed_callback, void,(void (*fn)(void)));/* menu.c */ P(rootmenu,struct menu,);
scripts/kconfig/qconf.cc +12 -1
@@ -38,6 +38,8 @@ #endif static QApplication *configApp; static ConfigSettings *configSettings; +QAction *ConfigMainWindow::saveAction; + static inline QString qgettext(const char* str) { return QString::fromLocal8Bit(gettext(str));
@@ -1305,8 +1307,11 @@ ConfigMainWindow::ConfigMainWindow(void) connect(quitAction, SIGNAL(activated()), SLOT(close())); QAction *loadAction = new QAction("Load", QPixmap(xpm_load), "&Load", CTRL+Key_L, this); connect(loadAction, SIGNAL(activated()), SLOT(loadConfig())); - QAction *saveAction = new QAction("Save", QPixmap(xpm_save), "&Save", CTRL+Key_S, this); + saveAction = new QAction("Save", QPixmap(xpm_save), "&Save", CTRL+Key_S, this); connect(saveAction, SIGNAL(activated()), SLOT(saveConfig())); + conf_set_changed_callback(conf_changed); + // Set saveAction's initial state + conf_changed(); QAction *saveAsAction = new QAction("Save As...", "Save &As...", 0, this); connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs())); QAction *searchAction = new QAction("Search", "&Search", CTRL+Key_F, this);
@@ -1657,6 +1662,12 @@ void ConfigMainWindow::saveSettings(void configSettings->writeSizes("/split2", split2->sizes()); } +void ConfigMainWindow::conf_changed(void) +{ + if (saveAction) + saveAction->setEnabled(conf_get_changed()); +} + void fixup_rootmenu(struct menu *menu) { struct menu *child;
scripts/kconfig/qconf.h +3 -0
@@ -297,6 +297,9 @@ protected: class ConfigMainWindow : public QMainWindow {Q_OBJECT + + static QAction *saveAction; +static void conf_changed (void ); public:ConfigMainWindow (void); public slots:
Signature · 1 line
1.4.2.3
PATCH 4/4 Set gconf's save-widget's sensitivity according to .config's changed state
Clean up a little.
--- scripts/kconfig/gconf.c | 35 ++++++++++++++++++----------------- scripts/kconfig/gconf.glade | 4 ++-- 2 files changed, 20 insertions(+), 19 deletions(-)
scripts/kconfig/gconf.c +18 -17
@@ -38,8 +38,6 @@ static gboolean show_all = FALSE;static gboolean show_debug = FALSE;static gboolean resizeable = FALSE; -static gboolean config_changed = FALSE; -static char nohelp_text[] =N_ ("Sorry, no help available for this option yet.\n" );
@@ -50,6 +48,8 @@ GtkWidget *text_w = NULL;GtkWidget *hpaned =NULL ;GtkWidget *vpaned =NULL ;GtkWidget *back_btn =NULL ; +GtkWidget *save_btn =NULL ; +GtkWidget *save_menu_item =NULL ;GtkTextTag *tag1, *tag2;GdkColor color;
@@ -75,7 +75,7 @@ static void display_tree_part(void);static void update_tree (struct menu *src,GtkTreeIter * dst);static void set_node (GtkTreeIter * node,struct menu *menu,gchar ** row);static gchar **fill_row (struct menu *menu); - +static void conf_changed (void );/* Helping/Debugging Functions */
@@ -224,6 +224,10 @@ void init_main_window(const gchar * gladgtk_check_menu_item_set_active ((GtkCheckMenuItem *) widget, show_value); + save_btn =glade_xml_get_widget (xml,"button3" ); + save_menu_item =glade_xml_get_widget (xml,"save1" ); +conf_set_changed_callback (conf_changed); + style =gtk_widget_get_style (main_wnd); widget =glade_xml_get_widget (xml,"toolbar1" );
@@ -512,14 +516,14 @@ static void text_insert_msg(const char */* Main Windows Callbacks */ -void on_save1_activate (GtkMenuItem * menuitem,gpointer user_data); +void on_save_activate (GtkMenuItem * menuitem,gpointer user_data);gboolean on_window1_delete_event (GtkWidget * widget,GdkEvent * event,gpointer user_data) {GtkWidget *dialog, *label;gint result; -if (config_changed == FALSE) +if (!conf_get_changed ())return FALSE; dialog = gtk_dialog_new_with_buttons(_("Warning !"),
@@ -543,7 +547,7 @@ gboolean on_window1_delete_event(GtkWidg result =gtk_dialog_run (GTK_DIALOG (dialog));switch (result) {case GTK_RESPONSE_YES : -on_save1_activate (NULL ,NULL ); +on_save_activate (NULL ,NULL );return FALSE;case GTK_RESPONSE_NO :return FALSE;
@@ -621,12 +625,10 @@ void on_load1_activate(GtkMenuItem * men } -void on_save1_activate (GtkMenuItem * menuitem,gpointer user_data) +void on_save_activate (GtkMenuItem * menuitem,gpointer user_data) {if (conf_write (NULL ))text_insert_msg (_ ("Error" ),_ ("Unable to save configuration !" )); - - config_changed = FALSE; }
@@ -819,12 +821,6 @@ void on_load_clicked(GtkButton * button, } -void on_save_clicked (GtkButton * button,gpointer user_data) -{ -on_save1_activate (NULL , user_data); -} - -void on_single_clicked (GtkButton * button,gpointer user_data) { view_mode =SINGLE_VIEW ;
@@ -899,7 +895,6 @@ static void renderer_edited(GtkCellRendesym_set_string_value (sym, new_def); - config_changed = TRUE;update_tree (&rootmenu,NULL );gtk_tree_path_free (path);
@@ -930,7 +925,6 @@ static void change_sym_value(struct menuif (!sym_tristate_within_range (sym, newval)) newval = yes;sym_set_tristate_value (sym, newval); - config_changed = TRUE;if (view_mode ==FULL_VIEW )update_tree (&rootmenu,NULL );else if (view_mode ==SPLIT_VIEW ) {
@@ -1633,3 +1627,10 @@ #endifreturn 0 ; } + +static void conf_changed (void ) +{ +bool changed =conf_get_changed (); +gtk_widget_set_sensitive (save_btn, changed); +gtk_widget_set_sensitive (save_menu_item, changed); +}
scripts/kconfig/gconf.glade +2 -2
@@ -70,7 +70,7 @@ <property name="tooltip" translatable="yes">Save the config in .config</property> <property name="label" translatable="yes">_Save</property> <property name="use_underline">True</property> - <signal name="activate" handler="on_save1_activate"/> + <signal name="activate" handler="on_save_activate"/> <accelerator key="S" modifiers="GDK_CONTROL_MASK" signal="activate"/> <child internal-child="image">
@@ -380,7 +380,7 @@ <property name="visible_horizontal">True</property> <property name="visible_vertical">True</property> <property name="is_important">False</property> - <signal name="clicked" handler="on_save_clicked"/> + <signal name="clicked" handler="on_save_activate"/> </widget> <packing> <property name="expand">False</property>
Signature · 1 line
1.4.2.3
Quoted 22 lines · On Wed, 18 Oct 2006 00:23:04 +0200 Karsten Wiese <[email protected]>…
Hi
this disables the save-widgets, as long as you haven't changed anything yet when you are in the qt/gtk -GUI after
"make xconfig" or "make gconfig".
There were no objections on kbuild-devel,
though no comments neither on "Take 3".Should apply from 2.6.19-rc1 onwards.
Karsten
---------- Weitergeleitete Nachricht ----------
Subject: [PATCH 0/4] kconfig: Only activate UI save widgets when .config changed; Take 3
Date: Dienstag, 10. Oktober 2006 15:33
From: Karsten Wiese <[email protected]>
To: [email protected]
Cc: Sam Ravnborg <[email protected]>, Roman Zippel <[email protected]>Hi
Quoted 9 lines
the patchset sent following up tries to implement
functionality for *config's UIsto know a .config's change state.
to accordingly
set GUI's save-widgets sensitivity, remind the user to save changes.
So I'm pretending to be kbuild maintainer and I now realise I simply don't know what this patch series does.
Can you please explain it a lot more?
Am Sonntag, 10. Dezember 2006 09:10 schrieb Andrew Morton:
Quoted 5 lines
So I'm pretending to be kbuild maintainer and I now realise I simply don't know what this patch series does.
Can you please explain it a lot more?
lets "make xconfig" on a freshly untarred kernel-tree.
look at the floppy disk icon of the qt application, that has just started:
Its in a normal, active state.
Mouse click on it:
.config is being saved.
Now in the current -mm head version, you'll notice something new:
after the mouse click on the floppy disk icon, the icon is greyed out. If you mouse click on it now, nothing happens, which is ok IMHO, as nothing has changed.
If you change some CONFIG_*, the floppy disk icon returns to "active state", that is, if you mouse click it now, .config is written.
The "icon greying out" aka "save widget de/activation" is done by this patch series.
Its done for the save-icons and the file-save menu entries of the applications launched after "make xconfig" or "make gconfig" is called. Purpose is:
"let the (gtk/qt kernel configuration) application show me if there are
unsaved changes to the .config,
so there's 1 thing less I might wonder about"
more?
Karsten
Randy Dunlap
Acked-byQuoted 27 lines · On Mon, 11 Dec 2006 14:08:51 +0100 Karsten Wiese wrote:
Am Sonntag, 10. Dezember 2006 09:10 schrieb Andrew Morton:
Quoted 5 lines
So I'm pretending to be kbuild maintainer and I now realise I simply don't know what this patch series does.
Can you please explain it a lot more?
lets "make xconfig" on a freshly untarred kernel-tree.
look at the floppy disk icon of the qt application, that has just started:
Its in a normal, active state.
Mouse click on it:
.config is being saved.
Now in the current -mm head version, you'll notice something new:
after the mouse click on the floppy disk icon, the icon is greyed out. If you mouse click on it now, nothing happens, which is ok IMHO, as nothing has changed.
If you change some CONFIG_*, the floppy disk icon returns to "active state", that is, if you mouse click it now, .config is written.
The "icon greying out" aka "save widget de/activation" is done by this patch series.
Its done for the save-icons and the file-save menu entries of the applications launched after "make xconfig" or "make gconfig" is called. Purpose is:
"let the (gtk/qt kernel configuration) application show me if there are
unsaved changes to the .config,
so there's 1 thing less I might wonder about"
Quoted 1 line
more?
I reviewed the patches and tested menu/x/gconfig.
They all look good to me.
Thanks,
---
~Randy