[anjuta] bgo #605763 - No file found while adding a simple c++ class



commit 9a48b435605508e5715abb7382a3c216c4c56a9a
Author: Sébastien Granjoux <seb sfo free fr>
Date:   Sun Jan 10 10:39:10 2010 +0100

    bgo #605763 -  No file found while adding a simple c++ class

 libanjuta/interfaces/libanjuta.idl |   21 ++++++++++++++++-----
 plugins/class-gen/plugin.c         |   16 +++++++++++++++-
 plugins/file-wizard/file.c         |   10 +++++++++-
 3 files changed, 40 insertions(+), 7 deletions(-)
---
diff --git a/libanjuta/interfaces/libanjuta.idl b/libanjuta/interfaces/libanjuta.idl
index ea98645..f0fadea 100644
--- a/libanjuta/interfaces/libanjuta.idl
+++ b/libanjuta/interfaces/libanjuta.idl
@@ -3302,7 +3302,10 @@ interface IAnjutaProjectManager
 	* @element_uri: fixme
 	* @err: Error propagation and reporting.
 	* 
-	* fixme
+	* Emitted when a new element is added to the project. It can be
+	* a source, a target or a group. The URI does not always correspond
+	* to an existing file. This signal can be emitted several time for
+	* the same element.
 	*/
 	void ::element_added (const gchar *element_uri);
 	
@@ -3461,14 +3464,22 @@ interface IAnjutaProjectManager
 	/**
 	* ianjuta_project_manager_add_sources:
 	* @obj: Self
-	* @source_uris_to_add: fixme
+	* @source_uris_to_add: sources URI to add
 	* @default_location_uri: fixme
 	* @err: Error propagation and reporting.
 	*
-	* Prompt the user to add a file to the project. If the user selects
-	* multiple files only the first uri is returned.
+	* Prompt the user to add a file to the project. Depending on the 
+	* project backend, it can be possible that the source files must
+	* be located in a particular directory. You can pass to this
+	* function relative URI and it will return absolute URI valid
+	* for the target selected by the user.
 	*
-	* Returns: element URIs. Must be freed when no longer required.
+	* You can add non existing file. In this case the element_added
+	* signal will be emitted with a non existing file. So it is
+	* up to the caller to reemit this signal later when the file
+	* is created.
+	*
+	* Returns: absolute element URIs. Must be freed when no longer required.
 	*/
 	List<const gchar*> add_sources (List<const gchar*> source_uris_to_add, const gchar *default_location_uri);
 	
diff --git a/plugins/class-gen/plugin.c b/plugins/class-gen/plugin.c
index f178601..9178c4b 100644
--- a/plugins/class-gen/plugin.c
+++ b/plugins/class-gen/plugin.c
@@ -313,6 +313,8 @@ cg_plugin_generator_created_cb (CgGenerator *generator,
 	{
 		GFile* header = g_file_new_for_path (header_file);
 		GFile* source = g_file_new_for_path (source_file);
+		IAnjutaProjectManager *manager;
+
 		ianjuta_file_loader_load (loader, header, FALSE, NULL);
 		ianjuta_file_loader_load (loader, source, FALSE, NULL);
 
@@ -320,7 +322,19 @@ cg_plugin_generator_created_cb (CgGenerator *generator,
 		{
 			cg_plugin_add_to_repository (plugin, header, source);
 		}
-		
+	
+		manager = anjuta_shell_get_interface (ANJUTA_PLUGIN (plugin)->shell, IAnjutaProjectManager, NULL);
+		if (manager)
+		{
+			gchar *huri = g_file_get_uri (header);
+			gchar *suri = g_file_get_uri (source);
+
+			g_signal_emit_by_name (G_OBJECT (manager), "element_added", huri);
+			g_signal_emit_by_name (G_OBJECT (manager), "element_added", suri);
+			g_free (huri);
+			g_free (suri);
+		}
+
 		g_object_unref (header);
 		g_object_unref (source);
 	}
diff --git a/plugins/file-wizard/file.c b/plugins/file-wizard/file.c
index 3c95607..98c9294 100644
--- a/plugins/file-wizard/file.c
+++ b/plugins/file-wizard/file.c
@@ -351,6 +351,8 @@ on_new_file_okbutton_clicked(GtkWidget *window, GdkEvent *event,
 		
 		if (uri_list)
 		{
+			GList* node;
+
 			/* Save main file */
 			file = g_file_new_for_uri ((const gchar *)uri_list->data);
 			ianjuta_file_savable_save_as (IANJUTA_FILE_SAVABLE (te), file, NULL);		
@@ -373,7 +375,6 @@ on_new_file_okbutton_clicked(GtkWidget *window, GdkEvent *event,
 				if (ivcs)
 				{					
 					GList* files = NULL;
-					GList* node;
 					AnjutaAsyncNotify* notify = anjuta_async_notify_new();
 					for (node = uri_list; node != NULL; node = g_list_next (node))
 					{
@@ -383,6 +384,13 @@ on_new_file_okbutton_clicked(GtkWidget *window, GdkEvent *event,
 					g_list_foreach (files, (GFunc) g_object_unref, NULL);
 				}
 			}
+
+			/* Re emit element_added for symbol-db */
+			for (node = uri_list; node != NULL; node = g_list_next (node))
+			{
+				g_signal_emit_by_name (G_OBJECT (pm), "element_added", node->data);
+			}
+
 			g_list_foreach (uri_list, (GFunc)g_free, NULL);
 			g_list_free (uri_list);
 		}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]