[geany/geany] 233ca0: Add project_write_config() to force project file rewrite

Jiří Techet git-noreply at xxxxx
Wed Dec 10 23:11:05 UTC 2014


Branch:      refs/heads/master
Author:      Jiří Techet <techet at gmail.com>
Committer:   Jiří Techet <techet at gmail.com>
Date:        Sat, 25 Oct 2014 20:30:54 UTC
Commit:      233ca08e886f6a1d543aa87fc454057e61a20e0c
             https://github.com/geany/geany/commit/233ca08e886f6a1d543aa87fc454057e61a20e0c

Log Message:
-----------
Add project_write_config() to force project file rewrite

Since plugins don't have direct access to the project file,
only through the project-save signal, they need some way to emit this
signal when saving their preferences outside the project dialog,
which is what this function does.


Modified Paths:
--------------
    plugins/geanyfunctions.h
    src/plugindata.h
    src/plugins.c
    src/project.c
    src/project.h

Modified: plugins/geanyfunctions.h
2 lines changed, 2 insertions(+), 0 deletions(-)
===================================================================
@@ -436,5 +436,7 @@
 	geany_functions->p_build->build_set_menu_item
 #define build_get_group_count \
 	geany_functions->p_build->build_get_group_count
+#define project_write_config \
+	geany_functions->p_project->project_write_config
 
 #endif


Modified: src/plugindata.h
8 lines changed, 8 insertions(+), 0 deletions(-)
===================================================================
@@ -288,6 +288,7 @@ typedef struct GeanyFunctions
 	struct StashFuncs			*p_stash;			/**< See stash.h */
 	struct SymbolsFuncs			*p_symbols;			/**< See symbols.h */
 	struct BuildFuncs			*p_build;			/**< See build.h */
+	struct ProjectFuncs			*p_project;			/**< See project.h */
 }
 GeanyFunctions;
 
@@ -738,6 +739,13 @@ typedef struct BuildFuncs
 }
 BuildFuncs;
 
+/* See project.h */
+typedef struct ProjectFuncs
+{
+	void (*project_write_config)(void);
+}
+ProjectFuncs;
+
 /* Deprecated aliases */
 #ifndef GEANY_DISABLE_DEPRECATED
 


Modified: src/plugins.c
7 lines changed, 6 insertions(+), 1 deletions(-)
===================================================================
@@ -361,6 +361,10 @@ static BuildFuncs build_funcs = {
 	&build_get_group_count
 };
 
+static ProjectFuncs project_funcs = {
+	&project_write_config
+};
+
 static GeanyFunctions geany_functions = {
 	&doc_funcs,
 	&sci_funcs,
@@ -384,7 +388,8 @@ static GeanyFunctions geany_functions = {
 	&msgwin_funcs,
 	&stash_funcs,
 	&symbols_funcs,
-	&build_funcs
+	&build_funcs,
+	&project_funcs
 };
 
 static GeanyData geany_data;


Modified: src/project.c
12 lines changed, 12 insertions(+), 0 deletions(-)
===================================================================
@@ -1153,6 +1153,18 @@ static gboolean write_config(gboolean emit_signal)
 }
 
 
+/** Forces the project file rewrite and emission of the project-save signal. Plugins 
+ * can use this function to save additional project data outside the project dialog.
+ *
+ *  @since 1.25
+ */
+void project_write_config(void)
+{
+	if (!write_config(TRUE))
+		SHOW_ERR(_("Project file could not be written"));
+}
+
+
 /* Constructs the project's base path which is used for "Make all" and "Execute".
  * The result is an absolute string in UTF-8 encoding which is either the same as
  * base path if it is absolute or it is built out of project file name's dir and base_path.


Modified: src/project.h
3 lines changed, 3 insertions(+), 0 deletions(-)
===================================================================
@@ -47,6 +47,9 @@ typedef struct GeanyProject
 GeanyProject;
 
 
+void project_write_config(void);
+
+
 #ifdef GEANY_PRIVATE
 
 typedef struct ProjectPrefs



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list