[geany/geany] 2b9848: Merge pull request #335 from ntrel/save-cleanup

Nick Treleaven git-noreply at xxxxx
Fri Sep 26 10:45:27 UTC 2014


Branch:      refs/heads/master
Author:      Nick Treleaven <nick.treleaven at btinternet.com>
Committer:   Nick Treleaven <nick.treleaven at btinternet.com>
Date:        Fri, 26 Sep 2014 10:45:27 UTC
Commit:      2b98487a70953fc268a5fa76c774f1c676adf0d2
             https://github.com/geany/geany/commit/2b98487a70953fc268a5fa76c774f1c676adf0d2

Log Message:
-----------
Merge pull request #335 from ntrel/save-cleanup

Notify user when trying to save read-only document


Modified Paths:
--------------
    src/document.c
    src/documentprivate.h

Modified: src/document.c
10 lines changed, 7 insertions(+), 3 deletions(-)
===================================================================
@@ -1655,6 +1655,7 @@ gboolean document_save_file_as(GeanyDocument *doc, const gchar *utf8_fname)
 
 	if (new_file)
 	{
+		// assume user wants to throw away read-only setting
 		sci_set_readonly(doc->editor->sci, FALSE);
 		doc->readonly = FALSE;
 		if (doc->priv->protected > 0)
@@ -1928,11 +1929,14 @@ gboolean document_save_file(GeanyDocument *doc, gboolean force)
 		return dialogs_show_save_as();
 	}
 
-	/* the "changed" flag should exclude the "readonly" flag, but check it anyway for safety */
-	if (doc->readonly)
-		return FALSE;
 	if (!force && !doc->changed)
 		return FALSE;
+	if (doc->readonly)
+	{
+		ui_set_statusbar(TRUE,
+			_("Cannot save read-only document '%s'!"), DOC_FILENAME(doc));
+		return FALSE;
+	}
 	if (doc->priv->protected)
 	{
 		return save_file_handle_infobars(doc, force);


Modified: src/documentprivate.h
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -93,7 +93,7 @@ typedef struct GeanyDocumentPrivate
 	time_t			 mtime;
 	/* ID of the idle callback updating the tag list */
 	guint			 tag_list_update_source;
-	/* Whether it's temoporarily protected (read-only and saving is prevented). Does
+	/* Whether it's temporarily protected (read-only and saving needs confirmation). Does
 	 * not imply doc->readonly as writable files can be protected */
 	gint			 protected;
 	/* Save pointer to info bars allowing to cancel them programatically (to avoid multiple ones) */



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list