All pastes #29957 Raw Edit

Something

public text v1 · immutable
#29957 ·published 2005-11-21 14:07 UTC
rendered paste body
Index: bindings/python/gedit.defs
===================================================================
RCS file: /cvs/gnome/gedit/bindings/python/Attic/gedit.defs,v
retrieving revision 1.1.2.7
diff -u -p -r1.1.2.7 gedit.defs
--- bindings/python/gedit.defs	6 Nov 2005 11:56:14 -0000	1.1.2.7
+++ bindings/python/gedit.defs	21 Nov 2005 13:54:28 -0000
@@ -118,29 +118,28 @@
   (return-type "GeditDocument*")
 )
 
-
-(define-method get_uri_
+(define-method get_uri
   (of-object "GeditDocument")
-  (c-name "gedit_document_get_uri_")
-  (return-type "const-gchar*")
+  (c-name "gedit_document_get_uri")
+  (return-type "gchar*")
 )
 
 (define-method get_uri_for_display
   (of-object "GeditDocument")
   (c-name "gedit_document_get_uri_for_display")
-  (return-type "const-gchar*")
+  (return-type "gchar*")
 )
 
 (define-method get_short_name_for_display
   (of-object "GeditDocument")
   (c-name "gedit_document_get_short_name_for_display")
-  (return-type "const-gchar*")
+  (return-type "gchar*")
 )
 
 (define-method get_mime_type
   (of-object "GeditDocument")
   (c-name "gedit_document_get_mime_type")
-  (return-type "const-gchar*")
+  (return-type "gchar*")
 )
 
 (define-method get_readonly
Index: gedit/gedit-commands-file.c
===================================================================
RCS file: /cvs/gnome/gedit/gedit/Attic/gedit-commands-file.c,v
retrieving revision 1.1.2.6
diff -u -p -r1.1.2.6 gedit-commands-file.c
--- gedit/gedit-commands-file.c	17 Oct 2005 09:45:13 -0000	1.1.2.6
+++ gedit/gedit-commands-file.c	21 Nov 2005 13:54:35 -0000
@@ -165,14 +165,19 @@ load_file_list (GeditWindow         *win
 		if (loaded_files == 1)
 		{
 			GeditDocument *doc;
+			gchar *uri_for_display;
 
 			g_return_val_if_fail (tab != NULL, loaded_files);
 
 			doc = gedit_tab_get_document (tab);
+			uri_for_display = gedit_document_get_uri_for_display (doc);
+
 			gedit_statusbar_flash_message (GEDIT_STATUSBAR (window->priv->statusbar),
 						       window->priv->generic_message_cid,
 						       _("Loading file '%s'\342\200\246"),
-						       gedit_document_get_uri_for_display (doc));
+						       uri_for_display);
+
+			g_free (uri_for_display);
 		}
 		else
 		{
@@ -301,9 +306,9 @@ gedit_cmd_file_open (GtkAction   *action
 	doc = gedit_window_get_active_document (window);
 	if (doc != NULL)
 	{
-		const gchar *uri;
+		gchar *uri;
 
-		uri = gedit_document_get_uri_ (doc);
+		uri = gedit_document_get_uri (doc);
 
 		if ((uri != NULL) &&
 		    gedit_utils_uri_has_file_scheme (uri))
@@ -318,6 +323,8 @@ gedit_cmd_file_open (GtkAction   *action
 				default_path = g_strdup ("file:///");
 			}
 		}
+
+		g_free (uri);
 	}
 
 	if (default_path == NULL)
@@ -725,7 +732,7 @@ file_save_as (GeditTab    *tab,
 
 	/* Set the suggested file name */
 	doc = gedit_tab_get_document (tab);
-	uri = gedit_document_get_uri_ (doc);
+	uri = gedit_document_get_uri (doc);
 
 	if ((uri != NULL) &&
 	    gedit_utils_uri_has_file_scheme (uri))
@@ -734,18 +741,24 @@ file_save_as (GeditTab    *tab,
 						    uri);
 	}
 
+	g_free (uri);
+
 	if (!uri_set)
 	{
 		const gchar *default_path;
+		gchar *docname;
 
 		default_path = _gedit_window_get_default_path (window);
+		docname = gedit_document_get_short_name_for_display (doc);
 
 		if (default_path != NULL)
 			gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (save_dialog),
 								 default_path);
 
 		gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (save_dialog),
-						   gedit_document_get_short_name_for_display (doc));
+						   docname);
+
+		g_free (docname);
 	}
 
 	/* Set suggested encoding */
