[geany/geany] 88a362: Merge pull request #334 from ntrel/confirm-infobar-reload

Nick Treleaven git-noreply at xxxxx
Thu Sep 25 10:53:16 UTC 2014


Branch:      refs/heads/master
Author:      Nick Treleaven <nick.treleaven at btinternet.com>
Committer:   Nick Treleaven <nick.treleaven at btinternet.com>
Date:        Thu, 25 Sep 2014 10:53:16 UTC
Commit:      88a36268efd91b91f188024019c01ed68896667d
             https://github.com/geany/geany/commit/88a36268efd91b91f188024019c01ed68896667d

Log Message:
-----------
Merge pull request #334 from ntrel/confirm-infobar-reload

Confirm infobar reload when document has modifications


Modified Paths:
--------------
    plugins/geanyfunctions.h
    src/document.c
    src/document.h
    src/plugindata.h
    src/plugins.c

Modified: plugins/geanyfunctions.h
4 lines changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -52,8 +52,8 @@
 	geany_functions->p_document->document_open_files
 #define document_remove_page \
 	geany_functions->p_document->document_remove_page
-#define document_reload_file \
-	geany_functions->p_document->document_reload_file
+#define document_reload_force \
+	geany_functions->p_document->document_reload_force
 #define document_set_encoding \
 	geany_functions->p_document->document_set_encoding
 #define document_set_text_changed \


Modified: src/document.c
24 lines changed, 18 insertions(+), 6 deletions(-)
===================================================================
@@ -1409,7 +1409,7 @@ void document_open_files(const GSList *filenames, gboolean readonly, GeanyFilety
 
 
 /**
- *  Reloads the document with the specified file encoding
+ *  Reloads the document with the specified file encoding.
  *  @a forced_enc or @c NULL to auto-detect the file encoding.
  *
  *  @param doc The document to reload.
@@ -1417,7 +1417,7 @@ void document_open_files(const GSList *filenames, gboolean readonly, GeanyFilety
  *
  *  @return @c TRUE if the document was actually reloaded or @c FALSE otherwise.
  **/
-gboolean document_reload_file(GeanyDocument *doc, const gchar *forced_enc)
+gboolean document_reload_force(GeanyDocument *doc, const gchar *forced_enc)
 {
 	gint pos = 0;
 	GeanyDocument *new_doc;
@@ -1458,7 +1458,7 @@ gboolean document_reload_prompt(GeanyDocument *doc, const gchar *forced_enc)
 		_("Any unsaved changes will be lost."),
 		_("Are you sure you want to reload '%s'?"), base_name))
 	{
-		result = document_reload_file(doc, forced_enc);
+		result = document_reload_force(doc, forced_enc);
 		if (forced_enc != NULL)
 			ui_update_statusbar(doc, -1);
 	}
@@ -3218,7 +3218,6 @@ static GtkWidget* document_show_message(GeanyDocument *doc, GtkMessageType msgty
 	g_free(markup);
 
 	g_signal_connect(info_widget, "response", G_CALLBACK(response_cb), doc);
-	g_signal_connect_after(info_widget, "response", G_CALLBACK(gtk_widget_destroy), NULL);
 
 	hbox = gtk_hbox_new(FALSE, 12);
 	gtk_box_pack_start(GTK_BOX(content_area), hbox, TRUE, TRUE, 0);
@@ -3266,15 +3265,28 @@ static GtkWidget* document_show_message(GeanyDocument *doc, GtkMessageType msgty
 
 static void on_monitor_reload_file_response(GtkWidget *bar, gint response_id, GeanyDocument *doc)
 {
+	gboolean close = FALSE;
+
+	// disable info bar so actions complete normally
 	unprotect_document(doc);
 	doc->priv->info_bars[MSG_TYPE_RELOAD] = NULL;
 
 	if (response_id == RESPONSE_DOCUMENT_RELOAD)
-		document_reload_file(doc, doc->encoding);
+		close = document_reload_prompt(doc, doc->encoding);
 	else if (response_id == RESPONSE_DOCUMENT_SAVE)
-		document_save_file(doc, TRUE);
+		close = document_save_file(doc, TRUE);	// force overwrite
 	else if (response_id == GTK_RESPONSE_CANCEL)
+	{
 		document_set_text_changed(doc, TRUE);
+		close = TRUE;
+	}
+	if (!close)
+	{
+		doc->priv->info_bars[MSG_TYPE_RELOAD] = bar;
+		protect_document(doc);
+		return;
+	}
+	gtk_widget_destroy(bar);
 }
 
 


Modified: src/document.h
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -196,7 +196,7 @@ gboolean document_save_file_as(GeanyDocument *doc, const gchar *utf8_fname);
 GeanyDocument* document_open_file(const gchar *locale_filename, gboolean readonly,
 		GeanyFiletype *ft, const gchar *forced_enc);
 
-gboolean document_reload_file(GeanyDocument *doc, const gchar *forced_enc);
+gboolean document_reload_force(GeanyDocument *doc, const gchar *forced_enc);
 
 gboolean document_reload_prompt(GeanyDocument *doc, const gchar *forced_enc);
 


Modified: src/plugindata.h
6 lines changed, 4 insertions(+), 2 deletions(-)
===================================================================
@@ -58,7 +58,7 @@ G_BEGIN_DECLS
  * @warning You should not test for values below 200 as previously
  * @c GEANY_API_VERSION was defined as an enum value, not a macro.
  */
-#define GEANY_API_VERSION 219
+#define GEANY_API_VERSION 220
 
 /* hack to have a different ABI when built with GTK3 because loading GTK2-linked plugins
  * with GTK3-linked Geany leads to crash */
@@ -310,7 +310,7 @@ typedef struct DocumentFuncs
 	void		(*document_open_files) (const GSList *filenames, gboolean readonly,
 			struct GeanyFiletype *ft, const gchar *forced_enc);
 	gboolean	(*document_remove_page) (guint page_num);
-	gboolean	(*document_reload_file) (struct GeanyDocument *doc, const gchar *forced_enc);
+	gboolean	(*document_reload_force) (struct GeanyDocument *doc, const gchar *forced_enc);
 	void		(*document_set_encoding) (struct GeanyDocument *doc, const gchar *new_encoding);
 	void		(*document_set_text_changed) (struct GeanyDocument *doc, gboolean changed);
 	void		(*document_set_filetype) (struct GeanyDocument *doc, struct GeanyFiletype *type);
@@ -741,6 +741,8 @@ BuildFuncs;
 /* Deprecated aliases */
 #ifndef GEANY_DISABLE_DEPRECATED
 
+#define document_reload_file document_reload_force
+
 /** @deprecated - copy into your plugin code if needed.
  * @c NULL-safe way to get the index of @a doc_ptr in the documents array. */
 #define DOC_IDX(doc_ptr) \


Modified: src/plugins.c
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -98,7 +98,7 @@ static DocumentFuncs doc_funcs = {
 	&document_open_file,
 	&document_open_files,
 	&document_remove_page,
-	&document_reload_file,
+	&document_reload_force,
 	&document_set_encoding,
 	&document_set_text_changed,
 	&document_set_filetype,



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