aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog1
-rw-r--r--calendar/cal-util/cal-util.h9
-rw-r--r--calendar/gui/alarm-notify/alarm-notify.c9
-rw-r--r--calendar/gui/calendar-commands.c34
-rw-r--r--calendar/gui/calendar-offline-handler.c2
-rw-r--r--calendar/gui/comp-editor-factory.c4
-rw-r--r--calendar/gui/control-factory.c2
-rw-r--r--calendar/gui/e-cal-model-tasks.c4
-rw-r--r--calendar/gui/e-cal-model.c124
-rw-r--r--calendar/gui/e-cal-model.h3
-rw-r--r--calendar/gui/e-cal-view.c279
-rw-r--r--calendar/gui/e-cal-view.h11
-rw-r--r--calendar/gui/e-calendar-view.c279
-rw-r--r--calendar/gui/e-calendar-view.h11
-rw-r--r--calendar/gui/e-day-view-main-item.c44
-rw-r--r--calendar/gui/e-day-view-top-item.c18
-rw-r--r--calendar/gui/e-day-view.c701
-rw-r--r--calendar/gui/e-day-view.h2
-rw-r--r--calendar/gui/e-week-view-event-item.c46
-rw-r--r--calendar/gui/e-week-view.c411
-rw-r--r--calendar/gui/e-week-view.h2
-rw-r--r--calendar/gui/gnome-cal.c410
-rw-r--r--calendar/gui/gnome-cal.h10
-rw-r--r--calendar/gui/goto.c2
-rw-r--r--calendar/gui/itip-bonobo-control.c22
-rw-r--r--calendar/gui/print.c202
26 files changed, 1326 insertions, 1316 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 66efa153be..aa452faf12 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -516,7 +516,6 @@
* cal-client/cal-client-multi.[ch]:
* cal-client/Makefile.am: removed obsolete code.
->>>>>>> 1.1841.2.20
2003-07-29 Rodrigo Moya <rodrigo@ximian.com>
Fixes all "alarm daemon doesn't start with session"
diff --git a/calendar/cal-util/cal-util.h b/calendar/cal-util/cal-util.h
index 19c73270b3..03d5cd736b 100644
--- a/calendar/cal-util/cal-util.h
+++ b/calendar/cal-util/cal-util.h
@@ -99,6 +99,15 @@ char *cal_util_expand_uri (char *uri, gboolean tasks);
void cal_util_add_timezones_from_component (icalcomponent *vcal_comp,
icalcomponent *icalcomp);
+gboolean cal_util_component_is_instance (icalcomponent *icalcomp);
+gboolean cal_util_component_has_alarms (icalcomponent *icalcomp);
+gboolean cal_util_component_has_organizer (icalcomponent *icalcomp);
+gboolean cal_util_component_has_recurrences (icalcomponent *icalcomp);
+gboolean cal_util_component_has_rdates (icalcomponent *icalcomp);
+gboolean cal_util_component_has_rrules (icalcomponent *icalcomp);
+
+gboolean cal_util_event_dates_match (icalcomponent *icalcomp1, icalcomponent *icalcomp2);
+
/* The static capabilities to be supported by backends */
#define CAL_STATIC_CAPABILITY_NO_ALARM_REPEAT "no-alarm-repeat"
#define CAL_STATIC_CAPABILITY_NO_AUDIO_ALARMS "no-audio-alarms"
diff --git a/calendar/gui/alarm-notify/alarm-notify.c b/calendar/gui/alarm-notify/alarm-notify.c
index 20ba5547f1..800eeb80f6 100644
--- a/calendar/gui/alarm-notify/alarm-notify.c
+++ b/calendar/gui/alarm-notify/alarm-notify.c
@@ -445,16 +445,17 @@ alarm_notify_add_calendar (AlarmNotify *an, const char *str_uri, gboolean load_a
/* we only add the URI to load_afterwards if we open it
correctly */
lc = g_new (LoadedClient, 1);
+ lc->client = client;
+ lc->uri = uri;
+ lc->refcount = 1;
+ lc->timeout_id = -1;
+
g_signal_connect (G_OBJECT (client), "cal_opened",
G_CALLBACK (cal_opened_cb),
lc);
if (cal_client_open_calendar (client, str_uri, FALSE)) {
- lc->client = client;
- lc->uri = uri;
- lc->refcount = 1;
- lc->timeout_id = -1;
g_hash_table_insert (priv->uri_client_hash,
g_strdup (str_uri), lc);
} else {
diff --git a/calendar/gui/calendar-commands.c b/calendar/gui/calendar-commands.c
index 6b91e79463..38206a66b9 100644
--- a/calendar/gui/calendar-commands.c
+++ b/calendar/gui/calendar-commands.c
@@ -314,8 +314,8 @@ static void
publish_freebusy_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path)
{
GnomeCalendar *gcal;
- CalClient *client;
- GList *comp_list;
+ GList *client_list, *cl;
+ GList *comp_list = NULL;
icaltimezone *utc;
time_t start = time (NULL), end;
@@ -325,20 +325,26 @@ publish_freebusy_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path)
start = time_day_begin_with_zone (start, utc);
end = time_add_week_with_zone (start, 6, utc);
- client = gnome_calendar_get_cal_client (gcal);
- comp_list = cal_client_get_free_busy (client, NULL, start, end);
- if (comp_list) {
- GList *l;
+ client_list = e_cal_model_get_client_list (gnome_calendar_get_calendar_model (gcal));
+ for (cl = client_list; cl != NULL; cl = cl->next) {
+ GList *tmp_comp_list;
- for (l = comp_list; l; l = l->next) {
- CalComponent *comp = CAL_COMPONENT (l->data);
- itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, comp, client, NULL);
+ tmp_comp_list = cal_client_get_free_busy ((CalClient *) cl->data, NULL, start, end);
+ if (tmp_comp_list) {
+ GList *l;
- g_object_unref (comp);
- }
+ for (l = comp_list; l; l = l->next) {
+ CalComponent *comp = CAL_COMPONENT (l->data);
+ itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, comp, (CalClient *) cl->data, NULL);
+
+ g_object_unref (comp);
+ }
- g_list_free (comp_list);
+ g_list_free (comp_list);
+ }
}
+
+ g_list_free (client_list);
}
static void
@@ -589,7 +595,7 @@ sensitize_calendar_commands (GnomeCalendar *gcal, BonoboControl *control, gboole
g_assert (uic != NULL);
n_selected = enable ? gnome_calendar_get_num_events_selected (gcal) : 0;
- read_only = cal_client_is_read_only (gnome_calendar_get_cal_client (gcal));
+ read_only = cal_client_is_read_only (e_cal_model_get_default_client (gnome_calendar_get_calendar_model (gcal)));
bonobo_ui_component_set_prop (uic, "/commands/Cut", "sensitive",
n_selected == 0 || read_only ? "0" : "1",
@@ -620,7 +626,7 @@ sensitize_calendar_commands (GnomeCalendar *gcal, BonoboControl *control, gboole
event = NULL;
if (event) {
- if (cal_component_has_recurrences (event->comp))
+ if (cal_util_component_has_recurrences (event->comp_data->icalcomp))
has_recurrences = TRUE;
}
}
diff --git a/calendar/gui/calendar-offline-handler.c b/calendar/gui/calendar-offline-handler.c
index fd59965283..458f951d9a 100644
--- a/calendar/gui/calendar-offline-handler.c
+++ b/calendar/gui/calendar-offline-handler.c
@@ -164,8 +164,6 @@ backend_cal_opened_offline (CalClient *client, CalClientOpenStatus status, gpoin
static void
backend_cal_opened_online (CalClient *client, CalClientOpenStatus status, gpointer data)
{
- CalendarOfflineHandler *offline_handler = data;
-
if (status != CAL_CLIENT_OPEN_SUCCESS) {
g_object_unref (G_OBJECT (client));
return;
diff --git a/calendar/gui/comp-editor-factory.c b/calendar/gui/comp-editor-factory.c
index af52c8f4e2..f76e0d4f03 100644
--- a/calendar/gui/comp-editor-factory.c
+++ b/calendar/gui/comp-editor-factory.c
@@ -95,7 +95,7 @@ static void comp_editor_factory_finalize (GObject *object);
static void impl_editExisting (PortableServer_Servant servant,
const CORBA_char *str_uri,
- const GNOME_Evolution_Calendar_CalObjUID uid,
+ const CORBA_char *uid,
CORBA_Environment *ev);
static void impl_editNew (PortableServer_Servant servant,
const CORBA_char *str_uri,
@@ -585,7 +585,7 @@ queue_edit_existing (OpenClient *oc, const char *uid)
static void
impl_editExisting (PortableServer_Servant servant,
const CORBA_char *str_uri,
- const GNOME_Evolution_Calendar_CalObjUID uid,
+ const CORBA_char *uid,
CORBA_Environment *ev)
{
CompEditorFactory *factory;
diff --git a/calendar/gui/control-factory.c b/calendar/gui/control-factory.c
index 8a6f6faf11..c245c983b9 100644
--- a/calendar/gui/control-factory.c
+++ b/calendar/gui/control-factory.c
@@ -75,7 +75,7 @@ get_prop (BonoboPropertyBag *bag,
switch (arg_id) {
case PROPERTY_CALENDAR_URI_IDX:
- uri = cal_client_get_uri (gnome_calendar_get_cal_client (gcal));
+ uri = cal_client_get_uri (e_cal_model_get_default_client (gnome_calendar_get_calendar_model (gcal)));
BONOBO_ARG_SET_STRING (arg, uri);
break;
diff --git a/calendar/gui/e-cal-model-tasks.c b/calendar/gui/e-cal-model-tasks.c
index 7e00aca84d..deeb341512 100644
--- a/calendar/gui/e-cal-model-tasks.c
+++ b/calendar/gui/e-cal-model-tasks.c
@@ -957,9 +957,11 @@ ecmt_get_color_for_component (ECalModel *model, ECalModelComponent *comp_data)
case E_CAL_MODEL_TASKS_DUE_NEVER:
case E_CAL_MODEL_TASKS_DUE_FUTURE:
case E_CAL_MODEL_TASKS_DUE_COMPLETE:
+ break;
}
- return E_CAL_MODEL_CLASS (parent_class)->get_color_for_component (model, comp_data);
+ return "black";
+ /* return E_CAL_MODEL_CLASS (parent_class)->get_color_for_component (model, comp_data); */
}
static void
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c
index 92f5649270..1f2e4a8f13 100644
--- a/calendar/gui/e-cal-model.c
+++ b/calendar/gui/e-cal-model.c
@@ -224,7 +224,6 @@ e_cal_model_finalize (GObject *object)
}
if (priv->accounts) {
- g_object_unref (priv->accounts);
priv->accounts = NULL;
}
@@ -615,7 +614,6 @@ ecm_append_row (ETableModel *etm, ETableModel *source, int row)
{
ECalModelClass *model_class;
ECalModelComponent comp_data;
- icalcomponent *icalcomp;
ECalModel *source_model = (ECalModel *) source;
ECalModel *model = (ECalModel *) etm;
@@ -644,11 +642,11 @@ ecm_append_row (ETableModel *etm, ETableModel *source, int row)
model_class->fill_component_from_model (model, &comp_data, source_model, row);
}
- if (cal_client_update_objects (comp_data.client, icalcomp) != CAL_CLIENT_RESULT_SUCCESS) {
+ if (cal_client_update_objects (comp_data.client, comp_data.icalcomp) != CAL_CLIENT_RESULT_SUCCESS) {
/* FIXME: show error dialog */
}
- icalcomponent_free (icalcomp);
+ icalcomponent_free (comp_data.icalcomp);
}
static void *
@@ -811,42 +809,53 @@ ecm_value_to_string (ETableModel *etm, int col, const void *value)
/* ECalModel class methods */
+typedef struct {
+ const gchar *color;
+ GList *uris;
+} AssignedColorData;
+
static const char *
ecm_get_color_for_component (ECalModel *model, ECalModelComponent *comp_data)
{
ECalModelPrivate *priv;
- gint i, pos;
- GList *l;
- gchar *colors[] = {
- "#718DA9", /* 113 141 169 */
- "#C6E2E2", /* 198 226 226 */
- "#8DC671", /* 141 198 113 */
- "#C6E2A9", /* 198 226 169 */
- "#C6A971", /* 198 169 113 */
- "#FFE271", /* 255 226 113 */
- "#E27171", /* 226 113 113 */
- "#FFA9A9", /* 255 169 169 */
- "#C68DC6", /* 198 141 198 */
- "#E2C6E2", /* 226 198 226 */
- "#D6D684", /* 214 214 132 */
- "#5B5B84" /* 91 91 132 */
+ gint i, first_empty = 0;
+ static AssignedColorData assigned_colors[] = {
+ { "#BECEDD", NULL }, /* 190 206 221 Blue */
+ { "#E2F0EF", NULL }, /* 226 240 239 Light Blue */
+ { "#C6E2B7", NULL }, /* 198 226 183 Green */
+ { "#E2F0D3", NULL }, /* 226 240 211 Light Green */
+ { "#E2D4B7", NULL }, /* 226 212 183 Khaki */
+ { "#EAEAC1", NULL }, /* 234 234 193 Light Khaki */
+ { "#F0B8B7", NULL }, /* 240 184 183 Pink */
+ { "#FED4D3", NULL }, /* 254 212 211 Light Pink */
+ { "#E2C6E1", NULL }, /* 226 198 225 Purple */
+ { "#F0E2EF", NULL } /* 240 226 239 Light Purple */
};
g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
- g_return_val_if_fail (comp_data != NULL, NULL);
priv = model->priv;
+
+ for (i = 0; i < G_N_ELEMENTS (assigned_colors); i++) {
+ GList *l;
- for (l = priv->clients, i = 0; l != NULL; l = l->next, i++) {
- ECalModelClient *client_data = (ECalModelClient *) l->data;
+ if (assigned_colors[i].uris == NULL) {
+ first_empty = i;
+ continue;
+ }
- if (client_data->client == comp_data->client) {
- pos = i % G_N_ELEMENTS (colors);
- return colors[pos];
+ for (l = assigned_colors[i].uris; l != NULL; l = l->next) {
+ if (!strcmp ((const char *) l->data,
+ cal_client_get_uri (comp_data->client)))
+ return assigned_colors[i].color;
}
}
- return NULL;
+ /* return the first unused color */
+ assigned_colors[first_empty].uris = g_list_append (assigned_colors[first_empty].uris,
+ g_strdup (cal_client_get_uri (comp_data->client)));
+
+ return assigned_colors[first_empty].color;
}
/**
@@ -987,6 +996,25 @@ e_cal_model_get_default_client (ECalModel *model)
return client_data->client;
}
+/**
+ * e_cal_model_get_client_list
+ */
+GList *
+e_cal_model_get_client_list (ECalModel *model)
+{
+ GList *list = NULL, *l;
+
+ g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
+
+ for (l = model->priv->clients; l != NULL; l = l->next) {
+ ECalModelClient *client_data = (ECalModelClient *) l->data;
+
+ list = g_list_append (list, client_data->client);
+ }
+
+ return list;
+}
+
static ECalModelComponent *
search_by_uid_and_client (ECalModelPrivate *priv, CalClient *client, const char *uid)
{
@@ -1208,6 +1236,16 @@ update_query_for_client (ECalModel *model, ECalModelClient *client_data)
}
static void
+backend_died_cb (CalClient *client, gpointer user_data)
+{
+ ECalModel *model;
+
+ model = E_CAL_MODEL (user_data);
+
+ e_cal_model_remove_client (model, client);
+}
+
+static void
add_new_client (ECalModel *model, CalClient *client)
{
ECalModelPrivate *priv;
@@ -1222,6 +1260,9 @@ add_new_client (ECalModel *model, CalClient *client)
priv->clients = g_list_append (priv->clients, client_data);
+ g_signal_connect (G_OBJECT (client_data->client), "backend_died",
+ G_CALLBACK (backend_died_cb), model);
+
update_query_for_client (model, client_data);
}
@@ -1368,6 +1409,7 @@ e_cal_model_create_component_with_defaults (ECalModel *model)
ECalModelPrivate *priv;
CalComponent *comp;
icalcomponent *icalcomp;
+ CalClient *client;
g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
@@ -1375,12 +1417,16 @@ e_cal_model_create_component_with_defaults (ECalModel *model)
g_return_val_if_fail (priv->clients != NULL, NULL);
+ client = e_cal_model_get_default_client (model);
+ if (!client)
+ return icalcomponent_new (priv->kind);
+
switch (priv->kind) {
case ICAL_VEVENT_COMPONENT :
- comp = cal_comp_event_new_with_defaults ((CalClient *) priv->clients->data);
+ comp = cal_comp_event_new_with_defaults (client);
break;
case ICAL_VTODO_COMPONENT :
- comp = cal_comp_task_new_with_defaults ((CalClient *) priv->clients->data);
+ comp = cal_comp_task_new_with_defaults (client);
break;
default:
return NULL;
@@ -1470,3 +1516,25 @@ e_cal_model_date_value_to_string (ECalModel *model, const void *value)
buffer, sizeof (buffer));
return g_strdup (buffer);
}
+
+/**
+ * e_cal_model_free_component_data
+ */
+void
+e_cal_model_free_component_data (ECalModelComponent *comp_data)
+{
+ g_return_if_fail (comp_data != NULL);
+
+ if (comp_data->icalcomp)
+ icalcomponent_free (comp_data->icalcomp);
+ if (comp_data->dtstart)
+ g_free (comp_data->dtstart);
+ if (comp_data->dtend)
+ g_free (comp_data->dtend);
+ if (comp_data->due)
+ g_free (comp_data->due);
+ if (comp_data->completed)
+ g_free (comp_data->completed);
+
+ g_free (comp_data);
+}
diff --git a/calendar/gui/e-cal-model.h b/calendar/gui/e-cal-model.h
index bb19ba7329..ec8ab36c44 100644
--- a/calendar/gui/e-cal-model.h
+++ b/calendar/gui/e-cal-model.h
@@ -88,6 +88,7 @@ void e_cal_model_set_default_category (ECalModel *model, const gc
void e_cal_model_set_use_24_hour_format (ECalModel *model, gboolean use24);
CalClient *e_cal_model_get_default_client (ECalModel *model);
+GList *e_cal_model_get_client_list (ECalModel *model);
void e_cal_model_add_client (ECalModel *model, CalClient *client);
void e_cal_model_remove_client (ECalModel *model, CalClient *client);
void e_cal_model_remove_all_clients (ECalModel *model);
@@ -100,6 +101,8 @@ ECalModelComponent *e_cal_model_get_component_at (ECalModel *model, gint row);
gchar *e_cal_model_date_value_to_string (ECalModel *model, const void *value);
+void e_cal_model_free_component_data (ECalModelComponent *comp_data);
+
G_END_DECLS
#endif
diff --git a/calendar/gui/e-cal-view.c b/calendar/gui/e-cal-view.c
index ef3d8b9ab3..f91b7fd60e 100644
--- a/calendar/gui/e-cal-view.c
+++ b/calendar/gui/e-cal-view.c
@@ -23,6 +23,7 @@
#include <config.h>
#include <string.h>
+#include <gtk/gtkimage.h>
#include <gtk/gtkinvisible.h>
#include <gtk/gtkstock.h>
#include <libgnome/gnome-i18n.h>
@@ -33,6 +34,8 @@
#include "evolution-activity-client.h"
#include "calendar-commands.h"
#include "calendar-config.h"
+#include "comp-util.h"
+#include "e-cal-model-calendar.h"
#include "e-cal-view.h"
#include "itip-utils.h"
#include "dialogs/delete-comp.h"
@@ -52,11 +55,8 @@ struct _ECalViewPrivate {
/* The GnomeCalendar we are associated to */
GnomeCalendar *calendar;
- /* Calendar client we are monitoring */
- CalClient *client;
-
- /* Search expression */
- gchar *sexp;
+ /* The calendar model we are monitoring */
+ ECalModel *model;
/* The activity client used to show messages on the status bar. */
EvolutionActivityClient *activity;
@@ -94,7 +94,6 @@ static void
e_cal_view_class_init (ECalViewClass *klass)
{
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
@@ -158,6 +157,30 @@ e_cal_view_class_init (ECalViewClass *klass)
}
static void
+model_changed_cb (ETableModel *etm, gpointer user_data)
+{
+ ECalView *cal_view = E_CAL_VIEW (user_data);
+
+ e_cal_view_update_query (cal_view);
+}
+
+static void
+model_row_changed_cb (ETableModel *etm, int row, gpointer user_data)
+{
+ ECalView *cal_view = E_CAL_VIEW (user_data);
+
+ e_cal_view_update_query (cal_view);
+}
+
+static void
+model_rows_changed_cb (ETableModel *etm, int row, int count, gpointer user_data)
+{
+ ECalView *cal_view = E_CAL_VIEW (user_data);
+
+ e_cal_view_update_query (cal_view);
+}
+
+static void
selection_get (GtkWidget *invisible,
GtkSelectionData *selection_data,
guint info,
@@ -200,6 +223,7 @@ selection_received (GtkWidget *invisible,
struct icaldurationtype ic_dur;
char *uid;
icaltimezone *default_zone;
+ CalClient *client;
g_return_if_fail (E_IS_CAL_VIEW (cal_view));
@@ -214,7 +238,8 @@ selection_received (GtkWidget *invisible,
return;
default_tzid = calendar_config_get_timezone ();
- cal_client_get_timezone (cal_view->priv->client, default_tzid, &default_zone);
+ client = e_cal_model_get_default_client (cal_view->priv->model);
+ cal_client_get_timezone (client, default_tzid, &default_zone);
/* check the type of the component */
kind = icalcomponent_isa (icalcomp);
@@ -254,12 +279,12 @@ selection_received (GtkWidget *invisible,
comp, icalcomponent_new_clone (subcomp));
cal_component_set_uid (comp, uid);
- cal_client_update_object (cal_view->priv->client, comp);
- if (itip_organizer_is_user (comp, cal_view->priv->client) &&
- send_component_dialog (gtk_widget_get_toplevel (cal_view),
- cal_view->priv->client, comp, TRUE)) {
+ cal_client_update_object (client, comp);
+ if (itip_organizer_is_user (comp, client) &&
+ send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (cal_view)),
+ client, comp, TRUE)) {
itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp,
- cal_view->priv->client, NULL);
+ client, NULL);
}
free (uid);
@@ -288,12 +313,12 @@ selection_received (GtkWidget *invisible,
comp, icalcomponent_new_clone (icalcomp));
cal_component_set_uid (comp, uid);
- cal_client_update_object (cal_view->priv->client, comp);
- if (itip_organizer_is_user (comp, cal_view->priv->client) &&
- send_component_dialog (gtk_widget_get_toplevel (cal_view),
- cal_view->priv->client, comp, TRUE)) {
+ cal_client_update_object (client, comp);
+ if (itip_organizer_is_user (comp, client) &&
+ send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (cal_view)),
+ client, comp, TRUE)) {
itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp,
- cal_view->priv->client, NULL);
+ client, NULL);
}
free (uid);
@@ -308,7 +333,7 @@ e_cal_view_init (ECalView *cal_view, ECalViewClass *klass)
{
cal_view->priv = g_new0 (ECalViewPrivate, 1);
- cal_view->priv->sexp = g_strdup ("#t"); /* match all by default */
+ cal_view->priv->model = (ECalModel *) e_cal_model_calendar_new ();
/* Set up the invisible widget for the clipboard selections */
cal_view->priv->invisible = gtk_invisible_new ();
@@ -334,14 +359,10 @@ e_cal_view_destroy (GtkObject *object)
g_return_if_fail (E_IS_CAL_VIEW (cal_view));
if (cal_view->priv) {
- if (cal_view->priv->client) {
- g_object_unref (cal_view->priv->client);
- cal_view->priv->client = NULL;
- }
-
- if (cal_view->priv->sexp) {
- g_free (cal_view->priv->sexp);
- cal_view->priv->sexp = NULL;
+ if (cal_view->priv->model) {
+ g_signal_handlers_disconnect_by_func (cal_view->priv->model, model_changed_cb, cal_view);
+ g_object_unref (cal_view->priv->model);
+ cal_view->priv->model = NULL;
}
if (cal_view->priv->activity) {
@@ -386,69 +407,33 @@ e_cal_view_set_calendar (ECalView *cal_view, GnomeCalendar *calendar)
cal_view->priv->calendar = calendar;
}
-CalClient *
-e_cal_view_get_cal_client (ECalView *cal_view)
+ECalModel *
+e_cal_view_get_model (ECalView *cal_view)
{
g_return_val_if_fail (E_IS_CAL_VIEW (cal_view), NULL);
- return cal_view->priv->client;
-}
-
-static void
-cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer user_data)
-{
- ECalView *cal_view = (ECalView *) user_data;
-
- if (status != CAL_CLIENT_OPEN_SUCCESS)
- return;
-
- e_cal_view_update_query (cal_view);
+ return cal_view->priv->model;
}
void
-e_cal_view_set_cal_client (ECalView *cal_view, CalClient *client)
+e_cal_view_set_model (ECalView *cal_view, ECalModel *model)
{
g_return_if_fail (E_IS_CAL_VIEW (cal_view));
+ g_return_if_fail (E_IS_CAL_MODEL (model));
- if (client == cal_view->priv->client)
- return;
-
- if (IS_CAL_CLIENT (client))
- g_object_ref (client);
-
- if (cal_view->priv->client) {
- g_signal_handlers_disconnect_matched (cal_view->priv->client, G_SIGNAL_MATCH_DATA, 0, 0,
- NULL, NULL, cal_view);
- g_object_unref (cal_view->priv->client);
+ if (cal_view->priv->model) {
+ g_signal_handlers_disconnect_matched (cal_view->priv->model, G_SIGNAL_MATCH_DATA,
+ 0, 0, 0, NULL, cal_view);
+ g_object_unref (cal_view->priv->model);
}
- cal_view->priv->client = client;
- if (cal_view->priv->client) {
- if (cal_client_get_load_state (cal_view->priv->client) == CAL_CLIENT_LOAD_LOADED)
- e_cal_view_update_query (cal_view);
- else
- g_signal_connect (cal_view->priv->client, "cal_opened",
- G_CALLBACK (cal_opened_cb), cal_view);
- }
-}
+ cal_view->priv->model = model;
+ g_object_ref (cal_view->priv->model);
+ g_signal_connect (G_OBJECT (cal_view->priv->model), "model_changed", G_CALLBACK (model_changed_cb), cal_view);
+ g_signal_connect (G_OBJECT (cal_view->priv->model), "model_row_changed", G_CALLBACK (model_row_changed_cb), cal_view);
+ g_signal_connect (G_OBJECT (cal_view->priv->model), "model_rows_inserted", G_CALLBACK (model_rows_changed_cb), cal_view);
+ g_signal_connect (G_OBJECT (cal_view->priv->model), "model_rows_deleted", G_CALLBACK (model_rows_changed_cb), cal_view);
-const gchar *
-e_cal_view_get_query (ECalView *cal_view)
-{
- g_return_val_if_fail (E_IS_CAL_VIEW (cal_view), NULL);
-
- return (const gchar *) cal_view->priv->sexp;
-}
-
-void
-e_cal_view_set_query (ECalView *cal_view, const gchar *sexp)
-{
- g_return_if_fail (E_IS_CAL_VIEW (cal_view));
-
- if (cal_view->priv->sexp)
- g_free (cal_view->priv->sexp);
-
- cal_view->priv->sexp = g_strdup (sexp);
e_cal_view_update_query (cal_view);
}
@@ -553,9 +538,13 @@ e_cal_view_update_query (ECalView *cal_view)
{
g_return_if_fail (E_IS_CAL_VIEW (cal_view));
+ e_cal_view_set_status_message (cal_view, _("Searching"));
+
if (E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->update_query) {
E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->update_query (cal_view);
}
+
+ e_cal_view_set_status_message (cal_view, NULL);
}
void
@@ -574,20 +563,27 @@ e_cal_view_cut_clipboard (ECalView *cal_view)
e_cal_view_copy_clipboard (cal_view);
for (l = selected; l != NULL; l = l->next) {
+ CalComponent *comp;
+
ECalViewEvent *event = (ECalViewEvent *) l->data;
if (!event)
continue;
- if (itip_organizer_is_user (event->comp, cal_view->priv->client)
- && cancel_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (cal_view),
- cal_view->priv->client, event->comp, TRUE))
- itip_send_comp (CAL_COMPONENT_METHOD_CANCEL, event->comp,
- cal_view->priv->client, NULL);
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
+
+ if (itip_organizer_is_user (comp, event->comp_data->client)
+ && cancel_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (cal_view)),
+ event->comp_data->client, comp, TRUE))
+ itip_send_comp (CAL_COMPONENT_METHOD_CANCEL, comp,
+ event->comp_data->client, NULL);
- cal_component_get_uid (event->comp, &uid);
- delete_error_dialog (cal_client_remove_object (cal_view->priv->client, uid),
+ cal_component_get_uid (comp, &uid);
+ delete_error_dialog (cal_client_remove_object (event->comp_data->client, uid),
CAL_COMPONENT_EVENT);
+
+ g_object_unref (comp);
}
e_cal_view_set_status_message (cal_view, NULL);
@@ -616,13 +612,13 @@ e_cal_view_copy_clipboard (ECalView *cal_view)
event = (ECalViewEvent *) l->data;
if (event)
- cal_util_add_timezones_from_component (vcal_comp, cal_component_get_icalcomponent (event->comp));
+ cal_util_add_timezones_from_component (vcal_comp, event->comp_data->icalcomp);
}
for (l = selected; l != NULL; l = l->next) {
event = (ECalViewEvent *) l->data;
- new_icalcomp = icalcomponent_new_clone (cal_component_get_icalcomponent (event->comp));
+ new_icalcomp = icalcomponent_new_clone (event->comp_data->icalcomp);
icalcomponent_add_component (vcal_comp, new_icalcomp);
}
@@ -650,29 +646,36 @@ e_cal_view_paste_clipboard (ECalView *cal_view)
}
static void
-delete_event (ECalView *cal_view, CalComponent *comp)
+delete_event (ECalView *cal_view, ECalViewEvent *event)
{
+ CalComponent *comp;
CalComponentVType vtype;
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
vtype = cal_component_get_vtype (comp);
if (delete_component_dialog (comp, FALSE, 1, vtype, GTK_WIDGET (cal_view))) {
const char *uid;
- if (itip_organizer_is_user (comp, cal_view->priv->client)
- && cancel_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (cal_view),
- cal_view->priv->client,
+ if (itip_organizer_is_user (comp, event->comp_data->client)
+ && cancel_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (cal_view)),
+ event->comp_data->client,
comp, TRUE))
itip_send_comp (CAL_COMPONENT_METHOD_CANCEL, comp,
- cal_view->priv->client, NULL);
+ event->comp_data->client, NULL);
cal_component_get_uid (comp, &uid);
- if (!uid || !*uid)
+ if (!uid || !*uid) {
+ g_object_unref (comp);
return;
+ }
delete_error_dialog (
- cal_client_remove_object (cal_view->priv->client, uid), CAL_COMPONENT_EVENT);
+ cal_client_remove_object (event->comp_data->client, uid), CAL_COMPONENT_EVENT);
}
+
+ g_object_unref (comp);
}
void
@@ -687,7 +690,7 @@ e_cal_view_delete_selected_event (ECalView *cal_view)
event = (ECalViewEvent *) selected->data;
if (event)
- delete_event (cal_view, event->comp);
+ delete_event (cal_view, event);
g_list_free (selected);
}
@@ -705,7 +708,7 @@ e_cal_view_delete_selected_events (ECalView *cal_view)
for (l = selected; l != NULL; l = l->next) {
event = (ECalViewEvent *) l->data;
if (event)
- delete_event (cal_view, event->comp);
+ delete_event (cal_view, event);
}
g_list_free (selected);
@@ -723,22 +726,23 @@ e_cal_view_delete_selected_occurrence (ECalView *cal_view)
event = (ECalViewEvent *) selected->data;
- if (cal_component_is_instance (event->comp)) {
+ if (cal_util_component_is_instance (event->comp_data->icalcomp)) {
const char *uid;
- cal_component_get_uid (event->comp, &uid);
+ uid = icalcomponent_get_uid (event->comp_data->icalcomp);
delete_error_dialog (
- cal_client_remove_object_with_mod (cal_view->priv->client, uid, CALOBJ_MOD_THIS),
+ cal_client_remove_object_with_mod (event->comp_data->client, uid, CALOBJ_MOD_THIS),
CAL_COMPONENT_EVENT);
} else {
CalComponent *comp;
/* we must duplicate the CalComponent, or we won't know it has changed
when we get the "update_event" signal */
- comp = cal_component_clone (event->comp);
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
cal_comp_util_add_exdate (comp, event->start, cal_view->priv->zone);
- if (cal_client_update_object (cal_view->priv->client, comp)
+ if (cal_client_update_object (event->comp_data->client, comp)
!= CAL_CLIENT_RESULT_SUCCESS)
g_message ("e_cal_view_delete_selected_occurrence(): Could not update the object!");
@@ -813,7 +817,8 @@ on_edit_appointment (GtkWidget *widget, gpointer user_data)
ECalViewEvent *event = (ECalViewEvent *) selected->data;
if (event)
- gnome_calendar_edit_object (cal_view->priv->calendar, event->comp, FALSE);
+ gnome_calendar_edit_object (cal_view->priv->calendar, event->comp_data->client,
+ event->comp_data->icalcomp, FALSE);
g_list_free (selected);
}
@@ -875,8 +880,7 @@ on_save_as (GtkWidget *widget, gpointer user_data)
return;
event = (ECalViewEvent *) selected->data;
- ical_string = cal_client_get_component_as_string (cal_view->priv->client,
- cal_component_get_icalcomponent (event->comp));
+ ical_string = cal_client_get_component_as_string (event->comp_data->client, event->comp_data->icalcomp);
if (ical_string == NULL) {
g_warning ("Couldn't convert item to a string");
return;
@@ -901,6 +905,7 @@ on_print_event (GtkWidget *widget, gpointer user_data)
ECalView *cal_view;
GList *selected;
ECalViewEvent *event;
+ CalComponent *comp;
cal_view = E_CAL_VIEW (user_data);
selected = e_cal_view_get_selected_events (cal_view);
@@ -908,7 +913,12 @@ on_print_event (GtkWidget *widget, gpointer user_data)
return;
event = (ECalViewEvent *) selected->data;
- print_comp (event->comp, cal_view->priv->client, FALSE);
+
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
+ print_comp (comp, event->comp_data->client, FALSE);
+
+ g_object_unref (comp);
}
static void
@@ -920,7 +930,7 @@ on_meeting (GtkWidget *widget, gpointer user_data)
selected = e_cal_view_get_selected_events (cal_view);
if (selected) {
ECalViewEvent *event = (ECalViewEvent *) selected->data;
- gnome_calendar_edit_object (cal_view->priv->calendar, event->comp, TRUE);
+ gnome_calendar_edit_object (cal_view->priv->calendar, event->comp_data->client, event->comp_data->icalcomp, TRUE);
g_list_free (selected);
}
@@ -934,10 +944,15 @@ on_forward (GtkWidget *widget, gpointer user_data)
selected = e_cal_view_get_selected_events (cal_view);
if (selected) {
+ CalComponent *comp;
ECalViewEvent *event = (ECalViewEvent *) selected->data;
- itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, event->comp, cal_view->priv->client, NULL);
+
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
+ itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, comp, event->comp_data->client, NULL);
g_list_free (selected);
+ g_object_unref (comp);
}
}
@@ -947,7 +962,7 @@ on_publish (GtkWidget *widget, gpointer user_data)
ECalView *cal_view;
icaltimezone *utc;
time_t start = time (NULL), end;
- GList *comp_list;
+ GList *comp_list, *client_list, *cl;
cal_view = E_CAL_VIEW (user_data);
@@ -955,19 +970,24 @@ on_publish (GtkWidget *widget, gpointer user_data)
start = time_day_begin_with_zone (start, utc);
end = time_add_week_with_zone (start, 6, utc);
- comp_list = cal_client_get_free_busy (cal_view->priv->client, NULL, start, end);
- if (comp_list) {
- GList *l;
+ client_list = e_cal_model_get_client_list (cal_view->priv->model);
+ for (cl = client_list; cl != NULL; cl = cl->next) {
+ comp_list = cal_client_get_free_busy ((CalClient *) cl->data, NULL, start, end);
+ if (comp_list) {
+ GList *l;
- for (l = comp_list; l; l = l->next) {
- CalComponent *comp = CAL_COMPONENT (l->data);
- itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, comp, cal_view->priv->client, NULL);
+ for (l = comp_list; l; l = l->next) {
+ CalComponent *comp = CAL_COMPONENT (l->data);
+ itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, comp, (CalClient *) cl->data, NULL);
- g_object_unref (comp);
- }
+ g_object_unref (comp);
+ }
- g_list_free (comp_list);
+ g_list_free (comp_list);
+ }
}
+
+ g_list_free (client_list);
}
static void
@@ -1149,8 +1169,10 @@ setup_popup_icons (EPopupMenu *context_menu)
for (i = 0; context_menu[i].name; i++) {
GtkWidget *pixmap_widget = NULL;
- if (!strcmp (context_menu[i].name, _("_Print...")))
- pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_PRINT);
+ if (!strcmp (context_menu[i].name, _("_Paste")))
+ pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_PASTE, GTK_ICON_SIZE_MENU);
+ else if (!strcmp (context_menu[i].name, _("_Print...")))
+ pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_PRINT, GTK_ICON_SIZE_MENU);
if (pixmap_widget)
gtk_widget_show (pixmap_widget);
@@ -1166,6 +1188,7 @@ e_cal_view_create_popup_menu (ECalView *cal_view)
EPopupMenu *context_menu;
guint32 disable_mask = 0, hide_mask = 0;
GtkMenu *popup;
+ CalClient *client = NULL;
g_return_val_if_fail (E_IS_CAL_VIEW (cal_view), NULL);
@@ -1179,29 +1202,39 @@ e_cal_view_create_popup_menu (ECalView *cal_view)
cal_view->priv->view_menu = gnome_calendar_setup_view_popup (cal_view->priv->calendar);
main_items[9].submenu = cal_view->priv->view_menu;
context_menu = main_items;
+
+ client = e_cal_model_get_default_client (cal_view->priv->model);
} else {
ECalViewEvent *event;
context_menu = child_items;
event = (ECalViewEvent *) selected->data;
- if (cal_component_has_recurrences (event->comp))
+ if (cal_util_component_has_recurrences (event->comp_data->icalcomp))
hide_mask |= MASK_SINGLE;
else
hide_mask |= MASK_RECURRING;
- if (cal_component_is_instance (event->comp))
+ if (cal_util_component_is_instance (event->comp_data->icalcomp))
hide_mask |= MASK_INSTANCE;
- if (cal_component_has_organizer (event->comp)) {
+ if (cal_util_component_has_organizer (event->comp_data->icalcomp)) {
+ CalComponent *comp;
+
disable_mask |= MASK_MEETING;
- if (!itip_organizer_is_user (event->comp, cal_view->priv->client))
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
+ if (!itip_organizer_is_user (comp, event->comp_data->client))
disable_mask |= MASK_MEETING_ORGANIZER;
+
+ g_object_unref (comp);
}
+
+ client = event->comp_data->client;
}
- if (cal_client_is_read_only (cal_view->priv->client))
+ if (cal_client_is_read_only (client))
disable_mask |= MASK_EDITABLE;
if (being_edited)
diff --git a/calendar/gui/e-cal-view.h b/calendar/gui/e-cal-view.h
index b957ad0e2d..ea7c11a00d 100644
--- a/calendar/gui/e-cal-view.h
+++ b/calendar/gui/e-cal-view.h
@@ -25,6 +25,7 @@
#include <cal-client/cal-client.h>
#include <gtk/gtktable.h>
+#include "e-cal-model.h"
#include "gnome-cal.h"
G_BEGIN_DECLS
@@ -49,8 +50,8 @@ typedef enum {
#define E_CAL_VIEW_EVENT_FIELDS \
GnomeCanvasItem *canvas_item; \
- CalClient *client; \
- CalComponent *comp; \
+ ECalModelComponent *comp_data; \
+ gboolean allocated_comp_data; \
time_t start; \
time_t end; \
guint16 start_minute; \
@@ -91,10 +92,8 @@ GType e_cal_view_get_type (void);
GnomeCalendar *e_cal_view_get_calendar (ECalView *cal_view);
void e_cal_view_set_calendar (ECalView *cal_view, GnomeCalendar *calendar);
-CalClient *e_cal_view_get_cal_client (ECalView *cal_view);
-void e_cal_view_set_cal_client (ECalView *cal_view, CalClient *client);
-const gchar *e_cal_view_get_query (ECalView *cal_view);
-void e_cal_view_set_query (ECalView *cal_view, const gchar *sexp);
+ECalModel *e_cal_view_get_model (ECalView *cal_view);
+void e_cal_view_set_model (ECalView *cal_view, ECalModel *model);
icaltimezone *e_cal_view_get_timezone (ECalView *cal_view);
void e_cal_view_set_timezone (ECalView *cal_view, icaltimezone *zone);
diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c
index ef3d8b9ab3..f91b7fd60e 100644
--- a/calendar/gui/e-calendar-view.c
+++ b/calendar/gui/e-calendar-view.c
@@ -23,6 +23,7 @@
#include <config.h>
#include <string.h>
+#include <gtk/gtkimage.h>
#include <gtk/gtkinvisible.h>
#include <gtk/gtkstock.h>
#include <libgnome/gnome-i18n.h>
@@ -33,6 +34,8 @@
#include "evolution-activity-client.h"
#include "calendar-commands.h"
#include "calendar-config.h"
+#include "comp-util.h"
+#include "e-cal-model-calendar.h"
#include "e-cal-view.h"
#include "itip-utils.h"
#include "dialogs/delete-comp.h"
@@ -52,11 +55,8 @@ struct _ECalViewPrivate {
/* The GnomeCalendar we are associated to */
GnomeCalendar *calendar;
- /* Calendar client we are monitoring */
- CalClient *client;
-
- /* Search expression */
- gchar *sexp;
+ /* The calendar model we are monitoring */
+ ECalModel *model;
/* The activity client used to show messages on the status bar. */
EvolutionActivityClient *activity;
@@ -94,7 +94,6 @@ static void
e_cal_view_class_init (ECalViewClass *klass)
{
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
@@ -158,6 +157,30 @@ e_cal_view_class_init (ECalViewClass *klass)
}
static void
+model_changed_cb (ETableModel *etm, gpointer user_data)
+{
+ ECalView *cal_view = E_CAL_VIEW (user_data);
+
+ e_cal_view_update_query (cal_view);
+}
+
+static void
+model_row_changed_cb (ETableModel *etm, int row, gpointer user_data)
+{
+ ECalView *cal_view = E_CAL_VIEW (user_data);
+
+ e_cal_view_update_query (cal_view);
+}
+
+static void
+model_rows_changed_cb (ETableModel *etm, int row, int count, gpointer user_data)
+{
+ ECalView *cal_view = E_CAL_VIEW (user_data);
+
+ e_cal_view_update_query (cal_view);
+}
+
+static void
selection_get (GtkWidget *invisible,
GtkSelectionData *selection_data,
guint info,
@@ -200,6 +223,7 @@ selection_received (GtkWidget *invisible,
struct icaldurationtype ic_dur;
char *uid;
icaltimezone *default_zone;
+ CalClient *client;
g_return_if_fail (E_IS_CAL_VIEW (cal_view));
@@ -214,7 +238,8 @@ selection_received (GtkWidget *invisible,
return;
default_tzid = calendar_config_get_timezone ();
- cal_client_get_timezone (cal_view->priv->client, default_tzid, &default_zone);
+ client = e_cal_model_get_default_client (cal_view->priv->model);
+ cal_client_get_timezone (client, default_tzid, &default_zone);
/* check the type of the component */
kind = icalcomponent_isa (icalcomp);
@@ -254,12 +279,12 @@ selection_received (GtkWidget *invisible,
comp, icalcomponent_new_clone (subcomp));
cal_component_set_uid (comp, uid);
- cal_client_update_object (cal_view->priv->client, comp);
- if (itip_organizer_is_user (comp, cal_view->priv->client) &&
- send_component_dialog (gtk_widget_get_toplevel (cal_view),
- cal_view->priv->client, comp, TRUE)) {
+ cal_client_update_object (client, comp);
+ if (itip_organizer_is_user (comp, client) &&
+ send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (cal_view)),
+ client, comp, TRUE)) {
itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp,
- cal_view->priv->client, NULL);
+ client, NULL);
}
free (uid);
@@ -288,12 +313,12 @@ selection_received (GtkWidget *invisible,
comp, icalcomponent_new_clone (icalcomp));
cal_component_set_uid (comp, uid);
- cal_client_update_object (cal_view->priv->client, comp);
- if (itip_organizer_is_user (comp, cal_view->priv->client) &&
- send_component_dialog (gtk_widget_get_toplevel (cal_view),
- cal_view->priv->client, comp, TRUE)) {
+ cal_client_update_object (client, comp);
+ if (itip_organizer_is_user (comp, client) &&
+ send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (cal_view)),
+ client, comp, TRUE)) {
itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp,
- cal_view->priv->client, NULL);
+ client, NULL);
}
free (uid);
@@ -308,7 +333,7 @@ e_cal_view_init (ECalView *cal_view, ECalViewClass *klass)
{
cal_view->priv = g_new0 (ECalViewPrivate, 1);
- cal_view->priv->sexp = g_strdup ("#t"); /* match all by default */
+ cal_view->priv->model = (ECalModel *) e_cal_model_calendar_new ();
/* Set up the invisible widget for the clipboard selections */
cal_view->priv->invisible = gtk_invisible_new ();
@@ -334,14 +359,10 @@ e_cal_view_destroy (GtkObject *object)
g_return_if_fail (E_IS_CAL_VIEW (cal_view));
if (cal_view->priv) {
- if (cal_view->priv->client) {
- g_object_unref (cal_view->priv->client);
- cal_view->priv->client = NULL;
- }
-
- if (cal_view->priv->sexp) {
- g_free (cal_view->priv->sexp);
- cal_view->priv->sexp = NULL;
+ if (cal_view->priv->model) {
+ g_signal_handlers_disconnect_by_func (cal_view->priv->model, model_changed_cb, cal_view);
+ g_object_unref (cal_view->priv->model);
+ cal_view->priv->model = NULL;
}
if (cal_view->priv->activity) {
@@ -386,69 +407,33 @@ e_cal_view_set_calendar (ECalView *cal_view, GnomeCalendar *calendar)
cal_view->priv->calendar = calendar;
}
-CalClient *
-e_cal_view_get_cal_client (ECalView *cal_view)
+ECalModel *
+e_cal_view_get_model (ECalView *cal_view)
{
g_return_val_if_fail (E_IS_CAL_VIEW (cal_view), NULL);
- return cal_view->priv->client;
-}
-
-static void
-cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer user_data)
-{
- ECalView *cal_view = (ECalView *) user_data;
-
- if (status != CAL_CLIENT_OPEN_SUCCESS)
- return;
-
- e_cal_view_update_query (cal_view);
+ return cal_view->priv->model;
}
void
-e_cal_view_set_cal_client (ECalView *cal_view, CalClient *client)
+e_cal_view_set_model (ECalView *cal_view, ECalModel *model)
{
g_return_if_fail (E_IS_CAL_VIEW (cal_view));
+ g_return_if_fail (E_IS_CAL_MODEL (model));
- if (client == cal_view->priv->client)
- return;
-
- if (IS_CAL_CLIENT (client))
- g_object_ref (client);
-
- if (cal_view->priv->client) {
- g_signal_handlers_disconnect_matched (cal_view->priv->client, G_SIGNAL_MATCH_DATA, 0, 0,
- NULL, NULL, cal_view);
- g_object_unref (cal_view->priv->client);
+ if (cal_view->priv->model) {
+ g_signal_handlers_disconnect_matched (cal_view->priv->model, G_SIGNAL_MATCH_DATA,
+ 0, 0, 0, NULL, cal_view);
+ g_object_unref (cal_view->priv->model);
}
- cal_view->priv->client = client;
- if (cal_view->priv->client) {
- if (cal_client_get_load_state (cal_view->priv->client) == CAL_CLIENT_LOAD_LOADED)
- e_cal_view_update_query (cal_view);
- else
- g_signal_connect (cal_view->priv->client, "cal_opened",
- G_CALLBACK (cal_opened_cb), cal_view);
- }
-}
+ cal_view->priv->model = model;
+ g_object_ref (cal_view->priv->model);
+ g_signal_connect (G_OBJECT (cal_view->priv->model), "model_changed", G_CALLBACK (model_changed_cb), cal_view);
+ g_signal_connect (G_OBJECT (cal_view->priv->model), "model_row_changed", G_CALLBACK (model_row_changed_cb), cal_view);
+ g_signal_connect (G_OBJECT (cal_view->priv->model), "model_rows_inserted", G_CALLBACK (model_rows_changed_cb), cal_view);
+ g_signal_connect (G_OBJECT (cal_view->priv->model), "model_rows_deleted", G_CALLBACK (model_rows_changed_cb), cal_view);
-const gchar *
-e_cal_view_get_query (ECalView *cal_view)
-{
- g_return_val_if_fail (E_IS_CAL_VIEW (cal_view), NULL);
-
- return (const gchar *) cal_view->priv->sexp;
-}
-
-void
-e_cal_view_set_query (ECalView *cal_view, const gchar *sexp)
-{
- g_return_if_fail (E_IS_CAL_VIEW (cal_view));
-
- if (cal_view->priv->sexp)
- g_free (cal_view->priv->sexp);
-
- cal_view->priv->sexp = g_strdup (sexp);
e_cal_view_update_query (cal_view);
}
@@ -553,9 +538,13 @@ e_cal_view_update_query (ECalView *cal_view)
{
g_return_if_fail (E_IS_CAL_VIEW (cal_view));
+ e_cal_view_set_status_message (cal_view, _("Searching"));
+
if (E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->update_query) {
E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->update_query (cal_view);
}
+
+ e_cal_view_set_status_message (cal_view, NULL);
}
void
@@ -574,20 +563,27 @@ e_cal_view_cut_clipboard (ECalView *cal_view)
e_cal_view_copy_clipboard (cal_view);
for (l = selected; l != NULL; l = l->next) {
+ CalComponent *comp;
+
ECalViewEvent *event = (ECalViewEvent *) l->data;
if (!event)
continue;
- if (itip_organizer_is_user (event->comp, cal_view->priv->client)
- && cancel_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (cal_view),
- cal_view->priv->client, event->comp, TRUE))
- itip_send_comp (CAL_COMPONENT_METHOD_CANCEL, event->comp,
- cal_view->priv->client, NULL);
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
+
+ if (itip_organizer_is_user (comp, event->comp_data->client)
+ && cancel_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (cal_view)),
+ event->comp_data->client, comp, TRUE))
+ itip_send_comp (CAL_COMPONENT_METHOD_CANCEL, comp,
+ event->comp_data->client, NULL);
- cal_component_get_uid (event->comp, &uid);
- delete_error_dialog (cal_client_remove_object (cal_view->priv->client, uid),
+ cal_component_get_uid (comp, &uid);
+ delete_error_dialog (cal_client_remove_object (event->comp_data->client, uid),
CAL_COMPONENT_EVENT);
+
+ g_object_unref (comp);
}
e_cal_view_set_status_message (cal_view, NULL);
@@ -616,13 +612,13 @@ e_cal_view_copy_clipboard (ECalView *cal_view)
event = (ECalViewEvent *) l->data;
if (event)
- cal_util_add_timezones_from_component (vcal_comp, cal_component_get_icalcomponent (event->comp));
+ cal_util_add_timezones_from_component (vcal_comp, event->comp_data->icalcomp);
}
for (l = selected; l != NULL; l = l->next) {
event = (ECalViewEvent *) l->data;
- new_icalcomp = icalcomponent_new_clone (cal_component_get_icalcomponent (event->comp));
+ new_icalcomp = icalcomponent_new_clone (event->comp_data->icalcomp);
icalcomponent_add_component (vcal_comp, new_icalcomp);
}
@@ -650,29 +646,36 @@ e_cal_view_paste_clipboard (ECalView *cal_view)
}
static void
-delete_event (ECalView *cal_view, CalComponent *comp)
+delete_event (ECalView *cal_view, ECalViewEvent *event)
{
+ CalComponent *comp;
CalComponentVType vtype;
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
vtype = cal_component_get_vtype (comp);
if (delete_component_dialog (comp, FALSE, 1, vtype, GTK_WIDGET (cal_view))) {
const char *uid;
- if (itip_organizer_is_user (comp, cal_view->priv->client)
- && cancel_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (cal_view),
- cal_view->priv->client,
+ if (itip_organizer_is_user (comp, event->comp_data->client)
+ && cancel_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (cal_view)),
+ event->comp_data->client,
comp, TRUE))
itip_send_comp (CAL_COMPONENT_METHOD_CANCEL, comp,
- cal_view->priv->client, NULL);
+ event->comp_data->client, NULL);
cal_component_get_uid (comp, &uid);
- if (!uid || !*uid)
+ if (!uid || !*uid) {
+ g_object_unref (comp);
return;
+ }
delete_error_dialog (
- cal_client_remove_object (cal_view->priv->client, uid), CAL_COMPONENT_EVENT);
+ cal_client_remove_object (event->comp_data->client, uid), CAL_COMPONENT_EVENT);
}
+
+ g_object_unref (comp);
}
void
@@ -687,7 +690,7 @@ e_cal_view_delete_selected_event (ECalView *cal_view)
event = (ECalViewEvent *) selected->data;
if (event)
- delete_event (cal_view, event->comp);
+ delete_event (cal_view, event);
g_list_free (selected);
}
@@ -705,7 +708,7 @@ e_cal_view_delete_selected_events (ECalView *cal_view)
for (l = selected; l != NULL; l = l->next) {
event = (ECalViewEvent *) l->data;
if (event)
- delete_event (cal_view, event->comp);
+ delete_event (cal_view, event);
}
g_list_free (selected);
@@ -723,22 +726,23 @@ e_cal_view_delete_selected_occurrence (ECalView *cal_view)
event = (ECalViewEvent *) selected->data;
- if (cal_component_is_instance (event->comp)) {
+ if (cal_util_component_is_instance (event->comp_data->icalcomp)) {
const char *uid;
- cal_component_get_uid (event->comp, &uid);
+ uid = icalcomponent_get_uid (event->comp_data->icalcomp);
delete_error_dialog (
- cal_client_remove_object_with_mod (cal_view->priv->client, uid, CALOBJ_MOD_THIS),
+ cal_client_remove_object_with_mod (event->comp_data->client, uid, CALOBJ_MOD_THIS),
CAL_COMPONENT_EVENT);
} else {
CalComponent *comp;
/* we must duplicate the CalComponent, or we won't know it has changed
when we get the "update_event" signal */
- comp = cal_component_clone (event->comp);
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
cal_comp_util_add_exdate (comp, event->start, cal_view->priv->zone);
- if (cal_client_update_object (cal_view->priv->client, comp)
+ if (cal_client_update_object (event->comp_data->client, comp)
!= CAL_CLIENT_RESULT_SUCCESS)
g_message ("e_cal_view_delete_selected_occurrence(): Could not update the object!");
@@ -813,7 +817,8 @@ on_edit_appointment (GtkWidget *widget, gpointer user_data)
ECalViewEvent *event = (ECalViewEvent *) selected->data;
if (event)
- gnome_calendar_edit_object (cal_view->priv->calendar, event->comp, FALSE);
+ gnome_calendar_edit_object (cal_view->priv->calendar, event->comp_data->client,
+ event->comp_data->icalcomp, FALSE);
g_list_free (selected);
}
@@ -875,8 +880,7 @@ on_save_as (GtkWidget *widget, gpointer user_data)
return;
event = (ECalViewEvent *) selected->data;
- ical_string = cal_client_get_component_as_string (cal_view->priv->client,
- cal_component_get_icalcomponent (event->comp));
+ ical_string = cal_client_get_component_as_string (event->comp_data->client, event->comp_data->icalcomp);
if (ical_string == NULL) {
g_warning ("Couldn't convert item to a string");
return;
@@ -901,6 +905,7 @@ on_print_event (GtkWidget *widget, gpointer user_data)
ECalView *cal_view;
GList *selected;
ECalViewEvent *event;
+ CalComponent *comp;
cal_view = E_CAL_VIEW (user_data);
selected = e_cal_view_get_selected_events (cal_view);
@@ -908,7 +913,12 @@ on_print_event (GtkWidget *widget, gpointer user_data)
return;
event = (ECalViewEvent *) selected->data;
- print_comp (event->comp, cal_view->priv->client, FALSE);
+
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
+ print_comp (comp, event->comp_data->client, FALSE);
+
+ g_object_unref (comp);
}
static void
@@ -920,7 +930,7 @@ on_meeting (GtkWidget *widget, gpointer user_data)
selected = e_cal_view_get_selected_events (cal_view);
if (selected) {
ECalViewEvent *event = (ECalViewEvent *) selected->data;
- gnome_calendar_edit_object (cal_view->priv->calendar, event->comp, TRUE);
+ gnome_calendar_edit_object (cal_view->priv->calendar, event->comp_data->client, event->comp_data->icalcomp, TRUE);
g_list_free (selected);
}
@@ -934,10 +944,15 @@ on_forward (GtkWidget *widget, gpointer user_data)
selected = e_cal_view_get_selected_events (cal_view);
if (selected) {
+ CalComponent *comp;
ECalViewEvent *event = (ECalViewEvent *) selected->data;
- itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, event->comp, cal_view->priv->client, NULL);
+
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
+ itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, comp, event->comp_data->client, NULL);
g_list_free (selected);
+ g_object_unref (comp);
}
}
@@ -947,7 +962,7 @@ on_publish (GtkWidget *widget, gpointer user_data)
ECalView *cal_view;
icaltimezone *utc;
time_t start = time (NULL), end;
- GList *comp_list;
+ GList *comp_list, *client_list, *cl;
cal_view = E_CAL_VIEW (user_data);
@@ -955,19 +970,24 @@ on_publish (GtkWidget *widget, gpointer user_data)
start = time_day_begin_with_zone (start, utc);
end = time_add_week_with_zone (start, 6, utc);
- comp_list = cal_client_get_free_busy (cal_view->priv->client, NULL, start, end);
- if (comp_list) {
- GList *l;
+ client_list = e_cal_model_get_client_list (cal_view->priv->model);
+ for (cl = client_list; cl != NULL; cl = cl->next) {
+ comp_list = cal_client_get_free_busy ((CalClient *) cl->data, NULL, start, end);
+ if (comp_list) {
+ GList *l;
- for (l = comp_list; l; l = l->next) {
- CalComponent *comp = CAL_COMPONENT (l->data);
- itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, comp, cal_view->priv->client, NULL);
+ for (l = comp_list; l; l = l->next) {
+ CalComponent *comp = CAL_COMPONENT (l->data);
+ itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, comp, (CalClient *) cl->data, NULL);
- g_object_unref (comp);
- }
+ g_object_unref (comp);
+ }
- g_list_free (comp_list);
+ g_list_free (comp_list);
+ }
}
+
+ g_list_free (client_list);
}
static void
@@ -1149,8 +1169,10 @@ setup_popup_icons (EPopupMenu *context_menu)
for (i = 0; context_menu[i].name; i++) {
GtkWidget *pixmap_widget = NULL;
- if (!strcmp (context_menu[i].name, _("_Print...")))
- pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_PRINT);
+ if (!strcmp (context_menu[i].name, _("_Paste")))
+ pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_PASTE, GTK_ICON_SIZE_MENU);
+ else if (!strcmp (context_menu[i].name, _("_Print...")))
+ pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_PRINT, GTK_ICON_SIZE_MENU);
if (pixmap_widget)
gtk_widget_show (pixmap_widget);
@@ -1166,6 +1188,7 @@ e_cal_view_create_popup_menu (ECalView *cal_view)
EPopupMenu *context_menu;
guint32 disable_mask = 0, hide_mask = 0;
GtkMenu *popup;
+ CalClient *client = NULL;
g_return_val_if_fail (E_IS_CAL_VIEW (cal_view), NULL);
@@ -1179,29 +1202,39 @@ e_cal_view_create_popup_menu (ECalView *cal_view)
cal_view->priv->view_menu = gnome_calendar_setup_view_popup (cal_view->priv->calendar);
main_items[9].submenu = cal_view->priv->view_menu;
context_menu = main_items;
+
+ client = e_cal_model_get_default_client (cal_view->priv->model);
} else {
ECalViewEvent *event;
context_menu = child_items;
event = (ECalViewEvent *) selected->data;
- if (cal_component_has_recurrences (event->comp))
+ if (cal_util_component_has_recurrences (event->comp_data->icalcomp))
hide_mask |= MASK_SINGLE;
else
hide_mask |= MASK_RECURRING;
- if (cal_component_is_instance (event->comp))
+ if (cal_util_component_is_instance (event->comp_data->icalcomp))
hide_mask |= MASK_INSTANCE;
- if (cal_component_has_organizer (event->comp)) {
+ if (cal_util_component_has_organizer (event->comp_data->icalcomp)) {
+ CalComponent *comp;
+
disable_mask |= MASK_MEETING;
- if (!itip_organizer_is_user (event->comp, cal_view->priv->client))
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
+ if (!itip_organizer_is_user (comp, event->comp_data->client))
disable_mask |= MASK_MEETING_ORGANIZER;
+
+ g_object_unref (comp);
}
+
+ client = event->comp_data->client;
}
- if (cal_client_is_read_only (cal_view->priv->client))
+ if (cal_client_is_read_only (client))
disable_mask |= MASK_EDITABLE;
if (being_edited)
diff --git a/calendar/gui/e-calendar-view.h b/calendar/gui/e-calendar-view.h
index b957ad0e2d..ea7c11a00d 100644
--- a/calendar/gui/e-calendar-view.h
+++ b/calendar/gui/e-calendar-view.h
@@ -25,6 +25,7 @@
#include <cal-client/cal-client.h>
#include <gtk/gtktable.h>
+#include "e-cal-model.h"
#include "gnome-cal.h"
G_BEGIN_DECLS
@@ -49,8 +50,8 @@ typedef enum {
#define E_CAL_VIEW_EVENT_FIELDS \
GnomeCanvasItem *canvas_item; \
- CalClient *client; \
- CalComponent *comp; \
+ ECalModelComponent *comp_data; \
+ gboolean allocated_comp_data; \
time_t start; \
time_t end; \
guint16 start_minute; \
@@ -91,10 +92,8 @@ GType e_cal_view_get_type (void);
GnomeCalendar *e_cal_view_get_calendar (ECalView *cal_view);
void e_cal_view_set_calendar (ECalView *cal_view, GnomeCalendar *calendar);
-CalClient *e_cal_view_get_cal_client (ECalView *cal_view);
-void e_cal_view_set_cal_client (ECalView *cal_view, CalClient *client);
-const gchar *e_cal_view_get_query (ECalView *cal_view);
-void e_cal_view_set_query (ECalView *cal_view, const gchar *sexp);
+ECalModel *e_cal_view_get_model (ECalView *cal_view);
+void e_cal_view_set_model (ECalView *cal_view, ECalModel *model);
icaltimezone *e_cal_view_get_timezone (ECalView *cal_view);
void e_cal_view_set_timezone (ECalView *cal_view, icaltimezone *zone);
diff --git a/calendar/gui/e-day-view-main-item.c b/calendar/gui/e-day-view-main-item.c
index 560c2d79d2..f5a1921dee 100644
--- a/calendar/gui/e-day-view-main-item.c
+++ b/calendar/gui/e-day-view-main-item.c
@@ -326,11 +326,16 @@ e_day_view_main_item_draw_events_in_vbars (EDayViewMainItem *dvmitem,
/* Draw the busy times corresponding to the events in the day. */
for (event_num = 0; event_num < day_view->events[day]->len;
event_num++) {
+ CalComponent *comp;
+
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
+
/* If the event is TRANSPARENT, skip it. */
- cal_component_get_transparency (event->comp, &transparency);
+ cal_component_get_transparency (comp, &transparency);
if (transparency == CAL_COMPONENT_TRANSP_TRANSPARENT)
continue;
@@ -350,6 +355,8 @@ e_day_view_main_item_draw_events_in_vbars (EDayViewMainItem *dvmitem,
gdk_draw_rectangle (drawable, gc, TRUE,
grid_x, bar_y,
E_DAY_VIEW_BAR_WIDTH - 2, bar_h);
+
+ g_object_unref (comp);
}
}
@@ -373,11 +380,16 @@ e_day_view_main_item_draw_long_events_in_vbars (EDayViewMainItem *dvmitem,
for (event_num = 0; event_num < day_view->long_events->len;
event_num++) {
+ CalComponent *comp;
+
event = &g_array_index (day_view->long_events, EDayViewEvent,
event_num);
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
+
/* If the event is TRANSPARENT, skip it. */
- cal_component_get_transparency (event->comp, &transparency);
+ cal_component_get_transparency (comp, &transparency);
if (transparency == CAL_COMPONENT_TRANSP_TRANSPARENT)
continue;
@@ -416,6 +428,7 @@ e_day_view_main_item_draw_long_events_in_vbars (EDayViewMainItem *dvmitem,
}
+ g_object_unref (comp);
}
}
@@ -451,6 +464,7 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
gint item_x, item_y, item_w, item_h, bar_y1, bar_y2;
GtkStyle *style;
GdkGC *gc;
+ GdkColor bg_color;
CalComponent *comp;
gint num_icons, icon_x, icon_y, icon_x_inc, icon_y_inc;
gint max_icon_w, max_icon_h;
@@ -469,7 +483,6 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
style = GTK_WIDGET (day_view)->style;
gc = day_view->main_gc;
- gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR]);
/* Get the position of the event. If it is not shown skip it.*/
if (!e_day_view_get_event_position (day_view, day, event_num,
@@ -483,22 +496,34 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
- /* Fill in the white background. Note that for events in the first
+ /* Fill in the event background. Note that for events in the first
column of the day, we might not want to paint over the vertical bar,
since that is used for multiple events. But then you can't see
where the event in the first column finishes. */
+
+ if (gdk_color_parse (e_cal_model_get_color_for_component (e_cal_view_get_model (E_CAL_VIEW (day_view)), event->comp_data),
+ &bg_color)) {
+ GdkColormap *colormap;
+
+ colormap = gtk_widget_get_colormap (GTK_WIDGET (day_view));
+ if (gdk_colormap_alloc_color (colormap, &bg_color, TRUE, TRUE))
+ gdk_gc_set_foreground (gc, &bg_color);
+ }
+
#if 1
if (event->start_row_or_col == 0)
- gdk_draw_rectangle (drawable, style->white_gc, TRUE,
+ gdk_draw_rectangle (drawable, gc, TRUE,
item_x + E_DAY_VIEW_BAR_WIDTH, item_y + 1,
MAX (item_w - E_DAY_VIEW_BAR_WIDTH - 1, 0),
item_h - 2);
else
#endif
- gdk_draw_rectangle (drawable, style->white_gc, TRUE,
+ gdk_draw_rectangle (drawable, gc, TRUE,
item_x + 1, item_y + 1,
MAX (item_w - 2, 0), item_h - 2);
+ gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR]);
+
/* Draw the right edge of the vertical bar. */
gdk_draw_line (drawable, style->black_gc,
item_x + E_DAY_VIEW_BAR_WIDTH - 1,
@@ -521,8 +546,11 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
bar_y2 = item_y + item_h - 1;
}
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
+
/* Only fill it in if the event isn't TRANSPARENT. */
- cal_component_get_transparency (event->comp, &transparency);
+ cal_component_get_transparency (comp, &transparency);
if (transparency != CAL_COMPONENT_TRANSP_TRANSPARENT) {
gdk_draw_rectangle (drawable, gc, TRUE,
item_x + 1, bar_y1,
@@ -560,7 +588,6 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
icon_x = item_x + E_DAY_VIEW_BAR_WIDTH + E_DAY_VIEW_ICON_X_PAD;
icon_y = item_y + E_DAY_VIEW_EVENT_BORDER_HEIGHT
+ E_DAY_VIEW_ICON_Y_PAD;
- comp = event->comp;
if (cal_component_has_alarms (comp)) {
draw_reminder_icon = TRUE;
@@ -724,6 +751,7 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
/* free memory */
cal_component_free_categories_list (categories_list);
+ g_object_unref (comp);
}
diff --git a/calendar/gui/e-day-view-top-item.c b/calendar/gui/e-day-view-top-item.c
index d589538e22..a84e6d5468 100644
--- a/calendar/gui/e-day-view-top-item.c
+++ b/calendar/gui/e-day-view-top-item.c
@@ -353,6 +353,7 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
GdkRectangle clip_rect;
GSList *categories_list, *elem;
PangoLayout *layout;
+ GdkColor bg_color;
day_view = dvtitem->day_view;
@@ -375,7 +376,8 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
gc = day_view->main_gc;
fg_gc = style->fg_gc[GTK_STATE_NORMAL];
bg_gc = style->bg_gc[GTK_STATE_NORMAL];
- comp = event->comp;
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
/* Draw the lines across the top & bottom of the entire event. */
gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BORDER]);
@@ -387,7 +389,18 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
item_x + item_w - 1 - x, item_y + item_h - 1 - y);
/* Fill it in. */
- gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND]);
+ if (gdk_color_parse (e_cal_model_get_color_for_component (e_cal_view_get_model (E_CAL_VIEW (day_view)),
+ event->comp_data),
+ &bg_color)) {
+ GdkColormap *colormap;
+
+ colormap = gtk_widget_get_colormap (GTK_WIDGET (day_view));
+ if (gdk_colormap_alloc_color (colormap, &bg_color, TRUE, TRUE))
+ gdk_gc_set_foreground (gc, &bg_color);
+ else
+ gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND]);
+ } else
+ gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND]);
gdk_draw_rectangle (drawable, gc, TRUE,
item_x - x, item_y + 1 - y,
item_w, item_h - 2);
@@ -594,6 +607,7 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
}
cal_component_free_categories_list (categories_list);
+ g_object_unref (comp);
gdk_gc_set_clip_mask (gc, NULL);
}
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 307a0324bb..1511709881 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -107,6 +107,11 @@
we get from the server. */
#define E_DAY_VIEW_LAYOUT_TIMEOUT 100
+typedef struct {
+ EDayView *day_view;
+ ECalModelComponent *comp_data;
+} AddEventData;
+
/* Drag and Drop stuff. */
enum {
TARGET_CALENDAR_EVENT,
@@ -153,10 +158,10 @@ static gboolean e_day_view_do_key_press (GtkWidget *widget,
GdkEventKey *event);
static gboolean e_day_view_popup_menu (GtkWidget *widget);
static GList *e_day_view_get_selected_events (ECalView *cal_view);
-static void e_day_view_get_selected_time_range (EDayView *day_view, time_t *start_time, time_t *end_time);
-static void e_day_view_set_selected_time_range (EDayView *day_view, time_t start_time, time_t end_time);
-static gboolean e_day_view_get_visible_time_range (EDayView *day_view, time_t *start_time, time_t *end_time);
-static void e_day_view_update_query (EDayView *day_view);
+static void e_day_view_get_selected_time_range (ECalView *cal_view, time_t *start_time, time_t *end_time);
+static void e_day_view_set_selected_time_range (ECalView *cal_view, time_t start_time, time_t end_time);
+static gboolean e_day_view_get_visible_time_range (ECalView *cal_view, time_t *start_time, time_t *end_time);
+static void e_day_view_update_query (ECalView *cal_view);
static void e_day_view_goto_start_of_work_day (EDayView *day_view);
static void e_day_view_goto_end_of_work_day (EDayView *day_view);
static void e_day_view_change_duration_to_start_of_work_day (EDayView *day_view);
@@ -498,7 +503,7 @@ timezone_changed_cb (ECalView *cal_view, icaltimezone *old_zone,
lower = icaltime_as_timet_with_zone (tt, new_zone);
e_day_view_recalc_day_starts (day_view, lower);
- e_day_view_update_query (day_view);
+ e_day_view_update_query ((ECalView *) day_view);
}
static void
@@ -861,11 +866,6 @@ e_day_view_destroy (GtkObject *object)
e_day_view_stop_auto_scroll (day_view);
- if (e_cal_view_get_cal_client (E_CAL_VIEW (day_view))) {
- g_signal_handlers_disconnect_matched (e_cal_view_get_cal_client (E_CAL_VIEW (day_view)),
- G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, day_view);
- }
-
if (day_view->query) {
g_signal_handlers_disconnect_matched (day_view->query, G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, day_view);
@@ -1426,176 +1426,6 @@ e_day_view_focus_out (GtkWidget *widget, GdkEventFocus *event)
return FALSE;
}
-/* Callback used when a component is updated in the live query */
-static void
-query_obj_updated_cb (CalQuery *query, const char *uid,
- gboolean query_in_progress, int n_scanned, int total,
- gpointer data)
-{
- EDayView *day_view;
- EDayViewEvent *event;
- CalComponent *comp;
- icalcomponent *icalcomp;
- CalClientGetStatus status;
- gint day, event_num;
-
- day_view = E_DAY_VIEW (data);
-
- /* If our time hasn't been set yet, just return. */
- if (day_view->lower == 0 && day_view->upper == 0)
- return;
-
- /* Get the event from the server. */
- status = cal_client_get_object (e_cal_view_get_cal_client (E_CAL_VIEW (day_view)), uid, &icalcomp);
-
- switch (status) {
- case CAL_CLIENT_GET_SUCCESS:
- comp = cal_component_new ();
- if (!cal_component_set_icalcomponent (comp, icalcomp)) {
- g_object_unref (comp);
- icalcomponent_free (icalcomp);
-
- g_message ("query_obj_updated_cb(): Invalid object %s", uid);
- return;
- }
- break;
-
- case CAL_CLIENT_GET_SYNTAX_ERROR:
- g_message ("query_obj_updated_cb(): Syntax error when getting object `%s'", uid);
- return;
-
- case CAL_CLIENT_GET_NOT_FOUND:
- /* The object is no longer in the server, so do nothing */
- return;
-
- default:
- g_assert_not_reached ();
- return;
- }
-
- /* If the event already exists and the dates didn't change, we can
- update the event fairly easily without changing the events arrays
- or computing a new layout. */
- if (e_day_view_find_event_from_uid (day_view, uid, &day, &event_num)) {
- if (day == E_DAY_VIEW_LONG_EVENT)
- event = &g_array_index (day_view->long_events,
- EDayViewEvent, event_num);
- else
- event = &g_array_index (day_view->events[day],
- EDayViewEvent, event_num);
-
- if (!cal_component_has_recurrences (comp)
- && !cal_component_has_recurrences (event->comp)
- && cal_component_event_dates_match (comp, event->comp)) {
-#if 0
- g_print ("updated object's dates unchanged\n");
-#endif
- e_day_view_foreach_event_with_uid (day_view, uid, e_day_view_update_event_cb, comp);
- g_object_unref (comp);
- gtk_widget_queue_draw (day_view->top_canvas);
- gtk_widget_queue_draw (day_view->main_canvas);
- return;
- }
-
- /* The dates have changed, so we need to remove the
- old occurrrences before adding the new ones. */
-#if 0
- g_print ("dates changed - removing occurrences\n");
-#endif
- e_day_view_foreach_event_with_uid (day_view, uid,
- e_day_view_remove_event_cb,
- NULL);
- }
-
- /* Add the occurrences of the event. */
- cal_recur_generate_instances (comp, day_view->lower,
- day_view->upper,
- e_day_view_add_event, day_view,
- cal_client_resolve_tzid_cb,
- e_cal_view_get_cal_client (E_CAL_VIEW (day_view)),
- e_cal_view_get_timezone (E_CAL_VIEW (day_view)));
- g_object_unref (comp);
-
- e_day_view_queue_layout (day_view);
-}
-
-/* Callback used when a component is removed from the live query */
-static void
-query_obj_removed_cb (CalQuery *query, const char *uid, gpointer data)
-{
- EDayView *day_view;
-
- day_view = E_DAY_VIEW (data);
-
- e_day_view_foreach_event_with_uid (day_view, uid,
- e_day_view_remove_event_cb, NULL);
-
- e_day_view_check_layout (day_view);
- gtk_widget_queue_draw (day_view->top_canvas);
- gtk_widget_queue_draw (day_view->main_canvas);
-}
-
-/* Callback used when a query ends */
-static void
-query_query_done_cb (CalQuery *query, CalQueryDoneStatus status, const char *error_str, gpointer data)
-{
- EDayView *day_view;
-
- day_view = E_DAY_VIEW (data);
-
- /* FIXME */
-
- e_cal_view_set_status_message (E_CAL_VIEW (day_view), NULL);
-
- if (status != CAL_QUERY_DONE_SUCCESS)
- fprintf (stderr, "query done: %s\n", error_str);
-}
-
-/* Callback used when an evaluation error occurs when running a query */
-static void
-query_eval_error_cb (CalQuery *query, const char *error_str, gpointer data)
-{
- EDayView *day_view;
-
- day_view = E_DAY_VIEW (data);
-
- /* FIXME */
-
- e_cal_view_set_status_message (E_CAL_VIEW (day_view), NULL);
-
- fprintf (stderr, "eval error: %s\n", error_str);
-}
-
-
-/* Builds a complete query sexp for the day view by adding the predicates to
- * filter only for VEVENTS that fit in the day view's time range.
- */
-static char *
-adjust_query_sexp (EDayView *day_view, const char *sexp)
-{
- char *start, *end;
- char *new_sexp;
-
- /* If the dates have not been set yet, we just want an empty query. */
- if (day_view->lower == 0 || day_view->upper == 0)
- return NULL;
-
- start = isodate_from_time_t (day_view->lower);
- end = isodate_from_time_t (day_view->upper);
-
- new_sexp = g_strdup_printf ("(and (= (get-vtype) \"VEVENT\")"
- " (occur-in-time-range? (make-time \"%s\")"
- " (make-time \"%s\"))"
- " %s)",
- start, end,
- sexp);
-
- g_free (start);
- g_free (end);
-
- return new_sexp;
-}
-
/**
* e_day_view_set_default_category:
* @day_view: A day view.
@@ -1623,9 +1453,9 @@ e_day_view_update_event_cb (EDayView *day_view,
gpointer data)
{
EDayViewEvent *event;
- CalComponent *comp;
+ ECalModelComponent *comp_data;
- comp = data;
+ comp_data = data;
#if 0
g_print ("In e_day_view_update_event_cb day:%i event_num:%i\n",
day, event_num);
@@ -1638,9 +1468,10 @@ e_day_view_update_event_cb (EDayView *day_view,
event_num);
}
- g_object_unref (event->comp);
- event->comp = comp;
- g_object_ref (comp);
+ if (event->allocated_comp_data)
+ e_cal_model_free_component_data (event->comp_data);
+ event->comp_data = comp_data;
+ event->allocated_comp_data = FALSE;
if (day == E_DAY_VIEW_LONG_EVENT) {
e_day_view_update_long_event_label (day_view, event_num);
@@ -1715,10 +1546,9 @@ e_day_view_foreach_event_with_uid (EDayView *day_view,
event = &g_array_index (day_view->events[day],
EDayViewEvent, event_num);
- cal_component_get_uid (event->comp, &u);
+ u = icalcomponent_get_uid (event->comp_data->icalcomp);
if (uid && !strcmp (uid, u)) {
- if (!(*callback) (day_view, day, event_num,
- data))
+ if (!(*callback) (day_view, day, event_num, data))
return;
}
}
@@ -1730,10 +1560,9 @@ e_day_view_foreach_event_with_uid (EDayView *day_view,
event = &g_array_index (day_view->long_events,
EDayViewEvent, event_num);
- cal_component_get_uid (event->comp, &u);
+ u = icalcomponent_get_uid (event->comp_data->icalcomp);
if (u && !strcmp (uid, u)) {
- if (!(*callback) (day_view, E_DAY_VIEW_LONG_EVENT,
- event_num, data))
+ if (!(*callback) (day_view, E_DAY_VIEW_LONG_EVENT, event_num, data))
return;
}
}
@@ -1768,7 +1597,11 @@ e_day_view_remove_event_cb (EDayView *day_view,
if (event->canvas_item)
gtk_object_destroy (GTK_OBJECT (event->canvas_item));
- g_object_unref (event->comp);
+
+ if (event->allocated_comp_data) {
+ e_cal_model_free_component_data (event->comp_data);
+ event->allocated_comp_data = FALSE;
+ }
if (day == E_DAY_VIEW_LONG_EVENT) {
g_array_remove_index (day_view->long_events, event_num);
@@ -1794,17 +1627,16 @@ e_day_view_update_event_label (EDayView *day_view,
gint offset;
gint start_hour, start_display_hour, start_minute, start_suffix_width;
gint end_hour, end_display_hour, end_minute, end_suffix_width;
- CalComponentText summary;
+ const gchar *summary;
- event = &g_array_index (day_view->events[day], EDayViewEvent,
- event_num);
+ event = &g_array_index (day_view->events[day], EDayViewEvent, event_num);
/* If the event isn't visible just return. */
if (!event->canvas_item)
return;
- cal_component_get_summary (event->comp, &summary);
- text = summary.value ? (char*) summary.value : "";
+ summary = icalcomponent_get_summary (event->comp_data->icalcomp);
+ text = summary ? (char *) summary : "";
if (day_view->editing_event_day == day
&& day_view->editing_event_num == event_num)
@@ -1886,7 +1718,7 @@ e_day_view_update_long_event_label (EDayView *day_view,
gint event_num)
{
EDayViewEvent *event;
- CalComponentText summary;
+ const gchar *summary;
event = &g_array_index (day_view->long_events, EDayViewEvent,
event_num);
@@ -1895,9 +1727,9 @@ e_day_view_update_long_event_label (EDayView *day_view,
if (!event->canvas_item)
return;
- cal_component_get_summary (event->comp, &summary);
+ summary = icalcomponent_get_summary (event->comp_data->icalcomp);
gnome_canvas_item_set (event->canvas_item,
- "text", summary.value ? summary.value : "",
+ "text", summary ? summary : "",
NULL);
}
@@ -1965,7 +1797,7 @@ e_day_view_find_event_from_uid (EDayView *day_view,
event = &g_array_index (day_view->events[day],
EDayViewEvent, event_num);
- cal_component_get_uid (event->comp, &u);
+ u = icalcomponent_get_uid (event->comp_data->icalcomp);
if (u && !strcmp (uid, u)) {
*day_return = day;
*event_num_return = event_num;
@@ -1979,7 +1811,7 @@ e_day_view_find_event_from_uid (EDayView *day_view,
event = &g_array_index (day_view->long_events,
EDayViewEvent, event_num);
- cal_component_get_uid (event->comp, &u);
+ u = icalcomponent_get_uid (event->comp_data->icalcomp);
if (u && !strcmp (uid, u)) {
*day_return = E_DAY_VIEW_LONG_EVENT;
*event_num_return = event_num;
@@ -1996,13 +1828,14 @@ e_day_view_find_event_from_uid (EDayView *day_view,
and are both visible in the view, then the selection is set to those times,
otherwise it is set to 1 hour from the start of the working day. */
static void
-e_day_view_set_selected_time_range (EDayView *day_view,
+e_day_view_set_selected_time_range (ECalView *cal_view,
time_t start_time,
time_t end_time)
{
time_t lower;
gint start_row, start_col, end_row, end_col;
gboolean need_redraw = FALSE, start_in_grid, end_in_grid;
+ EDayView *day_view = E_DAY_VIEW (cal_view);
g_return_if_fail (E_IS_DAY_VIEW (day_view));
@@ -2019,7 +1852,7 @@ e_day_view_set_selected_time_range (EDayView *day_view,
/* See if we need to change the days shown. */
if (lower != day_view->lower) {
e_day_view_recalc_day_starts (day_view, lower);
- e_day_view_update_query (day_view);
+ e_day_view_update_query ((ECalView *) day_view);
}
/* Set the selection. */
@@ -2215,12 +2048,11 @@ e_day_view_find_work_week_start (EDayView *day_view,
/* Returns the selected time range. */
static void
-e_day_view_get_selected_time_range (EDayView *day_view,
- time_t *start_time,
- time_t *end_time)
+e_day_view_get_selected_time_range (ECalView *cal_view, time_t *start_time, time_t *end_time)
{
gint start_col, start_row, end_col, end_row;
time_t start, end;
+ EDayView *day_view = E_DAY_VIEW (cal_view);
start_col = day_view->selection_start_day;
start_row = day_view->selection_start_row;
@@ -2254,10 +2086,12 @@ e_day_view_get_selected_time_range (EDayView *day_view,
/* Gets the visible time range. Returns FALSE if no time range has been set. */
static gboolean
-e_day_view_get_visible_time_range (EDayView *day_view,
+e_day_view_get_visible_time_range (ECalView *cal_view,
time_t *start_time,
time_t *end_time)
{
+ EDayView *day_view = E_DAY_VIEW (cal_view);
+
/* If the date isn't set, return FALSE. */
if (day_view->lower == 0 && day_view->upper == 0)
return FALSE;
@@ -2345,7 +2179,7 @@ e_day_view_set_days_shown (EDayView *day_view,
e_day_view_recalc_day_starts (day_view, day_view->lower);
e_day_view_recalc_cell_sizes (day_view);
- e_day_view_update_query (day_view);
+ e_day_view_update_query ((ECalView *) day_view);
}
@@ -2622,7 +2456,7 @@ e_day_view_recalc_work_week (EDayView *day_view)
day_view->selection_start_day = -1;
e_day_view_recalc_day_starts (day_view, lower);
- e_day_view_update_query (day_view);
+ e_day_view_update_query ((ECalView *) day_view);
/* This updates the date navigator. */
e_day_view_update_calendar_selection_time (day_view);
@@ -2750,8 +2584,7 @@ e_day_view_on_top_canvas_button_press (GtkWidget *widget,
if (event->type == GDK_2BUTTON_PRESS) {
time_t dtstart, dtend;
- e_day_view_get_selected_time_range (day_view, &dtstart,
- &dtend);
+ e_day_view_get_selected_time_range ((ECalView *) day_view, &dtstart, &dtend);
gnome_calendar_new_appointment_for (e_cal_view_get_calendar (E_CAL_VIEW (day_view)),
dtstart, dtend,
TRUE, FALSE);
@@ -2872,8 +2705,7 @@ e_day_view_on_main_canvas_button_press (GtkWidget *widget,
if (event->type == GDK_2BUTTON_PRESS) {
time_t dtstart, dtend;
- e_day_view_get_selected_time_range (day_view, &dtstart,
- &dtend);
+ e_day_view_get_selected_time_range ((ECalView *) day_view, &dtstart, &dtend);
gnome_calendar_new_appointment_for (e_cal_view_get_calendar (E_CAL_VIEW (day_view)),
dtstart, dtend,
FALSE, FALSE);
@@ -2920,6 +2752,7 @@ e_day_view_on_main_canvas_scroll (GtkWidget *widget,
e_day_view_scroll (day_view, -E_DAY_VIEW_WHEEL_MOUSE_STEP_SIZE);
return TRUE;
default:
+ break;
}
return FALSE;
@@ -2940,25 +2773,12 @@ e_day_view_on_time_canvas_scroll (GtkWidget *widget,
e_day_view_scroll (day_view, -E_DAY_VIEW_WHEEL_MOUSE_STEP_SIZE);
return TRUE;
default:
+ break;
}
return FALSE;
}
-
-/* Callback used when a component is destroyed. Expects the closure data to be
- * a pointer to a boolean; will set it to TRUE.
- */
-static void
-comp_destroy_cb (gpointer data, GObject *deadbeef)
-{
- gboolean *destroyed;
-
- destroyed = data;
- *destroyed = TRUE;
-}
-
-
static gboolean
e_day_view_on_long_event_button_press (EDayView *day_view,
gint event_num,
@@ -2982,24 +2802,17 @@ e_day_view_on_long_event_button_press (EDayView *day_view,
}
} else if (event->button == 3) {
EDayViewEvent *e;
- gboolean destroyed;
e = &g_array_index (day_view->long_events, EDayViewEvent, event_num);
- destroyed = FALSE;
- g_object_weak_ref ((GObject *) e->comp, comp_destroy_cb, &destroyed);
if (!GTK_WIDGET_HAS_FOCUS (day_view))
gtk_widget_grab_focus (GTK_WIDGET (day_view));
- if (!destroyed) {
- g_object_weak_unref ((GObject *) e->comp, comp_destroy_cb, &destroyed);
-
- e_day_view_set_selected_time_range_in_top_visible (day_view, e->start, e->end);
+ e_day_view_set_selected_time_range_in_top_visible (day_view, e->start, e->end);
- e_day_view_on_event_right_click (day_view, event,
- E_DAY_VIEW_LONG_EVENT,
- event_num);
- }
+ e_day_view_on_event_right_click (day_view, event,
+ E_DAY_VIEW_LONG_EVENT,
+ event_num);
return TRUE;
}
@@ -3031,24 +2844,16 @@ e_day_view_on_event_button_press (EDayView *day_view,
}
} else if (event->button == 3) {
EDayViewEvent *e;
- gboolean destroyed;
e = &g_array_index (day_view->events[day], EDayViewEvent, event_num);
- destroyed = FALSE;
- g_object_weak_ref ((GObject *) e->comp, comp_destroy_cb, &destroyed);
-
if (!GTK_WIDGET_HAS_FOCUS (day_view))
gtk_widget_grab_focus (GTK_WIDGET (day_view));
- if (!destroyed) {
- g_object_weak_unref ((GObject *) e->comp, comp_destroy_cb, &destroyed);
-
- e_day_view_set_selected_time_range_visible (day_view, e->start, e->end);
+ e_day_view_set_selected_time_range_visible (day_view, e->start, e->end);
- e_day_view_on_event_right_click (day_view, event,
- day, event_num);
- }
+ e_day_view_on_event_right_click (day_view, event,
+ day, event_num);
return TRUE;
}
@@ -3076,30 +2881,21 @@ e_day_view_on_long_event_click (EDayView *day_view,
&& E_TEXT (event->canvas_item)->editing)
return;
- if ((cal_component_is_instance (event->comp) || !cal_component_has_recurrences (event->comp))
+ if ((cal_util_component_is_instance (event->comp_data->icalcomp) ||
+ !cal_util_component_has_recurrences (event->comp_data->icalcomp))
&& (pos == E_CAL_VIEW_POS_LEFT_EDGE
|| pos == E_CAL_VIEW_POS_RIGHT_EDGE)) {
- gboolean destroyed;
-
if (!e_day_view_find_long_event_days (event,
day_view->days_shown,
day_view->day_starts,
&start_day, &end_day))
return;
- destroyed = FALSE;
- g_object_weak_ref ((GObject *) event->comp, comp_destroy_cb, &destroyed);
-
/* Grab the keyboard focus, so the event being edited is saved
and we can use the Escape key to abort the resize. */
if (!GTK_WIDGET_HAS_FOCUS (day_view))
gtk_widget_grab_focus (GTK_WIDGET (day_view));
- if (destroyed)
- return;
-
- g_object_weak_unref ((GObject *) event->comp, comp_destroy_cb, &destroyed);
-
if (gdk_pointer_grab (GTK_LAYOUT (day_view->top_canvas)->bin_window, FALSE,
GDK_POINTER_MOTION_MASK
| GDK_BUTTON_RELEASE_MASK,
@@ -3160,24 +2956,15 @@ e_day_view_on_event_click (EDayView *day_view,
&& E_TEXT (event->canvas_item)->editing)
return;
- if ((cal_component_is_instance (event->comp) || !cal_component_has_recurrences (event->comp))
+ if ((cal_util_component_is_instance (event->comp_data->icalcomp) ||
+ !cal_util_component_has_recurrences (event->comp_data->icalcomp))
&& (pos == E_CAL_VIEW_POS_TOP_EDGE
|| pos == E_CAL_VIEW_POS_BOTTOM_EDGE)) {
- gboolean destroyed;
-
- destroyed = FALSE;
- g_object_weak_ref ((GObject *) event->comp, comp_destroy_cb, &destroyed);
-
/* Grab the keyboard focus, so the event being edited is saved
and we can use the Escape key to abort the resize. */
if (!GTK_WIDGET_HAS_FOCUS (day_view))
gtk_widget_grab_focus (GTK_WIDGET (day_view));
- if (destroyed)
- return;
-
- g_object_weak_unref ((GObject *) event->comp, comp_destroy_cb, &destroyed);
-
if (gdk_pointer_grab (GTK_LAYOUT (day_view->main_canvas)->bin_window, FALSE,
GDK_POINTER_MOTION_MASK
| GDK_BUTTON_RELEASE_MASK,
@@ -3311,7 +3098,7 @@ e_day_view_on_event_double_click (EDayView *day_view,
gint event_num)
{
EDayViewEvent *event;
- gboolean destroyed;
+ GnomeCalendar *calendar;
if (day == -1)
event = &g_array_index (day_view->long_events, EDayViewEvent,
@@ -3320,22 +3107,13 @@ e_day_view_on_event_double_click (EDayView *day_view,
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
- destroyed = FALSE;
- g_object_weak_ref ((GObject *) event->comp, comp_destroy_cb, &destroyed);
-
e_day_view_stop_editing_event (day_view);
- if (!destroyed) {
- GnomeCalendar *calendar;
-
- g_object_weak_unref ((GObject *) event->comp, comp_destroy_cb, &destroyed);
-
- calendar = e_cal_view_get_calendar (E_CAL_VIEW (day_view));
- if (calendar)
- gnome_calendar_edit_object (calendar, event->comp, FALSE);
- else
- g_warning ("Calendar not set");
- }
+ calendar = e_cal_view_get_calendar (E_CAL_VIEW (day_view));
+ if (calendar)
+ gnome_calendar_edit_object (calendar, event->comp_data->client, event->comp_data->icalcomp, FALSE);
+ else
+ g_warning ("Calendar not set");
}
static void
@@ -3344,7 +3122,6 @@ e_day_view_show_popup_menu (EDayView *day_view,
gint day,
gint event_num)
{
- EDayViewEvent *event;
GtkMenu *popup;
day_view->popup_event_day = day;
@@ -3400,12 +3177,76 @@ e_day_view_get_selected_events (ECalView *cal_view)
return list;
}
+static void
+process_component (EDayView *day_view, ECalModelComponent *comp_data)
+{
+ EDayViewEvent *event;
+ gint day, event_num;
+ const char *uid;
+ CalComponent *comp;
+ AddEventData add_event_data;
+
+ /* If our time hasn't been set yet, just return. */
+ if (day_view->lower == 0 && day_view->upper == 0)
+ return;
+
+ /* If the event already exists and the dates didn't change, we can
+ update the event fairly easily without changing the events arrays
+ or computing a new layout. */
+ uid = icalcomponent_get_uid (comp_data->icalcomp);
+
+ if (e_day_view_find_event_from_uid (day_view, uid, &day, &event_num)) {
+ if (day == E_DAY_VIEW_LONG_EVENT)
+ event = &g_array_index (day_view->long_events,
+ EDayViewEvent, event_num);
+ else
+ event = &g_array_index (day_view->events[day],
+ EDayViewEvent, event_num);
+
+ if (!cal_util_component_has_recurrences (comp_data->icalcomp)
+ && !cal_component_has_recurrences (event->comp_data->icalcomp)
+ && cal_util_event_dates_match (event->comp_data->icalcomp, comp_data->icalcomp)) {
+#if 0
+ g_print ("updated object's dates unchanged\n");
+#endif
+ e_day_view_foreach_event_with_uid (day_view, uid, e_day_view_update_event_cb, comp_data);
+ gtk_widget_queue_draw (day_view->top_canvas);
+ gtk_widget_queue_draw (day_view->main_canvas);
+ return;
+ }
+
+ /* The dates have changed, so we need to remove the
+ old occurrrences before adding the new ones. */
+#if 0
+ g_print ("dates changed - removing occurrences\n");
+#endif
+ e_day_view_foreach_event_with_uid (day_view, uid,
+ e_day_view_remove_event_cb,
+ NULL);
+ }
+
+ /* Add the occurrences of the event. */
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp));
+ add_event_data.day_view = day_view;
+ add_event_data.comp_data = comp_data;
+ cal_recur_generate_instances (comp, day_view->lower,
+ day_view->upper,
+ e_day_view_add_event, &add_event_data,
+ cal_client_resolve_tzid_cb,
+ comp_data->client,
+ e_cal_view_get_timezone (E_CAL_VIEW (day_view)));
+ g_object_unref (comp);
+
+ e_day_view_queue_layout (day_view);
+}
+
/* Restarts a query for the day view */
static void
-e_day_view_update_query (EDayView *day_view)
+e_day_view_update_query (ECalView *cal_view)
{
- CalQuery *old_query;
- char *real_sexp;
+ gint rows, r;
+ EDayView *day_view = E_DAY_VIEW (cal_view);
e_day_view_stop_editing_event (day_view);
@@ -3414,36 +3255,18 @@ e_day_view_update_query (EDayView *day_view)
e_day_view_free_events (day_view);
e_day_view_queue_layout (day_view);
- old_query = day_view->query;
- day_view->query = NULL;
-
- if (old_query) {
- g_signal_handlers_disconnect_matched (old_query, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, day_view);
- g_object_unref (old_query);
- }
-
- real_sexp = adjust_query_sexp (day_view, e_cal_view_get_query (E_CAL_VIEW (day_view)));
- if (!real_sexp)
- return; /* No time range is set, so don't start a query */
-
e_cal_view_set_status_message (E_CAL_VIEW (day_view), _("Searching"));
- day_view->query = cal_client_get_query (e_cal_view_get_cal_client (E_CAL_VIEW (day_view)), real_sexp);
- g_free (real_sexp);
- if (!day_view->query) {
- g_message ("e_day_view_update_query(): Could not create the query");
- return;
+ rows = e_table_model_row_count (E_TABLE_MODEL (e_cal_view_get_model (E_CAL_VIEW (day_view))));
+ for (r = 0; r < rows; r++) {
+ ECalModelComponent *comp_data;
+
+ comp_data = e_cal_model_get_component_at (e_cal_view_get_model (E_CAL_VIEW (day_view)), r);
+ g_assert (comp_data != NULL);
+ process_component (day_view, comp_data);
}
- g_signal_connect (day_view->query, "obj_updated",
- G_CALLBACK (query_obj_updated_cb), day_view);
- g_signal_connect (day_view->query, "obj_removed",
- G_CALLBACK (query_obj_removed_cb), day_view);
- g_signal_connect (day_view->query, "query_done",
- G_CALLBACK (query_query_done_cb), day_view);
- g_signal_connect (day_view->query, "eval_error",
- G_CALLBACK (query_eval_error_cb), day_view);
+ e_cal_view_set_status_message (E_CAL_VIEW (day_view), NULL);
}
static void
@@ -3474,13 +3297,15 @@ e_day_view_unrecur_appointment (EDayView *day_view)
/* For the recurring object, we add an exception to get rid of the
instance. */
- comp = cal_component_clone (event->comp);
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
cal_comp_util_add_exdate (comp, event->start, e_cal_view_get_timezone (E_CAL_VIEW (day_view)));
/* For the unrecurred instance we duplicate the original object,
create a new uid for it, get rid of the recurrence rules, and set
the start & end times to the instances times. */
- new_comp = cal_component_clone (event->comp);
+ new_comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
cal_component_set_uid (new_comp, cal_component_gen_uid ());
cal_component_set_rdate_list (new_comp, NULL);
cal_component_set_rrule_list (new_comp, NULL);
@@ -3501,13 +3326,13 @@ e_day_view_unrecur_appointment (EDayView *day_view)
/* Now update both CalComponents. Note that we do this last since at
* present the updates happen synchronously so our event may disappear.
*/
- if (cal_client_update_object (e_cal_view_get_cal_client (E_CAL_VIEW (day_view)), comp)
+ if (cal_client_update_object (event->comp_data->client, comp)
!= CAL_CLIENT_RESULT_SUCCESS)
g_message ("e_day_view_on_unrecur_appointment(): Could not update the object!");
g_object_unref (comp);
- if (cal_client_update_object (e_cal_view_get_cal_client (E_CAL_VIEW (day_view)), new_comp)
+ if (cal_client_update_object (event->comp_data->client, new_comp)
!= CAL_CLIENT_RESULT_SUCCESS)
g_message ("e_day_view_on_unrecur_appointment(): Could not update the object!");
@@ -3592,7 +3417,7 @@ e_day_view_update_calendar_selection_time (EDayView *day_view)
time_t start, end;
GnomeCalendar *calendar;
- e_day_view_get_selected_time_range (day_view, &start, &end);
+ e_day_view_get_selected_time_range ((ECalView *) day_view, &start, &end);
#if 0
g_print ("Start: %s", ctime (&start));
@@ -3652,7 +3477,8 @@ e_day_view_on_top_canvas_motion (GtkWidget *widget,
event = &g_array_index (day_view->long_events, EDayViewEvent,
day_view->pressed_event_num);
- if ((cal_component_is_instance (event->comp) || !cal_component_has_recurrences (event->comp))
+ if ((cal_util_component_is_instance (event->comp_data->icalcomp) ||
+ !cal_util_component_has_recurrences (event->comp_data->icalcomp))
&& (abs (canvas_x - day_view->drag_event_x)
> E_DAY_VIEW_DRAG_START_OFFSET
|| abs (canvas_y - day_view->drag_event_y)
@@ -3680,7 +3506,8 @@ e_day_view_on_top_canvas_motion (GtkWidget *widget,
cursor = day_view->normal_cursor;
/* Recurring events can't be resized. */
- if (event && (cal_component_is_instance (event->comp) || !cal_component_has_recurrences (event->comp))) {
+ if (event && (cal_util_component_is_instance (event->comp_data->icalcomp) ||
+ !cal_util_component_has_recurrences (event->comp_data->icalcomp))) {
switch (pos) {
case E_CAL_VIEW_POS_LEFT_EDGE:
case E_CAL_VIEW_POS_RIGHT_EDGE:
@@ -3756,7 +3583,8 @@ e_day_view_on_main_canvas_motion (GtkWidget *widget,
event = &g_array_index (day_view->events[day_view->pressed_event_day], EDayViewEvent, day_view->pressed_event_num);
- if ((cal_component_is_instance (event->comp) || !cal_component_has_recurrences (event->comp))
+ if ((cal_util_component_is_instance (event->comp_data->icalcomp) ||
+ !cal_util_component_has_recurrences (event->comp_data->icalcomp))
&& (abs (canvas_x - day_view->drag_event_x)
> E_DAY_VIEW_DRAG_START_OFFSET
|| abs (canvas_y - day_view->drag_event_y)
@@ -3784,7 +3612,8 @@ e_day_view_on_main_canvas_motion (GtkWidget *widget,
cursor = day_view->normal_cursor;
/* Recurring events can't be resized. */
- if (event && (cal_component_is_instance (event->comp) || !cal_component_has_recurrences (event->comp))) {
+ if (event && (cal_util_component_is_instance (event->comp_data->icalcomp) ||
+ !cal_util_component_has_recurrences (event->comp_data->icalcomp))) {
switch (pos) {
case E_CAL_VIEW_POS_LEFT_EDGE:
cursor = day_view->move_cursor;
@@ -4010,16 +3839,17 @@ e_day_view_finish_long_event_resize (EDayView *day_view)
time_t dt;
CalClient *client;
- client = e_cal_view_get_cal_client (E_CAL_VIEW (day_view));
-
event_num = day_view->resize_event_num;
event = &g_array_index (day_view->long_events, EDayViewEvent,
event_num);
+ client = event->comp_data->client;
+
/* We use a temporary copy of the comp since we don't want to
change the original comp here. Otherwise we would not detect that
the event's time had changed in the "update_event" callback. */
- comp = cal_component_clone (event->comp);
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
date.value = &itt;
/* FIXME: Should probably keep the timezone of the original start
@@ -4044,7 +3874,7 @@ e_day_view_finish_long_event_resize (EDayView *day_view)
if (recur_component_dialog (comp, &mod, NULL)) {
if (cal_client_update_object_with_mod (client, comp, mod) == CAL_CLIENT_RESULT_SUCCESS) {
if (itip_organizer_is_user (comp, client) &&
- send_component_dialog (gtk_widget_get_toplevel (day_view),
+ send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (day_view)),
client, comp, FALSE))
itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, client, NULL);
} else {
@@ -4055,7 +3885,7 @@ e_day_view_finish_long_event_resize (EDayView *day_view)
}
} else if (cal_client_update_object (client, comp) == CAL_CLIENT_RESULT_SUCCESS) {
if (itip_organizer_is_user (comp, client) &&
- send_component_dialog (gtk_widget_get_toplevel (day_view),
+ send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (day_view)),
client, comp, TRUE))
itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, client, NULL);
} else {
@@ -4083,17 +3913,18 @@ e_day_view_finish_resize (EDayView *day_view)
time_t dt;
CalClient *client;
- client = e_cal_view_get_cal_client (E_CAL_VIEW (day_view));
-
day = day_view->resize_event_day;
event_num = day_view->resize_event_num;
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
+ client = event->comp_data->client;
+
/* We use a temporary shallow copy of the ico since we don't want to
change the original ico here. Otherwise we would not detect that
the event's time had changed in the "update_event" callback. */
- comp = cal_component_clone (event->comp);
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
date.value = &itt;
/* FIXME: Should probably keep the timezone of the original start
@@ -4129,7 +3960,7 @@ e_day_view_finish_resize (EDayView *day_view)
if (recur_component_dialog (comp, &mod, NULL)) {
if (cal_client_update_object_with_mod (client, comp, mod) == CAL_CLIENT_RESULT_SUCCESS) {
if (itip_organizer_is_user (comp, client) &&
- send_component_dialog (gtk_widget_get_toplevel (day_view),
+ send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (day_view)),
client, comp, FALSE))
itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, client, NULL);
} else {
@@ -4140,7 +3971,7 @@ e_day_view_finish_resize (EDayView *day_view)
}
} else if (cal_client_update_object (client, comp) == CAL_CLIENT_RESULT_SUCCESS) {
if (itip_organizer_is_user (comp, client) &&
- send_component_dialog (gtk_widget_get_toplevel (day_view), client, comp, FALSE))
+ send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (day_view)), client, comp, FALSE))
itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, client, NULL);
} else {
g_message ("e_day_view_finish_resize(): Could not update the object!");
@@ -4218,7 +4049,11 @@ e_day_view_free_event_array (EDayView *day_view,
event = &g_array_index (array, EDayViewEvent, event_num);
if (event->canvas_item)
gtk_object_destroy (GTK_OBJECT (event->canvas_item));
- g_object_unref (event->comp);
+
+ if (event->allocated_comp_data) {
+ e_cal_model_free_component_data (event->comp_data);
+ event->allocated_comp_data = FALSE;
+ }
}
g_array_set_size (array, 0);
@@ -4233,40 +4068,50 @@ e_day_view_add_event (CalComponent *comp,
gpointer data)
{
- EDayView *day_view;
EDayViewEvent event;
gint day, offset;
struct icaltimetype start_tt, end_tt;
+ AddEventData *add_event_data;
- day_view = E_DAY_VIEW (data);
+ add_event_data = data;
#if 0
- g_print ("Day view lower: %s", ctime (&day_view->lower));
- g_print ("Day view upper: %s", ctime (&day_view->upper));
+ g_print ("Day view lower: %s", ctime (&add_event_data->day_view->lower));
+ g_print ("Day view upper: %s", ctime (&add_event_data->day_view->upper));
g_print ("Event start: %s", ctime (&start));
g_print ("Event end : %s\n", ctime (&end));
#endif
/* Check that the event times are valid. */
g_return_val_if_fail (start <= end, TRUE);
- g_return_val_if_fail (start < day_view->upper, TRUE);
- g_return_val_if_fail (end > day_view->lower, TRUE);
+ g_return_val_if_fail (start < add_event_data->day_view->upper, TRUE);
+ g_return_val_if_fail (end > add_event_data->day_view->lower, TRUE);
start_tt = icaltime_from_timet_with_zone (start, FALSE,
- e_cal_view_get_timezone (E_CAL_VIEW (day_view)));
+ e_cal_view_get_timezone (E_CAL_VIEW (add_event_data->day_view)));
end_tt = icaltime_from_timet_with_zone (end, FALSE,
- e_cal_view_get_timezone (E_CAL_VIEW (day_view)));
+ e_cal_view_get_timezone (E_CAL_VIEW (add_event_data->day_view)));
+
+ if (add_event_data->comp_data) {
+ event.comp_data = add_event_data->comp_data;
+ event.allocated_comp_data = FALSE;
+ } else {
+ event.comp_data = g_new0 (ECalModelComponent, 1);
+ event.allocated_comp_data = TRUE;
+
+ event.comp_data->client = e_cal_model_get_default_client (e_cal_view_get_model (E_CAL_VIEW (add_event_data->day_view)));
+ cal_component_commit_sequence (comp);
+ event.comp_data->icalcomp = icalcomponent_new_clone (cal_component_get_icalcomponent (comp));
+ }
- event.comp = comp;
- g_object_ref (comp);
event.start = start;
event.end = end;
event.canvas_item = NULL;
/* Calculate the start & end minute, relative to the top of the
display. */
- offset = day_view->first_hour_shown * 60
- + day_view->first_minute_shown;
+ offset = add_event_data->day_view->first_hour_shown * 60
+ + add_event_data->day_view->first_minute_shown;
event.start_minute = start_tt.hour * 60 + start_tt.minute - offset;
event.end_minute = end_tt.hour * 60 + end_tt.minute - offset;
@@ -4274,40 +4119,41 @@ e_day_view_add_event (CalComponent *comp,
event.num_columns = 0;
event.different_timezone = FALSE;
- if (!cal_comp_util_compare_event_timezones (comp, e_cal_view_get_cal_client (E_CAL_VIEW (day_view)),
- e_cal_view_get_timezone (E_CAL_VIEW (day_view))))
+ if (!cal_comp_util_compare_event_timezones (comp,
+ event.comp_data->client,
+ e_cal_view_get_timezone (E_CAL_VIEW (add_event_data->day_view))))
event.different_timezone = TRUE;
/* Find out which array to add the event to. */
- for (day = 0; day < day_view->days_shown; day++) {
- if (start >= day_view->day_starts[day]
- && end <= day_view->day_starts[day + 1]) {
+ for (day = 0; day < add_event_data->day_view->days_shown; day++) {
+ if (start >= add_event_data->day_view->day_starts[day]
+ && end <= add_event_data->day_view->day_starts[day + 1]) {
/* Special case for when the appointment ends at
midnight, i.e. the start of the next day. */
- if (end == day_view->day_starts[day + 1]) {
+ if (end == add_event_data->day_view->day_starts[day + 1]) {
/* If the event last the entire day, then we
skip it here so it gets added to the top
canvas. */
- if (start == day_view->day_starts[day])
- break;
+ if (start == add_event_data->day_view->day_starts[day])
+ break;
event.end_minute = 24 * 60;
}
- g_array_append_val (day_view->events[day], event);
- day_view->events_sorted[day] = FALSE;
- day_view->need_layout[day] = TRUE;
+ g_array_append_val (add_event_data->day_view->events[day], event);
+ add_event_data->day_view->events_sorted[day] = FALSE;
+ add_event_data->day_view->need_layout[day] = TRUE;
return TRUE;
}
}
/* The event wasn't within one day so it must be a long event,
i.e. shown in the top canvas. */
- g_array_append_val (day_view->long_events, event);
- day_view->long_events_sorted = FALSE;
- day_view->long_events_need_layout = TRUE;
+ g_array_append_val (add_event_data->day_view->long_events, event);
+ add_event_data->day_view->long_events_sorted = FALSE;
+ add_event_data->day_view->long_events_need_layout = TRUE;
return TRUE;
}
@@ -4435,7 +4281,8 @@ e_day_view_reshape_long_event (EDayView *day_view,
/* We don't show the icons while resizing, since we'd have to
draw them on top of the resize rect. Nor when editing. */
num_icons = 0;
- comp = event->comp;
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
/* Set up Pango prerequisites */
font_desc = gtk_widget_get_style (GTK_WIDGET (day_view))->font_desc;
@@ -4488,7 +4335,7 @@ e_day_view_reshape_long_event (EDayView *day_view,
"editable", TRUE,
"use_ellipsis", TRUE,
"draw_background", FALSE,
- "fill_color_rgba", GNOME_CANVAS_COLOR(0, 0, 0),
+ "fill_color_rgba", GNOME_CANVAS_COLOR (0, 0, 0),
"im_context", E_CANVAS (day_view->top_canvas)->im_context,
NULL);
g_signal_connect (event->canvas_item, "event",
@@ -4580,11 +4427,9 @@ e_day_view_reshape_day_event (EDayView *day_view,
EDayViewEvent *event;
gint item_x, item_y, item_w, item_h;
gint num_icons, icons_offset;
- CalComponent *comp;
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
- comp = event->comp;
if (!e_day_view_get_event_position (day_view, day, event_num,
&item_x, &item_y,
@@ -4607,6 +4452,10 @@ e_day_view_reshape_day_event (EDayView *day_view,
|| day_view->resize_event_day != day
|| day_view->resize_event_num != event_num) {
GSList *categories_list, *elem;
+ CalComponent *comp;
+
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
if (cal_component_has_alarms (comp))
num_icons++;
@@ -4781,6 +4630,7 @@ static gboolean
e_day_view_do_key_press (GtkWidget *widget, GdkEventKey *event)
{
EDayView *day_view;
+ icalcomponent *icalcomp;
CalComponent *comp;
gint day, event_num;
gchar *initial_text;
@@ -4789,7 +4639,8 @@ e_day_view_do_key_press (GtkWidget *widget, GdkEventKey *event)
time_t dtstart, dtend;
CalComponentDateTime start_dt, end_dt;
struct icaltimetype start_tt, end_tt;
- const char *uid;
+ const char *uid;
+ AddEventData add_event_data;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (E_IS_DAY_VIEW (widget), FALSE);
@@ -4797,11 +4648,6 @@ e_day_view_do_key_press (GtkWidget *widget, GdkEventKey *event)
day_view = E_DAY_VIEW (widget);
keyval = event->keyval;
-
- if (!(e_cal_view_get_cal_client (E_CAL_VIEW (day_view))
- && cal_client_get_load_state (e_cal_view_get_cal_client (E_CAL_VIEW (day_view)))
- == CAL_CLIENT_LOAD_LOADED))
- return TRUE;
/* The Escape key aborts a resize operation. */
if (day_view->resize_drag_pos != E_CAL_VIEW_POS_NONE) {
@@ -4918,9 +4764,13 @@ e_day_view_do_key_press (GtkWidget *widget, GdkEventKey *event)
/* Add a new event covering the selected range */
- comp = cal_comp_event_new_with_defaults (e_cal_view_get_cal_client (E_CAL_VIEW (day_view)));
+ icalcomp = e_cal_model_create_component_with_defaults (e_cal_view_get_model (E_CAL_VIEW (day_view)));
+ uid = icalcomponent_get_uid (icalcomp);
- e_day_view_get_selected_time_range (day_view, &dtstart, &dtend);
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomp);
+
+ e_day_view_get_selected_time_range ((ECalView *) day_view, &dtstart, &dtend);
start_tt = icaltime_from_timet_with_zone (dtstart, FALSE,
e_cal_view_get_timezone (E_CAL_VIEW (day_view)));
@@ -4946,12 +4796,13 @@ e_day_view_do_key_press (GtkWidget *widget, GdkEventKey *event)
/* We add the event locally and start editing it. We don't send it
to the server until the user finishes editing it. */
- e_day_view_add_event (comp, dtstart, dtend, day_view);
+ add_event_data.day_view = day_view;
+ add_event_data.comp_data = NULL;
+ e_day_view_add_event (comp, dtstart, dtend, &add_event_data);
e_day_view_check_layout (day_view);
gtk_widget_queue_draw (day_view->top_canvas);
gtk_widget_queue_draw (day_view->main_canvas);
- cal_component_get_uid (comp, &uid);
if (e_day_view_find_event_from_uid (day_view, uid, &day, &event_num)) {
e_day_view_start_editing_event (day_view, day, event_num,
initial_text);
@@ -5715,7 +5566,7 @@ cancel_editing (EDayView *day_view)
{
int day, event_num;
EDayViewEvent *event;
- CalComponentText summary;
+ const gchar *summary;
day = day_view->editing_event_day;
event_num = day_view->editing_event_num;
@@ -5729,9 +5580,9 @@ cancel_editing (EDayView *day_view)
/* Reset the text to what was in the component */
- cal_component_get_summary (event->comp, &summary);
+ summary = icalcomponent_get_summary (event->comp_data->icalcomp);
g_object_set (G_OBJECT (event->canvas_item),
- "text", summary.value ? summary.value : "",
+ "text", summary ? summary : "",
NULL);
/* Stop editing */
@@ -5841,6 +5692,7 @@ e_day_view_on_editing_stopped (EDayView *day_view,
EDayViewEvent *event;
gchar *text = NULL;
CalComponentText summary;
+ CalComponent *comp;
/* Note: the item we are passed here isn't reliable, so we just stop
the edit of whatever item was being edited. We also receive this
@@ -5883,11 +5735,14 @@ e_day_view_on_editing_stopped (EDayView *day_view,
NULL);
g_assert (text != NULL);
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
+
if (string_is_empty (text) &&
- !cal_comp_is_on_server (event->comp, e_cal_view_get_cal_client (E_CAL_VIEW (day_view)))) {
+ !cal_comp_is_on_server (comp, event->comp_data->client)) {
const char *uid;
- cal_component_get_uid (event->comp, &uid);
+ cal_component_get_uid (comp, &uid);
e_day_view_foreach_event_with_uid (day_view, uid,
e_day_view_remove_event_cb, NULL);
@@ -5898,7 +5753,7 @@ e_day_view_on_editing_stopped (EDayView *day_view,
}
/* Only update the summary if necessary. */
- cal_component_get_summary (event->comp, &summary);
+ cal_component_get_summary (comp, &summary);
if (summary.value && !strcmp (text, summary.value)) {
if (day == E_DAY_VIEW_LONG_EVENT)
e_day_view_reshape_long_event (day_view, event_num);
@@ -5906,34 +5761,31 @@ e_day_view_on_editing_stopped (EDayView *day_view,
e_day_view_update_event_label (day_view, day,
event_num);
} else if (summary.value || !string_is_empty (text)) {
- CalClient *client;
-
- client = e_cal_view_get_cal_client (E_CAL_VIEW (day_view));
-
summary.value = text;
summary.altrep = NULL;
- cal_component_set_summary (event->comp, &summary);
+ cal_component_set_summary (comp, &summary);
- if (cal_component_is_instance (event->comp)) {
+ if (cal_component_is_instance (comp)) {
CalObjModType mod;
- if (recur_component_dialog (event->comp, &mod, NULL)) {
- if (cal_client_update_object_with_mod (client, event->comp, mod) == CAL_CLIENT_RESULT_SUCCESS) {
- if (itip_organizer_is_user (event->comp, client)
- && send_component_dialog (gtk_widget_get_toplevel (day_view),
- client, event->comp, FALSE))
- itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, event->comp,
- client, NULL);
+ if (recur_component_dialog (comp, &mod, NULL)) {
+ if (cal_client_update_object_with_mod (event->comp_data->client, comp, mod)
+ == CAL_CLIENT_RESULT_SUCCESS) {
+ if (itip_organizer_is_user (comp, event->comp_data->client)
+ && send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (day_view)),
+ event->comp_data->client, comp, FALSE))
+ itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp,
+ event->comp_data->client, NULL);
} else {
g_message ("e_day_view_on_editing_stopped(): Could not update the object!");
}
}
- } else if (cal_client_update_object (client, event->comp) == CAL_CLIENT_RESULT_SUCCESS) {
- if (itip_organizer_is_user (event->comp, client) &&
- send_component_dialog (gtk_widget_get_toplevel (day_view),
- client, event->comp, FALSE))
- itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, event->comp,
- client, NULL);
+ } else if (cal_client_update_object (event->comp_data->client, comp) == CAL_CLIENT_RESULT_SUCCESS) {
+ if (itip_organizer_is_user (comp, event->comp_data->client) &&
+ send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (day_view)),
+ event->comp_data->client, comp, FALSE))
+ itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp,
+ event->comp_data->client, NULL);
} else {
g_message ("e_day_view_on_editing_stopped(): Could not update the object!");
}
@@ -5941,6 +5793,7 @@ e_day_view_on_editing_stopped (EDayView *day_view,
out:
+ g_object_unref (comp);
g_free (text);
g_signal_emit_by_name (day_view, "selection_changed");
@@ -6579,11 +6432,11 @@ e_day_view_update_top_canvas_drag (EDayView *day_view,
set the text then. */
if (!(day_view->drag_long_event_item->object.flags
& GNOME_CANVAS_ITEM_VISIBLE)) {
- CalComponentText summary;
+ const gchar *summary;
if (event) {
- cal_component_get_summary (event->comp, &summary);
- text = g_strdup (summary.value);
+ summary = icalcomponent_get_summary (event->comp_data->icalcomp);
+ text = g_strdup (summary);
} else {
text = NULL;
}
@@ -6741,11 +6594,11 @@ e_day_view_update_main_canvas_drag (EDayView *day_view,
time it moves, so we check if it is currently invisible and only
set the text then. */
if (!(day_view->drag_item->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) {
- CalComponentText summary;
+ const gchar *summary;
if (event) {
- cal_component_get_summary (event->comp, &summary);
- text = g_strdup (summary.value);
+ summary = icalcomponent_get_summary (event->comp_data->icalcomp);
+ text = g_strdup (summary);
} else {
text = NULL;
}
@@ -6887,7 +6740,7 @@ e_day_view_on_drag_data_get (GtkWidget *widget,
if (info == TARGET_CALENDAR_EVENT) {
const char *event_uid;
- cal_component_get_uid (event->comp, &event_uid);
+ event_uid = icalcomponent_get_uid (event->comp_data->icalcomp);
g_return_if_fail (event_uid != NULL);
gtk_selection_data_set (selection_data, selection_data->target,
@@ -6897,10 +6750,10 @@ e_day_view_on_drag_data_get (GtkWidget *widget,
icalcomponent *vcal;
vcal = cal_util_new_top_level ();
- cal_util_add_timezones_from_component (vcal, cal_component_get_icalcomponent (event->comp));
+ cal_util_add_timezones_from_component (vcal, event->comp_data->icalcomp);
icalcomponent_add_component (
vcal,
- icalcomponent_new_clone (cal_component_get_icalcomponent (event->comp)));
+ icalcomponent_new_clone (event->comp_data->icalcomp));
comp_str = icalcomponent_as_ical_string (vcal);
if (comp_str) {
@@ -6935,7 +6788,7 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget,
gboolean all_day_event;
CalClient *client;
- client = e_cal_view_get_cal_client (E_CAL_VIEW (day_view));
+ client = e_cal_model_get_default_client (e_cal_view_get_model (E_CAL_VIEW (day_view)));
/* Note that we only support DnD within the EDayView at present. */
if ((data->length >= 0) && (data->format == 8)
@@ -6972,9 +6825,11 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget,
day_view->drag_event_num);
}
+ client = event->comp_data->client;
+
event_uid = data->data;
- cal_component_get_uid (event->comp, &uid);
+ uid = icalcomponent_get_uid (event->comp_data->icalcomp);
if (!event_uid || !uid || strcmp (event_uid, uid))
g_warning ("Unexpected event UID");
@@ -6984,7 +6839,8 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget,
Otherwise we would not detect that the event's time
had changed in the "update_event" callback. */
- comp = cal_component_clone (event->comp);
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
if (start_offset == 0 && end_offset == 0)
all_day_event = TRUE;
@@ -7038,7 +6894,7 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget,
if (recur_component_dialog (comp, &mod, NULL)) {
if (cal_client_update_object_with_mod (client, comp, mod) == CAL_CLIENT_RESULT_SUCCESS) {
if (itip_organizer_is_user (comp, client)
- && send_component_dialog (gtk_widget_get_toplevel (day_view),
+ && send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (day_view)),
client, comp, FALSE))
itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp,
client, NULL);
@@ -7050,7 +6906,7 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget,
} else if (cal_client_update_object (client, comp)
== CAL_CLIENT_RESULT_SUCCESS) {
if (itip_organizer_is_user (comp, client) &&
- send_component_dialog (gtk_widget_get_toplevel (day_view),
+ send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (day_view)),
client, comp, FALSE))
itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp,
client, NULL);
@@ -7090,7 +6946,7 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget,
time_t dt;
CalClient *client;
- client = e_cal_view_get_cal_client (E_CAL_VIEW (day_view));
+ client = e_cal_model_get_default_client (e_cal_view_get_model (E_CAL_VIEW (day_view)));
gnome_canvas_get_scroll_offsets (GNOME_CANVAS (widget),
&scroll_x, &scroll_y);
@@ -7132,9 +6988,11 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget,
end_offset = day_view->mins_per_row - end_offset;
}
+ client = event->comp_data->client;
+
event_uid = data->data;
- cal_component_get_uid (event->comp, &uid);
+ uid = icalcomponent_get_uid (event->comp_data->icalcomp);
if (!event_uid || !uid || strcmp (event_uid, uid))
g_warning ("Unexpected event UID");
@@ -7142,7 +7000,8 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget,
don't want to change the original comp here.
Otherwise we would not detect that the event's time
had changed in the "update_event" callback. */
- comp = cal_component_clone (event->comp);
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
date.value = &itt;
date.tzid = icaltimezone_get_tzid (e_cal_view_get_timezone (E_CAL_VIEW (day_view)));
@@ -7172,7 +7031,7 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget,
if (recur_component_dialog (comp, &mod, NULL)) {
if (cal_client_update_object_with_mod (client, comp, mod) == CAL_CLIENT_RESULT_SUCCESS) {
if (itip_organizer_is_user (comp, client)
- && send_component_dialog (gtk_widget_get_toplevel (day_view),
+ && send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (day_view)),
client, comp, FALSE))
itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp,
client, NULL);
@@ -7183,7 +7042,7 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget,
}
} else if (cal_client_update_object (client, comp) == CAL_CLIENT_RESULT_SUCCESS) {
if (itip_organizer_is_user (comp, client) &&
- send_component_dialog (gtk_widget_get_toplevel (day_view),
+ send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (day_view)),
client, comp, FALSE))
itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp,
client, NULL);
diff --git a/calendar/gui/e-day-view.h b/calendar/gui/e-day-view.h
index 1e903ff59c..1c39fd5844 100644
--- a/calendar/gui/e-day-view.h
+++ b/calendar/gui/e-day-view.h
@@ -528,7 +528,7 @@ void e_day_view_set_week_start_day (EDayView *day_view,
gint week_start_day);
void e_day_view_delete_occurrence (EDayView *day_view);
-
+void e_day_view_unrecur_appointment (EDayView *day_view);
/* Returns the number of selected events (0 or 1 at present). */
gint e_day_view_get_num_events_selected (EDayView *day_view);
diff --git a/calendar/gui/e-week-view-event-item.c b/calendar/gui/e-week-view-event-item.c
index 37318141a9..139f28bb13 100644
--- a/calendar/gui/e-week-view-event-item.c
+++ b/calendar/gui/e-week-view-event-item.c
@@ -236,6 +236,7 @@ e_week_view_event_item_draw (GnomeCanvasItem *canvas_item,
gboolean draw_start, draw_end;
gboolean draw_start_triangle = FALSE, draw_end_triangle = FALSE;
GdkRectangle clip_rect;
+ GdkColor bg_color;
#if 0
g_print ("In e_week_view_event_item_draw %i,%i %ix%i\n",
@@ -282,7 +283,29 @@ e_week_view_event_item_draw (GnomeCanvasItem *canvas_item,
one_day_event = e_week_view_is_one_day_event (week_view,
wveitem->event_num);
if (one_day_event) {
- time_x = x1 + E_WEEK_VIEW_EVENT_L_PAD;
+ time_x = x1 + E_WEEK_VIEW_EVENT_L_PAD + 1;
+ rect_x = x1 + E_WEEK_VIEW_EVENT_L_PAD;
+ rect_w = x2 - x1 - E_WEEK_VIEW_EVENT_L_PAD - E_WEEK_VIEW_EVENT_R_PAD + 1;
+
+ if (gdk_color_parse (e_cal_model_get_color_for_component (e_cal_view_get_model (E_CAL_VIEW (week_view)),
+ event->comp_data),
+ &bg_color)) {
+ GdkColormap *colormap;
+
+ colormap = gtk_widget_get_colormap (GTK_WIDGET (week_view));
+ if (gdk_colormap_alloc_color (colormap, &bg_color, TRUE, TRUE))
+ gdk_gc_set_foreground (gc, &bg_color);
+ else
+ gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND]);
+ } else
+ gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND]);
+ gdk_draw_rectangle (drawable, gc, TRUE, rect_x, y1 + 1, rect_w, y2 - y1 - 1);
+
+ gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BORDER]);
+ gdk_draw_line (drawable, gc, rect_x, y1 + 1, rect_x + rect_w, y1 + 1);
+ gdk_draw_line (drawable, gc, rect_x, y2, rect_x + rect_w, y2);
+ gdk_draw_line (drawable, gc, rect_x, y1 + 1, rect_x, y1 + (y2 - (y1 + 1)));
+ gdk_draw_line (drawable, gc, rect_x + rect_w, y1 + 1, rect_x + rect_w, y1 + (y2 - (y1 + 1)));
/* Draw the start and end times, as required. */
switch (week_view->time_format) {
@@ -354,9 +377,19 @@ e_week_view_event_item_draw (GnomeCanvasItem *canvas_item,
rect_w -= 2;
}
- gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND]);
- gdk_draw_rectangle (drawable, gc, TRUE,
- rect_x, y1 + 1, rect_w, y2 - y1 - 1);
+ if (gdk_color_parse (e_cal_model_get_color_for_component (e_cal_view_get_model (E_CAL_VIEW (week_view)),
+ event->comp_data),
+ &bg_color)) {
+ GdkColormap *colormap;
+
+ colormap = gtk_widget_get_colormap (GTK_WIDGET (week_view));
+ if (gdk_colormap_alloc_color (colormap, &bg_color, TRUE, TRUE))
+ gdk_gc_set_foreground (gc, &bg_color);
+ else
+ gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND]);
+ } else
+ gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND]);
+ gdk_draw_rectangle (drawable, gc, TRUE, rect_x, y1 + 1, rect_w, y2 - y1 - 1);
gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BORDER]);
rect_x2 = rect_x + rect_w - 1;
@@ -572,7 +605,8 @@ e_week_view_event_item_draw_icons (EWeekViewEventItem *wveitem,
wveitem->event_num);
span = &g_array_index (week_view->spans, EWeekViewEventSpan,
event->spans_index + wveitem->span_num);
- comp = event->comp;
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
gc = week_view->main_gc;
@@ -870,7 +904,7 @@ e_week_view_event_item_double_click (EWeekViewEventItem *wveitem,
calendar = e_cal_view_get_calendar (E_CAL_VIEW (week_view));
if (calendar)
- gnome_calendar_edit_object (calendar, event->comp, FALSE);
+ gnome_calendar_edit_object (calendar, event->comp_data->client, event->comp_data->icalcomp, FALSE);
else
g_warning ("Calendar not set");
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index 621d2e485c..27e25c9a86 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -87,6 +87,11 @@
#define E_WEEK_VIEW_LAYOUT_TIMEOUT 100
+typedef struct {
+ EWeekView *week_view;
+ ECalModelComponent *comp_data;
+} AddEventData;
+
static void e_week_view_class_init (EWeekViewClass *class);
static void e_week_view_init (EWeekView *week_view);
static void e_week_view_destroy (GtkObject *object);
@@ -112,10 +117,10 @@ static gboolean e_week_view_get_next_tab_event (EWeekView *week_view,
static gboolean e_week_view_focus (GtkWidget *widget,
GtkDirectionType direction);
static GList *e_week_view_get_selected_events (ECalView *cal_view);
-static void e_week_view_get_selected_time_range (EWeekView *cal_view, time_t *start_time, time_t *end_time);
-static void e_week_view_set_selected_time_range (EWeekView *cal_view, time_t start_time, time_t end_time);
-static gboolean e_week_view_get_visible_time_range (EWeekView *cal_view, time_t *start_time, time_t *end_time);
-static void e_week_view_update_query (EWeekView *week_view);
+static void e_week_view_get_selected_time_range (ECalView *cal_view, time_t *start_time, time_t *end_time);
+static void e_week_view_set_selected_time_range (ECalView *cal_view, time_t start_time, time_t end_time);
+static gboolean e_week_view_get_visible_time_range (ECalView *cal_view, time_t *start_time, time_t *end_time);
+static void e_week_view_update_query (ECalView *cal_view);
static void e_week_view_draw_shadow (EWeekView *week_view);
static gboolean e_week_view_on_button_press (GtkWidget *widget,
@@ -257,7 +262,7 @@ timezone_changed_cb (ECalView *cal_view, icaltimezone *old_zone,
lower = icaltime_as_timet_with_zone (tt, new_zone);
e_week_view_recalc_day_starts (week_view, lower);
- e_week_view_update_query (week_view);
+ e_week_view_update_query ((ECalView *) week_view);
}
static void
@@ -435,12 +440,6 @@ e_week_view_destroy (GtkObject *object)
g_array_free (week_view->events, TRUE);
week_view->events = NULL;
}
-
- if (e_cal_view_get_cal_client (E_CAL_VIEW (week_view))) {
- g_signal_handlers_disconnect_matched (
- e_cal_view_get_cal_client (E_CAL_VIEW (week_view)), G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, week_view);
- }
if (week_view->query) {
g_signal_handlers_disconnect_matched (week_view->query, G_SIGNAL_MATCH_DATA,
@@ -1060,64 +1059,49 @@ e_week_view_get_selected_events (ECalView *cal_view)
return list;
}
-/* Callback used when a component is updated in the live query */
static void
-query_obj_updated_cb (CalQuery *query, const char *uid,
- gboolean query_in_progress, int n_scanned, int total,
- gpointer data)
+process_component (EWeekView *week_view, ECalModelComponent *comp_data)
{
- EWeekView *week_view;
EWeekViewEvent *event;
gint event_num, num_days;
CalComponent *comp = NULL;
- icalcomponent *icalcomp;
- CalClientGetStatus status;
-
- week_view = E_WEEK_VIEW (data);
+ AddEventData add_event_data;
+ const char *uid;
/* If we don't have a valid date set yet, just return. */
if (!g_date_valid (&week_view->first_day_shown))
return;
- /* Get the event from the server. */
- status = cal_client_get_object (e_cal_view_get_cal_client (E_CAL_VIEW (week_view)), uid, &icalcomp);
-
- switch (status) {
- case CAL_CLIENT_GET_SUCCESS:
- comp = cal_component_new ();
- if (!cal_component_set_icalcomponent (comp, icalcomp)) {
- g_object_unref (comp);
- icalcomponent_free (icalcomp);
-
- g_message ("query_obj_updated_cb(): Could not set icalcomponent on CalComponent");
- return;
- }
- break;
-
- case CAL_CLIENT_GET_SYNTAX_ERROR:
- g_message ("obj_updated_cb(): Syntax error when getting object `%s'", uid);
- return;
+ comp = cal_component_new ();
+ if (!cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp))) {
+ g_object_unref (comp);
- case CAL_CLIENT_GET_NOT_FOUND:
- /* The object is no longer in the server, so do nothing */
+ g_message ("process_component(): Could not set icalcomponent on CalComponent");
return;
}
+ cal_component_get_uid (comp, &uid);
+
/* If the event already exists and the dates didn't change, we can
update the event fairly easily without changing the events arrays
or computing a new layout. */
if (e_week_view_find_event_from_uid (week_view, uid, &event_num)) {
+ CalComponent *tmp_comp;
+
event = &g_array_index (week_view->events, EWeekViewEvent,
event_num);
+ tmp_comp = cal_component_new ();
+ cal_component_set_icalcomponent (tmp_comp, icalcomponent_new_clone (comp_data->icalcomp));
if (!cal_component_has_recurrences (comp)
- && !cal_component_has_recurrences (event->comp)
- && cal_component_event_dates_match (comp, event->comp)) {
+ && !cal_component_has_recurrences (tmp_comp)
+ && cal_component_event_dates_match (comp, tmp_comp)) {
#if 0
g_print ("updated object's dates unchanged\n");
#endif
- e_week_view_foreach_event_with_uid (week_view, uid, e_week_view_update_event_cb, comp);
+ e_week_view_foreach_event_with_uid (week_view, uid, e_week_view_update_event_cb, comp_data);
g_object_unref (comp);
+ g_object_unref (tmp_comp);
gtk_widget_queue_draw (week_view->main_canvas);
return;
}
@@ -1130,17 +1114,21 @@ query_obj_updated_cb (CalQuery *query, const char *uid,
e_week_view_foreach_event_with_uid (week_view, uid,
e_week_view_remove_event_cb,
NULL);
+
+ g_object_unref (tmp_comp);
}
/* Add the occurrences of the event. */
num_days = week_view->multi_week_view ? week_view->weeks_shown * 7 : 7;
+ add_event_data.week_view = week_view;
+ add_event_data.comp_data = comp_data;
cal_recur_generate_instances (comp,
week_view->day_starts[0],
week_view->day_starts[num_days],
- e_week_view_add_event, week_view,
+ e_week_view_add_event, &add_event_data,
cal_client_resolve_tzid_cb,
- e_cal_view_get_cal_client (E_CAL_VIEW (week_view)),
+ comp_data->client,
e_cal_view_get_timezone (E_CAL_VIEW (week_view)));
g_object_unref (comp);
@@ -1148,132 +1136,29 @@ query_obj_updated_cb (CalQuery *query, const char *uid,
e_week_view_queue_layout (week_view);
}
-/* Callback used when a component is removed from the live query */
-static void
-query_obj_removed_cb (CalClient *client, const char *uid, gpointer data)
-{
- EWeekView *week_view;
-
- week_view = E_WEEK_VIEW (data);
-
- e_week_view_foreach_event_with_uid (week_view, uid,
- e_week_view_remove_event_cb, NULL);
-
- gtk_widget_queue_draw (week_view->main_canvas);
- e_week_view_check_layout (week_view);
-}
-
-/* Callback used when a query ends */
-static void
-query_query_done_cb (CalQuery *query, CalQueryDoneStatus status, const char *error_str, gpointer data)
-{
- EWeekView *week_view;
-
- week_view = E_WEEK_VIEW (data);
-
- /* FIXME */
-
- e_cal_view_set_status_message (E_CAL_VIEW (week_view), NULL);
-
- if (status != CAL_QUERY_DONE_SUCCESS)
- fprintf (stderr, "query done: %s\n", error_str);
-
- gtk_widget_queue_draw (week_view->main_canvas);
-}
-
-/* Callback used when an evaluation error occurs when running a query */
-static void
-query_eval_error_cb (CalQuery *query, const char *error_str, gpointer data)
-{
- EWeekView *week_view;
-
- week_view = E_WEEK_VIEW (data);
-
- /* FIXME */
-
- e_cal_view_set_status_message (E_CAL_VIEW (week_view), NULL);
-
- fprintf (stderr, "eval error: %s\n", error_str);
-
- gtk_widget_queue_draw (week_view->main_canvas);
-}
-
-/* Builds a complete query sexp for the week view by adding the predicates to
- * filter only for VEVENTS that fit in the week view's time range.
- */
-static char *
-adjust_query_sexp (EWeekView *week_view, const char *sexp)
-{
- int num_days;
- char *start, *end;
- char *new_sexp;
-
- /* If the dates have not been set yet, we just want an empty query. */
- if (!g_date_valid (&week_view->first_day_shown))
- return NULL;
-
- num_days = week_view->multi_week_view ? week_view->weeks_shown * 7 : 7;
-
- start = isodate_from_time_t (week_view->day_starts[0]);
- end = isodate_from_time_t (week_view->day_starts[num_days]);
-
- new_sexp = g_strdup_printf ("(and (= (get-vtype) \"VEVENT\")"
- " (occur-in-time-range? (make-time \"%s\")"
- " (make-time \"%s\"))"
- " %s)",
- start, end,
- sexp);
-
- g_free (start);
- g_free (end);
-
- return new_sexp;
-}
-
/* Restarts a query for the week view */
static void
-e_week_view_update_query (EWeekView *week_view)
+e_week_view_update_query (ECalView *cal_view)
{
- CalQuery *old_query;
- char *real_sexp;
+ gint rows, r;
+ EWeekView *week_view = E_WEEK_VIEW (cal_view);
gtk_widget_queue_draw (week_view->main_canvas);
e_week_view_free_events (week_view);
e_week_view_queue_layout (week_view);
- old_query = week_view->query;
- week_view->query = NULL;
-
- if (old_query) {
- g_signal_handlers_disconnect_matched (old_query, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, week_view);
- g_object_unref (old_query);
- }
-
- g_assert (e_cal_view_get_query (E_CAL_VIEW (week_view)) != NULL);
-
- real_sexp = adjust_query_sexp (week_view, e_cal_view_get_query (E_CAL_VIEW (week_view)));
- if (!real_sexp) {
- return; /* No time range is set, so don't start a query */
- }
-
e_cal_view_set_status_message (E_CAL_VIEW (week_view), _("Searching"));
- week_view->query = cal_client_get_query (e_cal_view_get_cal_client (E_CAL_VIEW (week_view)), real_sexp);
- g_free (real_sexp);
- if (!week_view->query) {
- g_message ("e_week_view_update_query(): Could not create the query");
- return;
+ rows = e_table_model_row_count (E_TABLE_MODEL (e_cal_view_get_model (E_CAL_VIEW (week_view))));
+ for (r = 0; r < rows; r++) {
+ ECalModelComponent *comp_data;
+
+ comp_data = e_cal_model_get_component_at (e_cal_view_get_model (E_CAL_VIEW (week_view)), r);
+ g_assert (comp_data != NULL);
+ process_component (week_view, comp_data);
}
- g_signal_connect (week_view->query, "obj_updated",
- G_CALLBACK (query_obj_updated_cb), week_view);
- g_signal_connect (week_view->query, "obj_removed",
- G_CALLBACK (query_obj_removed_cb), week_view);
- g_signal_connect (week_view->query, "query_done",
- G_CALLBACK (query_query_done_cb), week_view);
- g_signal_connect (week_view->query, "eval_error",
- G_CALLBACK (query_eval_error_cb), week_view);
+ e_cal_view_set_status_message (E_CAL_VIEW (week_view), NULL);
}
static void
@@ -1326,13 +1211,14 @@ e_week_view_set_default_category (EWeekView *week_view, const char *category)
month and the days between start_time and end_time will be selected.
To select a single day, use the same value for start_time & end_time. */
static void
-e_week_view_set_selected_time_range (EWeekView *week_view,
+e_week_view_set_selected_time_range (ECalView *cal_view,
time_t start_time,
time_t end_time)
{
GDate date, base_date, end_date;
gint day_offset, weekday, week_start_offset, num_days;
gboolean update_adjustment_value = FALSE;
+ EWeekView *week_view = E_WEEK_VIEW (cal_view);
g_return_if_fail (E_IS_WEEK_VIEW (week_view));
@@ -1389,7 +1275,7 @@ e_week_view_set_selected_time_range (EWeekView *week_view,
start_time = time_day_begin_with_zone (start_time,
e_cal_view_get_timezone (E_CAL_VIEW (week_view)));
e_week_view_recalc_day_starts (week_view, start_time);
- e_week_view_update_query (week_view);
+ e_week_view_update_query ((ECalView *) week_view);
}
/* Set the selection to the given days. */
@@ -1463,11 +1349,12 @@ e_week_view_set_selected_time_range_visible (EWeekView *week_view,
/* Returns the selected time range. */
static void
-e_week_view_get_selected_time_range (EWeekView *week_view,
+e_week_view_get_selected_time_range (ECalView *cal_view,
time_t *start_time,
time_t *end_time)
{
gint start_day, end_day;
+ EWeekView *week_view = E_WEEK_VIEW (cal_view);
start_day = week_view->selection_start_day;
end_day = week_view->selection_end_day;
@@ -1486,11 +1373,12 @@ e_week_view_get_selected_time_range (EWeekView *week_view,
/* Gets the visible time range. Returns FALSE if no time range has been set. */
static gboolean
-e_week_view_get_visible_time_range (EWeekView *week_view,
+e_week_view_get_visible_time_range (ECalView *cal_view,
time_t *start_time,
time_t *end_time)
{
gint num_days;
+ EWeekView *week_view = E_WEEK_VIEW (cal_view);
/* If we don't have a valid date set yet, return FALSE. */
if (!g_date_valid (&week_view->first_day_shown))
@@ -1569,7 +1457,7 @@ e_week_view_set_first_day_shown (EWeekView *week_view,
e_cal_view_get_timezone (E_CAL_VIEW (week_view)));
e_week_view_recalc_day_starts (week_view, start_time);
- e_week_view_update_query (week_view);
+ e_week_view_update_query ((ECalView *) week_view);
}
/* Try to keep the previous selection, but if it is no longer shown
@@ -1706,7 +1594,7 @@ e_week_view_set_weeks_shown (EWeekView *week_view,
if (g_date_valid (&week_view->first_day_shown))
e_week_view_set_first_day_shown (week_view, &week_view->first_day_shown);
- e_week_view_update_query (week_view);
+ e_week_view_update_query ((ECalView *) week_view);
}
}
@@ -1872,29 +1760,27 @@ e_week_view_update_event_cb (EWeekView *week_view,
EWeekViewEvent *event;
EWeekViewEventSpan *span;
gint span_num;
- gchar *text;
- CalComponent *comp;
+ const gchar *text;
+ ECalModelComponent *comp_data;
- comp = data;
+ comp_data = data;
event = &g_array_index (week_view->events, EWeekViewEvent, event_num);
- g_object_unref (event->comp);
- event->comp = comp;
- g_object_ref (comp);
+ if (event->allocated_comp_data)
+ e_cal_model_free_component_data (event->comp_data);
+ event->comp_data = comp_data;
+ event->allocated_comp_data = FALSE;
for (span_num = 0; span_num < event->num_spans; span_num++) {
span = &g_array_index (week_view->spans, EWeekViewEventSpan,
event->spans_index + span_num);
if (span->text_item) {
- CalComponentText t;
-
- cal_component_get_summary (event->comp, &t);
- text = (char*) t.value;
+ text = icalcomponent_get_summary (comp_data->icalcomp);
gnome_canvas_item_set (span->text_item,
"text", text ? text : "",
- NULL);
+ NULL);
e_week_view_reshape_event_span (week_view, event_num,
span_num);
@@ -1928,7 +1814,7 @@ e_week_view_foreach_event_with_uid (EWeekView *week_view,
event = &g_array_index (week_view->events, EWeekViewEvent,
event_num);
- cal_component_get_uid (event->comp, &u);
+ u = icalcomponent_get_uid (event->comp_data->icalcomp);
if (u && !strcmp (uid, u)) {
if (!(*callback) (week_view, event_num, data))
return;
@@ -1969,7 +1855,10 @@ e_week_view_remove_event_cb (EWeekView *week_view,
}
}
- g_object_unref (event->comp);
+ if (event->allocated_comp_data) {
+ e_cal_model_free_component_data (event->comp_data);
+ event->allocated_comp_data = FALSE;
+ }
g_array_remove_index (week_view->events, event_num);
week_view->events_need_layout = TRUE;
@@ -2325,7 +2214,8 @@ e_week_view_free_events (EWeekView *week_view)
for (event_num = 0; event_num < week_view->events->len; event_num++) {
event = &g_array_index (week_view->events, EWeekViewEvent,
event_num);
- g_object_unref (event->comp);
+ if (event->allocated_comp_data)
+ e_cal_model_free_component_data (event->comp_data);
}
g_array_set_size (week_view->events, 0);
@@ -2366,32 +2256,41 @@ e_week_view_add_event (CalComponent *comp,
gpointer data)
{
- EWeekView *week_view;
+ AddEventData *add_event_data;
EWeekViewEvent event;
gint num_days;
struct icaltimetype start_tt, end_tt;
- week_view = E_WEEK_VIEW (data);
+ add_event_data = data;
/* Check that the event times are valid. */
- num_days = week_view->multi_week_view ? week_view->weeks_shown * 7 : 7;
+ num_days = add_event_data->week_view->multi_week_view ? add_event_data->week_view->weeks_shown * 7 : 7;
#if 0
g_print ("View start:%li end:%li Event start:%li end:%li\n",
- week_view->day_starts[0], week_view->day_starts[num_days],
+ add_event_data->week_view->day_starts[0], add_event_data->week_view->day_starts[num_days],
start, end);
#endif
g_return_val_if_fail (start <= end, TRUE);
- g_return_val_if_fail (start < week_view->day_starts[num_days], TRUE);
- g_return_val_if_fail (end > week_view->day_starts[0], TRUE);
+ g_return_val_if_fail (start < add_event_data->week_view->day_starts[num_days], TRUE);
+ g_return_val_if_fail (end > add_event_data->week_view->day_starts[0], TRUE);
start_tt = icaltime_from_timet_with_zone (start, FALSE,
- e_cal_view_get_timezone (E_CAL_VIEW (week_view)));
+ e_cal_view_get_timezone (E_CAL_VIEW (add_event_data->week_view)));
end_tt = icaltime_from_timet_with_zone (end, FALSE,
- e_cal_view_get_timezone (E_CAL_VIEW (week_view)));
+ e_cal_view_get_timezone (E_CAL_VIEW (add_event_data->week_view)));
- event.comp = comp;
- g_object_ref (event.comp);
+ if (add_event_data->comp_data) {
+ event.comp_data = add_event_data->comp_data;
+ event.allocated_comp_data = FALSE;
+ } else {
+ event.comp_data = g_new0 (ECalModelComponent, 1);
+ event.allocated_comp_data = TRUE;
+
+ event.comp_data->client = e_cal_model_get_default_client (e_cal_view_get_model (E_CAL_VIEW (add_event_data->week_view)));
+ cal_component_commit_sequence (comp);
+ event.comp_data->icalcomp = icalcomponent_new_clone (cal_component_get_icalcomponent (comp));
+ }
event.start = start;
event.end = end;
event.spans_index = 0;
@@ -2403,13 +2302,15 @@ e_week_view_add_event (CalComponent *comp,
event.end_minute = 24 * 60;
event.different_timezone = FALSE;
- if (!cal_comp_util_compare_event_timezones (comp, e_cal_view_get_cal_client (E_CAL_VIEW (week_view)),
- e_cal_view_get_timezone (E_CAL_VIEW (week_view))))
+ if (!cal_comp_util_compare_event_timezones (
+ comp,
+ event.comp_data->client,
+ e_cal_view_get_timezone (E_CAL_VIEW (add_event_data->week_view))))
event.different_timezone = TRUE;
- g_array_append_val (week_view->events, event);
- week_view->events_sorted = FALSE;
- week_view->events_need_layout = TRUE;
+ g_array_append_val (add_event_data->week_view->events, event);
+ add_event_data->week_view->events_sorted = FALSE;
+ add_event_data->week_view->events_need_layout = TRUE;
return TRUE;
}
@@ -2555,7 +2456,8 @@ e_week_view_reshape_event_span (EWeekView *week_view,
event = &g_array_index (week_view->events, EWeekViewEvent, event_num);
span = &g_array_index (week_view->spans, EWeekViewEventSpan,
event->spans_index + span_num);
- comp = event->comp;
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
one_day_event = e_week_view_is_one_day_event (week_view, event_num);
@@ -2569,6 +2471,8 @@ e_week_view_reshape_event_span (EWeekView *week_view,
gtk_object_destroy (GTK_OBJECT (span->text_item));
span->background_item = NULL;
span->text_item = NULL;
+
+ g_object_unref (comp);
return;
}
@@ -2643,6 +2547,7 @@ e_week_view_reshape_event_span (EWeekView *week_view,
"fill_color_rgba", GNOME_CANVAS_COLOR(0, 0, 0),
"im_context", E_CANVAS (week_view->main_canvas)->im_context,
NULL);
+
g_signal_connect (span->text_item, "event",
G_CALLBACK (e_week_view_on_text_item_event),
week_view);
@@ -2786,6 +2691,7 @@ e_week_view_reshape_event_span (EWeekView *week_view,
NULL);
e_canvas_item_move_absolute (span->text_item, text_x, text_y);
+ g_object_unref (comp);
g_object_unref (layout);
pango_font_metrics_unref (font_metrics);
}
@@ -2829,7 +2735,7 @@ e_week_view_on_adjustment_changed (GtkAdjustment *adjustment,
lower = icaltime_as_timet_with_zone (start_tt, e_cal_view_get_timezone (E_CAL_VIEW (week_view)));
e_week_view_recalc_day_starts (week_view, lower);
- e_week_view_update_query (week_view);
+ e_week_view_update_query ((ECalView *) week_view);
/* Update the selection, if needed. */
if (week_view->selection_start_day != -1) {
@@ -2913,7 +2819,7 @@ cancel_editing (EWeekView *week_view)
int event_num, span_num;
EWeekViewEvent *event;
EWeekViewEventSpan *span;
- CalComponentText summary;
+ const gchar *summary;
event_num = week_view->editing_event_num;
span_num = week_view->editing_span_num;
@@ -2925,26 +2831,13 @@ cancel_editing (EWeekView *week_view)
/* Reset the text to what was in the component */
- cal_component_get_summary (event->comp, &summary);
- g_object_set (G_OBJECT (span->text_item), "text", summary.value ? summary.value : "", NULL);
+ summary = icalcomponent_get_summary (event->comp_data->icalcomp);
+ g_object_set (G_OBJECT (span->text_item), "text", summary ? summary : "", NULL);
/* Stop editing */
e_week_view_stop_editing_event (week_view);
}
-/* Callback used when a component is destroyed. Expects the closure data to be
- * a pointer to a boolean; will set it to TRUE.
- */
-static void
-comp_destroy_cb (gpointer data, GObject *deadbeef)
-{
- gboolean *destroyed;
-
- destroyed = data;
- *destroyed = TRUE;
-}
-
-
static gboolean
e_week_view_on_text_item_event (GnomeCanvasItem *item,
GdkEvent *gdkevent,
@@ -2989,7 +2882,7 @@ e_week_view_on_text_item_event (GnomeCanvasItem *item,
event_num);
if (calendar)
- gnome_calendar_edit_object (calendar, event->comp, FALSE);
+ gnome_calendar_edit_object (calendar, event->comp_data->client, event->comp_data->icalcomp, FALSE);
else
g_warning ("Calendar not set");
@@ -3002,25 +2895,17 @@ e_week_view_on_text_item_event (GnomeCanvasItem *item,
if (gdkevent->button.button == 3 && !E_TEXT (item)->editing) {
EWeekViewEvent *e;
- gboolean destroyed;
e = &g_array_index (week_view->events, EWeekViewEvent, event_num);
- destroyed = FALSE;
- g_object_weak_ref ((GObject *) e->comp, comp_destroy_cb, &destroyed);
-
if (!GTK_WIDGET_HAS_FOCUS (week_view))
gtk_widget_grab_focus (GTK_WIDGET (week_view));
- if (!destroyed) {
- g_object_weak_unref ((GObject *) e->comp, comp_destroy_cb, &destroyed);
-
- e_week_view_set_selected_time_range_visible (week_view, e->start, e->end);
+ e_week_view_set_selected_time_range_visible (week_view, e->start, e->end);
- e_week_view_show_popup_menu (week_view,
- (GdkEventButton*) gdkevent,
- event_num);
- }
+ e_week_view_show_popup_menu (week_view,
+ (GdkEventButton*) gdkevent,
+ event_num);
gtk_signal_emit_stop_by_name (GTK_OBJECT (item->canvas),
"button_press_event");
@@ -3130,6 +3015,7 @@ e_week_view_on_editing_stopped (EWeekView *week_view,
EWeekViewEvent *event;
EWeekViewEventSpan *span;
gchar *text = NULL;
+ CalComponent *comp;
CalComponentText summary;
const char *uid;
@@ -3151,7 +3037,7 @@ e_week_view_on_editing_stopped (EWeekView *week_view,
week_view->editing_event_num = -1;
/* Check that the event is still valid. */
- cal_component_get_uid (event->comp, &uid);
+ uid = icalcomponent_get_uid (event->comp_data->icalcomp);
if (!uid)
return;
@@ -3159,12 +3045,14 @@ e_week_view_on_editing_stopped (EWeekView *week_view,
g_object_get (G_OBJECT (span->text_item), "text", &text, NULL);
g_assert (text != NULL);
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
+
if (string_is_empty (text) &&
- !cal_comp_is_on_server (event->comp,
- e_cal_view_get_cal_client (E_CAL_VIEW (week_view)))) {
+ !cal_comp_is_on_server (comp, event->comp_data->client)) {
const char *uid;
- cal_component_get_uid (event->comp, &uid);
+ cal_component_get_uid (comp, &uid);
e_week_view_foreach_event_with_uid (week_view, uid,
e_week_view_remove_event_cb, NULL);
@@ -3174,39 +3062,37 @@ e_week_view_on_editing_stopped (EWeekView *week_view,
}
/* Only update the summary if necessary. */
- cal_component_get_summary (event->comp, &summary);
+ cal_component_get_summary (comp, &summary);
if (summary.value && !strcmp (text, summary.value)) {
if (!e_week_view_is_one_day_event (week_view, event_num))
e_week_view_reshape_event_span (week_view, event_num,
span_num);
} else if (summary.value || !string_is_empty (text)) {
- CalClient *client;
summary.value = text;
summary.altrep = NULL;
- cal_component_set_summary (event->comp, &summary);
+ cal_component_set_summary (comp, &summary);
- client = e_cal_view_get_cal_client (E_CAL_VIEW (week_view));
- if (cal_component_is_instance (event->comp)) {
+ if (cal_component_is_instance (comp)) {
CalObjModType mod;
- if (recur_component_dialog (event->comp, &mod, NULL)) {
- if (cal_client_update_object_with_mod (client, event->comp, mod)
+ if (recur_component_dialog (comp, &mod, NULL)) {
+ if (cal_client_update_object_with_mod (event->comp_data->client, comp, mod)
== CAL_CLIENT_RESULT_SUCCESS) {
- if (itip_organizer_is_user (event->comp, client)
- && send_component_dialog (gtk_widget_get_toplevel (week_view),
- client, event->comp, FALSE))
- itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, event->comp,
- client, NULL);
+ if (itip_organizer_is_user (comp, event->comp_data->client)
+ && send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (week_view)),
+ event->comp_data->client, comp, FALSE))
+ itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp,
+ event->comp_data->client, NULL);
} else {
g_message ("e_week_view_on_editing_stopped(): Could not update the object!");
}
}
- } else if (cal_client_update_object (client, event->comp) == CAL_CLIENT_RESULT_SUCCESS) {
- if (itip_organizer_is_user (event->comp, client) &&
- send_component_dialog (gtk_widget_get_toplevel (week_view),
- client, event->comp, FALSE))
- itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, event->comp,
- client, NULL);
+ } else if (cal_client_update_object (event->comp_data->client, comp) == CAL_CLIENT_RESULT_SUCCESS) {
+ if (itip_organizer_is_user (comp, event->comp_data->client) &&
+ send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (week_view)),
+ event->comp_data->client, comp, FALSE))
+ itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp,
+ event->comp_data->client, NULL);
} else {
g_message ("e_week_view_on_editing_stopped(): Could not update the object!");
}
@@ -3215,6 +3101,7 @@ e_week_view_on_editing_stopped (EWeekView *week_view,
out:
g_free (text);
+ g_object_unref (comp);
g_signal_emit_by_name (week_view, "selection_changed");
}
@@ -3271,7 +3158,7 @@ e_week_view_find_event_from_uid (EWeekView *week_view,
event = &g_array_index (week_view->events, EWeekViewEvent,
event_num);
- cal_component_get_uid (event->comp, &u);
+ u = icalcomponent_get_uid (event->comp_data->icalcomp);
if (u && !strcmp (uid, u)) {
*event_num_return = event_num;
return TRUE;
@@ -3313,12 +3200,14 @@ e_week_view_do_key_press (GtkWidget *widget, GdkEventKey *event)
{
EWeekView *week_view;
CalComponent *comp;
+ icalcomponent *icalcomp;
gint event_num;
gchar *initial_text;
CalComponentDateTime date;
struct icaltimetype itt;
time_t dtstart, dtend;
const char *uid;
+ AddEventData add_event_data;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (E_IS_WEEK_VIEW (widget), FALSE);
@@ -3326,10 +3215,6 @@ e_week_view_do_key_press (GtkWidget *widget, GdkEventKey *event)
week_view = E_WEEK_VIEW (widget);
- if (cal_client_get_load_state (e_cal_view_get_cal_client (E_CAL_VIEW (week_view)))
- != CAL_CLIENT_LOAD_LOADED)
- return TRUE;
-
/* The Escape key aborts a resize operation. */
#if 0
if (week_view->resize_drag_pos != E_CAL_VIEW_POS_NONE) {
@@ -3374,7 +3259,11 @@ e_week_view_do_key_press (GtkWidget *widget, GdkEventKey *event)
initial_text = e_utf8_from_gtk_event_key (widget, event->keyval, event->string);
/* Add a new event covering the selected range. */
- comp = cal_comp_event_new_with_defaults (e_cal_view_get_cal_client (E_CAL_VIEW (week_view)));
+ icalcomp = e_cal_model_create_component_with_defaults (e_cal_view_get_model (E_CAL_VIEW (week_view)));
+ uid = icalcomponent_get_uid (icalcomp);
+
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomp);
dtstart = week_view->day_starts[week_view->selection_start_day];
dtend = week_view->day_starts[week_view->selection_end_day + 1];
@@ -3397,11 +3286,12 @@ e_week_view_do_key_press (GtkWidget *widget, GdkEventKey *event)
/* We add the event locally and start editing it. We don't send it
to the server until the user finishes editing it. */
- e_week_view_add_event (comp, dtstart, dtend, week_view);
+ add_event_data.week_view = week_view;
+ add_event_data.comp_data = NULL;
+ e_week_view_add_event (comp, dtstart, dtend, &add_event_data);
e_week_view_check_layout (week_view);
gtk_widget_queue_draw (week_view->main_canvas);
- cal_component_get_uid (comp, &uid);
if (e_week_view_find_event_from_uid (week_view, uid, &event_num)) {
e_week_view_start_editing_event (week_view, event_num, 0,
initial_text);
@@ -3607,7 +3497,6 @@ e_week_view_show_popup_menu (EWeekView *week_view,
GdkEventButton *bevent,
gint event_num)
{
- EWeekViewEvent *event;
GtkMenu *popup;
week_view->popup_event_num = event_num;
@@ -3641,13 +3530,15 @@ e_week_view_unrecur_appointment (EWeekView *week_view)
/* For the recurring object, we add a exception to get rid of the
instance. */
- comp = cal_component_clone (event->comp);
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
cal_comp_util_add_exdate (comp, event->start, e_cal_view_get_timezone (E_CAL_VIEW (week_view)));
/* For the unrecurred instance we duplicate the original object,
create a new uid for it, get rid of the recurrence rules, and set
the start & end times to the instances times. */
- new_comp = cal_component_clone (event->comp);
+ new_comp = cal_component_new ();
+ cal_component_set_icalcomponent (new_comp, icalcomponent_new_clone (event->comp_data->icalcomp));
cal_component_set_uid (new_comp, cal_component_gen_uid ());
cal_component_set_rdate_list (new_comp, NULL);
cal_component_set_rrule_list (new_comp, NULL);
@@ -3667,13 +3558,13 @@ e_week_view_unrecur_appointment (EWeekView *week_view)
/* Now update both CalComponents. Note that we do this last since at
present the updates happen synchronously so our event may disappear.
*/
- if (cal_client_update_object (e_cal_view_get_cal_client (E_CAL_VIEW (week_view)), comp)
+ if (cal_client_update_object (event->comp_data->client, comp)
!= CAL_CLIENT_RESULT_SUCCESS)
g_message ("e_week_view_on_unrecur_appointment(): Could not update the object!");
g_object_unref (comp);
- if (cal_client_update_object (e_cal_view_get_cal_client (E_CAL_VIEW (week_view)), new_comp)
+ if (cal_client_update_object (event->comp_data->client, new_comp)
!= CAL_CLIENT_RESULT_SUCCESS)
g_message ("e_week_view_on_unrecur_appointment(): Could not update the object!");
diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h
index db821a2639..09a4fa881f 100644
--- a/calendar/gui/e-week-view.h
+++ b/calendar/gui/e-week-view.h
@@ -395,6 +395,8 @@ void e_week_view_set_24_hour_format (EWeekView *week_view,
void e_week_view_delete_occurrence (EWeekView *week_view);
+void e_week_view_unrecur_appointment (EWeekView *week_view);
+
/* Returns the number of selected events (0 or 1 at present). */
gint e_week_view_get_num_events_selected (EWeekView *week_view);
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index a67f20e9a7..ca93085e96 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -44,6 +44,7 @@
#include "dialogs/event-editor.h"
#include "dialogs/task-editor.h"
#include "comp-util.h"
+#include "e-cal-model-calendar.h"
#include "e-day-view.h"
#include "e-day-view-time-item.h"
#include "e-week-view.h"
@@ -69,9 +70,6 @@ struct _GnomeCalendarPrivate {
* The Calendar Folder.
*/
- /* The calendar client object we monitor */
- CalClient *client;
-
/* Set of categories from the calendar client */
GPtrArray *cal_categories;
@@ -112,7 +110,7 @@ struct _GnomeCalendarPrivate {
GtkWidget *month_view;
/* Calendar query for the date navigator */
- CalQuery *dn_query;
+ GList *dn_queries; /* list of CalQueries */
char *sexp;
guint query_timeout;
@@ -147,7 +145,7 @@ struct _GnomeCalendarPrivate {
time_t visible_end;
/* Calendar query for purging old events */
- CalQuery *exp_query;
+ GList *exp_queries;
time_t exp_older_than;
};
@@ -384,7 +382,7 @@ dn_query_obj_updated_cb (CalQuery *query, const char *uid,
return;
}
- status = cal_client_get_object (priv->client, uid, &icalcomp);
+ status = cal_client_get_object (cal_query_get_client (query), uid, &icalcomp);
switch (status) {
case CAL_CLIENT_GET_SUCCESS:
@@ -409,7 +407,7 @@ dn_query_obj_updated_cb (CalQuery *query, const char *uid,
return;
}
- tag_calendar_by_comp (priv->date_navigator, comp, priv->client, NULL,
+ tag_calendar_by_comp (priv->date_navigator, comp, cal_query_get_client (query), NULL,
FALSE, TRUE);
g_object_unref (comp);
}
@@ -604,46 +602,61 @@ update_query (GnomeCalendar *gcal)
GnomeCalendarPrivate *priv;
CalQuery *old_query;
char *real_sexp;
+ GList *l, *client_list;
priv = gcal->priv;
e_calendar_item_clear_marks (priv->date_navigator->calitem);
- if (!(priv->client
- && cal_client_get_load_state (priv->client) == CAL_CLIENT_LOAD_LOADED))
- return;
+ e_cal_view_set_status_message (E_CAL_VIEW (priv->week_view), _("Searching"));
- old_query = priv->dn_query;
- priv->dn_query = NULL;
+ /* free the previous queries */
+ for (l = priv->dn_queries; l != NULL; l = l->next) {
+ old_query = l->data;
- if (old_query) {
- g_signal_handlers_disconnect_matched (old_query, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, gcal);
- g_object_unref (old_query);
+ if (old_query) {
+ g_signal_handlers_disconnect_matched (old_query, G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, gcal);
+ g_object_unref (old_query);
+ }
}
+ g_list_free (priv->dn_queries);
+ priv->dn_queries = NULL;
+
g_assert (priv->sexp != NULL);
real_sexp = adjust_query_sexp (gcal, priv->sexp);
- if (!real_sexp)
+ if (!real_sexp) {
+ e_cal_view_set_status_message (E_CAL_VIEW (priv->week_view), NULL);
return; /* No time range is set, so don't start a query */
+ }
- priv->dn_query = cal_client_get_query (priv->client, real_sexp);
- g_free (real_sexp);
+ /* create queries for each loaded client */
+ client_list = e_cal_model_get_client_list (e_cal_view_get_model (E_CAL_VIEW (priv->day_view)));
+ for (l = client_list; l != NULL; l = l->next) {
+ old_query = cal_client_get_query ((CalClient *) l->data, real_sexp);
+ if (!old_query) {
+ g_message ("update_query(): Could not create the query");
+ continue;
+ }
- if (!priv->dn_query) {
- g_message ("update_query(): Could not create the query");
- return;
+ g_signal_connect (old_query, "obj_updated",
+ G_CALLBACK (dn_query_obj_updated_cb), gcal);
+ g_signal_connect (old_query, "obj_removed",
+ G_CALLBACK (dn_query_obj_removed_cb), gcal);
+ g_signal_connect (old_query, "query_done",
+ G_CALLBACK (dn_query_query_done_cb), gcal);
+ g_signal_connect (old_query, "eval_error",
+ G_CALLBACK (dn_query_eval_error_cb), gcal);
+
+ priv->dn_queries = g_list_append (priv->dn_queries, old_query);
}
- g_signal_connect (priv->dn_query, "obj_updated",
- G_CALLBACK (dn_query_obj_updated_cb), gcal);
- g_signal_connect (priv->dn_query, "obj_removed",
- G_CALLBACK (dn_query_obj_removed_cb), gcal);
- g_signal_connect (priv->dn_query, "query_done",
- G_CALLBACK (dn_query_query_done_cb), gcal);
- g_signal_connect (priv->dn_query, "eval_error",
- G_CALLBACK (dn_query_eval_error_cb), gcal);
+ g_list_free (client_list);
+ g_free (real_sexp);
+
+ e_cal_view_set_status_message (E_CAL_VIEW (priv->week_view), NULL);
}
/**
@@ -675,10 +688,10 @@ gnome_calendar_set_query (GnomeCalendar *gcal, const char *sexp)
update_query (gcal);
/* Set the query on the main view */
- e_cal_view_set_query (E_CAL_VIEW (gnome_calendar_get_current_view_widget (gcal)), sexp);
+ model = e_cal_view_get_model (E_CAL_VIEW (gnome_calendar_get_current_view_widget (gcal)));
+ e_cal_model_set_query (model, sexp);
/* Set the query on the task pad */
-
model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo));
e_cal_model_set_query (model, sexp);
}
@@ -817,6 +830,7 @@ setup_widgets (GnomeCalendar *gcal)
GtkWidget *w;
gchar *filename;
ETable *etable;
+ ECalModel *model;
priv = gcal->priv;
@@ -939,6 +953,14 @@ setup_widgets (GnomeCalendar *gcal)
connect_week_view_focus (gcal, E_WEEK_VIEW (priv->month_view));
+ model = (ECalModel *) e_cal_model_calendar_new ();
+ e_cal_view_set_model (E_CAL_VIEW (priv->day_view), model);
+ e_cal_view_set_model (E_CAL_VIEW (priv->work_week_view), model);
+ e_cal_view_set_model (E_CAL_VIEW (priv->week_view), model);
+ e_cal_view_set_model (E_CAL_VIEW (priv->month_view), model);
+
+ g_object_unref (model);
+
gnome_calendar_update_config_settings (gcal, TRUE);
}
@@ -958,7 +980,7 @@ gnome_calendar_init (GnomeCalendar *gcal)
priv->range_selected = FALSE;
setup_widgets (gcal);
- priv->dn_query = NULL;
+ priv->dn_queries = NULL;
priv->sexp = g_strdup ("#t"); /* Match all */
priv->selection_start_time = time_day_begin_with_zone (time (NULL),
@@ -971,7 +993,7 @@ gnome_calendar_init (GnomeCalendar *gcal)
priv->visible_start = -1;
priv->visible_end = -1;
- priv->exp_query = NULL;
+ priv->exp_queries = NULL;
}
/* Frees a set of categories */
@@ -1003,22 +1025,37 @@ gnome_calendar_destroy (GtkObject *object)
priv = gcal->priv;
if (priv) {
+ GList *l, *client_list;
+
free_categories (priv->cal_categories);
priv->cal_categories = NULL;
free_categories (priv->tasks_categories);
priv->tasks_categories = NULL;
+ /* disconnect from signals on all the clients */
+ client_list = e_cal_model_get_client_list (e_cal_view_get_model (E_CAL_VIEW (priv->week_view)));
+ for (l = client_list; l != NULL; l = l->next) {
+ g_signal_handlers_disconnect_matched ((CalClient *) l->data, G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, gcal);
+ }
+
+ g_list_free (client_list);
+
/* Save the TaskPad layout. */
filename = g_strdup_printf ("%s/config/TaskPad", evolution_dir);
e_calendar_table_save_state (E_CALENDAR_TABLE (priv->todo), filename);
g_free (filename);
- if (priv->dn_query) {
- g_signal_handlers_disconnect_matched (priv->dn_query, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, gcal);
- g_object_unref (priv->dn_query);
- priv->dn_query = NULL;
+ if (priv->dn_queries) {
+ for (l = priv->dn_queries; l != NULL; l = l->next) {
+ g_signal_handlers_disconnect_matched ((CalQuery *) l->data, G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, gcal);
+ g_object_unref ((CalQuery *) l->data);
+ }
+
+ g_list_free (priv->dn_queries);
+ priv->dn_queries = NULL;
}
if (priv->sexp) {
@@ -1030,13 +1067,6 @@ gnome_calendar_destroy (GtkObject *object)
g_source_remove (priv->query_timeout);
priv->query_timeout = 0;
}
-
- if (priv->client) {
- g_signal_handlers_disconnect_matched (priv->client, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, gcal);
- g_object_unref (priv->client);
- priv->client = NULL;
- }
if (priv->task_pad_client) {
g_signal_handlers_disconnect_matched (priv->task_pad_client, G_SIGNAL_MATCH_DATA,
@@ -1055,11 +1085,17 @@ gnome_calendar_destroy (GtkObject *object)
priv->view_menus = NULL;
}
- if (priv->exp_query) {
- g_signal_handlers_disconnect_matched (priv->exp_query, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, gcal);
- g_object_unref (priv->exp_query);
- priv->exp_query = NULL;
+ if (priv->exp_queries) {
+ GList *l;
+
+ for (l = priv->exp_queries; l != NULL; l = l->next) {
+ g_signal_handlers_disconnect_matched ((CalQuery *) l->data, G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, gcal);
+ g_object_unref (l->data);
+ }
+
+ g_list_free (priv->exp_queries);
+ priv->exp_queries = NULL;
}
g_free (priv);
@@ -1519,7 +1555,8 @@ gnome_calendar_setup_view_menus (GnomeCalendar *gcal, BonoboUIComponent *uic)
gal_view_collection_load (collection);
}
- priv->view_instance = gal_view_instance_new (collection, cal_client_get_uri (priv->client));
+ priv->view_instance = gal_view_instance_new (collection,
+ cal_client_get_uri (gnome_calendar_get_default_client (gcal)));
priv->view_menus = gal_view_menus_new (priv->view_instance);
gal_view_menus_set_show_define_views (priv->view_menus, FALSE);
@@ -1679,11 +1716,6 @@ client_cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer da
switch (status) {
case CAL_CLIENT_OPEN_SUCCESS:
- /* If this is the main CalClient, update the Date Navigator. */
- if (client == priv->client) {
- priv->query_timeout = g_timeout_add (100, update_query_timeout, gcal);
- }
-
/* Set the client's default timezone, if we have one. */
if (priv->zone) {
cal_client_set_default_timezone (client, priv->zone);
@@ -1693,11 +1725,16 @@ client_cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer da
uristr = get_uri_without_password (cal_client_get_uri (client));
msg = g_strdup_printf (_("Adding alarms for %s"), uristr);
g_free (uristr);
- if (client == priv->client) {
- e_cal_view_set_status_message (E_CAL_VIEW (priv->week_view), msg);
- }
- else if (client == priv->task_pad_client) {
+ if (client == priv->task_pad_client) {
e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo), msg);
+ e_cal_model_add_client (e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo)),
+ priv->task_pad_client);
+ }
+ else {
+ e_cal_view_set_status_message (E_CAL_VIEW (priv->week_view), msg);
+ e_cal_model_add_client (e_cal_view_get_model (E_CAL_VIEW (priv->week_view)), client);
+
+ priv->query_timeout = g_timeout_add (100, update_query_timeout, gcal);
}
g_free (msg);
@@ -1726,12 +1763,10 @@ client_cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer da
return;
}
- if (client == priv->client) {
- e_cal_view_set_status_message (E_CAL_VIEW (priv->week_view), NULL);
- }
- else if (client == priv->task_pad_client) {
+ if (client == priv->task_pad_client)
e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo), NULL);
- }
+ else
+ e_cal_view_set_status_message (E_CAL_VIEW (priv->week_view), NULL);
}
/* Duplicates an array of categories */
@@ -1834,14 +1869,13 @@ client_categories_changed_cb (CalClient *client, GPtrArray *categories, gpointer
gcal = GNOME_CALENDAR (data);
priv = gcal->priv;
- if (client == priv->client) {
- free_categories (priv->cal_categories);
- priv->cal_categories = copy_categories (categories);
- } else if (client == priv->task_pad_client) {
+ if (client == priv->task_pad_client) {
free_categories (priv->tasks_categories);
priv->tasks_categories = copy_categories (categories);
- } else
- g_assert_not_reached ();
+ } else {
+ free_categories (priv->cal_categories);
+ priv->cal_categories = copy_categories (categories);
+ }
merged = merge_categories (priv->cal_categories, priv->tasks_categories);
cal_search_bar_set_categories (CAL_SEARCH_BAR (priv->search_bar), merged);
@@ -1879,8 +1913,14 @@ backend_died_cb (CalClient *client, gpointer data)
gcal = GNOME_CALENDAR (data);
priv = gcal->priv;
- uristr = get_uri_without_password (cal_client_get_uri (priv->client));
- if (client == priv->client) {
+ uristr = get_uri_without_password (cal_client_get_uri (client));
+ if (client == priv->task_pad_client) {
+ message = g_strdup_printf (_("The task backend for\n%s\n has crashed. "
+ "You will have to restart Evolution in order "
+ "to use it again"),
+ uristr);
+ e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo), NULL);
+ } else {
message = g_strdup_printf (_("The calendar backend for\n%s\n has crashed. "
"You will have to restart Evolution in order "
"to use it again"),
@@ -1889,15 +1929,6 @@ backend_died_cb (CalClient *client, gpointer data)
e_cal_view_set_status_message (E_CAL_VIEW (priv->work_week_view), NULL);
e_cal_view_set_status_message (E_CAL_VIEW (priv->week_view), NULL);
e_cal_view_set_status_message (E_CAL_VIEW (priv->month_view), NULL);
- } else if (client == priv->task_pad_client) {
- message = g_strdup_printf (_("The task backend for\n%s\n has crashed. "
- "You will have to restart Evolution in order "
- "to use it again"),
- uristr);
- e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo), NULL);
- } else {
- message = NULL;
- g_assert_not_reached ();
}
gnome_error_dialog_parented (message, GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gcal))));
@@ -1910,7 +1941,6 @@ gnome_calendar_construct (GnomeCalendar *gcal)
{
GnomeCalendarPrivate *priv;
GnomeCalendarViewType view_type;
- ECalModel *model;
g_return_val_if_fail (gcal != NULL, NULL);
g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL);
@@ -1918,27 +1948,6 @@ gnome_calendar_construct (GnomeCalendar *gcal)
priv = gcal->priv;
/*
- * Calendar Folder Client.
- */
- priv->client = cal_client_new ();
- if (!priv->client)
- return NULL;
-
- g_signal_connect (priv->client, "cal_opened",
- G_CALLBACK (client_cal_opened_cb), gcal);
- g_signal_connect (priv->client, "backend_error",
- G_CALLBACK (backend_error_cb), gcal);
- g_signal_connect (priv->client, "categories_changed",
- G_CALLBACK (client_categories_changed_cb), gcal);
- g_signal_connect (priv->client, "backend_died",
- G_CALLBACK (backend_died_cb), gcal);
-
- e_cal_view_set_cal_client (E_CAL_VIEW (priv->day_view), priv->client);
- e_cal_view_set_cal_client (E_CAL_VIEW (priv->work_week_view), priv->client);
- e_cal_view_set_cal_client (E_CAL_VIEW (priv->week_view), priv->client);
- e_cal_view_set_cal_client (E_CAL_VIEW (priv->month_view), priv->client);
-
- /*
* TaskPad Folder Client.
*/
priv->task_pad_client = cal_client_new ();
@@ -1954,11 +1963,6 @@ gnome_calendar_construct (GnomeCalendar *gcal)
g_signal_connect (priv->task_pad_client, "backend_died",
G_CALLBACK (backend_died_cb), gcal);
- model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo));
- g_assert (model != NULL);
-
- e_cal_model_add_client (model, priv->task_pad_client);
-
/* Get the default view to show. */
view_type = calendar_config_get_default_view ();
if (view_type < GNOME_CAL_DAY_VIEW || view_type > GNOME_CAL_MONTH_VIEW)
@@ -1996,15 +2000,15 @@ gnome_calendar_set_ui_component (GnomeCalendar *gcal,
}
/**
- * gnome_calendar_get_cal_client:
+ * gnome_calendar_get_calendar_model:
* @gcal: A calendar view.
*
- * Queries the calendar client interface object that a calendar view is using.
+ * Queries the calendar model object that a calendar view is using.
*
* Return value: A calendar client interface object.
**/
-CalClient *
-gnome_calendar_get_cal_client (GnomeCalendar *gcal)
+ECalModel *
+gnome_calendar_get_calendar_model (GnomeCalendar *gcal)
{
GnomeCalendarPrivate *priv;
@@ -2013,7 +2017,18 @@ gnome_calendar_get_cal_client (GnomeCalendar *gcal)
priv = gcal->priv;
- return priv->client;
+ return e_cal_view_get_model (E_CAL_VIEW (priv->week_view));
+}
+
+/**
+ * gnome_calendar_get_default_client
+ */
+CalClient *
+gnome_calendar_get_default_client (GnomeCalendar *gcal)
+{
+ g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL);
+
+ return e_cal_model_get_default_client (e_cal_view_get_model (E_CAL_VIEW (gcal->priv->week_view)));
}
/**
@@ -2088,12 +2103,12 @@ gboolean
gnome_calendar_open (GnomeCalendar *gcal, const char *str_uri)
{
GnomeCalendarPrivate *priv;
- char *tasks_uri;
gboolean success;
EUri *uri;
char *message;
char *real_uri;
char *urinopwd;
+ CalClient *client;
g_return_val_if_fail (gcal != NULL, FALSE);
g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), FALSE);
@@ -2102,64 +2117,42 @@ gnome_calendar_open (GnomeCalendar *gcal, const char *str_uri)
priv = gcal->priv;
g_return_val_if_fail (
- cal_client_get_load_state (priv->client) == CAL_CLIENT_LOAD_NOT_LOADED,
- FALSE);
-
- g_return_val_if_fail (
cal_client_get_load_state (priv->task_pad_client) == CAL_CLIENT_LOAD_NOT_LOADED,
FALSE);
uri = e_uri_new (str_uri);
- if (!uri || !g_strncasecmp (uri->protocol, "file", 4))
- real_uri = g_concat_dir_and_file (str_uri, "calendar.ics");
- else
- real_uri = g_strdup (str_uri);
+ if (!uri || !g_strncasecmp (uri->protocol, "file", 4))
+ real_uri = g_concat_dir_and_file (str_uri, "calendar.ics");
+ else
+ real_uri = g_strdup (str_uri);
- urinopwd = get_uri_without_password (real_uri);
+ urinopwd = get_uri_without_password (str_uri);
message = g_strdup_printf (_("Opening calendar at %s"), urinopwd);
g_free (urinopwd);
e_cal_view_set_status_message (E_CAL_VIEW (priv->week_view), message);
g_free (message);
- if (!cal_client_open_calendar (priv->client, real_uri, FALSE)) {
- g_message ("gnome_calendar_open(): Could not issue the request to open the calendar folder");
- g_free (real_uri);
- e_uri_free (uri);
+ client = cal_client_new ();
+ g_signal_connect (G_OBJECT (client), "cal_opened", G_CALLBACK (client_cal_opened_cb), gcal);
+ g_signal_connect (G_OBJECT (client), "backend_error", G_CALLBACK (backend_error_cb), gcal);
+ g_signal_connect (G_OBJECT (client), "categories_changed", G_CALLBACK (client_categories_changed_cb), gcal);
+ g_signal_connect (G_OBJECT (client), "backend_died", G_CALLBACK (backend_died_cb), gcal);
+
+ if (!cal_client_open_calendar (client, real_uri, FALSE)) {
+ g_warning (G_STRLOC ": Could not issue the request to open the calendar folder");
+ g_object_unref (client);
e_cal_view_set_status_message (E_CAL_VIEW (priv->week_view), NULL);
return FALSE;
}
/* Open the appropriate Tasks folder to show in the TaskPad */
-
- if (!uri) {
- tasks_uri = g_strdup_printf ("%s/local/Tasks/tasks.ics", evolution_dir);
- message = g_strdup_printf (_("Opening tasks at %s"), tasks_uri);
- e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo), message);
- g_free (message);
-
- success = cal_client_open_calendar (priv->task_pad_client, tasks_uri, FALSE);
- g_free (tasks_uri);
- }
- else {
- if (!g_strncasecmp (uri->protocol, "file", 4)) {
- tasks_uri = g_strdup_printf ("%s/local/Tasks/tasks.ics", evolution_dir);
- message = g_strdup_printf (_("Opening tasks at %s"), tasks_uri);
- e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo), message);
- g_free (message);
-
- success = cal_client_open_calendar (priv->task_pad_client, tasks_uri, FALSE);
- g_free (tasks_uri);
- }
- else {
- e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo),
- _("Opening default tasks folder"));
- success = cal_client_open_default_tasks (priv->task_pad_client, FALSE);
- }
- }
+ e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo),
+ _("Opening default tasks folder"));
+ success = cal_client_open_default_tasks (priv->task_pad_client, FALSE);
g_free (real_uri);
- e_uri_free (uri);
+ e_uri_free (uri);
if (!success) {
g_message ("gnome_calendar_open(): Could not issue the request to open the tasks folder");
@@ -2184,6 +2177,7 @@ gnome_calendar_update_config_settings (GnomeCalendar *gcal,
gint start_hour, start_minute, end_hour, end_minute;
gboolean use_24_hour, show_event_end, compress_weekend;
char *location;
+ GList *client_list;
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
@@ -2260,10 +2254,20 @@ gnome_calendar_update_config_settings (GnomeCalendar *gcal,
location = calendar_config_get_timezone ();
priv->zone = icaltimezone_get_builtin_timezone (location);
- if (priv->client
- && cal_client_get_load_state (priv->client) == CAL_CLIENT_LOAD_LOADED) {
- cal_client_set_default_timezone (priv->client, priv->zone);
+ client_list = e_cal_model_get_client_list (e_cal_view_get_model (E_CAL_VIEW (priv->week_view)));
+ if (client_list) {
+ GList *l;
+
+ for (l = client_list; l != NULL; l = l->next) {
+ CalClient *client = l->data;
+
+ if (cal_client_get_load_state (client) == CAL_CLIENT_LOAD_LOADED)
+ cal_client_set_default_timezone (client, priv->zone);
+ }
+
+ g_list_free (client_list);
}
+
if (priv->task_pad_client
&& cal_client_get_load_state (priv->task_pad_client) == CAL_CLIENT_LOAD_LOADED) {
cal_client_set_default_timezone (priv->task_pad_client,
@@ -2333,37 +2337,42 @@ gnome_calendar_get_selected_time_range (GnomeCalendar *gcal,
}
void
-gnome_calendar_edit_object (GnomeCalendar *gcal, CalComponent *comp,
- gboolean meeting)
+gnome_calendar_edit_object (GnomeCalendar *gcal, CalClient *client, icalcomponent *icalcomp, gboolean meeting)
{
GnomeCalendarPrivate *priv;
CompEditor *ce;
const char *uid;
+ CalComponent *comp;
- g_return_if_fail (gcal != NULL);
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- g_return_if_fail (comp != NULL);
+ g_return_if_fail (IS_CAL_CLIENT (client));
+ g_return_if_fail (icalcomp != NULL);
priv = gcal->priv;
- cal_component_get_uid (comp, &uid);
+ uid = icalcomponent_get_uid (icalcomp);
ce = e_comp_editor_registry_find (comp_editor_registry, uid);
if (!ce) {
EventEditor *ee;
- ee = event_editor_new (priv->client);
+ ee = event_editor_new (client);
if (!ee) {
g_message ("gnome_calendar_edit_object(): Could not create the event editor");
return;
}
ce = COMP_EDITOR (ee);
-
+
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (icalcomp));
+
comp_editor_edit_comp (ce, comp);
if (meeting)
event_editor_show_meeting (ee);
e_comp_editor_registry_add (comp_editor_registry, ce, FALSE);
+
+ g_object_unref (comp);
}
comp_editor_focus (ce);
@@ -2390,6 +2399,7 @@ gnome_calendar_new_appointment_for (GnomeCalendar *cal,
struct icaltimetype itt;
CalComponentDateTime dt;
CalComponent *comp;
+ icalcomponent *icalcomp;
CalComponentTransparency transparency;
const char *category;
@@ -2404,7 +2414,9 @@ gnome_calendar_new_appointment_for (GnomeCalendar *cal,
else
dt.tzid = icaltimezone_get_tzid (priv->zone);
- comp = cal_comp_event_new_with_defaults (priv->client);
+ icalcomp = e_cal_model_create_component_with_defaults (e_cal_view_get_model (E_CAL_VIEW (priv->week_view)));
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomp);
/* DTSTART, DTEND */
@@ -2441,7 +2453,7 @@ gnome_calendar_new_appointment_for (GnomeCalendar *cal,
cal_component_commit_sequence (comp);
- gnome_calendar_edit_object (cal, comp, meeting);
+ gnome_calendar_edit_object (cal, gnome_calendar_get_default_client (cal), icalcomp, meeting);
g_object_unref (comp);
}
@@ -2477,6 +2489,7 @@ gnome_calendar_new_task (GnomeCalendar *gcal)
GnomeCalendarPrivate *priv;
TaskEditor *tedit;
CalComponent *comp;
+ icalcomponent *icalcomp;
const char *category;
g_return_if_fail (gcal != NULL);
@@ -2486,7 +2499,9 @@ gnome_calendar_new_task (GnomeCalendar *gcal)
tedit = task_editor_new (priv->task_pad_client);
- comp = cal_comp_task_new_with_defaults (priv->client);
+ icalcomp = e_cal_model_create_component_with_defaults (e_cal_view_get_model (E_CAL_VIEW (priv->week_view)));
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomp);
category = cal_search_bar_get_category (CAL_SEARCH_BAR (priv->search_bar));
cal_component_set_categories (comp, category);
@@ -3007,7 +3022,7 @@ purging_obj_updated_cb (CalQuery *query, const char *uid,
priv = gcal->priv;
- if (cal_client_get_object (priv->client, uid, &icalcomp) != CAL_CLIENT_GET_SUCCESS)
+ if (cal_client_get_object (cal_query_get_client (query), uid, &icalcomp) != CAL_CLIENT_GET_SUCCESS)
return;
comp = cal_component_new ();
@@ -3028,16 +3043,16 @@ purging_obj_updated_cb (CalQuery *query, const char *uid,
(CalRecurInstanceFn) check_instance_cb,
&closure,
(CalRecurResolveTimezoneFn) cal_client_resolve_tzid_cb,
- priv->client, priv->zone);
+ cal_query_get_client (query), priv->zone);
if (closure.remove) {
e_cal_view_set_status_message (E_CAL_VIEW (priv->week_view), msg);
- delete_error_dialog (cal_client_remove_object (priv->client, uid),
+ delete_error_dialog (cal_client_remove_object (cal_query_get_client (query), uid),
CAL_COMPONENT_EVENT);
}
} else {
e_cal_view_set_status_message (E_CAL_VIEW (priv->week_view), msg);
- delete_error_dialog (cal_client_remove_object (priv->client, uid), CAL_COMPONENT_EVENT);
+ delete_error_dialog (cal_client_remove_object (cal_query_get_client (query), uid), CAL_COMPONENT_EVENT);
}
g_object_unref (comp);
@@ -3054,10 +3069,11 @@ purging_eval_error_cb (CalQuery *query, const char *error_str, gpointer data)
e_cal_view_set_status_message (E_CAL_VIEW (priv->week_view), NULL);
- g_signal_handlers_disconnect_matched (priv->exp_query, G_SIGNAL_MATCH_DATA,
+ g_signal_handlers_disconnect_matched (query, G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, gcal);
- g_object_unref (priv->exp_query);
- priv->exp_query = NULL;
+
+ priv->exp_queries = g_list_remove (priv->exp_queries, query);
+ g_object_unref (query);
}
static void
@@ -3070,10 +3086,11 @@ purging_query_done_cb (CalQuery *query, CalQueryDoneStatus status, const char *e
e_cal_view_set_status_message (E_CAL_VIEW (priv->week_view), NULL);
- g_signal_handlers_disconnect_matched (priv->exp_query, G_SIGNAL_MATCH_DATA,
+ g_signal_handlers_disconnect_matched (query, G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, gcal);
- g_object_unref (priv->exp_query);
- priv->exp_query = NULL;
+
+ priv->exp_queries = g_list_remove (priv->exp_queries, query);
+ g_object_unref (query);
}
void
@@ -3081,13 +3098,14 @@ gnome_calendar_purge (GnomeCalendar *gcal, time_t older_than)
{
GnomeCalendarPrivate *priv;
char *sexp, *start, *end;
+ GList *client_list, *l;
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
priv = gcal->priv;
/* if we have a query, we are already purging */
- if (priv->exp_query)
+ if (priv->exp_queries)
return;
priv->exp_older_than = older_than;
@@ -3099,21 +3117,33 @@ gnome_calendar_purge (GnomeCalendar *gcal, time_t older_than)
start, end);
e_cal_view_set_status_message (E_CAL_VIEW (priv->week_view), _("Purging"));
- priv->exp_query = cal_client_get_query (priv->client, sexp);
+ client_list = e_cal_model_get_client_list (e_cal_view_get_model (E_CAL_VIEW (priv->week_view)));
+ for (l = client_list; l != NULL; l = l->next) {
+ CalQuery *exp_query;
+
+ if (cal_client_is_read_only ((CalClient *) l->data))
+ continue;
+
+ exp_query = cal_client_get_query ((CalClient *) l->data, sexp);
+ if (!exp_query) {
+ e_cal_view_set_status_message (E_CAL_VIEW (priv->week_view), NULL);
+ g_message ("gnome_calendar_purge(): Could not create the query");
+ continue;
+ }
+
+ g_signal_connect (exp_query, "obj_updated", G_CALLBACK (purging_obj_updated_cb), gcal);
+ g_signal_connect (exp_query, "query_done", G_CALLBACK (purging_query_done_cb), gcal);
+ g_signal_connect (exp_query, "eval_error", G_CALLBACK (purging_eval_error_cb), gcal);
+
+ priv->exp_queries = g_list_append (priv->exp_queries, exp_query);
+ }
+
+ g_list_free (client_list);
g_free (sexp);
g_free (start);
g_free (end);
- if (!priv->exp_query) {
- e_cal_view_set_status_message (E_CAL_VIEW (priv->week_view), NULL);
- g_message ("gnome_calendar_purge(): Could not create the query");
- return;
- }
-
- g_signal_connect (priv->exp_query, "obj_updated", G_CALLBACK (purging_obj_updated_cb), gcal);
- g_signal_connect (priv->exp_query, "query_done", G_CALLBACK (purging_query_done_cb), gcal);
- g_signal_connect (priv->exp_query, "eval_error", G_CALLBACK (purging_eval_error_cb), gcal);
}
ECalendarTable*
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
index f3f9d3dc06..ff5b1a6bd0 100644
--- a/calendar/gui/gnome-cal.h
+++ b/calendar/gui/gnome-cal.h
@@ -101,7 +101,10 @@ GtkWidget *gnome_calendar_new (void);
void gnome_calendar_set_ui_component (GnomeCalendar *cal,
BonoboUIComponent *ui_component);
-CalClient *gnome_calendar_get_cal_client (GnomeCalendar *gcal);
+ECalendarTable *gnome_calendar_get_task_pad (GnomeCalendar *gcal);
+
+ECalModel *gnome_calendar_get_calendar_model (GnomeCalendar *gcal);
+CalClient *gnome_calendar_get_default_client (GnomeCalendar *gcal);
CalClient *gnome_calendar_get_task_pad_cal_client(GnomeCalendar *gcal);
gboolean gnome_calendar_open (GnomeCalendar *gcal, const char *str_uri);
@@ -142,8 +145,9 @@ void gnome_calendar_get_selected_time_range (GnomeCalendar *gcal,
time_t *end_time);
void gnome_calendar_edit_object (GnomeCalendar *gcal,
- CalComponent *comp,
- gboolean meeting);
+ CalClient *client,
+ icalcomponent *icalcomp,
+ gboolean meeting);
void gnome_calendar_new_appointment (GnomeCalendar *gcal);
void gnome_calendar_new_appointment_for (GnomeCalendar *cal,
diff --git a/calendar/gui/goto.c b/calendar/gui/goto.c
index 2ce74507d5..770e2e40ac 100644
--- a/calendar/gui/goto.c
+++ b/calendar/gui/goto.c
@@ -72,7 +72,7 @@ ecal_date_range_changed (ECalendarItem *calitem, gpointer user_data)
GoToDialog *dlg = user_data;
CalClient *client;
- client = gnome_calendar_get_cal_client (dlg->gcal);
+ client = gnome_calendar_get_default_client (dlg->gcal);
if (client)
tag_calendar_by_client (dlg->ecal, client);
}
diff --git a/calendar/gui/itip-bonobo-control.c b/calendar/gui/itip-bonobo-control.c
index 1a0769ccec..6ce9bf6799 100644
--- a/calendar/gui/itip-bonobo-control.c
+++ b/calendar/gui/itip-bonobo-control.c
@@ -163,20 +163,20 @@ pstream_save (BonoboPersistStream *ps, const Bonobo_Stream stream,
g_free (text);
} /* pstream_save */
-static CORBA_long
-pstream_get_max_size (BonoboPersistStream *ps, void *data,
- CORBA_Environment *ev)
-{
- EItipControl *itip = data;
- gint len;
+/* static CORBA_long */
+/* pstream_get_max_size (BonoboPersistStream *ps, void *data, */
+/* CORBA_Environment *ev) */
+/* { */
+/* EItipControl *itip = data; */
+/* gint len; */
- len = e_itip_control_get_data_size (itip);
+/* len = e_itip_control_get_data_size (itip); */
- if (len > 0)
- return len;
+/* if (len > 0) */
+/* return len; */
- return 0L;
-}
+/* return 0L; */
+/* } */
static Bonobo_Persist_ContentTypeList *
pstream_get_content_types (BonoboPersistStream *ps, void *closure,
diff --git a/calendar/gui/print.c b/calendar/gui/print.c
index f338bc2e36..6aeb9f6566 100644
--- a/calendar/gui/print.c
+++ b/calendar/gui/print.c
@@ -561,7 +561,7 @@ print_month_small (GnomePrintContext *pc, GnomeCalendar *gcal, time_t month,
top -= header_size;
- client = gnome_calendar_get_cal_client (gcal);
+ client = gnome_calendar_get_default_client (gcal);
col_width = (right - left) / 7;
@@ -855,68 +855,68 @@ print_day_add_event (CalComponent *comp,
GArray **events)
{
- icaltimezone *zone = get_timezone ();
- EDayViewEvent event;
- gint day, offset;
- struct icaltimetype start_tt, end_tt;
-
-#if 0
- g_print ("Day view lower: %s", ctime (&day_starts[0]));
- g_print ("Day view upper: %s", ctime (&day_starts[days_shown]));
- g_print ("Event start: %s", ctime (&start));
- g_print ("Event end : %s\n", ctime (&end));
-#endif
-
- /* Check that the event times are valid. */
- g_return_val_if_fail (start <= end, -1);
- g_return_val_if_fail (start < day_starts[days_shown], -1);
- g_return_val_if_fail (end > day_starts[0], -1);
-
- start_tt = icaltime_from_timet_with_zone (start, FALSE, zone);
- end_tt = icaltime_from_timet_with_zone (end, FALSE, zone);
-
- event.comp = comp;
- g_object_ref (comp);
- event.start = start;
- event.end = end;
- event.canvas_item = NULL;
-
- /* Calculate the start & end minute, relative to the top of the
- display. */
- /*offset = day_view->first_hour_shown * 60
- + day_view->first_minute_shown;*/
- offset = 0;
- event.start_minute = start_tt.hour * 60 + start_tt.minute - offset;
- event.end_minute = end_tt.hour * 60 + end_tt.minute - offset;
-
- event.start_row_or_col = 0;
- event.num_columns = 0;
-
- /* Find out which array to add the event to. */
- for (day = 0; day < days_shown; day++) {
- if (start >= day_starts[day] && end <= day_starts[day + 1]) {
-
- /* Special case for when the appointment ends at
- midnight, i.e. the start of the next day. */
- if (end == day_starts[day + 1]) {
-
- /* If the event last the entire day, then we
- skip it here so it gets added to the top
- canvas. */
- if (start == day_starts[day])
- break;
-
- event.end_minute = 24 * 60;
- }
-
- g_array_append_val (events[day], event);
- return day;
- }
- }
-
- /* The event wasn't within one day so it must be a long event,
- i.e. shown in the top canvas. */
- g_array_append_val (long_events, event);
+/* icaltimezone *zone = get_timezone (); */
+/* EDayViewEvent event; */
+/* gint day, offset; */
+/* struct icaltimetype start_tt, end_tt; */
+
+/* #if 0 */
+/* g_print ("Day view lower: %s", ctime (&day_starts[0])); */
+/* g_print ("Day view upper: %s", ctime (&day_starts[days_shown])); */
+/* g_print ("Event start: %s", ctime (&start)); */
+/* g_print ("Event end : %s\n", ctime (&end)); */
+/* #endif */
+
+/* /\* Check that the event times are valid. *\/ */
+/* g_return_val_if_fail (start <= end, -1); */
+/* g_return_val_if_fail (start < day_starts[days_shown], -1); */
+/* g_return_val_if_fail (end > day_starts[0], -1); */
+
+/* start_tt = icaltime_from_timet_with_zone (start, FALSE, zone); */
+/* end_tt = icaltime_from_timet_with_zone (end, FALSE, zone); */
+
+/* event.comp = comp; */
+/* g_object_ref (comp); */
+/* event.start = start; */
+/* event.end = end; */
+/* event.canvas_item = NULL; */
+
+/* /\* Calculate the start & end minute, relative to the top of the */
+/* display. *\/ */
+/* /\*offset = day_view->first_hour_shown * 60 */
+/* + day_view->first_minute_shown;*\/ */
+/* offset = 0; */
+/* event.start_minute = start_tt.hour * 60 + start_tt.minute - offset; */
+/* event.end_minute = end_tt.hour * 60 + end_tt.minute - offset; */
+
+/* event.start_row_or_col = 0; */
+/* event.num_columns = 0; */
+
+/* /\* Find out which array to add the event to. *\/ */
+/* for (day = 0; day < days_shown; day++) { */
+/* if (start >= day_starts[day] && end <= day_starts[day + 1]) { */
+
+/* /\* Special case for when the appointment ends at */
+/* midnight, i.e. the start of the next day. *\/ */
+/* if (end == day_starts[day + 1]) { */
+
+/* /\* If the event last the entire day, then we */
+/* skip it here so it gets added to the top */
+/* canvas. *\/ */
+/* if (start == day_starts[day]) */
+/* break; */
+
+/* event.end_minute = 24 * 60; */
+/* } */
+
+/* g_array_append_val (events[day], event); */
+/* return day; */
+/* } */
+/* } */
+
+/* /\* The event wasn't within one day so it must be a long event, */
+/* i.e. shown in the top canvas. *\/ */
+/* g_array_append_val (long_events, event); */
return E_DAY_VIEW_LONG_EVENT;
}
@@ -945,7 +945,6 @@ free_event_array (GArray *array)
event = &g_array_index (array, EDayViewEvent, event_num);
if (event->canvas_item)
gtk_object_destroy (GTK_OBJECT (event->canvas_item));
- g_object_unref (event->comp);
}
g_array_set_size (array, 0);
@@ -958,7 +957,7 @@ print_day_long_event (GnomePrintContext *pc, GnomeFont *font,
double row_height, EDayViewEvent *event,
struct pdinfo *pdi)
{
- CalComponentText summary;
+ const gchar *summary;
double x1, x2, y1, y2;
double left_triangle_width = -1.0, right_triangle_width = -1.0;
char *text;
@@ -1023,8 +1022,8 @@ print_day_long_event (GnomePrintContext *pc, GnomeFont *font,
}
/* Print the text. */
- cal_component_get_summary (event->comp, &summary);
- text = summary.value ? (char*) summary.value : "";
+ summary = icalcomponent_get_summary (event->comp_data->icalcomp);
+ text = summary ? (char*) summary : "";
x1 += 4;
x2 -= 4;
@@ -1037,7 +1036,7 @@ print_day_event (GnomePrintContext *pc, GnomeFont *font,
double left, double right, double top, double bottom,
EDayViewEvent *event, struct pdinfo *pdi)
{
- CalComponentText summary;
+ const gchar *summary;
double x1, x2, y1, y2, col_width, row_height;
int start_offset, end_offset, start_row, end_row;
char *text, start_buffer[32], end_buffer[32];
@@ -1075,8 +1074,8 @@ print_day_event (GnomePrintContext *pc, GnomeFont *font,
print_border (pc, x1, x2, y1, y2, 1.0, 0.95);
- cal_component_get_summary (event->comp, &summary);
- text = summary.value ? (char*) summary.value : "";
+ summary = icalcomponent_get_summary (event->comp_data->icalcomp);
+ text = summary ? (char*) summary : "";
if (display_times) {
@@ -1142,7 +1141,7 @@ print_day_details (GnomePrintContext *pc, GnomeCalendar *gcal, time_t whence,
pdi.use_24_hour_format = calendar_config_get_24_hour_format ();
/* Get the events from the server. */
- client = gnome_calendar_get_cal_client (gcal);
+ client = gnome_calendar_get_default_client (gcal);
cal_client_generate_instances (client, CALOBJ_TYPE_EVENT, start, end,
print_day_details_cb, &pdi);
qsort (pdi.long_events->data, pdi.long_events->len,
@@ -1239,40 +1238,40 @@ print_week_summary_cb (CalComponent *comp,
gpointer data)
{
- icaltimezone *zone = get_timezone ();
- EWeekViewEvent event;
- struct icaltimetype start_tt, end_tt;
+/* icaltimezone *zone = get_timezone (); */
+/* EWeekViewEvent event; */
+/* struct icaltimetype start_tt, end_tt; */
- struct psinfo *psi = (struct psinfo *)data;
+/* struct psinfo *psi = (struct psinfo *)data; */
- /* Check that the event times are valid. */
+/* /\* Check that the event times are valid. *\/ */
-#if 0
- g_print ("View start:%li end:%li Event start:%li end:%li\n",
- psi->day_starts[0], psi->day_starts[psi->days_shown],
- start, end);
-#endif
+/* #if 0 */
+/* g_print ("View start:%li end:%li Event start:%li end:%li\n", */
+/* psi->day_starts[0], psi->day_starts[psi->days_shown], */
+/* start, end); */
+/* #endif */
- g_return_val_if_fail (start <= end, TRUE);
- g_return_val_if_fail (start < psi->day_starts[psi->days_shown], TRUE);
- g_return_val_if_fail (end > psi->day_starts[0], TRUE);
+/* g_return_val_if_fail (start <= end, TRUE); */
+/* g_return_val_if_fail (start < psi->day_starts[psi->days_shown], TRUE); */
+/* g_return_val_if_fail (end > psi->day_starts[0], TRUE); */
- start_tt = icaltime_from_timet_with_zone (start, FALSE, zone);
- end_tt = icaltime_from_timet_with_zone (end, FALSE, zone);
+/* start_tt = icaltime_from_timet_with_zone (start, FALSE, zone); */
+/* end_tt = icaltime_from_timet_with_zone (end, FALSE, zone); */
- event.comp = comp;
- g_object_ref (event.comp);
- event.start = start;
- event.end = end;
- event.spans_index = 0;
- event.num_spans = 0;
+/* event.comp = comp; */
+/* g_object_ref (event.comp); */
+/* event.start = start; */
+/* event.end = end; */
+/* event.spans_index = 0; */
+/* event.num_spans = 0; */
- event.start_minute = start_tt.hour * 60 + start_tt.minute;
- event.end_minute = end_tt.hour * 60 + end_tt.minute;
- if (event.end_minute == 0 && start != end)
- event.end_minute = 24 * 60;
+/* event.start_minute = start_tt.hour * 60 + start_tt.minute; */
+/* event.end_minute = end_tt.hour * 60 + end_tt.minute; */
+/* if (event.end_minute == 0 && start != end) */
+/* event.end_minute = 24 * 60; */
- g_array_append_val (psi->events, event);
+/* g_array_append_val (psi->events, event); */
return TRUE;
}
@@ -1404,13 +1403,13 @@ print_week_event (GnomePrintContext *pc, GnomeFont *font,
{
EWeekViewEventSpan *span;
gint span_num;
- CalComponentText summary;
+ const gchar *summary;
char *text;
int num_days, start_x, start_y, start_h, end_x, end_y, end_h;
double x1, x2, y1, y2;
- cal_component_get_summary (event->comp, &summary);
- text = summary.value ? (char*) summary.value : "";
+ summary = icalcomponent_get_summary (event->comp_data->icalcomp);
+ text = summary ? (char*) summary : "";
for (span_num = 0; span_num < event->num_spans; span_num++) {
span = &g_array_index (spans, EWeekViewEventSpan,
@@ -1578,7 +1577,7 @@ print_week_summary (GnomePrintContext *pc, GnomeCalendar *gcal,
}
/* Get the events from the server. */
- client = gnome_calendar_get_cal_client (gcal);
+ client = gnome_calendar_get_default_client (gcal);
cal_client_generate_instances (client, CALOBJ_TYPE_EVENT,
psi.day_starts[0],
psi.day_starts[psi.days_shown],
@@ -1632,7 +1631,6 @@ print_week_summary (GnomePrintContext *pc, GnomeCalendar *gcal,
/* Free everything. */
for (event_num = 0; event_num < psi.events->len; event_num++) {
event = &g_array_index (psi.events, EWeekViewEvent, event_num);
- g_object_unref (event->comp);
}
g_array_free (psi.events, TRUE);
g_array_free (spans, TRUE);