@@ -773,6 +786,7 @@ file_save (GeditTab    *tab,
 	   GeditWindow *window)
 {
 	GeditDocument *doc;
+	gchar *uri_for_display;
 
 	gedit_debug (DEBUG_COMMANDS);
 
@@ -789,10 +803,13 @@ file_save (GeditTab    *tab,
 		return file_save_as (tab, window);
 	}
 
+	uri_for_display = gedit_document_get_uri_for_display (doc);
 	gedit_statusbar_flash_message (GEDIT_STATUSBAR (window->priv->statusbar),
 				        window->priv->generic_message_cid,
 				       _("Saving file '%s'\342\200\246"),
-				       gedit_document_get_uri_for_display (doc));
+				       uri_for_display);
+
+	g_free (uri_for_display);
 
 	_gedit_tab_save (tab);
 }
@@ -898,10 +915,14 @@ gedit_cmd_file_save_all (GtkAction   *ac
 			   - GEDIT_TAB_STATE_CLOSING: this state is invalid in this case
 			*/
 
+			gchar *uri_for_display;
+
+			uri_for_display = gedit_document_get_uri_for_display (doc);
 			gedit_debug_message (DEBUG_COMMANDS,
 					     "File '%s' not saved. State: %d",
-					     gedit_document_get_uri_for_display (doc),
+					     uri_for_display,
 					     state);
+			g_free (uri_for_display);
 		}
 
 		l = g_list_next (l);
@@ -935,8 +956,9 @@ revert_dialog_response_cb (GtkDialog    
 			   gint           response_id,
 			   GeditWindow   *window)
 {
-	GeditTab      *tab;
+	GeditTab *tab;
 	GeditDocument *doc;
+	gchar *docname;
 
 	gedit_debug (DEBUG_COMMANDS);
 
@@ -955,12 +977,14 @@ revert_dialog_response_cb (GtkDialog    
 	}
 
 	doc = gedit_tab_get_document (tab);
+	docname = gedit_document_get_short_name_for_display (doc);
 
 	gedit_statusbar_flash_message (GEDIT_STATUSBAR (window->priv->statusbar),
 				        window->priv->generic_message_cid,
 				       _("Reverting the document '%s'\342\200\246"),
-				       gedit_document_get_short_name_for_display (doc));
+				       docname);
 
+	g_free (docname);
 	gtk_widget_destroy (GTK_WIDGET (dialog));
 
 	_gedit_tab_revert (tab);
@@ -971,14 +995,17 @@ revert_dialog (GeditWindow   *window,
 	       GeditDocument *doc)
 {
 	GtkWidget *dialog;
-	gchar     *primary_msg;
-	gchar     *secondary_msg;
-	glong      seconds;
+	gchar *docname;
+	gchar *primary_msg;
+	gchar *secondary_msg;
+	glong seconds;
 
 	gedit_debug (DEBUG_COMMANDS);
 
+	docname = gedit_document_get_short_name_for_display (doc);
 	primary_msg = g_strdup_printf (_("Revert unsaved changes to document '%s'?"),
-	                               gedit_document_get_short_name_for_display (doc));
+	                               docname);
+	g_free (docname);
 
 	seconds = MAX (1, _gedit_document_get_seconds_since_last_save_or_load (doc));
 
Index: gedit/gedit-document.c
===================================================================
RCS file: /cvs/gnome/gedit/gedit/gedit-document.c,v
retrieving revision 1.111.2.51
diff -u -p -r1.111.2.51 gedit-document.c
--- gedit/gedit-document.c	10 Nov 2005 15:36:19 -0000	1.111.2.51
+++ gedit/gedit-document.c	21 Nov 2005 13:54:43 -0000
@@ -89,10 +89,7 @@ struct _GeditDocumentPrivate
 	gchar	    *uri;
 	gint 	     untitled_number;
 
-	/* Cached data */
 	GnomeVFSURI *vfs_uri;
-	gchar	    *uri_for_display;
-	gchar	    *short_name_for_display;
 
 	const GeditEncoding *encoding;
 
