mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-14 07:44:21 +08:00
kconfig: pass new conf_changed value to the callback
Commit ee06a3ef7e
("kconfig: Update config changed flag before calling
callback") pointed out that conf_updated flag must be updated _before_
calling the callback, which needs to know the new value.
Given that, it makes sense to directly pass the new value to the
callback.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
This commit is contained in:
parent
0b62fe46d7
commit
03638aaa79
@ -1141,16 +1141,14 @@ int conf_write_autoconf(int overwrite)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool conf_changed;
|
static bool conf_changed;
|
||||||
static void (*conf_changed_callback)(void);
|
static void (*conf_changed_callback)(bool);
|
||||||
|
|
||||||
void conf_set_changed(bool val)
|
void conf_set_changed(bool val)
|
||||||
{
|
{
|
||||||
bool changed = conf_changed != val;
|
if (conf_changed_callback && conf_changed != val)
|
||||||
|
conf_changed_callback(val);
|
||||||
|
|
||||||
conf_changed = val;
|
conf_changed = val;
|
||||||
|
|
||||||
if (conf_changed_callback && changed)
|
|
||||||
conf_changed_callback();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool conf_get_changed(void)
|
bool conf_get_changed(void)
|
||||||
@ -1158,7 +1156,7 @@ bool conf_get_changed(void)
|
|||||||
return conf_changed;
|
return conf_changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void conf_set_changed_callback(void (*fn)(void))
|
void conf_set_changed_callback(void (*fn)(bool))
|
||||||
{
|
{
|
||||||
conf_changed_callback = fn;
|
conf_changed_callback = fn;
|
||||||
}
|
}
|
||||||
|
@ -84,11 +84,10 @@ static void replace_button_icon(GladeXML *xml, GdkDrawable *window,
|
|||||||
gtk_tool_button_set_icon_widget(button, image);
|
gtk_tool_button_set_icon_widget(button, image);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void conf_changed(void)
|
static void conf_changed(bool dirty)
|
||||||
{
|
{
|
||||||
bool changed = conf_get_changed();
|
gtk_widget_set_sensitive(save_btn, dirty);
|
||||||
gtk_widget_set_sensitive(save_btn, changed);
|
gtk_widget_set_sensitive(save_menu_item, dirty);
|
||||||
gtk_widget_set_sensitive(save_menu_item, changed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Main Window Initialization */
|
/* Main Window Initialization */
|
||||||
|
@ -13,7 +13,7 @@ int conf_write(const char *name);
|
|||||||
int conf_write_autoconf(int overwrite);
|
int conf_write_autoconf(int overwrite);
|
||||||
void conf_set_changed(bool val);
|
void conf_set_changed(bool val);
|
||||||
bool conf_get_changed(void);
|
bool conf_get_changed(void);
|
||||||
void conf_set_changed_callback(void (*fn)(void));
|
void conf_set_changed_callback(void (*fn)(bool));
|
||||||
void conf_set_message_callback(void (*fn)(const char *s));
|
void conf_set_message_callback(void (*fn)(const char *s));
|
||||||
bool conf_errors(void);
|
bool conf_errors(void);
|
||||||
|
|
||||||
|
@ -1849,10 +1849,10 @@ void ConfigMainWindow::saveSettings(void)
|
|||||||
configSettings->writeSizes("/split2", split2->sizes());
|
configSettings->writeSizes("/split2", split2->sizes());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigMainWindow::conf_changed(void)
|
void ConfigMainWindow::conf_changed(bool dirty)
|
||||||
{
|
{
|
||||||
if (saveAction)
|
if (saveAction)
|
||||||
saveAction->setEnabled(conf_get_changed());
|
saveAction->setEnabled(dirty);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fixup_rootmenu(struct menu *menu)
|
void fixup_rootmenu(struct menu *menu)
|
||||||
|
@ -239,7 +239,7 @@ class ConfigMainWindow : public QMainWindow {
|
|||||||
|
|
||||||
char *configname;
|
char *configname;
|
||||||
static QAction *saveAction;
|
static QAction *saveAction;
|
||||||
static void conf_changed(void);
|
static void conf_changed(bool);
|
||||||
public:
|
public:
|
||||||
ConfigMainWindow(void);
|
ConfigMainWindow(void);
|
||||||
public slots:
|
public slots:
|
||||||
|
Loading…
Reference in New Issue
Block a user