aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorJP Rosevear <jpr@src.gnome.org>1999-08-05 02:37:50 +0800
committerJP Rosevear <jpr@src.gnome.org>1999-08-05 02:37:50 +0800
commit393c87af52df8cfbb62d7ce884990819dae8d208 (patch)
tree4d63ae41f89355b3689b4dbfe7da9faa22f0690e /calendar
parent7e2281704d4da682c013ec04e63adbaa69c49ac6 (diff)
downloadgsoc2013-evolution-393c87af52df8cfbb62d7ce884990819dae8d208.tar
gsoc2013-evolution-393c87af52df8cfbb62d7ce884990819dae8d208.tar.gz
gsoc2013-evolution-393c87af52df8cfbb62d7ce884990819dae8d208.tar.bz2
gsoc2013-evolution-393c87af52df8cfbb62d7ce884990819dae8d208.tar.lz
gsoc2013-evolution-393c87af52df8cfbb62d7ce884990819dae8d208.tar.xz
gsoc2013-evolution-393c87af52df8cfbb62d7ce884990819dae8d208.tar.zst
gsoc2013-evolution-393c87af52df8cfbb62d7ce884990819dae8d208.zip
BUGFIX #1819
Please note that the calendar_save routine is now responsible for changing the filename attribute of the calendar struct, rather than the calling function. This was so that the filename could be reverted if the open failed. svn path=/trunk/; revision=1080
Diffstat (limited to 'calendar')
-rw-r--r--calendar/calendar.c27
-rw-r--r--calendar/gui/calendar.c27
-rw-r--r--calendar/gui/main.c9
-rw-r--r--calendar/main.c9
4 files changed, 52 insertions, 20 deletions
diff --git a/calendar/calendar.c b/calendar/calendar.c
index 339995cb92..dfeb1d6cc8 100644
--- a/calendar/calendar.c
+++ b/calendar/calendar.c
@@ -12,6 +12,8 @@
*
*/
+#include <gnome.h>
+#include <stdio.h>
#include <config.h>
#include <unistd.h>
#include <sys/stat.h>
@@ -396,8 +398,11 @@ void
calendar_save (Calendar *cal, char *fname)
{
VObject *vcal;
+ FILE *fp;
+ GtkWidget *dlg;
struct stat s;
-
+ int status;
+
if (fname == NULL)
fname = cal->filename;
@@ -412,11 +417,23 @@ calendar_save (Calendar *cal, char *fname)
g_free (backup_name);
}
- writeVObjectToFile (fname, vcal);
+ fp = fopen(fname,"w");
+ if (fp) {
+ writeVObject(fp, vcal);
+ fclose(fp);
+ if (strcmp(cal->filename, fname)) {
+ if (cal->filename)
+ g_free (cal->filename);
+ cal->filename = g_strdup (fname);
+ }
+ status = stat (fname, &s);
+ cal->file_time = s.st_mtime;
+ } else {
+ dlg = gnome_message_box_new(_("Failed to save calendar!"),
+ GNOME_MESSAGE_BOX_ERROR, "Ok", NULL);
+ gtk_widget_show(dlg);
+ }
- stat (fname, &s);
- cal->file_time = s.st_mtime;
-
cleanVObject (vcal);
cleanStrTbl ();
}
diff --git a/calendar/gui/calendar.c b/calendar/gui/calendar.c
index 339995cb92..dfeb1d6cc8 100644
--- a/calendar/gui/calendar.c
+++ b/calendar/gui/calendar.c
@@ -12,6 +12,8 @@
*
*/
+#include <gnome.h>
+#include <stdio.h>
#include <config.h>
#include <unistd.h>
#include <sys/stat.h>
@@ -396,8 +398,11 @@ void
calendar_save (Calendar *cal, char *fname)
{
VObject *vcal;
+ FILE *fp;
+ GtkWidget *dlg;
struct stat s;
-
+ int status;
+
if (fname == NULL)
fname = cal->filename;
@@ -412,11 +417,23 @@ calendar_save (Calendar *cal, char *fname)
g_free (backup_name);
}
- writeVObjectToFile (fname, vcal);
+ fp = fopen(fname,"w");
+ if (fp) {
+ writeVObject(fp, vcal);
+ fclose(fp);
+ if (strcmp(cal->filename, fname)) {
+ if (cal->filename)
+ g_free (cal->filename);
+ cal->filename = g_strdup (fname);
+ }
+ status = stat (fname, &s);
+ cal->file_time = s.st_mtime;
+ } else {
+ dlg = gnome_message_box_new(_("Failed to save calendar!"),
+ GNOME_MESSAGE_BOX_ERROR, "Ok", NULL);
+ gtk_widget_show(dlg);
+ }
- stat (fname, &s);
- cal->file_time = s.st_mtime;
-
cleanVObject (vcal);
cleanStrTbl ();
}
diff --git a/calendar/gui/main.c b/calendar/gui/main.c
index 3a49dfaa9a..6c4a4b4522 100644
--- a/calendar/gui/main.c
+++ b/calendar/gui/main.c
@@ -367,15 +367,14 @@ static void
save_ok (GtkWidget *widget, GtkFileSelection *fs)
{
GnomeCalendar *gcal;
+ gchar *fname;
gcal = GNOME_CALENDAR (gtk_object_get_user_data (GTK_OBJECT (fs)));
gtk_window_set_wmclass (GTK_WINDOW (gcal), "gnomecal", "gnomecal");
- if (gcal->cal->filename)
- g_free (gcal->cal->filename);
-
- gcal->cal->filename = g_strdup (gtk_file_selection_get_filename (fs));
- calendar_save (gcal->cal, gcal->cal->filename);
+ fname = g_strdup (gtk_file_selection_get_filename (fs));
+ calendar_save (gcal->cal, fname);
+ g_free(fname);
gtk_main_quit ();
}
diff --git a/calendar/main.c b/calendar/main.c
index 3a49dfaa9a..6c4a4b4522 100644
--- a/calendar/main.c
+++ b/calendar/main.c
@@ -367,15 +367,14 @@ static void
save_ok (GtkWidget *widget, GtkFileSelection *fs)
{
GnomeCalendar *gcal;
+ gchar *fname;
gcal = GNOME_CALENDAR (gtk_object_get_user_data (GTK_OBJECT (fs)));
gtk_window_set_wmclass (GTK_WINDOW (gcal), "gnomecal", "gnomecal");
- if (gcal->cal->filename)
- g_free (gcal->cal->filename);
-
- gcal->cal->filename = g_strdup (gtk_file_selection_get_filename (fs));
- calendar_save (gcal->cal, gcal->cal->filename);
+ fname = g_strdup (gtk_file_selection_get_filename (fs));
+ calendar_save (gcal->cal, fname);
+ g_free(fname);
gtk_main_quit ();
}