[geany/geany] 667c35: Use document_show_message() when a file is externally modified

Matthew Brush git-noreply at xxxxx
Sat May 24 12:47:57 UTC 2014


Branch:      refs/heads/master
Author:      Matthew Brush <matt at geany.org>
Committer:   Thomas Martitz <kugel at rockbox.org>
Date:        Sat, 24 May 2014 12:47:57 UTC
Commit:      667c35a004aeabfb254da3d91186b8f523869cf0
             https://github.com/geany/geany/commit/667c35a004aeabfb254da3d91186b8f523869cf0

Log Message:
-----------
Use document_show_message() when a file is externally modified

Two other related changes are that document_set_text_changed() is used to
indicate that the buffer is different from what's on disk and also that
the 'Close' button has been removed from the dialog since the user can easily
just close the document themselves the normal way.


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

Modified: src/document.c
26 lines changed, 14 insertions(+), 12 deletions(-)
===================================================================
@@ -2989,7 +2989,6 @@ gboolean document_close_all(void)
 }
 
 
-
 /* *
  * Shows a message related to a document.
  *
@@ -3102,25 +3101,28 @@ static GtkWidget* document_show_message(GeanyDocument *doc, GtkMessageType msgty
 	return info_widget;
 }
 
+static void on_monitor_reload_file_response(GtkWidget *bar, gint response_id, GeanyDocument *doc)
+{
+	if (response_id == GTK_RESPONSE_ACCEPT)
+		document_reload_file(doc, doc->encoding);
+}
+
+
 static void monitor_reload_file(GeanyDocument *doc)
 {
 	gchar *base_name = g_path_get_basename(doc->file_name);
-	gint ret;
 
-	/* we use No instead of Cancel to avoid mnemonic clash */
-	ret = dialogs_show_prompt(NULL,
-		GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
-		GTK_STOCK_NO, GTK_RESPONSE_CANCEL,
+	document_show_message(doc, GTK_MESSAGE_QUESTION, on_monitor_reload_file_response,
 		_("_Reload"), GTK_RESPONSE_ACCEPT,
+		GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+		NULL, GTK_RESPONSE_NONE,
 		_("Do you want to reload it?"),
-		_("The file '%s' on the disk is more recent than\nthe current buffer."),
+		_("The file '%s' on the disk is more recent than the current buffer."),
 		base_name);
-	g_free(base_name);
 
-	if (ret == GTK_RESPONSE_ACCEPT)
-		document_reload_file(doc, doc->encoding);
-	else if (ret == GTK_RESPONSE_CLOSE)
-		document_close(doc);
+	document_set_text_changed(doc, TRUE);
+
+	g_free(base_name);
 }
 
 



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