SF.net SVN: geany: [792] trunk
eht16 at users.sourceforge.net
eht16 at xxxxx
Tue Sep 5 18:33:57 UTC 2006
Revision: 792
http://svn.sourceforge.net/geany/?rev=792&view=rev
Author: eht16
Date: 2006-09-05 11:33:48 -0700 (Tue, 05 Sep 2006)
Log Message:
-----------
Don't quit when an error occurs while saving changed files.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/dialogs.c
trunk/src/document.c
trunk/src/document.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2006-09-05 16:55:40 UTC (rev 791)
+++ trunk/ChangeLog 2006-09-05 18:33:48 UTC (rev 792)
@@ -2,6 +2,8 @@
* src/templates.c, src/document.c, src/filetypes.c:
Added new file template for filetype HTML.
+ * src/document.c, src/dialogs.c:
+ Don't quit when an error occurs while saving changed files.
2006-09-05 Nick Treleaven <nick.treleaven at btinternet.com>
Modified: trunk/src/dialogs.c
===================================================================
--- trunk/src/dialogs.c 2006-09-05 16:55:40 UTC (rev 791)
+++ trunk/src/dialogs.c 2006-09-05 18:33:48 UTC (rev 792)
@@ -313,10 +313,13 @@
case GTK_RESPONSE_YES:
{
if (doc_list[idx].file_name == NULL)
+ {
dialogs_show_save_as();
+ ret = TRUE;
+ }
else
- document_save_file(idx, FALSE);
- ret = TRUE;
+ // document_save_file() returns the status if the file could be saved
+ ret = document_save_file(idx, FALSE);
break;
}
case GTK_RESPONSE_NO: ret = TRUE; break;
Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c 2006-09-05 16:55:40 UTC (rev 791)
+++ trunk/src/document.c 2006-09-05 18:33:48 UTC (rev 792)
@@ -676,22 +676,23 @@
/* This saves the file.
- * When force is set then it is always saved, even if it is unchanged(useful when using Save As) */
-void document_save_file(gint idx, gboolean force)
+ * When force is set then it is always saved, even if it is unchanged(useful when using Save As)
+ * It returns whether the file could be saved or not. */
+gboolean document_save_file(gint idx, gboolean force)
{
gchar *data;
FILE *fp;
gint bytes_written, len;
gchar *locale_filename = NULL;
- if (idx == -1) return;
- if (! force && ! doc_list[idx].changed) return;
+ if (idx == -1) return FALSE;
+ if (! force && ! doc_list[idx].changed) return FALSE;
if (doc_list[idx].file_name == NULL)
{
msgwin_status_add(_("Error saving file."));
utils_beep();
- return;
+ return FALSE;
}
// replaces tabs by spaces
@@ -739,7 +740,7 @@
geany_debug("encoding error: %s)", conv_error->message);
g_error_free(conv_error);
g_free(data);
- return;
+ return FALSE;
}
else
{
@@ -760,7 +761,7 @@
msgwin_status_add(_("Error saving file (%s)."), strerror(errno));
utils_beep();
g_free(data);
- return;
+ return FALSE;
}
bytes_written = fwrite(data, sizeof (gchar), len, fp);
fclose (fp);
@@ -771,7 +772,7 @@
{
msgwin_status_add(_("Error saving file."));
utils_beep();
- return;
+ return FALSE;
}
// ignore the following things if we are quitting
@@ -803,6 +804,7 @@
#endif
}
+ return TRUE;
}
Modified: trunk/src/document.h
===================================================================
--- trunk/src/document.h 2006-09-05 16:55:40 UTC (rev 791)
+++ trunk/src/document.h 2006-09-05 18:33:48 UTC (rev 792)
@@ -138,8 +138,9 @@
/* This saves the file.
- * When force is set then it is always saved, even if it is unchanged(useful when using Save As) */
-void document_save_file(gint, gboolean force);
+ * When force is set then it is always saved, even if it is unchanged(useful when using Save As)
+ * It returns whether the file could be saved or not. */
+gboolean document_save_file(gint idx, gboolean force);
/* special search function, used from the find entry in the toolbar */
void document_find_next(gint, const gchar*, gint, gboolean, gboolean);
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