Always emit the project-save signal when writing project file
For some reason "project-save" isn't emitted when closing project - see write_config(FALSE) in project_close(). This means that in this case plugins cannot save their configuration into the config file. This doesn't even correspond to the documentation of the signal "Sent when a project is saved (happens when the project is created, the properties dialog is closed or Geany is exited)" as the signal isn't emitted when exiting Geany because at this point Geany closes the project. The comment seems to indicate that the reason is that "project-save" shouldn't be emitted when "project-close" is emitted but I don't see any reason why. Bump API so plugins can rely on the changed behavior.
This commit is contained in:
parent
180e1da427
commit
e43c8d8314
@ -142,8 +142,9 @@ signal void (*document_close)(GObject *obj, GeanyDocument *doc, gpointer user_da
|
||||
signal void (*project_open)(GObject *obj, GKeyFile *config, gpointer user_data);
|
||||
|
||||
/** Sent when a project is saved (happens when the project is created, the properties
|
||||
* dialog is closed or Geany is exited). This signal is emitted shortly before Geany
|
||||
* will write the contents of the GKeyFile to the disc.
|
||||
* dialog is closed, before the project is closed, or when Geany is exited).
|
||||
* This signal is emitted shortly before Geany will write the contents of the
|
||||
* GKeyFile to the disc.
|
||||
*
|
||||
* @param obj a GeanyObject instance, should be ignored.
|
||||
* @param config an existing GKeyFile object which can be used to read and write data.
|
||||
|
@ -83,7 +83,7 @@ typedef struct _PropertyDialogElements
|
||||
static gboolean update_config(const PropertyDialogElements *e, gboolean new_project);
|
||||
static void on_file_save_button_clicked(GtkButton *button, PropertyDialogElements *e);
|
||||
static gboolean load_config(const gchar *filename);
|
||||
static gboolean write_config(gboolean emit_signal);
|
||||
static gboolean write_config(void);
|
||||
static void on_name_entry_changed(GtkEditable *editable, PropertyDialogElements *e);
|
||||
static void on_entries_changed(GtkEditable *editable, PropertyDialogElements *e);
|
||||
static void on_radio_long_line_custom_toggled(GtkToggleButton *radio, GtkWidget *spin_long_line);
|
||||
@ -246,7 +246,7 @@ void project_new(void)
|
||||
if (update_config(&e, TRUE))
|
||||
{
|
||||
// app->project is now set
|
||||
if (!write_config(TRUE))
|
||||
if (!write_config())
|
||||
{
|
||||
SHOW_ERR(_("Project file could not be written"));
|
||||
destroy_project(FALSE);
|
||||
@ -404,7 +404,7 @@ gboolean project_close(gboolean open_default)
|
||||
g_return_val_if_fail(app->project != NULL, FALSE);
|
||||
|
||||
/* save project session files, etc */
|
||||
if (!write_config(FALSE))
|
||||
if (!write_config())
|
||||
g_warning("Project file \"%s\" could not be written", app->project->file_name);
|
||||
|
||||
if (project_prefs.project_session)
|
||||
@ -619,7 +619,7 @@ static void show_project_properties(gboolean show_build)
|
||||
if (update_config(&e, FALSE))
|
||||
{
|
||||
g_signal_emit_by_name(geany_object, "project-dialog-confirmed", e.notebook);
|
||||
if (!write_config(TRUE))
|
||||
if (!write_config())
|
||||
SHOW_ERR(_("Project file could not be written"));
|
||||
else
|
||||
{
|
||||
@ -1092,11 +1092,8 @@ static void apply_editor_prefs(void)
|
||||
|
||||
|
||||
/* Write the project settings as well as the project session files into its configuration files.
|
||||
* emit_signal defines whether the project-save signal should be emitted. When write_config()
|
||||
* is called while closing a project, this is used to skip emitting the signal because
|
||||
* project-close will be emitted afterwards.
|
||||
* Returns: TRUE if project file was written successfully. */
|
||||
static gboolean write_config(gboolean emit_signal)
|
||||
static gboolean write_config(void)
|
||||
{
|
||||
GeanyProject *p;
|
||||
GKeyFile *config;
|
||||
@ -1134,10 +1131,7 @@ static gboolean write_config(gboolean emit_signal)
|
||||
if (project_prefs.project_session)
|
||||
configuration_save_session_files(config);
|
||||
build_save_menu(config, (gpointer)p, GEANY_BCS_PROJ);
|
||||
if (emit_signal)
|
||||
{
|
||||
g_signal_emit_by_name(geany_object, "project-save", config);
|
||||
}
|
||||
g_signal_emit_by_name(geany_object, "project-save", config);
|
||||
/* write the file */
|
||||
data = g_key_file_to_data(config, NULL, NULL);
|
||||
ret = (utils_write_file(filename, data) == 0);
|
||||
@ -1158,7 +1152,7 @@ static gboolean write_config(gboolean emit_signal)
|
||||
GEANY_API_SYMBOL
|
||||
void project_write_config(void)
|
||||
{
|
||||
if (!write_config(TRUE))
|
||||
if (!write_config())
|
||||
SHOW_ERR(_("Project file could not be written"));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user