aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/gnome-cal.c
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/gui/gnome-cal.c')
-rw-r--r--calendar/gui/gnome-cal.c410
1 files changed, 220 insertions, 190 deletions
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*