From b3694a9b736b6b2da7c7712b5be8b3d74c09eceb Mon Sep 17 00:00:00 2001 From: Matthew Brush Date: Sat, 10 Sep 2016 16:04:42 -0700 Subject: [PATCH] Add new API function to open a project file --- src/plugindata.h | 2 +- src/project.c | 22 ++++++++++++++++++++++ src/project.h | 2 ++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/plugindata.h b/src/plugindata.h index c8bd687939..b31b3bf608 100644 --- a/src/plugindata.h +++ b/src/plugindata.h @@ -59,7 +59,7 @@ G_BEGIN_DECLS * @warning You should not test for values below 200 as previously * @c GEANY_API_VERSION was defined as an enum value, not a macro. */ -#define GEANY_API_VERSION 228 +#define GEANY_API_VERSION 230 /* hack to have a different ABI when built with GTK3 because loading GTK2-linked plugins * with GTK3-linked Geany leads to crash */ diff --git a/src/project.c b/src/project.c index eda00faa2a..b7ac9f0934 100644 --- a/src/project.c +++ b/src/project.c @@ -1346,3 +1346,25 @@ void project_init(void) void project_finalize(void) { } + + +/** + * Open the given project file. + * + * This is done as if the user had done it using the `Project->Open` + * menu item (ie. it will confirm closing the current project). Any + * files in the project's session will be re-opened. + * + * @param project_locale_fn The filename of the project file in locale + * filename encoding. + * + * @return @c TRUE if the project was opened, @c FALSE otherwise. + * + * @since 1.29 (API 230) + */ +GEANY_API_SYMBOL +gboolean project_open_file(const gchar *project_locale_fn) +{ + return (project_ask_close() && + project_load_file_with_session(project_locale_fn)); +} diff --git a/src/project.h b/src/project.h index 1babde12c0..5af2733255 100644 --- a/src/project.h +++ b/src/project.h @@ -50,6 +50,8 @@ GeanyProject; void project_write_config(void); +gboolean project_open_file(const gchar *project_locale_fn); + #ifdef GEANY_PRIVATE