anjuta r4048 - in trunk: . plugins/debug-manager plugins/editor plugins/sourceview plugins/symbol-browser plugins/symbol-db



Author: jhs
Date: Fri Jul  4 18:23:00 2008
New Revision: 4048
URL: http://svn.gnome.org/viewvc/anjuta?rev=4048&view=rev

Log:
2008-07-04  Johannes Schmid  <jhs gnome org>

	* plugins/debug-manager/breakpoints.c (on_editor_saved):
	* plugins/symbol-browser/plugin.c (on_editor_saved):
	* plugins/symbol-db/plugin.c (on_editor_saved):
	Adapted to change in the \"saved\" signal of IAnjutaFile

	* plugins/editor/text_editor.c (text_editor_save_file):
	Fixed #541313 â Crash on saving file
	
	* plugins/sourceview/sourceview.c (on_save_finish):
	Emit \"saved\" signal

Modified:
   trunk/ChangeLog
   trunk/plugins/debug-manager/breakpoints.c
   trunk/plugins/editor/text_editor.c
   trunk/plugins/sourceview/sourceview.c
   trunk/plugins/symbol-browser/plugin.c
   trunk/plugins/symbol-db/plugin.c

Modified: trunk/plugins/debug-manager/breakpoints.c
==============================================================================
--- trunk/plugins/debug-manager/breakpoints.c	(original)
+++ trunk/plugins/debug-manager/breakpoints.c	Fri Jul  4 18:23:00 2008
@@ -490,12 +490,18 @@
 }
 
 static void
-on_editor_saved (IAnjutaEditor *editor, const gchar* uri, BreakpointsDBase *bd)
+on_editor_saved (IAnjutaEditor *editor, GFile* file, BreakpointsDBase *bd)
 {
 	GtkTreeIter iter;
 	GtkTreeModel *model = GTK_TREE_MODEL (bd->model);
+	gchar* uri;
 	
 	g_return_if_fail (model != NULL);
+	
+	if (!file)
+		return;
+	uri = g_file_get_uri (file);
+	
 	/* Update breakpoint position */
 	if (gtk_tree_model_get_iter_first (model, &iter))
 	{
@@ -518,6 +524,7 @@
 			}	
 		} while (gtk_tree_model_iter_next (model, &iter));
 	}
+	g_free (uri);
 }
 
 static void

