[Github-comments] [geany/geany] Add new API function to open a project file (#1222)

Colomban Wendling notifications at xxxxx
Sun Oct 23 15:39:14 UTC 2016


b4n commented on this pull request.

Looks mostly fine, see comments.

> + * 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));

It might make sense to perform the same checks as `osx.c` does, that is that the project file to open is not obviously the same as the currently open one:

```C
	if (app->project == NULL || 
		(g_strcmp0(utf8_path, app->project->file_name) != 0 && project_ask_close()))
		project_load_file_with_session(locale_path);
```

> +/**
+ * 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)

This new API should probably be used in `osx.c`'s `open_project_idle()` and in `ui_utils.c`'s `recent_project_activate_cb()`.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/1222#pullrequestreview-5366880
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20161023/0cd3a103/attachment.html>


More information about the Github-comments mailing list