Skip to content

Commit

Permalink
Add project_write_config() to force project file rewrite
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
techee committed Oct 25, 2014
1 parent c35dedf commit 233ca08
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
2 changes: 2 additions & 0 deletions plugins/geanyfunctions.h
Expand Up @@ -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
8 changes: 8 additions & 0 deletions src/plugindata.h
Expand Up @@ -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;

Expand Down Expand Up @@ -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

Expand Down
7 changes: 6 additions & 1 deletion src/plugins.c
Expand Up @@ -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,
Expand All @@ -384,7 +388,8 @@ static GeanyFunctions geany_functions = {
&msgwin_funcs,
&stash_funcs,
&symbols_funcs,
&build_funcs
&build_funcs,
&project_funcs
};

static GeanyData geany_data;
Expand Down
12 changes: 12 additions & 0 deletions src/project.c
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions src/project.h
Expand Up @@ -47,6 +47,9 @@ typedef struct GeanyProject
GeanyProject;


void project_write_config(void);


#ifdef GEANY_PRIVATE

typedef struct ProjectPrefs
Expand Down

0 comments on commit 233ca08

Please sign in to comment.