Modified: trunk/plugins/editor/text_editor.c
==============================================================================
--- trunk/plugins/editor/text_editor.c	(original)
+++ trunk/plugins/editor/text_editor.c	Fri Jul  4 18:23:00 2008
@@ -1049,31 +1049,31 @@
 	unsigned char c; /* unix-char */
 	unsigned char b; /* dos-char */
 } tr_dos[]= {
-	{ 'ä 0x84 },
-	{ 'Ä, 0x8e },
-	{ 'ß, 0xe1 },
-	{ 'ü81 },
-	{ 'Ü, 0x9a },
-	{ 'ö0x94 },
-	{ 'Ö, 0x99 },
-	{ 'é 0x82 },
-	{ 'É, 0x90 },
-	{ 'è 0x9a },
-	{ 'È, 0xd4 },
-	{ 'ê 0x88 },
-	{ 'Ê, 0xd2 },
-	{ 'á 0xa0 },
-	{ 'Á, 0xb5 },
-	{ 'à 0x85 },
-	{ 'À, 0xb7 },
-	{ 'â 0x83 },
-	{ 'Â, 0xb6 },
-	{ 'úxa3 },
-	{ 'Ú, 0xe9 },
-	{ 'ùx97 },
-	{ 'Ù, 0xeb },
-	{ 'ûx96 },
-	{ 'Û, 0xea }
+	{ 'Ã', 0x84 },
+	{ 'Ã', 0x8e },
+	{ 'Ã', 0xe1 },
+	{ 'Ã', 0x81 },
+	{ 'Ã', 0x9a },
+	{ 'Ã', 0x94 },
+	{ 'Ã', 0x99 },
+	{ 'Ã', 0x82 },
+	{ 'Ã', 0x90 },
+	{ 'Ã', 0x9a },
+	{ 'Ã', 0xd4 },
+	{ 'Ã', 0x88 },
+	{ 'Ã', 0xd2 },
+	{ 'Ã', 0xa0 },
+	{ 'Ã', 0xb5 },
+	{ 'Ã', 0x85 },
+	{ 'Ã', 0xb7 },
+	{ 'Ã', 0x83 },
+	{ 'Ã', 0xb6 },
+	{ 'Ã', 0xa3 },
+	{ 'Ã', 0xe9 },
+	{ 'Ã', 0x97 },
+	{ 'Ã', 0xeb },
+	{ 'Ã', 0x96 },
+	{ 'Ã', 0xea }
 };
 
 /*
@@ -1543,11 +1543,9 @@
 gboolean
 text_editor_save_file (TextEditor * te, gboolean update)
 {
-	gboolean ret = FALSE;
-	gchar *save_uri;
-	gboolean result;
 	GtkWindow *parent;
 	GError *error = NULL;
+	gboolean ret = FALSE;
 	
 	if (te == NULL)
 		return FALSE;
@@ -1561,93 +1559,28 @@
 	anjuta_status (te->status, _("Saving file..."), 5); 
 	text_editor_update_monitor (te, TRUE);
 	
-	save_uri = g_strconcat (te->uri, "~", NULL);
-	result = save_to_file (te, save_uri, &error);
-	if (!result)
-	{
-		GFile *gio_uri;
-		
+	if (!save_to_file (te, te->uri, &error))
+	{	
 		text_editor_thaw (te);
 		anjuta_util_dialog_error (parent,
 								  _("Could not save intermediate file %s: %s"),
-								  save_uri,
+								  te->uri,
 								  error->message);
-		
-		gio_uri = g_file_new_for_uri (save_uri);
-		g_file_delete (gio_uri, NULL, NULL);
-		
-		g_object_unref (gio_uri);
 		g_error_free (error);
 	}
 	else
 	{
-		GFile *src_gio;
-		GFile *dest_gio;
-		GFileInfo *info;
-		gboolean have_info;
-		char *dest_uri;
-
-		dest_uri = te->uri; 
-		
-		/* have_info is FALSE on newly created file */	
-		DEBUG_PRINT ("MY_TEST dest_uri: %s", dest_uri);
-
-		src_gio = g_file_new_for_uri (save_uri);
-		dest_gio = g_file_new_for_uri (te->uri);
-
-		have_info = g_file_query_exists (dest_gio, NULL);
-		if (have_info)
-		{
-			info = g_file_info_new ();
-			g_file_info_set_name (info, dest_uri);
-			g_file_info_get_is_symlink (info);
-			{
-				dest_uri = g_file_info_get_symlink_target (info);
-				g_object_unref (dest_gio);
-				dest_gio = g_file_new_for_uri (dest_uri);
-			}
-			g_object_unref (info);
-		}
-
-		/* Move 'file~' to 'file' */
-		
-		result = g_file_move (src_gio, dest_gio, G_FILE_COPY_OVERWRITE, 
-								NULL, NULL, NULL, &error);
-
+		GFile* file = g_file_new_for_uri (te->uri);
 		/* we need to update UI with the call to scintilla */
 		text_editor_thaw (te);
-		if (!result)
-		{
-			anjuta_util_dialog_error (parent,
-				_("Could not save file %s: %s."),
-				te->uri,
-				error->message);
-
-			if (have_info)
-			{
-				if (error->code == G_IO_ERROR_PERMISSION_DENIED)
-				{
-					anjuta_util_dialog_warning (parent,
-						_("Could not set file permissions %s: %s."),
-						te->uri,
-						error->message);
-				}
-			}
-			g_error_free (error);
-		}
-		else
-		{
-			scintilla_send_message (SCINTILLA (te->scintilla),
-									SCI_SETSAVEPOINT, 0, 0);
-			g_signal_emit_by_name (G_OBJECT (te), "saved", te->uri);
-			anjuta_status (te->status, _("File saved successfully"), 5);
-			ret = TRUE;
-		}
-		g_object_unref (src_gio);
-		g_object_unref (dest_gio);
+		scintilla_send_message (SCINTILLA (te->scintilla),
+								SCI_SETSAVEPOINT, 0, 0);
+		g_signal_emit_by_name (G_OBJECT (te), "saved", file);
+		g_object_unref (file);
+		anjuta_status (te->status, _("File saved successfully"), 5);
+		ret = TRUE;
 	}
 	text_editor_update_monitor (te, FALSE);
-	g_free (save_uri);
 
 	return ret;
 }

Modified: trunk/plugins/sourceview/sourceview.c
==============================================================================
--- trunk/plugins/sourceview/sourceview.c	(original)
+++ trunk/plugins/sourceview/sourceview.c	Fri Jul  4 18:23:00 2008
@@ -424,8 +424,11 @@
 static void on_save_finish(SourceviewIO* sio, Sourceview* sv)
 {	
 	const gchar* lang;
+	GFile* file = sourceview_io_get_file(sio);
 	gtk_text_buffer_set_modified(GTK_TEXT_BUFFER(sv->priv->document), FALSE);
+	g_signal_emit_by_name(G_OBJECT(sv), "saved", file);
 	g_signal_emit_by_name(G_OBJECT(sv), "save_point", TRUE);
+	g_object_unref (file);
 	/* Autodetect language */
 	ianjuta_editor_language_set_language(IANJUTA_EDITOR_LANGUAGE(sv), NULL, NULL);
 	lang = ianjuta_editor_language_get_language(IANJUTA_EDITOR_LANGUAGE(sv), NULL);

Modified: trunk/plugins/symbol-browser/plugin.c
==============================================================================
--- trunk/plugins/symbol-browser/plugin.c	(original)
+++ trunk/plugins/symbol-browser/plugin.c	Fri Jul  4 18:23:00 2008
@@ -625,7 +625,7 @@
 }
 
 static void
-on_editor_saved (IAnjutaEditor *editor, const gchar *saved_uri,
+on_editor_saved (IAnjutaEditor *editor, GFile* file,
 				 SymbolBrowserPlugin *sv_plugin)
 {
 	const gchar *old_uri;
@@ -638,13 +638,18 @@
 	/* tags_update =
 		anjuta_preferences_get_int (te->preferences, AUTOMATIC_TAGS_UPDATE);
 	*/
+	
+	if (!file)
+		return;
+	
 	tags_update = TRUE;
 	if (tags_update)
 	{
 		gchar *local_filename;
+		gchar *saved_uri = g_file_get_uri (file);
 		
 		/* Verify that it's local file */
-		local_filename = gnome_vfs_get_local_path_from_uri (saved_uri);
+		local_filename = g_file_get_path (file);
 		g_return_if_fail (local_filename != NULL);
 		g_free (local_filename);
 		
@@ -674,6 +679,7 @@
 								 file_symbol_model);
 		sv_plugin->locals_line_number = 0;
 		on_editor_update_ui (editor, sv_plugin);
+		g_free (saved_uri);
 
 #if 0
 		/* FIXME: Re-hilite all editors on tags update */

Modified: trunk/plugins/symbol-db/plugin.c
==============================================================================
--- trunk/plugins/symbol-db/plugin.c	(original)
+++ trunk/plugins/symbol-db/plugin.c	Fri Jul  4 18:23:00 2008
@@ -247,17 +247,16 @@
 	
 	/* Update when the user enters a newline */
 	if (ch == '\n')	
-		need_symbols_update = TRUE;	
+		need_symbols_update = TRUE;
 }
 
 
 static void
-on_editor_saved (IAnjutaEditor *editor, const gchar *saved_uri,
+on_editor_saved (IAnjutaEditor *editor, GFile* file,
 				 SymbolDBPlugin *sdb_plugin)
 {
 	const gchar *old_uri;
-	gboolean tags_update;
-	
+	gboolean tags_update;	
 	/* FIXME: Do this only if automatic tags update is enabled */
 	/* tags_update =
 		anjuta_preferences_get_int (te->preferences, AUTOMATIC_TAGS_UPDATE);
@@ -265,11 +264,11 @@
 	tags_update = TRUE;
 	if (tags_update)
 	{
-		gchar *local_filename;
+		gchar *local_filename = g_file_get_path (file);
+		gchar *saved_uri = g_file_get_uri (file);
 		GPtrArray *files_array;
 
 		/* Verify that it's local file */
-		local_filename = gnome_vfs_get_local_path_from_uri (saved_uri);
 		g_return_if_fail (local_filename != NULL);
 
 		files_array = g_ptr_array_new();		
@@ -292,6 +291,8 @@
 							 g_strdup (saved_uri));
 
 		on_editor_update_ui (editor, sdb_plugin);
+		g_free (local_filename);
+		g_free (saved_uri);
 	}
 }
 



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