[geany/geany-plugins] f4c61f: projectorganizer: Add a (hacky) way to show the file tree when the plugin is enabled

Jiří Techet git-noreply at xxxxx
Sun Mar 29 19:36:51 UTC 2015


Branch:      refs/heads/master
Author:      Jiří Techet <techet at gmail.com>
Committer:   Jiří Techet <techet at gmail.com>
Date:        Sun, 29 Mar 2015 19:36:51 UTC
Commit:      f4c61f69dd0407d0c5f325a66b6f13fc1e041684
             https://github.com/geany/geany-plugins/commit/f4c61f69dd0407d0c5f325a66b6f13fc1e041684

Log Message:
-----------
projectorganizer: Add a (hacky) way to show the file tree when the plugin is enabled

See the comment in the code for more info.


Modified Paths:
--------------
    projectorganizer/src/prjorg-main.c
    projectorganizer/src/prjorg-sidebar.c

Modified: projectorganizer/src/prjorg-main.c
33 lines changed, 28 insertions(+), 5 deletions(-)
===================================================================
@@ -124,10 +124,13 @@ static void on_project_dialog_close(G_GNUC_UNUSED GObject * obj, GtkWidget * not
 static void on_project_open(G_GNUC_UNUSED GObject * obj, GKeyFile * config,
 		G_GNUC_UNUSED gpointer user_data)
 {
-	prjorg_project_open(config);
-	prjorg_sidebar_update(TRUE);
-	prjorg_sidebar_activate(TRUE);
-	prjorg_menu_activate_menu_items(TRUE);
+	if (!prj_org)
+	{
+		prjorg_project_open(config);
+		prjorg_sidebar_update(TRUE);
+		prjorg_sidebar_activate(TRUE);
+		prjorg_menu_activate_menu_items(TRUE);
+	}
 }
 
 
@@ -141,12 +144,13 @@ static void on_project_close(G_GNUC_UNUSED GObject * obj, G_GNUC_UNUSED gpointer
 }
 
 
+/* May be called also after plugin_init(), see plugin_init() for more info */
 static void on_project_save(G_GNUC_UNUSED GObject * obj, GKeyFile * config,
 		G_GNUC_UNUSED gpointer user_data)
 {
 	if (!prj_org)
 	{
-		/* happens when the project is created */
+		/* happens when the project is created or the plugin is loaded */
 		prjorg_project_open(config);
 		prjorg_sidebar_update(TRUE);
 		prjorg_sidebar_activate(TRUE);
@@ -172,10 +176,29 @@ PluginCallback plugin_callbacks[] = {
 };
 
 
+static gboolean write_config_cb(gpointer user_data)
+{
+	if (geany_data->app->project && !prj_org)
+		project_write_config();
+	return FALSE;
+}
+
+
 void plugin_init(G_GNUC_UNUSED GeanyData * data)
 {
 	prjorg_menu_init();
 	prjorg_sidebar_init();
+	/* If the project is already open, we won't get the project-open signal
+	 * when the plugin is enabled in the plugin manager so the plugin won't
+	 * reload the project tree. However, we can force the call of the
+	 * project-save signal emission whose handler does a similar thing like
+	 * project-open so we get the same effect.
+	 *
+	 * For some reason this doesn't work when called directly from plugin_init()
+	 * so perform on idle instead. Also use low priority so hopefully normal
+	 * project opening happens before and we don't unnecessarily rewrite the
+	 * project file. */
+	g_idle_add_full(G_PRIORITY_LOW, write_config_cb, NULL, NULL);
 }
 
 


Modified: projectorganizer/src/prjorg-sidebar.c
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -1328,7 +1328,7 @@ void prjorg_sidebar_init(void)
 	g_signal_connect(G_OBJECT(s_file_view), "key-press-event",
 			G_CALLBACK(on_key_press), NULL);
 
-	set_intro_message(_("(Re)open project to start using the plugin"));
+	set_intro_message(_("Open a project to start using the plugin"));
 	prjorg_sidebar_activate(FALSE);
 
 	/**** popup menu ****/



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


More information about the Plugins-Commits mailing list