document-manager patch



Hi Dave,

This patch fixes a bug wrt the untitled flag on a document not being
reset and the uri_changed signal not being emitted. It also fixes the
bug where if you save a file and that file is smaller than the current
one, the file wasn't being truncated first which caused data from the
old version to remain.

OK to commit?

Jeroen


Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/anjuta2/ChangeLog,v
retrieving revision 1.216
diff -u -r1.216 ChangeLog
--- ChangeLog	11 Jun 2002 17:26:58 -0000	1.216
+++ ChangeLog	23 Jun 2002 15:31:54 -0000
@@ -1,3 +1,14 @@
+2002-06-23  Jeroen Zwartepoorte  <jeroen xs4all nl>
+
+	* plugins/document-manager/anjuta-document-manager.c:
+	(docman_doc_uri_changed): Emit uri_changed signal if uri changed (when
+	saving an untitled file for example).
+	* plugins/document-manager/anjuta-document.c:
+	(anjuta_bonobo_document_save_uri), (save_uri_from_control): Update
+	untitled flag on document & decrease untitled_count. Truncate file
+	before saving the document, otherwise data from last revision remains if
+	new file is smaller than the old one.
+
 2002-06-11  Dirk Vangestel <dirkvg linux be>
 
 	* src/window.c (anjuta_window_get_value): only init type if not already
Index: plugins/document-manager/anjuta-document-manager.c
===================================================================
RCS file: /cvs/gnome/anjuta2/plugins/document-manager/anjuta-document-manager.c,v
retrieving revision 1.22
diff -u -r1.22 anjuta-document-manager.c
--- plugins/document-manager/anjuta-document-manager.c	9 Jun 2002 00:30:20 -0000	1.22
+++ plugins/document-manager/anjuta-document-manager.c	23 Jun 2002 15:31:55 -0000
@@ -583,6 +583,11 @@
 		
                 set_doc_label (docman, document, basename);
 		g_free (basename);
+
+		if (ANJUTA_BONOBO_DOCUMENT (document)->untitled) {
+			ANJUTA_BONOBO_DOCUMENT (document)->untitled = FALSE;
+			docman->priv->untitled_count--;
+		}
         }
 }
 
Index: plugins/document-manager/anjuta-document.c
===================================================================
RCS file: /cvs/gnome/anjuta2/plugins/document-manager/anjuta-document.c,v
retrieving revision 1.49
diff -u -r1.49 anjuta-document.c
--- plugins/document-manager/anjuta-document.c	8 Jun 2002 23:12:14 -0000	1.49
+++ plugins/document-manager/anjuta-document.c	23 Jun 2002 15:31:56 -0000
@@ -209,12 +209,14 @@
 {
 	const char *mime_type;
 	char *uri_cpy;
+	gboolean uri_changed = TRUE;
 
 	/* There's a pretty good chance the uri passed in was the uri
 	 * we are about to free, so we save a copy */
 	uri_cpy = g_strdup (uri);
 
 	if (document->uri) {
+		uri_changed = strcmp (document->uri, uri_cpy);
 		g_free (document->uri);
 	}
 	document->uri = g_strdup (uri_cpy);
@@ -226,6 +228,8 @@
 	mime_type = gnome_vfs_get_mime_type (uri_cpy);
 	if (strcmp (document->mime_type, mime_type)) {
 		load_uri (document, uri_cpy);
+	} else if (uri_changed) {
+		g_signal_emit_by_name (document, "uri_changed", document->uri);
 	}
 
 	g_free (uri_cpy);
@@ -707,7 +711,9 @@
 		 g_warning ("The loaded component does not support Bonobo::PersistStream");
 	 } else {
 		 BonoboStreamVfs *stream;
-		 
+
+		gnome_vfs_truncate (uri, 0);
+
 		 stream = bonobo_stream_vfs_open (uri,
 						  Bonobo_Storage_WRITE,
 						  &ev);


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