gnome-panel r11154 - branches/gnome-2-22/applets/clock
- From: vuntz svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-panel r11154 - branches/gnome-2-22/applets/clock
- Date: Mon, 30 Jun 2008 14:56:52 +0000 (UTC)
Author: vuntz
Date: Mon Jun 30 14:56:52 2008
New Revision: 11154
URL: http://svn.gnome.org/viewvc/gnome-panel?rev=11154&view=rev
Log:
2008-06-30 Vincent Untz <vuntz gnome org>
Load calendars asynchronously. Fix bug #515948, and probably a few
others. Based on patch by Chenthill Palanisamy <pchenthill novell com>
* calendar-client.c: (calendar_client_set_timezone): always set the
timezone, even if the calendar is not loaded yet
(cal_opened_cb): new, callback when a calendar has been opened. We just
update the appointments/tasks when relevant.
(load_calendars): new, asynchronously open all calendars from a source
(calendar_client_init): move some stuff around, and call
load_calendars()
(calendar_client_update_appointments): ignore not-loaded calendars
(calendar_client_update_tasks): ditto
(calendar_client_source_finalize): disconnect the opened handler
(calendar_client_appointment_sources_changed): call load_calendars()
since there have been changes in the list of calendars
(calendar_client_task_sources_changed): ditto
* calendar-sources.c: (get_ecal_from_source): renamed from
load_esource(), we just don't open the calendar there anymore
(calendar_sources_load_esource_list): rename variable
Modified:
branches/gnome-2-22/applets/clock/ChangeLog
branches/gnome-2-22/applets/clock/calendar-client.c
branches/gnome-2-22/applets/clock/calendar-sources.c
Modified: branches/gnome-2-22/applets/clock/calendar-client.c
==============================================================================
--- branches/gnome-2-22/applets/clock/calendar-client.c (original)
+++ branches/gnome-2-22/applets/clock/calendar-client.c Mon Jun 30 14:56:52 2008
@@ -120,6 +120,11 @@
static void calendar_client_source_finalize (CalendarClientSource *source);
static void calendar_client_query_finalize (CalendarClientQuery *query);
+static void
+calendar_client_update_appointments (CalendarClient *client);
+static void
+calendar_client_update_tasks (CalendarClient *client);
+
enum
{
PROP_O,
@@ -269,9 +274,6 @@
for (l = esources; l; l = l->next) {
ECal *source = l->data;
- if (e_cal_get_load_state (source) != E_CAL_LOAD_LOADED)
- continue;
-
e_cal_set_default_timezone (source, client->priv->zone, NULL);
}
}
@@ -285,6 +287,79 @@
calendar_client_set_timezone (client);
}
+static void
+cal_opened_cb (ECal *ecal,
+ ECalendarStatus status,
+ CalendarClientSource *cl_source)
+{
+ ECalSourceType s_type;
+ CalendarClient *client = cl_source->client;
+
+ s_type = e_cal_get_source_type (ecal);
+
+ if (status == E_CALENDAR_STATUS_BUSY &&
+ e_cal_get_load_state (ecal) == E_CAL_LOAD_NOT_LOADED)
+ {
+ e_cal_open_async (ecal, FALSE);
+ return;
+ }
+
+ g_signal_handlers_disconnect_by_func (ecal, cal_opened_cb, cl_source);
+
+ if (status != E_CALENDAR_STATUS_OK)
+ {
+ if (s_type == E_CAL_SOURCE_TYPE_EVENT)
+ client->priv->appointment_sources = g_slist_remove (client->priv->appointment_sources,
+ cl_source);
+ else
+ client->priv->task_sources = g_slist_remove (client->priv->task_sources,
+ cl_source);
+
+ calendar_client_source_finalize (cl_source);
+ g_free (cl_source);
+
+ return;
+ }
+
+ if (s_type == E_CAL_SOURCE_TYPE_EVENT)
+ calendar_client_update_appointments (client);
+ else
+ calendar_client_update_tasks (client);
+}
+
+static void
+load_calendars (CalendarClient *client,
+ CalendarEventType type)
+{
+ GSList *l, *clients;
+
+ switch (type)
+ {
+ case CALENDAR_EVENT_APPOINTMENT:
+ clients = client->priv->appointment_sources;
+ break;
+ case CALENDAR_EVENT_TASK:
+ clients = client->priv->task_sources;
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+
+ for (l = clients; l != NULL; l = l->next)
+ {
+ ECal *ecal;
+ CalendarClientSource *cl_source = l->data;
+
+ ecal = cl_source->source;
+
+ if (e_cal_get_load_state (ecal) == E_CAL_LOAD_LOADED)
+ continue;
+
+ g_signal_connect (G_OBJECT (ecal), "cal_opened",
+ G_CALLBACK (cal_opened_cb), cl_source);
+ e_cal_open_async (ecal, TRUE);
+ }
+}
static void
calendar_client_init (CalendarClient *client)
@@ -294,6 +369,7 @@
client->priv = CALENDAR_CLIENT_GET_PRIVATE (client);
client->priv->calendar_sources = calendar_sources_get ();
+ client->priv->gconf_client = gconf_client_get_default ();
esources = calendar_sources_get_appointment_sources (client->priv->calendar_sources);
client->priv->appointment_sources =
@@ -302,6 +378,11 @@
esources = calendar_sources_get_task_sources (client->priv->calendar_sources);
client->priv->task_sources =
calendar_client_update_sources_list (client, NULL, esources, signals [TASKS_CHANGED]);
+
+ /* set the timezone before loading the clients */
+ calendar_client_set_timezone (client);
+ load_calendars (client, CALENDAR_EVENT_APPOINTMENT);
+ load_calendars (client, CALENDAR_EVENT_TASK);
g_signal_connect_swapped (client->priv->calendar_sources,
"appointment-sources-changed",
@@ -312,14 +393,11 @@
G_CALLBACK (calendar_client_task_sources_changed),
client);
- client->priv->gconf_client = gconf_client_get_default ();
-
gconf_client_add_dir (client->priv->gconf_client,
CALENDAR_CONFIG_PREFIX,
GCONF_CLIENT_PRELOAD_NONE,
NULL);
- calendar_client_set_timezone (client);
client->priv->zone_listener = gconf_client_notify_add (client->priv->gconf_client,
CALENDAR_CONFIG_TIMEZONE,
(GConfClientNotifyFunc) calendar_client_timezone_changed_cb,
@@ -1497,7 +1575,14 @@
month_begin, month_end);
for (l = client->priv->appointment_sources; l; l = l->next)
- calendar_client_start_query (client, l->data, query);
+ {
+ CalendarClientSource *cs = l->data;
+
+ if (e_cal_get_load_state (cs->source) != E_CAL_LOAD_LOADED)
+ continue;
+
+ calendar_client_start_query (client, cs, query);
+ }
g_free (month_begin);
g_free (month_end);
@@ -1557,7 +1642,14 @@
#endif /* FIX_BROKEN_TASKS_QUERY */
for (l = client->priv->task_sources; l; l = l->next)
- calendar_client_start_query (client, l->data, query);
+ {
+ CalendarClientSource *cs = l->data;
+
+ if (e_cal_get_load_state (cs->source) != E_CAL_LOAD_LOADED)
+ continue;
+
+ calendar_client_start_query (client, cs, query);
+ }
#ifdef FIX_BROKEN_TASKS_QUERY
g_free (day_begin);
@@ -1571,8 +1663,11 @@
{
source->client = NULL;
- if (source->source)
+ if (source->source) {
+ g_signal_handlers_disconnect_by_func (source->source,
+ cal_opened_cb, source);
g_object_unref (source->source);
+ }
source->source = NULL;
calendar_client_query_finalize (&source->completed_query);
@@ -1661,6 +1756,7 @@
esources,
signals [APPOINTMENTS_CHANGED]);
+ load_calendars (client, CALENDAR_EVENT_APPOINTMENT);
calendar_client_update_appointments (client);
}
@@ -1679,6 +1775,7 @@
esources,
signals [TASKS_CHANGED]);
+ load_calendars (client, CALENDAR_EVENT_TASK);
calendar_client_update_tasks (client);
}
Modified: branches/gnome-2-22/applets/clock/calendar-sources.c
==============================================================================
--- branches/gnome-2-22/applets/clock/calendar-sources.c (original)
+++ branches/gnome-2-22/applets/clock/calendar-sources.c Mon Jun 30 14:56:52 2008
@@ -311,14 +311,13 @@
return e_passwords_get_password (component_name, key);
}
+/* The clients are just created here but not loaded */
static ECal *
-load_esource (ESource *esource,
- ECalSourceType source_type,
- GSList *existing_clients)
+get_ecal_from_source (ESource *esource,
+ ECalSourceType source_type,
+ GSList *existing_clients)
{
- ECal *retval;
- GError *error;
-
+ ECal *retval;
if (existing_clients)
{
@@ -348,20 +347,6 @@
e_cal_set_auth_func (retval, auth_func_cb, NULL);
- error = NULL;
- if (!e_cal_open (retval, TRUE, &error))
- {
- g_assert (error != NULL);
- g_warning ("Cannot open calendar from uri '%s': %s\n",
- e_cal_get_uri (retval), error->message);
- g_error_free (error);
- g_object_unref (retval);
- return NULL;
- }
-
- dprintf (" Loaded calendar from uri '%s'\n",
- e_cal_get_uri (retval));
-
return retval;
}
@@ -466,7 +451,7 @@
static void
calendar_sources_load_esource_list (CalendarSourceData *source_data)
{
- GSList *loaded_clients = NULL;
+ GSList *clients = NULL;
GSList *groups, *l;
gboolean emit_signal = FALSE;
@@ -496,16 +481,16 @@
e_source_peek_relative_uri (esource));
if (is_source_selected (esource, source_data->selected_sources) &&
- (client = load_esource (esource, source_data->source_type, source_data->clients)))
+ (client = get_ecal_from_source (esource, source_data->source_type, source_data->clients)))
{
- loaded_clients = g_slist_prepend (loaded_clients, client);
+ clients = g_slist_prepend (clients, client);
}
}
}
dprintf ("\n");
if (source_data->loaded &&
- !compare_ecal_lists (source_data->clients, loaded_clients))
+ !compare_ecal_lists (source_data->clients, clients))
emit_signal = TRUE;
for (l = source_data->clients; l; l = l->next)
@@ -517,7 +502,7 @@
g_object_unref (l->data);
}
g_slist_free (source_data->clients);
- source_data->clients = g_slist_reverse (loaded_clients);
+ source_data->clients = g_slist_reverse (clients);
/* connect to backend_died after we disconnected the previous signal
* handlers. If we do it before, we'll lose some handlers (for clients that
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]