aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
authorArturo Espinosa <unammx@src.gnome.org>1998-04-29 10:38:48 +0800
committerArturo Espinosa <unammx@src.gnome.org>1998-04-29 10:38:48 +0800
commit282114a676e69a0b4c0656b3a6266d27165b2039 (patch)
treed34c5be00109f8f6af69412bbe67a6265f112098 /calendar/gui
parent55ae95fe78692dfa59a17520b40b6ac89fcad706 (diff)
downloadgsoc2013-evolution-282114a676e69a0b4c0656b3a6266d27165b2039.tar
gsoc2013-evolution-282114a676e69a0b4c0656b3a6266d27165b2039.tar.gz
gsoc2013-evolution-282114a676e69a0b4c0656b3a6266d27165b2039.tar.bz2
gsoc2013-evolution-282114a676e69a0b4c0656b3a6266d27165b2039.tar.lz
gsoc2013-evolution-282114a676e69a0b4c0656b3a6266d27165b2039.tar.xz
gsoc2013-evolution-282114a676e69a0b4c0656b3a6266d27165b2039.tar.zst
gsoc2013-evolution-282114a676e69a0b4c0656b3a6266d27165b2039.zip
Lots of fixes:
Lots of fixes: 1. Alarms are rescheduled when an event has been changed. 2. Avoid emitting spurious event changes. 3. Applied black magic to get the mail-notification working. Miguel. svn path=/trunk/; revision=199
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/alarm-notify/alarm.c5
-rw-r--r--calendar/gui/alarm-notify/alarm.h2
-rw-r--r--calendar/gui/alarm.c5
-rw-r--r--calendar/gui/alarm.h2
-rw-r--r--calendar/gui/calendar.c12
-rw-r--r--calendar/gui/calendar.h3
-rw-r--r--calendar/gui/gncal-full-day.c9
-rw-r--r--calendar/gui/gnome-cal.c60
8 files changed, 62 insertions, 36 deletions
diff --git a/calendar/gui/alarm-notify/alarm.c b/calendar/gui/alarm-notify/alarm.c
index aaa67f0aea..6573a1be3d 100644
--- a/calendar/gui/alarm-notify/alarm.c
+++ b/calendar/gui/alarm-notify/alarm.c
@@ -103,7 +103,7 @@ alarm_add (time_t alarm_time, AlarmFunction fn, void *closure)
}
}
-void
+int
alarm_kill (void *closure_key)
{
GList *p;
@@ -117,9 +117,10 @@ alarm_kill (void *closure_key)
head_alarm = alarms->data;
else
head_alarm = NULL;
- return;
+ return 1;
}
}
+ return 0;
}
void
diff --git a/calendar/gui/alarm-notify/alarm.h b/calendar/gui/alarm-notify/alarm.h
index 079eb79121..d37ff0c1bf 100644
--- a/calendar/gui/alarm-notify/alarm.h
+++ b/calendar/gui/alarm-notify/alarm.h
@@ -7,6 +7,6 @@ typedef void (*AlarmFunction)(time_t time, void *closuse);
void alarm_init (void);
void alarm_add (time_t alarm_time, AlarmFunction fn, void *closure);
-void alarm_kill (void *closure);
+int alarm_kill (void *closure);
#endif
diff --git a/calendar/gui/alarm.c b/calendar/gui/alarm.c
index aaa67f0aea..6573a1be3d 100644
--- a/calendar/gui/alarm.c
+++ b/calendar/gui/alarm.c
@@ -103,7 +103,7 @@ alarm_add (time_t alarm_time, AlarmFunction fn, void *closure)
}
}
-void
+int
alarm_kill (void *closure_key)
{
GList *p;
@@ -117,9 +117,10 @@ alarm_kill (void *closure_key)
head_alarm = alarms->data;
else
head_alarm = NULL;
- return;
+ return 1;
}
}
+ return 0;
}
void
diff --git a/calendar/gui/alarm.h b/calendar/gui/alarm.h
index 079eb79121..d37ff0c1bf 100644
--- a/calendar/gui/alarm.h
+++ b/calendar/gui/alarm.h
@@ -7,6 +7,6 @@ typedef void (*AlarmFunction)(time_t time, void *closuse);
void alarm_init (void);
void alarm_add (time_t alarm_time, AlarmFunction fn, void *closure);
-void alarm_kill (void *closure);
+int alarm_kill (void *closure);
#endif
diff --git a/calendar/gui/calendar.c b/calendar/gui/calendar.c
index 492ff24135..c53d2f1566 100644
--- a/calendar/gui/calendar.c
+++ b/calendar/gui/calendar.c
@@ -382,3 +382,15 @@ calendar_get_events_in_range (Calendar *cal, time_t start, time_t end)
calendar_iterate (cal, start, end, assemble_event_list, &l);
return l;
}
+
+void
+calendar_object_changed (Calendar *cal, iCalObject *obj, int flags)
+{
+ if (!(flags & CHANGE_DATES))
+ return;
+
+ /* Remove any alarms on the alarm list for this object */
+ while (alarm_kill (obj))
+ ;
+ ical_object_try_alarms (obj);
+}
diff --git a/calendar/gui/calendar.h b/calendar/gui/calendar.h
index 91d0f3338c..0a0e949d92 100644
--- a/calendar/gui/calendar.h
+++ b/calendar/gui/calendar.h
@@ -51,6 +51,9 @@ void calendar_iterate (Calendar *cal, time_t start, time_t end
/* Note this routine returns a GList with CalendarObjects */
GList *calendar_get_events_in_range (Calendar *cal, time_t start, time_t end);
+/* Informs the calendar that obj information has changed */
+void calendar_object_changed (Calendar *cal, iCalObject *obj, int flags);
+
/* Destroy the above list with this method */
void calendar_destroy_event_list (GList *l);
diff --git a/calendar/gui/gncal-full-day.c b/calendar/gui/gncal-full-day.c
index 4501c95c02..335cc2f17a 100644
--- a/calendar/gui/gncal-full-day.c
+++ b/calendar/gui/gncal-full-day.c
@@ -457,15 +457,20 @@ child_focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer data)
{
Child *child;
GncalFullDay *fullday;
-
+ char *text;
+
child = data;
/* Update summary in calendar object */
+ text = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);
+ if (child->ico->summary && strcmp (text, child->ico->summary) == 0)
+ return;
+
if (child->ico->summary)
g_free (child->ico->summary);
- child->ico->summary = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);
+ child->ico->summary = text;
child_set_size (child);
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index d44c5e89f3..d37d4156a8 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -196,14 +196,10 @@ gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj, int flags)
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
g_return_if_fail (obj != NULL);
- /* FIXME: for now we only update the views. Most likely we
- * need to do something else like set the last_mod field on
- * the iCalObject and such - Federico
- */
-
gcal->cal->modified = TRUE;
gnome_calendar_update_all (gcal, obj, flags);
+ calendar_object_changed (gcal->cal, obj, flags);
}
static int
@@ -269,6 +265,35 @@ execute (char *command, int close_standard)
}
void
+mail_notify (char *mail_address, char *text, time_t app_time)
+{
+ pid_t pid;
+ int p [2];
+ char *command;
+
+ pipe (p);
+ pid = fork ();
+ if (pid == 0){
+ const int top = max_open_files ();
+ int dev_null, i;
+
+ dev_null = open ("/dev/null", O_RDWR);
+ dup2 (p [0], 0);
+ dup2 (dev_null, 1);
+ dup2 (dev_null, 2);
+ execl ("/usr/lib/sendmail", "/usr/lib/sendmail",
+ mail_address, NULL);
+ _exit (127);
+ }
+ command = g_copy_strings ("To: ", mail_address, "\n",
+ "Subject: ", _("Reminder of your appointment at "),
+ ctime (&app_time), "\n\n", text, "\n", NULL);
+ write (p [1], command, strlen (command));
+
+ g_free (command);
+}
+
+void
calendar_notify (time_t time, void *data)
{
iCalObject *ico = data;
@@ -284,31 +309,9 @@ calendar_notify (time_t time, void *data)
}
if (ico->malarm.enabled && ico->malarm.trigger == time){
- char *command;
time_t app = ico->malarm.trigger + ico->malarm.offset;
- pid_t pid;
- int p [2];
-
- pipe (p);
- pid = fork ();
- if (pid == 0){
- const int top = max_open_files ();
- int dev_null, i;
- dev_null = open ("/dev/null", O_RDWR);
- dup2 (p [1], 0);
- dup2 (dev_null, 1);
- dup2 (dev_null, 2);
- execl ("/usr/lib/sendmail", "/usr/lib/sendmail",
- ico->malarm.data, NULL);
- _exit (127);
- }
- close (p [1]);
- command = g_copy_strings ("To: ", ico->malarm.data, "\n",
- "Subject: ", _("Reminder of your appointment at "),
- ctime (&app), "\n\n", NULL);
- write (p [0], command, strlen (command));
- g_free (command);
+ mail_notify (ico->malarm.data, ico->summary, app);
return;
}
@@ -325,3 +328,4 @@ calendar_notify (time_t time, void *data)
return;
}
}
+