2001-08-06 Damon Chaplin <damon@ximian.com> * gui/e-week-view.h: * gui/e-day-view.h: added 'different_timezone' fields to EDayViewEvent and EWeekViewEvent, to note that the event is in a different timezone. We now compute this once when we add the event to the array, rather than each time we draw the event. If it is set, we will draw the timezone icon next to the event. * gui/e-day-view-main-item.c: take transparency into account when drawing the blue vertical bars to represent busy time. * gui/tag-calendar.c: take transparency into account when tagging the mini calendar. * gui/e-calendar-table.c (e_calendar_table_init): removed the "None" options for transparency and classification, since these properties have defaults anyway, so we may as well use those to keep it simple. Also use "Free" and "Busy" for transparency, rather than "Transparent" and "Opaque". * gui/calendar-model.c: updated classification & transparency code as above. * gui/e-calendar-table.etspec: changed "Transparency" to "Show Time As" since people have a chance of understanding that. * gui/e-week-view.c: * gui/e-day-view.c: * gui/gnome-cal.c: added functions to get the visible time range. * gui/calendar-commands.c: finished stuff to set the folder bar label to the dates currently displayed. * gui/control-factory.c (control_factory_new_control): connected signal to update the folder title bar label when the dates shown are changed. I had to connect it here since we need the BonoboControl in the callback, and I don't know how to get the control from the widget. * gui/tasks-control.c (tasks_control_activate): clear the folder bar label. We could display something here at some point. * gui/dialogs/recurrence-page.glade: changed "_Add" to "A_dd", since we have an "_Actions" menu. (These also use Alt+key, right?) * gui/dialogs/event-page.glade: * gui/dialogs/event-page.c: added 'Show Time As' field, which is really the TRANSP property but with a better name! Also changed one of the "_Confidential" to "Con_fidential" since we already have "_Contacts" using the same 'C' key. * pcs/cal-backend-file.c (cal_backend_file_get_free_busy): skip events that are TRANSPARENT. Also added comment as this code looks inefficient. * cal-util/cal-component.c: removed stuff for comparing timezones. * gui/comp-util.c (cal_comp_util_compare_event_timezones): moved the above function here, and updated it to compare the UTC offsets of the times as well as the TZIDs. svn path=/trunk/; revision=11717
155 lines
4.3 KiB
C
155 lines
4.3 KiB
C
/* Evolution calendar - Utilities for manipulating CalComponent objects
|
||
*
|
||
* Copyright (C) 2000 Ximian, Inc.
|
||
* Copyright (C) 2000 Ximian, Inc.
|
||
*
|
||
* Author: Federico Mena-Quintero <federico@ximian.com>
|
||
*
|
||
* This program is free software; you can redistribute it and/or modify
|
||
* it under the terms of the GNU General Public License as published by
|
||
* the Free Software Foundation; either version 2 of the License, or
|
||
* (at your option) any later version.
|
||
*
|
||
* This program is distributed in the hope that it will be useful,
|
||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
* GNU General Public License for more details.
|
||
*
|
||
* You should have received a copy of the GNU General Public License
|
||
* along with this program; if not, write to the Free Software
|
||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||
*/
|
||
|
||
#ifdef HAVE_CONFIG_H
|
||
#include <config.h>
|
||
#endif
|
||
|
||
#include "comp-util.h"
|
||
|
||
|
||
|
||
/**
|
||
* cal_comp_util_add_exdate:
|
||
* @comp: A calendar component object.
|
||
* @itt: Time for the exception.
|
||
*
|
||
* Adds an exception date to the current list of EXDATE properties in a calendar
|
||
* component object.
|
||
**/
|
||
void
|
||
cal_comp_util_add_exdate (CalComponent *comp, time_t t, icaltimezone *zone)
|
||
{
|
||
GSList *list;
|
||
CalComponentDateTime *cdt;
|
||
|
||
g_return_if_fail (comp != NULL);
|
||
g_return_if_fail (IS_CAL_COMPONENT (comp));
|
||
|
||
cal_component_get_exdate_list (comp, &list);
|
||
|
||
cdt = g_new (CalComponentDateTime, 1);
|
||
cdt->value = g_new (struct icaltimetype, 1);
|
||
*cdt->value = icaltime_from_timet_with_zone (t, TRUE, zone);
|
||
cdt->tzid = g_strdup (icaltimezone_get_tzid (zone));
|
||
|
||
list = g_slist_append (list, cdt);
|
||
cal_component_set_exdate_list (comp, list);
|
||
cal_component_free_exdate_list (list);
|
||
}
|
||
|
||
|
||
|
||
/* Returns TRUE if the TZIDs are equivalent, i.e. both NULL or the same. */
|
||
static gboolean
|
||
cal_component_compare_tzid (const char *tzid1, const char *tzid2)
|
||
{
|
||
gboolean retval = TRUE;
|
||
|
||
if (tzid1) {
|
||
if (!tzid2 || strcmp (tzid1, tzid2))
|
||
retval = FALSE;
|
||
} else {
|
||
if (tzid2)
|
||
retval = FALSE;
|
||
}
|
||
|
||
return retval;
|
||
}
|
||
|
||
/**
|
||
* cal_comp_util_compare_event_timezones:
|
||
* @comp: A calendar component object.
|
||
* @client: A #CalClient.
|
||
*
|
||
* Checks if the component uses the given timezone for both the start and
|
||
* the end time, or if the UTC offsets of the start and end times are the same
|
||
* as in the given zone.
|
||
*
|
||
* Returns: TRUE if the component's start and end time are at the same UTC
|
||
* offset in the given timezone.
|
||
**/
|
||
gboolean
|
||
cal_comp_util_compare_event_timezones (CalComponent *comp,
|
||
CalClient *client,
|
||
icaltimezone *zone)
|
||
{
|
||
CalClientGetStatus status;
|
||
CalComponentDateTime start_datetime, end_datetime;
|
||
const char *tzid;
|
||
gboolean retval = FALSE;
|
||
icaltimezone *start_zone, *end_zone;
|
||
int offset1, offset2;
|
||
|
||
tzid = icaltimezone_get_tzid (zone);
|
||
|
||
cal_component_get_dtstart (comp, &start_datetime);
|
||
cal_component_get_dtend (comp, &end_datetime);
|
||
|
||
/* FIXME: DURATION may be used instead. */
|
||
if (cal_component_compare_tzid (tzid, start_datetime.tzid)
|
||
&& cal_component_compare_tzid (tzid, end_datetime.tzid)) {
|
||
/* If both TZIDs are the same as the given zone's TZID, then
|
||
we know the timezones are the same so we return TRUE. */
|
||
retval = TRUE;
|
||
} else {
|
||
/* If the TZIDs differ, we have to compare the UTC offsets
|
||
of the start and end times, using their own timezones and
|
||
the given timezone. */
|
||
status = cal_client_get_timezone (client,
|
||
start_datetime.tzid,
|
||
&start_zone);
|
||
if (status != CAL_CLIENT_GET_SUCCESS)
|
||
goto out;
|
||
|
||
offset1 = icaltimezone_get_utc_offset (start_zone,
|
||
start_datetime.value,
|
||
NULL);
|
||
offset2 = icaltimezone_get_utc_offset (zone,
|
||
start_datetime.value,
|
||
NULL);
|
||
if (offset1 == offset2) {
|
||
status = cal_client_get_timezone (client,
|
||
end_datetime.tzid,
|
||
&end_zone);
|
||
if (status != CAL_CLIENT_GET_SUCCESS)
|
||
goto out;
|
||
|
||
offset1 = icaltimezone_get_utc_offset (end_zone,
|
||
end_datetime.value,
|
||
NULL);
|
||
offset2 = icaltimezone_get_utc_offset (zone,
|
||
end_datetime.value,
|
||
NULL);
|
||
if (offset1 == offset2)
|
||
retval = TRUE;
|
||
}
|
||
}
|
||
|
||
out:
|
||
|
||
cal_component_free_datetime (&start_datetime);
|
||
cal_component_free_datetime (&end_datetime);
|
||
|
||
return retval;
|
||
}
|