]> err.no Git - linux-2.6/commitdiff
[PATCH] kconfig: add "void conf_set_changed_callback(void (*fn)(void))", use it in...
authorKarsten Wiese <annabellesgarden@yahoo.de>
Wed, 13 Dec 2006 08:34:08 +0000 (00:34 -0800)
committerLinus Torvalds <torvalds@woody.osdl.org>
Wed, 13 Dec 2006 17:05:48 +0000 (09:05 -0800)
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.

Signed-off-by: Karsten Wiese <fzu@wemgehoertderstaat.de>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Roman Zippel <zippel@linux-m68k.org>
Acked-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
scripts/kconfig/confdata.c
scripts/kconfig/lkc_proto.h
scripts/kconfig/qconf.cc
scripts/kconfig/qconf.h

index 4bbbb5b09c8d7b01a74000e4bea5b58cc5690aa7..664fe29dacef5b3f9e0d36353fe0968bccc01347 100644 (file)
@@ -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;
+}
index 84bb139789a0845c4398a64492a0adfdd8d9d204..15030770d1ad4e937272a6f03d7d704ebad70dff 100644 (file)
@@ -6,6 +6,7 @@ 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));
+P(conf_set_changed_callback, void,(void (*fn)(void)));
 
 /* menu.c */
 P(rootmenu,struct menu,);
index 8d60d99bd9f19474e58147a24f4ff6488fa01dad..0b2fcc417f590a0eed79b5709f0e48d50c8dda11 100644 (file)
@@ -38,6 +38,8 @@
 static QApplication *configApp;
 static ConfigSettings *configSettings;
 
+QAction *ConfigMainWindow::saveAction;
+
 static inline QString qgettext(const char* str)
 {
        return QString::fromLocal8Bit(gettext(str));
@@ -1306,8 +1308,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);
@@ -1658,6 +1663,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;
index 6a9e3b14c227ce6ff43befbe35d764a3423735ef..6fc1c5f14425162aab07eb5e35f8d24f0c8ccadc 100644 (file)
@@ -297,6 +297,9 @@ protected:
 
 class ConfigMainWindow : public QMainWindow {
        Q_OBJECT
+
+       static QAction *saveAction;
+       static void conf_changed(void);
 public:
        ConfigMainWindow(void);
 public slots: