Re: [evolution-patches] patch for #57567 (calendar)
- From: Rodrigo Moya <rodrigo novell com>
- To: Evolution Patches <evolution-patches lists ximian com>
- Subject: Re: [evolution-patches] patch for #57567 (calendar)
- Date: Mon, 17 Jan 2005 13:18:42 +0100
On Mon, 2005-01-17 at 12:58 +0100, Rodrigo Moya wrote:
> This should probably be committed to the 2.0 branch. Already committed
> to HEAD.
updated patch, with a check in save_file_when_idle to not save the file
if it's not dirty
--
Rodrigo Moya <rodrigo novell com>
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/ChangeLog,v
retrieving revision 1.324.2.10
diff -u -p -r1.324.2.10 ChangeLog
--- ChangeLog 6 Dec 2004 14:28:19 -0000 1.324.2.10
+++ ChangeLog 17 Jan 2005 12:18:53 -0000
@@ -1,3 +1,20 @@
+2005-01-17 Rodrigo Moya <rodrigo novell com>
+
+ Fixes #57567
+
+ * backends/file/e-cal-backend-file.c (save_file_when_idle): new
+ function, to save the file to disk at application's idle times.
+ (save): changed to just set the idle callback the first time and then,
+ just mark the file as dirty.
+ (e_cal_backend_file_finalize): remove the idle callback.
+ (e_cal_backend_file_dispose): save the file if dirty.
+ (e_cal_backend_file_init): initialize new members.
+
+2005-01-17 Rodrigo Moya <rodrigo novell com>
+
+ * libecal/e-cal-view.c (e_cal_view_set_property): make sure we clean
+ up the old view and listener before setting the new ones.
+
2004-12-06 Rodrigo Moya <rodrigo novell com>
Fixes #59904
Index: backends/file/e-cal-backend-file.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/backends/file/e-cal-backend-file.c,v
retrieving revision 1.35.2.1
diff -u -p -r1.35.2.1 e-cal-backend-file.c
--- backends/file/e-cal-backend-file.c 6 Dec 2004 14:28:19 -0000 1.35.2.1
+++ backends/file/e-cal-backend-file.c 17 Jan 2005 12:18:54 -0000
@@ -55,6 +55,8 @@ struct _ECalBackendFilePrivate {
/* Filename in the dir */
char *file_name;
gboolean read_only;
+ gboolean is_dirty;
+ guint dirty_idle_id;
/* Toplevel VCALENDAR component */
icalcomponent *icalcomp;
@@ -113,8 +115,8 @@ free_object (gpointer key, gpointer valu
}
/* Saves the calendar data */
-static void
-save (ECalBackendFile *cbfile)
+static gboolean
+save_file_when_idle (gpointer user_data)
{
ECalBackendFilePrivate *priv;
GnomeVFSURI *uri, *backup_uri;
@@ -123,11 +125,15 @@ save (ECalBackendFile *cbfile)
GnomeVFSFileSize out;
gchar *tmp, *backup_uristr;
char *buf;
+ ECalBackendFile *cbfile = user_data;
priv = cbfile->priv;
g_assert (priv->uri != NULL);
g_assert (priv->icalcomp != NULL);
+ if (!priv->is_dirty)
+ return TRUE;
+
uri = gnome_vfs_uri_new (priv->uri);
if (!uri)
goto error_malformed_uri;
@@ -176,16 +182,32 @@ save (ECalBackendFile *cbfile)
if (result != GNOME_VFS_OK)
goto error;
- return;
+ priv->is_dirty = FALSE;
+
+ return TRUE;
error_malformed_uri:
e_cal_backend_notify_error (E_CAL_BACKEND (cbfile),
_("Can't save calendar data: Malformed URI."));
- return;
+ return TRUE;
error:
e_cal_backend_notify_error (E_CAL_BACKEND (cbfile), gnome_vfs_result_to_string (result));
- return;
+ return TRUE;
+}
+
+static void
+save (ECalBackendFile *cbfile)
+{
+ ECalBackendFilePrivate *priv;
+
+ priv = cbfile->priv;
+
+ if (!priv->dirty_idle_id) {
+ priv->dirty_idle_id = g_idle_add ((GSourceFunc) save_file_when_idle, cbfile);
+ }
+
+ priv->is_dirty = TRUE;
}
static void
@@ -227,6 +249,8 @@ e_cal_backend_file_dispose (GObject *obj
priv = cbfile->priv;
/* Save if necessary */
+ if (priv->is_dirty)
+ save_file_when_idle (cbfile);
free_calendar_data (cbfile);
@@ -249,6 +273,11 @@ e_cal_backend_file_finalize (GObject *ob
/* Clean up */
+ if (priv->dirty_idle_id) {
+ g_source_remove (priv->dirty_idle_id);
+ priv->dirty_idle_id = 0;
+ }
+
if (priv->uri) {
g_free (priv->uri);
priv->uri = NULL;
@@ -2258,6 +2287,8 @@ e_cal_backend_file_init (ECalBackendFile
priv->uri = NULL;
priv->file_name = g_strdup ("calendar.ics");
priv->read_only = FALSE;
+ priv->is_dirty = FALSE;
+ priv->dirty_idle_id = 0;
priv->icalcomp = NULL;
priv->comp_uid_hash = NULL;
priv->comp = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]