anjuta r4351 - in trunk: . libanjuta/interfaces plugins/file-wizard plugins/project-manager



Author: sgranjoux
Date: Sat Oct 18 20:08:30 2008
New Revision: 4351
URL: http://svn.gnome.org/viewvc/anjuta?rev=4351&view=rev

Log:
	* plugins/project-manager/plugin.c,
	plugins/file-wizard/file.c,
	libanjuta/interfaces/libanjuta.idl:
	Fix #545668 - new file are not added correctly to the project


Modified:
   trunk/ChangeLog
   trunk/libanjuta/interfaces/libanjuta.idl
   trunk/plugins/file-wizard/file.c
   trunk/plugins/project-manager/plugin.c

Modified: trunk/libanjuta/interfaces/libanjuta.idl
==============================================================================
--- trunk/libanjuta/interfaces/libanjuta.idl	(original)
+++ trunk/libanjuta/interfaces/libanjuta.idl	Sat Oct 18 20:08:30 2008
@@ -2978,8 +2978,8 @@
 	/**
 	* ianjuta_project_manager_add_source:
 	* @obj: Self
-	* @source_uri_to_add: fixme
-	* @default_location_uri: fixme
+	* @source_uri_to_add: Target name or uri
+	* @default_location_uri: Default source location or NULL if don't care
 	* @err: Error propagation and reporting.
 	*
 	* Prompt the user to add a file to the project. If the user selects

Modified: trunk/plugins/file-wizard/file.c
==============================================================================
--- trunk/plugins/file-wizard/file.c	(original)
+++ trunk/plugins/file-wizard/file.c	Sat Oct 18 20:08:30 2008
@@ -31,10 +31,8 @@
 #include <string.h>
 #include <time.h>
 
-#include <gnome.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs.h>
 #include <libanjuta/interfaces/ianjuta-file.h>
+#include <libanjuta/interfaces/ianjuta-file-savable.h>
 #include <libanjuta/interfaces/ianjuta-document-manager.h>
 #include <libanjuta/interfaces/ianjuta-macro.h>
 #include <libanjuta/interfaces/ianjuta-file.h>
@@ -222,41 +220,6 @@
 	return TRUE;
 }
 
-static gboolean
-confirm_file_overwrite (AnjutaPlugin* plugin, const gchar *uri)
-{
-	GnomeVFSURI *vfs_uri;
-	gboolean ret = TRUE;
-	
-	vfs_uri = gnome_vfs_uri_new (uri);
-	if (gnome_vfs_uri_exists (vfs_uri))
-	{
-		GtkWidget *dialog;
-		gint res;
-		dialog = gtk_message_dialog_new (GTK_WINDOW (ANJUTA_PLUGIN (plugin)->shell),
-										 GTK_DIALOG_DESTROY_WITH_PARENT,
-										 GTK_MESSAGE_QUESTION,
-										 GTK_BUTTONS_NONE,
-										 _("The file '%s' already exists.\n"
-										   "Do you want to replace it with the "
-										   "one you are saving?"),
-										 uri);
-		gtk_dialog_add_button (GTK_DIALOG(dialog),
-							   GTK_STOCK_CANCEL,
-							   GTK_RESPONSE_CANCEL);
-		anjuta_util_dialog_add_button (GTK_DIALOG (dialog),
-								  _("_Replace"),
-								  GTK_STOCK_REFRESH,
-								  GTK_RESPONSE_YES);
-		res = gtk_dialog_run (GTK_DIALOG (dialog));
-		gtk_widget_destroy (dialog);
-		if (res != GTK_RESPONSE_YES)
-			ret = FALSE;
-	}
-	gnome_vfs_uri_unref (vfs_uri);
-	return ret;
-}
-
 gboolean
 on_new_file_okbutton_clicked(GtkWidget *window, GdkEvent *event,
 			                 gboolean user_data)
@@ -281,12 +244,18 @@
 		                       IAnjutaMacro, NULL);
 	entry = glade_xml_get_widget(nfg->xml, NEW_FILE_ENTRY);
 	name = gtk_entry_get_text(GTK_ENTRY(entry));
+
+	if (name && strlen (name) > 0)
+		te = ianjuta_document_manager_add_buffer (docman, name, NULL, NULL);
+	else
+		te = ianjuta_document_manager_add_buffer (docman, "", NULL, NULL);
+	if (te == NULL)
+		return FALSE;
 	
 	if (nfg->plugin->top_dir &&
 		gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (nfg->add_to_project)))
 	{
 		IAnjutaProjectManager *pm;
-		GnomeVFSHandle *vfs_write;
 		gchar* file_uri;
 		GFile* file;
 		
@@ -294,32 +263,15 @@
 										 IAnjutaProjectManager, NULL);
 		g_return_val_if_fail (pm != NULL, FALSE);
 		
-		file_uri = ianjuta_project_manager_add_source (pm, name, "", NULL);
+		file_uri = ianjuta_project_manager_add_source (pm, name, NULL, NULL);
 		if (!file_uri)
 			return FALSE;
-		
+	
 		/* Create empty file */
