[geany/geany] ab7a00: Don't prompt for reload from infobar when there are no unsaved changes

Nick Treleaven git-noreply at xxxxx
Fri Oct 10 15:59:43 UTC 2014


Branch:      refs/heads/master
Author:      Nick Treleaven <nick.treleaven at btinternet.com>
Committer:   Nick Treleaven <nick.treleaven at btinternet.com>
Date:        Fri, 10 Oct 2014 15:59:43 UTC
Commit:      ab7a0018b2518793f26af2fe20a06a8a1886e031
             https://github.com/geany/geany/commit/ab7a0018b2518793f26af2fe20a06a8a1886e031

Log Message:
-----------
Don't prompt for reload from infobar when there are no unsaved changes

Also warn about losing undo history when there are no changes.


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

Modified: src/document.c
19 lines changed, 13 insertions(+), 6 deletions(-)
===================================================================
@@ -1440,7 +1440,7 @@ gboolean document_reload_force(GeanyDocument *doc, const gchar *forced_enc)
 gboolean document_reload_prompt(GeanyDocument *doc, const gchar *forced_enc)
 {
 	gchar *base_name;
-	gboolean result = FALSE;
+	gboolean prompt, result = FALSE;
 
 	g_return_val_if_fail(doc != NULL, FALSE);
 
@@ -1453,9 +1453,11 @@ gboolean document_reload_prompt(GeanyDocument *doc, const gchar *forced_enc)
 
 	base_name = g_path_get_basename(doc->file_name);
 	/* don't prompt if file hasn't been edited at all */
-	if ((!doc->changed && !document_can_undo(doc) && !document_can_redo(doc)) ||
-		dialogs_show_question_full(NULL, _("_Reload"), GTK_STOCK_CANCEL,
-		_("Any unsaved changes will be lost."),
+	prompt = doc->changed || (document_can_undo(doc) || document_can_redo(doc));
+
+	if (!prompt || dialogs_show_question_full(NULL, _("_Reload"), GTK_STOCK_CANCEL,
+		doc->changed ? _("Any unsaved changes will be lost.") :
+			_("Undo history will be lost."),
 		_("Are you sure you want to reload '%s'?"), base_name))
 	{
 		result = document_reload_force(doc, forced_enc);
@@ -1463,7 +1465,6 @@ gboolean document_reload_prompt(GeanyDocument *doc, const gchar *forced_enc)
 			ui_update_statusbar(doc, -1);
 	}
 	g_free(base_name);
-
 	return result;
 }
 
@@ -3275,9 +3276,15 @@ static void on_monitor_reload_file_response(GtkWidget *bar, gint response_id, Ge
 	doc->priv->info_bars[MSG_TYPE_RELOAD] = NULL;
 
 	if (response_id == RESPONSE_DOCUMENT_RELOAD)
-		close = document_reload_prompt(doc, doc->encoding);
+	{
+		close = doc->changed ?
+			document_reload_prompt(doc, doc->encoding) :
+			document_reload_force(doc, doc->encoding);
+	}
 	else if (response_id == RESPONSE_DOCUMENT_SAVE)
+	{
 		close = document_save_file(doc, TRUE);	// force overwrite
+	}
 	else if (response_id == GTK_RESPONSE_CANCEL)
 	{
 		document_set_text_changed(doc, TRUE);



--------------
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