@@ -245,8 +242,6 @@ gedit_document_finalize (GObject *object
 		gnome_vfs_uri_unref (doc->priv->vfs_uri);
 
 	g_free (doc->priv->mime_type);
-	g_free (doc->priv->uri_for_display);
-	g_free (doc->priv->short_name_for_display);
 
 	if (doc->priv->loader)
 		g_object_unref (doc->priv->loader);
@@ -267,13 +262,13 @@ gedit_document_get_property (GObject    
 	switch (prop_id)
 	{
 		case PROP_URI:
-			g_value_set_string (value, gedit_document_get_uri_ (doc));
+			g_value_set_string (value, doc->priv->uri);
 			break;
 		case PROP_SHORTNAME:
-			g_value_set_string (value, gedit_document_get_short_name_for_display (doc));
+			g_value_take_string (value, gedit_document_get_short_name_for_display (doc));
 			break;
 		case PROP_MIME_TYPE:
-			g_value_set_string (value, gedit_document_get_mime_type (doc));
+			g_value_set_string (value, doc->priv->mime_type);
 			break;
 		case PROP_READ_ONLY:
 			g_value_set_boolean (value, doc->priv->readonly);
@@ -544,91 +539,6 @@ set_encoding (GeditDocument       *doc, 
 	g_object_notify (G_OBJECT (doc), "encoding");
 }
 
-static gchar *
-get_uri_shortname_for_display (GnomeVFSURI *uri)
-{
-	gchar    *name;	
-	gboolean  validated;
-
-	validated = FALSE;
-	name = gnome_vfs_uri_extract_short_name (uri);
-	
-	if (name == NULL)
-	{
-		name = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_PASSWORD);
-	}
-	else if (g_ascii_strcasecmp (uri->method_string, "file") == 0)
-	{
-		gchar *text_uri;
-		gchar *local_file;
-		text_uri = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_PASSWORD);
-		local_file = gnome_vfs_get_local_path_from_uri (text_uri);
-		
-		if (local_file != NULL)
-		{
-			g_free (name);
-			name = g_filename_display_basename (local_file);
-			validated = TRUE;
-		}
-		
-		g_free (local_file);
-		g_free (text_uri);
-	} 
-	else if (!gnome_vfs_uri_has_parent (uri)) 
-	{
-		const gchar *method;
-		
-		method = uri->method_string;
-		
-		if (name == NULL ||
-		    strcmp (name, GNOME_VFS_URI_PATH_STR) == 0) 
-		{
-			g_free (name);
-			name = g_strdup (method);
-		} 
-		/*
-		else 
-		{
-			gchar *tmp;
-			
-			tmp = name;
-			name = g_strdup_printf ("%s: %s", method, name);
-			g_free (tmp);
-		}
-		*/
-	}
-
-	if (!validated && !g_utf8_validate (name, -1, NULL)) 
-	{
-		gchar *utf8_name;
-		
-		utf8_name = gedit_utils_make_valid_utf8 (name);
-		g_free (name);
-		name = utf8_name;
-	}
-
-	return name;
-}
-
-static void
-update_uri_for_display (GeditDocument *doc)
-{
-	g_free (doc->priv->uri_for_display);
-	g_free (doc->priv->short_name_for_display);
-
-	if (doc->priv->uri == NULL)
-	{
-		doc->priv->uri_for_display = g_strdup_printf (_("Unsaved Document %d"),  
-							      doc->priv->untitled_number);	      
-		doc->priv->short_name_for_display = g_strdup (doc->priv->uri_for_display);
-	}
-	else
-	{
-		doc->priv->uri_for_display = gnome_vfs_format_uri_for_display (doc->priv->uri);
-		doc->priv->short_name_for_display = get_uri_shortname_for_display (doc->priv->vfs_uri);
-	}
-}
-
 static void
 gedit_document_init (GeditDocument *doc)
 {
@@ -640,8 +550,6 @@ gedit_document_init (GeditDocument *doc)
 	doc->priv->vfs_uri = NULL;
 	doc->priv->untitled_number = get_untitled_number ();
 
-	update_uri_for_display (doc);
-
 	doc->priv->mime_type = g_strdup ("text/plain");
 
 	doc->priv->readonly = FALSE;
@@ -711,9 +619,6 @@ set_uri (GeditDocument *doc,
 			release_untitled_number (doc->priv->untitled_number);
 			doc->priv->untitled_number = 0;
 		}
-
-		/* Update uri_for_display and short_name_for_display */
-		update_uri_for_display (doc);
 	}
 
 	g_return_if_fail (doc->priv->vfs_uri != NULL);
@@ -774,46 +679,120 @@ set_uri (GeditDocument *doc,
 
 		set_language (doc, language, FALSE);
 	}
-	
+
 	g_object_notify (G_OBJECT (doc), "uri");
+	g_object_notify (G_OBJECT (doc), "shortname");
 }
 
-const gchar *
-gedit_document_get_uri_ (GeditDocument *doc)
+gchar *
+gedit_document_get_uri (GeditDocument *doc)
 {
 	g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), NULL);
-	
-	return doc->priv->uri;
+
+	return g_strdup (doc->priv->uri);
 }
 
 /* Never returns NULL */
-const gchar *
+gchar *
 gedit_document_get_uri_for_display (GeditDocument *doc)
 {
 	g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), "");
-	g_return_val_if_fail (doc->priv->uri_for_display != NULL, "");
 