-		if (!confirm_file_overwrite (ANJUTA_PLUGIN (nfg->plugin), file_uri) ||
-			gnome_vfs_create (&vfs_write, file_uri, GNOME_VFS_OPEN_WRITE,
-							  FALSE, 0664) != GNOME_VFS_OK ||
-			gnome_vfs_close(vfs_write) != GNOME_VFS_OK)
-		{
-			g_free (file_uri);
-			return FALSE;
-		}
 		file = g_file_new_for_uri (file_uri);
-		ianjuta_file_open (IANJUTA_FILE (docman), file, NULL);
-		g_free (file_uri);
+		ianjuta_file_savable_save_as (IANJUTA_FILE_SAVABLE (te), file, NULL);
 		g_object_unref (file);
-	}
-	else
-	{
-		if (name && strlen (name) > 0)
-			te = ianjuta_document_manager_add_buffer (docman, name, "", NULL);
-		else
-			te = ianjuta_document_manager_add_buffer (docman, "", "", NULL);
-		if (te == NULL)
-			return FALSE;
+		g_free (file_uri);
 	}
 	
 	optionmenu = glade_xml_get_widget(nfg->xml, NEW_FILE_TYPE);

Modified: trunk/plugins/project-manager/plugin.c
==============================================================================
--- trunk/plugins/project-manager/plugin.c	(original)
+++ trunk/plugins/project-manager/plugin.c	Sat Oct 18 20:08:30 2008
@@ -1708,13 +1708,14 @@
 	ptr = strrchr (path, ':');
 	if (ptr)
 	{
+		*ptr = '\0';
 		if (ptr[1] == '/')
 		{
 			 /* ID is source ID, extract source uri */
-			ptr = strrchr (ptr, ':');
-			return g_strdup (ptr+1);
+			uri = strrchr (path, ':');		/* keep uri scheme */
+			*ptr = ':';
+			return g_strdup (uri+1);
 		}
-		*ptr = '\0';
 	}
 	
 	anjuta_shell_get (ANJUTA_PLUGIN (plugin)->shell,
@@ -2161,10 +2162,17 @@
 	g_return_val_if_fail (GBF_IS_PROJECT (plugin->project), FALSE);
 
 	update_operation_begin (plugin);
-	default_location_type =
-		ianjuta_project_manager_get_element_type (project_manager,
-												  default_location_uri, NULL);
-	location_id = get_element_id_from_uri (plugin, default_location_uri);
+	if (default_location_uri == NULL)
+	{
+		default_location_type = IANJUTA_PROJECT_MANAGER_UNKNOWN;
+	}
+	else
+	{
+		default_location_type =
+			ianjuta_project_manager_get_element_type (project_manager,
+													  default_location_uri, NULL);
+		location_id = get_element_id_from_uri (plugin, default_location_uri);
+	}
 	if (default_location_type == IANJUTA_PROJECT_MANAGER_GROUP)
 	{
 		source_id = gbf_project_util_add_source (plugin->model,



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