diff options
author | Rodrigo Moya <rodrigo@novell.com> | 2004-06-07 22:11:44 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@src.gnome.org> | 2004-06-07 22:11:44 +0800 |
commit | 94ab074ae6bb7fc8274c4201e53f6890dd357d5e (patch) | |
tree | fd76d2050d51cfe6ac91b0230efa0655e8e1cb5c /calendar/gui | |
parent | 5914e863dd76b7d7800170aae25a5c9a45ebf40d (diff) | |
download | gsoc2013-evolution-94ab074ae6bb7fc8274c4201e53f6890dd357d5e.tar gsoc2013-evolution-94ab074ae6bb7fc8274c4201e53f6890dd357d5e.tar.gz gsoc2013-evolution-94ab074ae6bb7fc8274c4201e53f6890dd357d5e.tar.bz2 gsoc2013-evolution-94ab074ae6bb7fc8274c4201e53f6890dd357d5e.tar.lz gsoc2013-evolution-94ab074ae6bb7fc8274c4201e53f6890dd357d5e.tar.xz gsoc2013-evolution-94ab074ae6bb7fc8274c4201e53f6890dd357d5e.tar.zst gsoc2013-evolution-94ab074ae6bb7fc8274c4201e53f6890dd357d5e.zip |
open task lists asynchronously. (client_cal_opened_cb): callback from the
2004-06-07 Rodrigo Moya <rodrigo@novell.com>
* gui/e-tasks.c (e_tasks_add_todo_source): open task lists
asynchronously.
(client_cal_opened_cb): callback from the client when opened.
* gui/gnome-cal.c (client_cal_opened_cb): disconnect from all
signals of the client when opening it fails. Clean up the status
messages correctly, based on source type.
(open_ecal): for tasks, use e_calendar_table_set_status_message
not e_calendar_view_set_status_message.
(gnome_calendar_remove_source_by_uid): call update_query only when
removing calendars, not tasks lists.
(update_query): set meaningful status messages.
svn path=/trunk/; revision=26236
Diffstat (limited to 'calendar/gui')
-rw-r--r-- | calendar/gui/e-tasks.c | 78 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.c | 37 |
2 files changed, 70 insertions, 45 deletions
diff --git a/calendar/gui/e-tasks.c b/calendar/gui/e-tasks.c index 56d9709d12..fbf652523a 100644 --- a/calendar/gui/e-tasks.c +++ b/calendar/gui/e-tasks.c @@ -738,6 +738,48 @@ backend_died_cb (ECal *client, gpointer data) g_object_unref (source); } +/* Callback from the calendar client when the calendar is opened */ +static void +client_cal_opened_cb (ECal *ecal, ECalendarStatus status, ETasks *tasks) +{ + ECalModel *model; + ESource *source; + ETasksPrivate *priv; + + priv = tasks->priv; + + source = e_cal_get_source (ecal); + + switch (status) { + case E_CALENDAR_STATUS_OK : + set_status_message (tasks, _("Loading tasks")); + model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view)); + e_cal_model_add_client (model, ecal); + + set_timezone (tasks); + set_status_message (tasks, NULL); + break; + default : + /* Make sure the source doesn't disappear on us */ + g_object_ref (source); + + priv->clients_list = g_list_remove (priv->clients_list, ecal); + g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_DATA, + 0, 0, NULL, NULL, tasks); + + /* Do this last because it unrefs the client */ + g_hash_table_remove (priv->clients, e_cal_get_uri (ecal)); + + gtk_signal_emit (GTK_OBJECT (tasks), e_tasks_signals[SOURCE_REMOVED], source); + + set_status_message (tasks, NULL); + g_object_unref (ecal); + g_object_unref (source); + + break; + } +} + void e_tasks_open_task (ETasks *tasks) { @@ -782,7 +824,6 @@ e_tasks_add_todo_source (ETasks *tasks, ESource *source) { ETasksPrivate *priv; ECal *client; - ECalModel *model; char *str_uri; GError *error = NULL; @@ -815,42 +856,11 @@ e_tasks_add_todo_source (ETasks *tasks, ESource *source) g_signal_connect (G_OBJECT (client), "backend_error", G_CALLBACK (backend_error_cb), tasks); g_signal_connect (G_OBJECT (client), "categories_changed", G_CALLBACK (client_categories_changed_cb), tasks); g_signal_connect (G_OBJECT (client), "backend_died", G_CALLBACK (backend_died_cb), tasks); + g_signal_connect (G_OBJECT (client), "cal_opened", G_CALLBACK (client_cal_opened_cb), tasks); gtk_signal_emit (GTK_OBJECT (tasks), e_tasks_signals[SOURCE_ADDED], source); - if (!e_cal_open (client, FALSE, &error)) { - GtkWidget *dialog; - - dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tasks))), - GTK_DIALOG_NO_SEPARATOR, - GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, - _("Error opening %s:\n%s"), - str_uri, error ? error->message : ""); - - g_error_free (error); - priv->clients_list = g_list_prepend (priv->clients_list, client); - g_signal_handlers_disconnect_matched (client, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, tasks); - - /* Do this last because it unrefs the client */ - g_hash_table_remove (priv->clients, str_uri); - - gtk_signal_emit (GTK_OBJECT (tasks), e_tasks_signals[SOURCE_REMOVED], source); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - - set_status_message (tasks, NULL); - - return FALSE; - } - - set_status_message (tasks, _("Loading tasks")); - model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view)); - e_cal_model_add_client (model, client); - - set_timezone (tasks); - set_status_message (tasks, NULL); + e_cal_open_async (client, FALSE); return TRUE; } diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 89f813580b..9a998e4bd5 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -656,6 +656,7 @@ update_query (GnomeCalendar *gcal) priv = gcal->priv; + e_calendar_view_set_status_message (priv->views[priv->current_view_type], _("Updating query")); e_calendar_item_clear_marks (priv->date_navigator->calitem); /* free the previous queries */ @@ -676,6 +677,7 @@ update_query (GnomeCalendar *gcal) real_sexp = adjust_e_cal_view_sexp (gcal, priv->sexp); if (!real_sexp) { + e_calendar_view_set_status_message (priv->views[priv->current_view_type], NULL); return; /* No time range is set, so don't start a query */ } @@ -707,7 +709,7 @@ update_query (GnomeCalendar *gcal) } g_free (real_sexp); - + e_calendar_view_set_status_message (priv->views[priv->current_view_type], NULL); update_todo_view (gcal); } @@ -1857,16 +1859,22 @@ client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal) priv = gcal->priv; - e_calendar_view_set_status_message (priv->views[priv->current_view_type], NULL); - source_type = e_cal_get_source_type (ecal); source = e_cal_get_source (ecal); - + + if (source_type == E_CAL_SOURCE_TYPE_EVENT) + e_calendar_view_set_status_message (priv->views[priv->current_view_type], NULL); + else + e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo), NULL); + if (status != E_CALENDAR_STATUS_OK) { /* Make sure the source doesn't disappear on us */ g_object_ref (source); priv->clients_list[source_type] = g_list_remove (priv->clients_list[source_type], ecal); + g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_DATA, + 0, 0, NULL, NULL, gcal); + g_hash_table_remove (priv->clients[source_type], e_source_peek_uid (source)); gtk_signal_emit (GTK_OBJECT (gcal), gnome_calendar_signals[SOURCE_REMOVED], source_type, source); @@ -1879,7 +1887,7 @@ client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal) e_cal_set_default_timezone (ecal, priv->zone, NULL); switch (source_type) { - case E_CAL_SOURCE_TYPE_EVENT: + case E_CAL_SOURCE_TYPE_EVENT : msg = g_strdup_printf (_("Loading appointments at %s"), e_cal_get_uri (ecal)); e_calendar_view_set_status_message (priv->views[priv->current_view_type], msg); g_free (msg); @@ -1898,7 +1906,7 @@ client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal) e_calendar_view_set_status_message (priv->views[priv->current_view_type], NULL); break; - case E_CAL_SOURCE_TYPE_TODO: + case E_CAL_SOURCE_TYPE_TODO : msg = g_strdup_printf (_("Loading tasks at %s"), e_cal_get_uri (ecal)); e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo), msg); g_free (msg); @@ -1922,8 +1930,16 @@ open_ecal (GnomeCalendar *gcal, ECal *cal, gboolean only_if_exists) priv = gcal->priv; - msg = g_strdup_printf (_("Opening %s"), e_cal_get_uri (cal)); - e_calendar_view_set_status_message (priv->views[priv->current_view_type], msg); + msg = g_strdup_printf (_("Opening %s"), e_cal_get_uri (cal)); + switch (e_cal_get_source_type (cal)) { + case E_CAL_SOURCE_TYPE_EVENT : + e_calendar_view_set_status_message (priv->views[priv->current_view_type], msg); + break; + case E_CAL_SOURCE_TYPE_TODO : + e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo), msg); + break; + } + g_free (msg); g_signal_connect (G_OBJECT (cal), "cal_opened", G_CALLBACK (client_cal_opened_cb), gcal); @@ -2285,6 +2301,8 @@ gnome_calendar_remove_source_by_uid (GnomeCalendar *gcal, ECalSourceType source_ e_cal_model_remove_client (model, client); } + /* update date navigator query */ + update_query (gcal); break; case E_CAL_SOURCE_TYPE_TODO: @@ -2299,9 +2317,6 @@ gnome_calendar_remove_source_by_uid (GnomeCalendar *gcal, ECalSourceType source_ g_hash_table_remove (priv->clients[source_type], uid); - /* update date navigator query */ - update_query (gcal); - return TRUE; } |