-	return doc->priv->uri_for_display;
+	if (doc->priv->uri == NULL)
+		return g_strdup_printf (_("Unsaved Document %d"),
+					doc->priv->untitled_number);	      
+	else
+		return gnome_vfs_format_uri_for_display (doc->priv->uri);
+}
+
+/* move to gedit-utils? */
+static gchar *
+get_uri_shortname_for_display (GnomeVFSURI *uri)
+{
+	gchar *name;	
+	gboolean  validated;
+
+	validated = FALSE;
+	name = gnome_vfs_uri_extract_short_name (uri);
+
+	if (name == NULL)
+	{
+		name = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_PASSWORD);
+	}
+	else if (g_ascii_strcasecmp (uri->method_string, "file") == 0)
+	{
+		gchar *text_uri;
+		gchar *local_file;
+		text_uri = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_PASSWORD);
+		local_file = gnome_vfs_get_local_path_from_uri (text_uri);
+
+		if (local_file != NULL)
+		{
+			g_free (name);
+			name = g_filename_display_basename (local_file);
+			validated = TRUE;
+		}
+
+		g_free (local_file);
+		g_free (text_uri);
+	} 
+	else if (!gnome_vfs_uri_has_parent (uri)) 
+	{
+		const gchar *method;
+
+		method = uri->method_string;
+
+		if (name == NULL ||
+		    strcmp (name, GNOME_VFS_URI_PATH_STR) == 0) 
+		{
+			g_free (name);
+			name = g_strdup (method);
+		} 
+		/*
+		else 
+		{
+			gchar *tmp;
+
+			tmp = name;
+			name = g_strdup_printf ("%s: %s", method, name);
+			g_free (tmp);
+		}
+		*/
+	}
+
+	if (!validated && !g_utf8_validate (name, -1, NULL)) 
+	{
+		gchar *utf8_name;
+
+		utf8_name = gedit_utils_make_valid_utf8 (name);
+		g_free (name);
+		name = utf8_name;
+	}
+
+	return name;
 }
 
 /* Never returns NULL */
-const gchar *
+gchar *
 gedit_document_get_short_name_for_display (GeditDocument *doc)
 {
 	g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), "");
-	g_return_val_if_fail (doc->priv->short_name_for_display != NULL, "");
-	
- 	return doc->priv->short_name_for_display;
+
+	if (doc->priv->uri == NULL)
+		return g_strdup_printf (_("Unsaved Document %d"),
+					doc->priv->untitled_number);	      
+	else
+		return get_uri_shortname_for_display (doc->priv->vfs_uri);
 }
 
 /* Never returns NULL */
-const gchar *
+gchar *
 gedit_document_get_mime_type (GeditDocument *doc)
 {
 	g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), "text/plain");
 	g_return_val_if_fail (doc->priv->mime_type != NULL, "text/plain");
 
- 	return doc->priv->mime_type;
+ 	return g_strdup (doc->priv->mime_type);
 }
 
 /* Note: do not emit the notify::read-only signal */
Index: gedit/gedit-document.h
===================================================================
RCS file: /cvs/gnome/gedit/gedit/gedit-document.h,v
retrieving revision 1.41.2.25
diff -u -p -r1.41.2.25 gedit-document.h
--- gedit/gedit-document.h	10 Nov 2005 15:36:19 -0000	1.41.2.25
+++ gedit/gedit-document.h	21 Nov 2005 13:54:47 -0000
@@ -137,14 +137,14 @@ GType		 gedit_document_get_type      	(v
 
 GeditDocument   *gedit_document_new 		(void);
 
-const gchar	*gedit_document_get_uri_ 	(GeditDocument       *doc);
+gchar		*gedit_document_get_uri 	(GeditDocument       *doc);
 
-const gchar	*gedit_document_get_uri_for_display
+gchar		*gedit_document_get_uri_for_display
 						(GeditDocument       *doc);
-const gchar	*gedit_document_get_short_name_for_display
+gchar		*gedit_document_get_short_name_for_display
 					 	(GeditDocument       *doc);
 
-const gchar	*gedit_document_get_mime_type 	(GeditDocument       *doc);
+gchar		*gedit_document_get_mime_type 	(GeditDocument       *doc);
 
 gboolean	 gedit_document_get_readonly 	(GeditDocument       *doc);
 
@@ -200,7 +200,6 @@ gboolean	 gedit_document_search_backward
 						 GtkTextIter         *match_start,
 						 GtkTextIter         *match_end);
 
