SF.net SVN: geany: [2443] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Thu Apr 3 15:45:25 UTC 2008


Revision: 2443
          http://geany.svn.sourceforge.net/geany/?rev=2443&view=rev
Author:   ntrel
Date:     2008-04-03 08:45:23 -0700 (Thu, 03 Apr 2008)

Log Message:
-----------
Make Close All check for unsaved documents first before closing any,
so that clicking cancel keeps all documents open.
This also prevents the UI from not being updated after cancelling
Close All.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/callbacks.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-04-03 15:38:16 UTC (rev 2442)
+++ trunk/ChangeLog	2008-04-03 15:45:23 UTC (rev 2443)
@@ -1,3 +1,12 @@
+2008-04-03  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>
+
+ * src/callbacks.c:
+   Make Close All check for unsaved documents first before closing any,
+   so that clicking cancel keeps all documents open.
+   This also prevents the UI from not being updated after cancelling
+   Close All.
+
+
 2008-04-03  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>
 
  * src/keybindings.c:

Modified: trunk/src/callbacks.c
===================================================================
--- trunk/src/callbacks.c	2008-04-03 15:38:16 UTC (rev 2442)
+++ trunk/src/callbacks.c	2008-04-03 15:45:23 UTC (rev 2443)
@@ -105,6 +105,7 @@
 }
 
 
+/* @return TRUE if all files were saved or had their changes discarded. */
 static gboolean account_for_unsaved(void)
 {
 	gint p;
@@ -135,25 +136,38 @@
 }
 
 
-/* should only be called from on_exit_clicked */
-static void quit_app(void)
+static void force_close_all()
 {
-	guint i;
+	guint i, len = doc_array->len;
 
-	configuration_save();
+	main_status.closing_all = TRUE;
 
-	/* ignore changes for all tabs (already asked user in on_exit_clicked) */
-	for (i = 0; i < doc_array->len; i++)
+	/* all documents should be accounted for, so ignore any changes */
+	for (i = 0; i < len; i++)
 	{
 		if (doc_list[i].is_valid && doc_list[i].changed)
 		{
 			doc_list[i].changed = FALSE;
 		}
 	}
+	for (i = 0; i < len; i++)
+	{
+		if (doc_list[i].is_valid)
+			document_remove(0);
+	}
+	main_status.closing_all = FALSE;
+}
+
+
+/* should only be called from on_exit_clicked */
+static void quit_app(void)
+{
+	configuration_save();
+
 	if (app->project != NULL)
 		project_close(FALSE);	/* save project session files */
 
-	on_close_all1_activate(NULL, NULL);
+	force_close_all();
 
 	main_quit();
 }
@@ -253,26 +267,23 @@
 }
 
 
+static gboolean close_all(void)
+{
+	if (! account_for_unsaved())
+		return FALSE;
+
+	force_close_all();
+
+	tm_workspace_update(TM_WORK_OBJECT(app->tm_workspace), TRUE, TRUE, FALSE);
+	return TRUE;
+}
+
+
 gboolean
 on_close_all1_activate                 (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
 {
-	gboolean ret = TRUE;
-	gint i, max = gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook));
-
-	main_status.closing_all = TRUE;
-	for(i = 0; i < max; i++)
-	{
-		if (! document_remove(0))
-		{
-			ret = FALSE;
-			break;
-		}
-	}
-	main_status.closing_all = FALSE;
-	tm_workspace_update(TM_WORK_OBJECT(app->tm_workspace), TRUE, TRUE, FALSE);
-	/* if cancel is clicked, cancel the complete exit process */
-	return ret;
+	return close_all();
 }
 
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list