diff options
-rw-r--r-- | calendar/ChangeLog | 34 | ||||
-rw-r--r-- | calendar/cal-client/cal-client.c | 3 | ||||
-rw-r--r-- | calendar/cal-util/cal-component.h | 3 | ||||
-rw-r--r-- | calendar/gui/alarm-notify/alarm-notify-dialog.c | 112 | ||||
-rw-r--r-- | calendar/gui/alarm-notify/alarm-notify-dialog.h | 3 | ||||
-rw-r--r-- | calendar/gui/alarm-notify/alarm-queue.c | 14 | ||||
-rw-r--r-- | calendar/gui/dialogs/alarm-page.c | 4 | ||||
-rw-r--r-- | calendar/gui/dialogs/event-page.c | 4 | ||||
-rw-r--r-- | calendar/gui/dialogs/meeting-page.c | 4 | ||||
-rw-r--r-- | calendar/gui/dialogs/recurrence-page.c | 4 | ||||
-rw-r--r-- | calendar/gui/dialogs/task-details-page.c | 4 | ||||
-rw-r--r-- | calendar/gui/dialogs/task-page.c | 4 | ||||
-rw-r--r-- | calendar/gui/goto.c | 2 | ||||
-rw-r--r-- | calendar/idl/evolution-calendar.idl | 3 | ||||
-rw-r--r-- | calendar/pcs/cal-backend-file.c | 26 |
15 files changed, 191 insertions, 33 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 1c1e0a1ecd..3546f6f376 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,37 @@ +2001-06-26 Federico Mena Quintero <federico@ximian.com> + + * idl/evolution-calendar.idl (CalAlarmInstance): Renamed the occur + field to occur_start; added an occur_end field. This way we can + present the complete times for the occurrence from the server. + + * cal-util/cal-component.h (CalAlarmInstance): Likewise. + + * pcs/cal-backend-file.c (add_alarm_occurrences_cb): Fill the new + fields appropriately. + (generate_absolute_triggers): Likewise; we use -1 in case the + component has no DTSTART or DTEND because there are no meaningful + occurrence dates here. + (fill_alarm_instances_seq): Fill in the new fields. + + * cal-client/cal-client.c (build_alarm_instance_list): Likewise. + + * gui/alarm-notify/alarm-notify-dialog.c (alarm_notify_dialog): + Take in both the occur_start and occur_end times. + + * gui/goto.c (goto_dialog): Free the dlg structure on the bail-out + cases. + + * gui/dialogs/event-page.c (get_widgets): Do not assert if we + cannot find the main widget; just return FALSE. + + * gui/dialogs/alarm-page.c (get_widgets): Likewise. + + * gui/dialogs/task-page.c (get_widgets): Likewise. + + * gui/dialogs/task-details-page.c (get_widgets): Likewise. + + * gui/dialogs/meeting-page.c (get_widgets): Likewise. + 2001-06-25 Peter Williams <peterw@ximian.com> * conduits/calendar/Makefile.am (INCLUDES): Fixes for diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c index 9e5461ea8e..a4a0851975 100644 --- a/calendar/cal-client/cal-client.c +++ b/calendar/cal-client/cal-client.c @@ -1376,7 +1376,8 @@ build_alarm_instance_list (CalComponent *comp, GNOME_Evolution_Calendar_CalAlarm instance = g_new (CalAlarmInstance, 1); instance->auid = auid; instance->trigger = corba_instance->trigger; - instance->occur = corba_instance->occur; + instance->occur_start = corba_instance->occur_start; + instance->occur_end = corba_instance->occur_end; alarms = g_slist_prepend (alarms, instance); } diff --git a/calendar/cal-util/cal-component.h b/calendar/cal-util/cal-component.h index cd9ee725ed..c8f21963b4 100644 --- a/calendar/cal-util/cal-component.h +++ b/calendar/cal-util/cal-component.h @@ -364,7 +364,8 @@ typedef struct { time_t trigger; /* Actual event occurrence to which this trigger corresponds */ - time_t occur; + time_t occur_start; + time_t occur_end; } CalAlarmInstance; /* Alarm trigger instances for a particular component */ diff --git a/calendar/gui/alarm-notify/alarm-notify-dialog.c b/calendar/gui/alarm-notify/alarm-notify-dialog.c index 99b244613a..219bf7b102 100644 --- a/calendar/gui/alarm-notify/alarm-notify-dialog.c +++ b/calendar/gui/alarm-notify/alarm-notify-dialog.c @@ -120,10 +120,106 @@ edit_clicked_cb (GtkWidget *widget, gpointer data) gtk_widget_destroy (an->dialog); } +/* Creates a heading for the alarm notification dialog */ +static char * +make_heading (CalComponent *comp, time_t occur_start, time_t occur_end) +{ + CalComponentVType vtype; + char *buf; + char s[128], e[128]; + + vtype = cal_component_get_vtype (comp); + + if (occur_start != -1) { + struct tm tm; + + tm = *localtime (&occur_start); + strftime (s, sizeof (s), "%A %b %d %Y %H:%M", &tm); + } + + if (occur_end != -1) { + struct tm tm; + + tm = *localtime (&occur_end); + strftime (e, sizeof (e), "%A %b %d %Y %H:%M", &tm); + } + + /* I love combinatorial explosion */ + + switch (vtype) { + case CAL_COMPONENT_EVENT: + if (occur_start != -1) { + if (occur_end != -1) + buf = g_strdup_printf (_("Notification about your appointment " + "starting on %s and ending on %s"), + s, e); + else + buf = g_strdup_printf (_("Notification about your appointment " + "starting on %s"), + s); + } else { + if (occur_end != -1) + buf = g_strdup_printf (_("Notification about your appointment " + "ending on %s"), + e); + else + buf = g_strdup_printf (_("Notification about your appointment")); + } + break; + + case CAL_COMPONENT_TODO: + if (occur_start != -1) { + if (occur_end != -1) + buf = g_strdup_printf (_("Notification about your task " + "starting on %s and ending on %s"), + s, e); + else + buf = g_strdup_printf (_("Notification about your task " + "starting on %s"), + s); + } else { + if (occur_end != -1) + buf = g_strdup_printf (_("Notification about your task " + "ending on %s"), + e); + else + buf = g_strdup_printf (_("Notification about your task")); + } + break; + + case CAL_COMPONENT_JOURNAL: + if (occur_start != -1) { + if (occur_end != -1) + buf = g_strdup_printf (_("Notification about your journal entry " + "starting on %s and ending on %s"), + s, e); + else + buf = g_strdup_printf (_("Notification about your journal entry " + "starting on %s"), + s); + } else { + if (occur_end != -1) + buf = g_strdup_printf (_("Notification about your journal entry " + "ending on %s"), + e); + else + buf = g_strdup_printf (_("Notification about your journal entry")); + } + break; + + default: + g_assert_not_reached(); + return NULL; + } + + return buf; +} + /** * alarm_notify_dialog: * @trigger: Trigger time for the alarm. - * @occur: Occurrence time for the event. + * @occur_start: Start of occurrence time for the event. + * @occur_end: End of occurrence time for the event. * @comp: Calendar component object which corresponds to the alarm. * @func: Function to be called when a dialog action is invoked. * @func_data: Closure data for @func. @@ -134,17 +230,17 @@ edit_clicked_cb (GtkWidget *widget, gpointer data) * Return value: TRUE on success, FALSE if the dialog could not be created. **/ gboolean -alarm_notify_dialog (time_t trigger, time_t occur, CalComponent *comp, +alarm_notify_dialog (time_t trigger, time_t occur_start, time_t occur_end, + CalComponent *comp, AlarmNotifyFunc func, gpointer func_data) { AlarmNotify *an; char buf[256]; + char *heading; struct tm tm_trigger; - struct tm tm_occur; CalComponentText summary; g_return_val_if_fail (trigger != -1, FALSE); - g_return_val_if_fail (occur != -1, FALSE); g_return_val_if_fail (comp != NULL, FALSE); g_return_val_if_fail (IS_CAL_COMPONENT (comp), FALSE); g_return_val_if_fail (func != NULL, FALSE); @@ -191,11 +287,9 @@ alarm_notify_dialog (time_t trigger, time_t occur, CalComponent *comp, /* Heading */ - tm_occur = *localtime (&occur); - strftime (buf, sizeof (buf), - _("Notification about your appointment on %A %b %d %Y %H:%M"), - &tm_occur); - gtk_label_set_text (GTK_LABEL (an->heading), buf); + heading = make_heading (comp, occur_start, occur_end); + gtk_label_set_text (GTK_LABEL (an->heading), heading); + g_free (heading); /* Summary */ diff --git a/calendar/gui/alarm-notify/alarm-notify-dialog.h b/calendar/gui/alarm-notify/alarm-notify-dialog.h index 1b37a097aa..6399261819 100644 --- a/calendar/gui/alarm-notify/alarm-notify-dialog.h +++ b/calendar/gui/alarm-notify/alarm-notify-dialog.h @@ -36,7 +36,8 @@ typedef enum { typedef void (* AlarmNotifyFunc) (AlarmNotifyResult result, int snooze_mins, gpointer data); -gboolean alarm_notify_dialog (time_t trigger, time_t occur, CalComponent *comp, +gboolean alarm_notify_dialog (time_t trigger, time_t occur_start, time_t occur_end, + CalComponent *comp, AlarmNotifyFunc func, gpointer func_data); diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index 2072e03c84..c0e66ff484 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -163,8 +163,6 @@ alarm_trigger_cb (gpointer alarm_id, time_t trigger, gpointer data) CalComponent *comp; GSList *l; QueuedAlarm *qa; - const char *auid; - time_t occur; cqa = data; comp = cqa->alarms->comp; @@ -181,15 +179,9 @@ alarm_trigger_cb (gpointer alarm_id, time_t trigger, gpointer data) g_assert (qa != NULL); - /* Fetch the alarm information. We use the trigger time passed to us - * instead of the one in the instance structure because this may not be - * the actual computed trigger but a snoozed one instead. - */ - - auid = qa->instance->auid; - occur = qa->instance->occur; - - if (!alarm_notify_dialog (trigger, occur, comp, notify_dialog_cb, comp)) + if (!alarm_notify_dialog (trigger, + qa->instance->occur_start, qa->instance->occur_end, + comp, notify_dialog_cb, comp)) g_message ("alarm_trigger_cb(): Could not create the alarm notify dialog"); } diff --git a/calendar/gui/dialogs/alarm-page.c b/calendar/gui/dialogs/alarm-page.c index 74e728ad4c..9a92b5c9a2 100644 --- a/calendar/gui/dialogs/alarm-page.c +++ b/calendar/gui/dialogs/alarm-page.c @@ -562,7 +562,9 @@ get_widgets (AlarmPage *apage) #define GW(name) glade_xml_get_widget (priv->xml, name) priv->main = GW ("alarm-page"); - g_assert (priv->main); + if (!priv->main) + return FALSE; + gtk_widget_ref (priv->main); gtk_widget_unparent (priv->main); diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c index 93d9b65e14..5646a31a76 100644 --- a/calendar/gui/dialogs/event-page.c +++ b/calendar/gui/dialogs/event-page.c @@ -534,7 +534,9 @@ get_widgets (EventPage *epage) #define GW(name) glade_xml_get_widget (priv->xml, name) priv->main = GW ("event-page"); - g_assert (priv->main); + if (!priv->main) + return FALSE; + gtk_widget_ref (priv->main); gtk_widget_unparent (priv->main); diff --git a/calendar/gui/dialogs/meeting-page.c b/calendar/gui/dialogs/meeting-page.c index 7932fbd177..fddaab1900 100644 --- a/calendar/gui/dialogs/meeting-page.c +++ b/calendar/gui/dialogs/meeting-page.c @@ -373,7 +373,9 @@ get_widgets (MeetingPage *mpage) #define GW(name) glade_xml_get_widget (priv->xml, name) priv->main = GW ("meeting-page"); - g_assert (priv->main); + if (!priv->main) + return FALSE; + gtk_widget_ref (priv->main); gtk_widget_unparent (priv->main); diff --git a/calendar/gui/dialogs/recurrence-page.c b/calendar/gui/dialogs/recurrence-page.c index c5c45def15..e1656ad83f 100644 --- a/calendar/gui/dialogs/recurrence-page.c +++ b/calendar/gui/dialogs/recurrence-page.c @@ -1747,7 +1747,9 @@ get_widgets (RecurrencePage *rpage) #define GW(name) glade_xml_get_widget (priv->xml, name) priv->main = GW ("recurrence-page"); - g_assert (priv->main); + if (!priv->main) + return FALSE; + gtk_widget_ref (priv->main); gtk_widget_unparent (priv->main); diff --git a/calendar/gui/dialogs/task-details-page.c b/calendar/gui/dialogs/task-details-page.c index 76a3cadcd4..2e4a5ddab1 100644 --- a/calendar/gui/dialogs/task-details-page.c +++ b/calendar/gui/dialogs/task-details-page.c @@ -320,7 +320,9 @@ get_widgets (TaskDetailsPage *tdpage) #define GW(name) glade_xml_get_widget (priv->xml, name) priv->main = GW ("task-details-page"); - g_assert (priv->main); + if (!priv->main) + return FALSE; + gtk_widget_ref (priv->main); gtk_widget_unparent (priv->main); diff --git a/calendar/gui/dialogs/task-page.c b/calendar/gui/dialogs/task-page.c index 02a1e1bfd3..ce01a389e6 100644 --- a/calendar/gui/dialogs/task-page.c +++ b/calendar/gui/dialogs/task-page.c @@ -618,7 +618,9 @@ get_widgets (TaskPage *tpage) #define GW(name) glade_xml_get_widget (priv->xml, name) priv->main = GW ("task-page"); - g_assert (priv->main); + if (!priv->main) + return FALSE; + gtk_widget_ref (priv->main); gtk_widget_unparent (priv->main); diff --git a/calendar/gui/goto.c b/calendar/gui/goto.c index 86dc92bb3a..16c1eecc9f 100644 --- a/calendar/gui/goto.c +++ b/calendar/gui/goto.c @@ -184,11 +184,13 @@ goto_dialog (GnomeCalendar *gcal) dlg->xml = glade_xml_new (EVOLUTION_GLADEDIR "/goto-dialog.glade", NULL); if (!dlg->xml) { g_message ("goto_dialog(): Could not load the Glade XML file!"); + g_free (dlg); return; } if (!get_widgets (dlg)) { g_message ("goto_dialog(): Could not find all widgets in the XML file!"); + g_free (dlg); return; } dlg->gcal = gcal; diff --git a/calendar/idl/evolution-calendar.idl b/calendar/idl/evolution-calendar.idl index 5ee0aa47a8..5f0d10513f 100644 --- a/calendar/idl/evolution-calendar.idl +++ b/calendar/idl/evolution-calendar.idl @@ -83,7 +83,8 @@ module Calendar { struct CalAlarmInstance { CalAlarmUID auid; Time_t trigger; - Time_t occur; + Time_t occur_start; + Time_t occur_end; }; /* Used to represent a list of alarm triggers for a single component */ diff --git a/calendar/pcs/cal-backend-file.c b/calendar/pcs/cal-backend-file.c index b7ba095a30..79a6018ec0 100644 --- a/calendar/pcs/cal-backend-file.c +++ b/calendar/pcs/cal-backend-file.c @@ -1240,7 +1240,8 @@ add_alarm_occurrences_cb (CalComponent *comp, time_t start, time_t end, gpointer instance = g_new (CalAlarmInstance, 1); instance->auid = auid; instance->trigger = trigger_time; - instance->occur = occur_time; + instance->occur_start = start; + instance->occur_end = end; aod->triggers = g_slist_prepend (aod->triggers, instance); aod->n_triggers++; @@ -1254,6 +1255,10 @@ static void generate_absolute_triggers (CalComponent *comp, struct alarm_occurrence_data *aod) { GList *l; + CalComponentDateTime dt_start, dt_end; + + cal_component_get_dtstart (comp, &dt_start); + cal_component_get_dtend (comp, &dt_end); for (l = aod->alarm_uids; l; l = l->next) { const char *auid; @@ -1280,11 +1285,25 @@ generate_absolute_triggers (CalComponent *comp, struct alarm_occurrence_data *ao instance = g_new (CalAlarmInstance, 1); instance->auid = auid; instance->trigger = abs_time; - instance->occur = abs_time; /* No particular occurrence, so just use the same time */ + + /* No particular occurrence, so just use the times from the component */ + + if (dt_start.value) + instance->occur_start = icaltime_as_timet (*dt_start.value); + else + instance->occur_start = -1; + + if (dt_end.value) + instance->occur_end = icaltime_as_timet (*dt_end.value); + else + instance->occur_end = -1; aod->triggers = g_slist_prepend (aod->triggers, instance); aod->n_triggers++; } + + cal_component_free_datetime (&dt_start); + cal_component_free_datetime (&dt_end); } /* Compares two alarm instances; called from g_slist_sort() */ @@ -1396,7 +1415,8 @@ fill_alarm_instances_seq (GNOME_Evolution_Calendar_CalAlarmInstanceSeq *seq, GSL corba_instance->auid = CORBA_string_dup (instance->auid); corba_instance->trigger = (long) instance->trigger; - corba_instance->occur = (long) instance->occur; + corba_instance->occur_start = (long) instance->occur_start; + corba_instance->occur_end = (long) instance->occur_end; } } |