-// CHECK: non sono sicuro sul da farsi... va cancellata? o può essere comoda averla qui?						 
 gint		 gedit_document_replace_all 	(GeditDocument       *doc,
 				            	 const gchar         *find, 
 						 const gchar         *replace, 
Index: gedit/gedit-print.c
===================================================================
RCS file: /cvs/gnome/gedit/gedit/gedit-print.c,v
retrieving revision 1.44.2.5
diff -u -p -r1.44.2.5 gedit-print.c
--- gedit/gedit-print.c	16 Sep 2005 15:10:47 -0000	1.44.2.5
+++ gedit/gedit-print.c	21 Nov 2005 13:54:51 -0000
@@ -174,7 +174,7 @@ buffer_set (GeditPrintJob *job, GParamSp
 		
 	if (gedit_prefs_manager_get_print_header ())
 	{
-		const gchar *doc_name;
+		gchar *doc_name;
 		gchar *name_to_display;
 		gchar *left;
 
@@ -194,6 +194,7 @@ buffer_set (GeditPrintJob *job, GParamSp
 
 		gtk_source_print_job_set_print_header (pjob, TRUE);
 
+		g_free (doc_name);
 		g_free (name_to_display);
 		g_free (left);
 	}	
Index: gedit/gedit-session.c
===================================================================
RCS file: /cvs/gnome/gedit/gedit/gedit-session.c,v
retrieving revision 1.9.8.5
diff -u -p -r1.9.8.5 gedit-session.c
--- gedit/gedit-session.c	26 Oct 2005 13:30:35 -0000	1.9.8.5
+++ gedit/gedit-session.c	21 Nov 2005 13:54:51 -0000
@@ -183,13 +183,16 @@ save_window_session (xmlTextWriterPtr  w
 		if (ret < 0)
 			return ret;
 
-		uri = gedit_document_get_uri_ (GEDIT_DOCUMENT (l->data));
+		uri = gedit_document_get_uri (GEDIT_DOCUMENT (l->data));
 
 		if (uri != NULL)
 		{
 			ret = xmlTextWriterWriteAttribute (writer,
 							   "uri", 
 							   uri);
+
+			g_free (uri);
+
 			if (ret < 0)
 				return ret;
 		}
Index: gedit/gedit-tab.c
===================================================================
RCS file: /cvs/gnome/gedit/gedit/Attic/gedit-tab.c,v
retrieving revision 1.1.2.61
diff -u -p -r1.1.2.61 gedit-tab.c
--- gedit/gedit-tab.c	6 Nov 2005 10:45:07 -0000	1.1.2.61
+++ gedit/gedit-tab.c	21 Nov 2005 13:54:58 -0000
@@ -335,7 +335,7 @@ recoverable_loading_error_message_area_r
 	doc = gedit_tab_get_document (tab);
 	g_return_if_fail (GEDIT_IS_DOCUMENT (doc));
 
-	uri = gedit_document_get_uri_ (doc);
+	uri = gedit_document_get_uri (doc);
 	g_return_if_fail (uri != NULL);
 	
 	if (response_id == GTK_RESPONSE_OK)
@@ -454,13 +454,14 @@ show_loading_message_area (GeditTab *tab
 	}
 	else
 	{
-		const gchar *uri;
+		gchar *uri;
 		gchar *str;
 
 		name = g_strdup (short_name);
 
 		uri = gedit_document_get_uri_for_display (doc);
 		str = gedit_utils_uri_get_dirname (uri);
+		g_free (uri);
 
 		if (str != NULL)
 		{
@@ -536,7 +537,7 @@ show_saving_message_area (GeditTab *tab)
 {
 	GtkWidget *area;
 	GeditDocument *doc = NULL;
-	const gchar *short_name;
+	gchar *short_name;
 	gchar *from;
 	gchar *to = NULL;
 	gchar *msg = NULL;
@@ -563,12 +564,13 @@ show_saving_message_area (GeditTab *tab)
 	{
 		from = gedit_utils_str_middle_truncate (short_name, 
 							MAX_MSG_LENGTH);
+		g_free (short_name);
 	}
 	else
 	{
 		gchar *str;
-		
-		from = g_strdup (short_name);
+
+		from = short_name;
 
 		to = gnome_vfs_format_uri_for_display (tab->priv->tmp_save_uri);
 
@@ -701,8 +703,8 @@ document_loaded (GeditDocument *document
 		 GeditTab      *tab)
 {
 	GtkWidget *emsg;
+	gchar *uri;
 	const GeditEncoding *encoding;
-	const gchar *uri;
 
 	g_return_if_fail ((tab->priv->state == GEDIT_TAB_STATE_LOADING) ||
 			  (tab->priv->state == GEDIT_TAB_STATE_REVERTING));
@@ -710,10 +712,10 @@ document_loaded (GeditDocument *document
 	g_timer_destroy (tab->priv->timer);
 	tab->priv->timer = NULL;
 	tab->priv->times_called = 0;
-	
+
 	set_message_area (tab, NULL);
-	
-	uri = gedit_document_get_uri_ (document);
+
+	uri = gedit_document_get_uri (document);
 
 	if (error != NULL)
 	{
@@ -807,10 +809,10 @@ document_loaded (GeditDocument *document
 			
 			if (d != document)
 			{
-				const gchar *u;
-				
-				u = gedit_document_get_uri_ (d);
-								
+				gchar *u;
+
+				u = gedit_document_get_uri (d);
+
 				if ((u != NULL) &&
 			    	    gnome_vfs_uris_match (uri, u))
 			    	{
@@ -834,8 +836,13 @@ document_loaded (GeditDocument *document
 							  "response",
 							  G_CALLBACK (file_already_open_warning_message_area_response),
 							  tab);
+
+					g_free (u);
+
 			    		break;
 			    	}
+
+				g_free (u);
 			}
 		}
 
@@ -843,7 +850,10 @@ document_loaded (GeditDocument *document
 
 		gedit_tab_set_state (tab, GEDIT_TAB_STATE_NORMAL);
 	}
-end:
+
+ end:
+	g_free (uri);
+
 	tab->priv->tmp_line_pos = 0;
 	tab->priv->tmp_encoding = NULL;
 }
@@ -947,9 +957,6 @@ no_backup_error_message_area_response (G
 		g_return_if_fail (tab->priv->tmp_save_uri != NULL);
 		g_return_if_fail (tab->priv->tmp_encoding != NULL);
 
-		g_return_if_fail (strcmp (tab->priv->tmp_save_uri, gedit_document_get_uri_ (doc)) == 0);
-		g_return_if_fail (tab->priv->tmp_encoding == gedit_document_get_encoding (doc));
-
 		gedit_tab_set_state (tab, GEDIT_TAB_STATE_SAVING);
 
 		/* don't bug the user again with this... */
@@ -985,9 +992,6 @@ externally_modified_error_message_area_r
 		g_return_if_fail (tab->priv->tmp_save_uri != NULL);
 		g_return_if_fail (tab->priv->tmp_encoding != NULL);
 
-		g_return_if_fail (strcmp (tab->priv->tmp_save_uri, gedit_document_get_uri_ (doc)) == 0);
-		g_return_if_fail (tab->priv->tmp_encoding == gedit_document_get_encoding (doc));
-
 		gedit_tab_set_state (tab, GEDIT_TAB_STATE_SAVING);
 
 		/* ignore mtime should not be persisted in save flags across saves */
@@ -1330,23 +1334,24 @@ _gedit_tab_get_tooltips	(GeditTab *tab)
 {
 	GeditDocument *doc;
 	gchar *tip;
-	const gchar *uri;
+	gchar *uri;
 	gchar *ruri;
-	const gchar *mime_type;
+	gchar *mime_type;
 	const gchar *mime_description = NULL;
 	gchar *mime_full_description; 
 	gchar *encoding;
 	const GeditEncoding *enc;
-	
+
 	g_return_val_if_fail (GEDIT_IS_TAB (tab), NULL);
 
 	doc = gedit_tab_get_document (tab);
-	
+
 	uri = gedit_document_get_uri_for_display (doc);
 	g_return_val_if_fail (uri != NULL, NULL);
 
 	ruri = 	gedit_utils_replace_home_dir_with_tilde (uri);
-	
+	g_free (uri);
+
 	switch (tab->priv->state)
 	{
 		case GEDIT_TAB_STATE_LOADING_ERROR:
@@ -1373,6 +1378,8 @@ _gedit_tab_get_tooltips	(GeditTab *tab)
 				mime_full_description = g_strdup_printf ("%s (%s)", 
 						mime_description, mime_type);
 
+			g_free (mime_type);
+
 			enc = gedit_document_get_encoding (doc);
 
 			if (enc == NULL)
@@ -1530,21 +1537,24 @@ _gedit_tab_get_icon (GeditTab *tab)
 						 icon_size);
 			break;
 		default:
-		{	
-			const gchar *raw_uri;
-			const gchar *mime_type;
+		{
+			gchar *raw_uri;
+			gchar *mime_type;
 			GeditDocument *doc;
-		
+
 			doc = gedit_tab_get_document (tab);
-			
-			raw_uri = gedit_document_get_uri_ (doc);
+
+			raw_uri = gedit_document_get_uri (doc);
 			mime_type = gedit_document_get_mime_type (doc);
 
 			pixbuf = get_icon (theme, raw_uri, mime_type, icon_size);
+
+			g_free (raw_uri);
+			g_free (mime_type);
 		}
 	}
-	
-	return pixbuf;	
+
+	return pixbuf;
 }
 
 GeditTab *
@@ -1590,6 +1600,7 @@ void
 _gedit_tab_revert (GeditTab *tab)
 {
 	GeditDocument *doc;
+	gchar *uri;
 
 	g_return_if_fail (GEDIT_IS_TAB (tab));
 	g_return_if_fail (tab->priv->state == GEDIT_TAB_STATE_NORMAL);
@@ -1599,14 +1610,19 @@ _gedit_tab_revert (GeditTab *tab)
 
 	gedit_tab_set_state (tab, GEDIT_TAB_STATE_REVERTING);
 
+	uri = gedit_document_get_uri (doc);
+	g_return_if_fail (uri != NULL);
+
 	tab->priv->tmp_line_pos = 0;
 	tab->priv->tmp_encoding = gedit_document_get_encoding (doc);
-	
+
 	gedit_document_load (doc,
-			     gedit_document_get_uri_ (doc),
+			     uri,
 			     tab->priv->tmp_encoding,
 			     0,
 			     FALSE);
+
+	g_free (uri);
 }
 
 void
@@ -1619,16 +1635,15 @@ _gedit_tab_save (GeditTab *tab)
 			  (tab->priv->state == GEDIT_TAB_STATE_SHOWING_PRINT_PREVIEW));
 	g_return_if_fail (tab->priv->tmp_save_uri == NULL);
 	g_return_if_fail (tab->priv->tmp_encoding == NULL);
-	
+
 	doc = gedit_tab_get_document (tab);
 	g_return_if_fail (GEDIT_IS_DOCUMENT (doc));
 	g_return_if_fail (!gedit_document_is_untitled (doc));
 
 	gedit_tab_set_state (tab, GEDIT_TAB_STATE_SAVING);
 
-	/* uri used in error messages... strdup because errors are async
-	 * and the string can go away, will be freed in documnt_loaded */
-	tab->priv->tmp_save_uri = g_strdup (gedit_document_get_uri_ (doc));
+	/* uri used in error messages, will be freed in document_loaded */
+	tab->priv->tmp_save_uri = gedit_document_get_uri (doc);
 	tab->priv->tmp_encoding = gedit_document_get_encoding (doc); 
 
 	gedit_document_save (doc, tab->priv->save_flags);
@@ -1655,7 +1670,7 @@ _gedit_tab_save_as (GeditTab            
 	gedit_tab_set_state (tab, GEDIT_TAB_STATE_SAVING);
 
 	/* uri used in error messages... strdup because errors are async
-	 * and the string can go away, will be freed in documnt_loaded */
+	 * and the string can go away, will be freed in document_loaded */
 	tab->priv->tmp_save_uri = g_strdup (uri);
 	tab->priv->tmp_encoding = encoding;
 
Index: gedit/gedit-window.c
===================================================================
RCS file: /cvs/gnome/gedit/gedit/Attic/gedit-window.c,v
retrieving revision 1.4.2.107
diff -u -p -r1.4.2.107 gedit-window.c
--- gedit/gedit-window.c	10 Nov 2005 15:36:19 -0000	1.4.2.107
+++ gedit/gedit-window.c	21 Nov 2005 13:55:37 -0000
@@ -1333,7 +1333,6 @@ static void 
 set_title (GeditWindow *window)
 {
 	GeditDocument *doc = NULL;
-	const gchar *short_name;
 	gchar *name;
 	gchar *dirname = NULL;
 	gchar *title = NULL;
@@ -1348,27 +1347,30 @@ set_title (GeditWindow *window)
 	doc = gedit_tab_get_document (window->priv->active_tab);
 	g_return_if_fail (doc != NULL);
 
-	short_name = gedit_document_get_short_name_for_display (doc);
+	name = gedit_document_get_short_name_for_display (doc);
 
-	len = g_utf8_strlen (short_name, -1);
+	len = g_utf8_strlen (name, -1);
 
 	/* if the name is awfully long, truncate it and be done with it,
 	 * otherwise also show the directory (ellipsized if needed)
 	 */
 	if (len > MAX_TITLE_LENGTH)
 	{
-		name = gedit_utils_str_middle_truncate (short_name, 
-							MAX_TITLE_LENGTH);
+		gchar *tmp;
+
+		tmp = gedit_utils_str_middle_truncate (name,
+						       MAX_TITLE_LENGTH);
+		g_free (name);
+		name = tmp;
 	}
 	else
 	{
-		const gchar *uri;
+		gchar *uri;
 		gchar *str;
 
-		name = g_strdup (short_name);
-
 		uri = gedit_document_get_uri_for_display (doc);
 		str = gedit_utils_uri_get_dirname (uri);
+		g_free (uri);
 
 		if (str != NULL)
 		{
@@ -1837,16 +1839,16 @@ static void
 update_default_path (GeditWindow   *window,
 		     GeditDocument *doc)
 {
-	const gchar *uri;
-	
-	uri = gedit_document_get_uri_(doc);
+	gchar *uri;
+
+	uri = gedit_document_get_uri (doc);
 	// CHECK: what does it happens when loading from stdin? - Paolo
 	g_return_if_fail (uri != NULL);
-	
+
 	if (gedit_utils_uri_has_file_scheme (uri))
 	{
 		gchar *default_path;
-			
+
 		// CHECK: does it work with uri chaining? - Paolo
 		default_path = g_path_get_dirname (uri);
 
@@ -1859,12 +1861,14 @@ update_default_path (GeditWindow   *wind
 		}
 
 		g_free (window->priv->default_path);
-				
+
 		window->priv->default_path = default_path;
-		
+
 		gedit_debug_message (DEBUG_WINDOW, 
 				     "New default path: %s", default_path);
 	}
+
+	g_free (uri);
 }
 
 static void
Index: plugins/docinfo/gedit-docinfo-plugin.c
===================================================================
RCS file: /cvs/gnome/gedit/plugins/docinfo/Attic/gedit-docinfo-plugin.c,v
retrieving revision 1.1.2.5
diff -u -p -r1.1.2.5 gedit-docinfo-plugin.c
--- plugins/docinfo/gedit-docinfo-plugin.c	13 Oct 2005 14:30:18 -0000	1.1.2.5
+++ plugins/docinfo/gedit-docinfo-plugin.c	21 Nov 2005 13:55:43 -0000
@@ -199,7 +199,7 @@ docinfo_real (GeditDocument *doc,
 	gint lines = 0;
 	gint bytes = 0;
 	gchar *tmp_str;
-	const gchar *file_name;
+	gchar *doc_name;
 
 	gedit_debug (DEBUG_PLUGINS);
 
@@ -222,9 +222,10 @@ docinfo_real (GeditDocument *doc,
 	gedit_debug_message (DEBUG_PLUGINS, "Chars non-space: %d", chars - white_chars);
 	gedit_debug_message (DEBUG_PLUGINS, "Bytes: %d", bytes);
 
-	file_name = gedit_document_get_short_name_for_display (doc);
-	tmp_str = g_strdup_printf ("<span weight=\"bold\">%s</span>", file_name);
+	doc_name = gedit_document_get_short_name_for_display (doc);
+	tmp_str = g_strdup_printf ("<span weight=\"bold\">%s</span>", doc_name);
 	gtk_label_set_markup (GTK_LABEL (dialog->file_name_label), tmp_str);
+	g_free (doc_name);
 	g_free (tmp_str);
 
 	tmp_str = g_strdup_printf("%d", lines);
Index: plugins/spell/gedit-spell-plugin.c
===================================================================
RCS file: /cvs/gnome/gedit/plugins/spell/Attic/gedit-spell-plugin.c,v
retrieving revision 1.1.2.2
diff -u -p -r1.1.2.2 gedit-spell-plugin.c
--- plugins/spell/gedit-spell-plugin.c	13 Oct 2005 14:30:18 -0000	1.1.2.2
+++ plugins/spell/gedit-spell-plugin.c	21 Nov 2005 13:55:47 -0000
@@ -129,12 +129,12 @@ set_spell_language_cb (GeditSpellChecker
 		       const GeditLanguage *lang,
 		       GeditDocument 	   *doc)
 {
-	const gchar *uri;
+	gchar *uri;
 
 	g_return_if_fail (GEDIT_IS_DOCUMENT (doc));
 	g_return_if_fail (lang != NULL);
 
-	uri = gedit_document_get_uri_ (doc);
+	uri = gedit_document_get_uri (doc);
 
 	if (uri != NULL)
 	{
@@ -148,6 +148,7 @@ set_spell_language_cb (GeditSpellChecker
 					    key);
 
 		g_free (key);
+		g_free (uri);
 	}
 }
 
@@ -165,11 +166,11 @@ get_spell_checker_from_document (GeditDo
 
 	if (data == NULL)
 	{
-		const gchar *uri;
-		
+		gchar *uri;
+
 		spell = gedit_spell_checker_new ();
 
-		uri = gedit_document_get_uri_ (doc);
+		uri = gedit_document_get_uri (doc);
 
 		if (uri != NULL)
 		{
@@ -188,7 +189,9 @@ get_spell_checker_from_document (GeditDo
 			if (lang != NULL)
 				gedit_spell_checker_set_language (spell,
 								  lang,
-								  NULL);	
+								  NULL);
+
+			g_free (uri);	
 		}
 
 		g_object_set_qdata_full (G_OBJECT (doc),