From a874d1e407014751ae72957679c89dc6bbe2f679 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Sat, 4 Aug 2001 03:13:43 +0000 Subject: New function; stops further notification from happening. This is needed 2001-08-03 Federico Mena Quintero * cal-client/query-listener.c (query_listener_stop_notification): New function; stops further notification from happening. This is needed since the listener is destroyed asynchronously from the Wombat and the corresponding CalQuery may already have died. (impl_notifyObjUpdated): Do not notify if requested. (impl_notifyObjRemoved): Likewise. (impl_notifyQueryDone): Likewise. (impl_notifyEvalError): Likewise. * cal-client/cal-query.c (cal_query_destroy): Use query_listener_stop_notification(). * cal-client/cal-listener.c (cal_listener_destroy): Nullify the pointers to the callback functions. * gui/e-day-view.c (update_query): Commit our state of no longer having a query before unrefing it. We may reenter from the ORBit main loop and we *really* want this information to be committed. * gui/e-week-view.c (update_query): Likewise. * gui/calendar-model.c (update_query): Likewise. * gui/tag-calendar.c (tag_calendar_by_comp): Added a "clear_first" argument that indicates whether the ECalendar should be cleared of any marks first. * gui/calendar-commands.c (calendar_control_activate): Removed ifdefed-out view buttons code from the Gnomecal days. * gui/gnome-cal.c (client_categories_changed_cb): Merge the categories of the calendar and tasks clients so that we can display the categories in both sets. (gnome_calendar_construct): Connect to "categories_changed" on both clients. (gnome_calendar_on_date_navigator_selection_changed): Removed call to gnome_calendar_update_view_buttons(). (gnome_calendar_update_view_buttons): Removed. We cannot have this until Bonobo supports radio toolbar items. (gnome_calendar_set_view_buttons): Removed. (gnome_calendar_dayjump): Do not use priv->day_button. (GnomeCalendarPrivate): Removed the {day,work_week,week,month}_button fields. (gnome_calendar_set_query): Start a retagging process of the date navigator so that it reflects the current query. (update_query): New function to restart a query for the date navigator. (initial_load): Use update_query() instead of tagging the date navigator directly. (gnome_calendar_on_date_navigator_date_range_changed): Likewise. (client_cal_opened_cb): Use update_query() instead of initial_load(). (initial_load): Removed. (client_obj_updated_cb): Removed. (client_obj_removed_cb): Removed. (gnome_calendar_new_appointment_for): Set the default category of the new component. (search_bar_category_changed_cb): Set the default category for the calendar views. * gui/cal-search-bar.c (cal_search_bar_set_categories): Sort the categories before creating the menu. * gui/e-day-view.c (adjust_query_sexp): Return NULL instead of "#f" if the time range is not set yet. (update_query): Do not start a query if the time range is not set. (e_day_view_set_default_category): New function. (e_day_view_key_press): Set the default category on the new component. * gui/e-week-view.c (adjust_query_sexp): Analogous to the above. (update_query): Analogous to the above. (e_week_view_set_default_category): Analogous to the above. (e_week_view_key_press): Analogous to the above. svn path=/trunk/; revision=11646 --- calendar/cal-client/cal-listener.c | 6 ++++++ calendar/cal-client/cal-query.c | 1 + calendar/cal-client/query-listener.c | 41 ++++++++++++++++++++++++++++++++++++ calendar/cal-client/query-listener.h | 2 ++ 4 files changed, 50 insertions(+) (limited to 'calendar/cal-client') diff --git a/calendar/cal-client/cal-listener.c b/calendar/cal-client/cal-listener.c index 087d5e9c00..0062718155 100644 --- a/calendar/cal-client/cal-listener.c +++ b/calendar/cal-client/cal-listener.c @@ -115,6 +115,12 @@ cal_listener_destroy (GtkObject *object) listener = CAL_LISTENER (object); priv = listener->priv; + priv->cal_opened_fn = NULL; + priv->obj_updated_fn = NULL; + priv->obj_removed_fn = NULL; + priv->categories_changed_fn = NULL; + priv->fn_data = NULL; + CORBA_exception_init (&ev); result = CORBA_Object_is_nil (priv->cal, &ev); diff --git a/calendar/cal-client/cal-query.c b/calendar/cal-client/cal-query.c index 727a2dcb3b..958bad9f52 100644 --- a/calendar/cal-client/cal-query.c +++ b/calendar/cal-client/cal-query.c @@ -181,6 +181,7 @@ cal_query_destroy (GtkObject *object) priv = query->priv; /* The server unrefs the query listener, so we just NULL it out here */ + query_listener_stop_notification (priv->ql); priv->ql = NULL; if (priv->corba_query != CORBA_OBJECT_NIL) { diff --git a/calendar/cal-client/query-listener.c b/calendar/cal-client/query-listener.c index 980b0a1ece..51563fd9b0 100644 --- a/calendar/cal-client/query-listener.c +++ b/calendar/cal-client/query-listener.c @@ -36,6 +36,9 @@ struct _QueryListenerPrivate { QueryListenerQueryDoneFn query_done_fn; QueryListenerEvalErrorFn eval_error_fn; gpointer fn_data; + + /* Whether notification is desired */ + gboolean notify : 1; }; @@ -105,6 +108,8 @@ query_listener_init (QueryListener *ql) priv->query_done_fn = NULL; priv->eval_error_fn = NULL; priv->fn_data = NULL; + + priv->notify = TRUE; } /* Destroy handler for the live search query listener */ @@ -126,6 +131,8 @@ query_listener_destroy (GtkObject *object) priv->eval_error_fn = NULL; priv->fn_data = NULL; + priv->notify = FALSE; + g_free (priv); ql->priv = NULL; @@ -152,6 +159,9 @@ impl_notifyObjUpdated (PortableServer_Servant servant, ql = QUERY_LISTENER (bonobo_object_from_servant (servant)); priv = ql->priv; + if (!priv->notify) + return; + g_assert (priv->obj_updated_fn != NULL); (* priv->obj_updated_fn) (ql, uid, query_in_progress, n_scanned, total, priv->fn_data); } @@ -168,6 +178,9 @@ impl_notifyObjRemoved (PortableServer_Servant servant, ql = QUERY_LISTENER (bonobo_object_from_servant (servant)); priv = ql->priv; + if (!priv->notify) + return; + g_assert (priv->obj_removed_fn != NULL); (* priv->obj_removed_fn) (ql, uid, priv->fn_data); } @@ -185,6 +198,9 @@ impl_notifyQueryDone (PortableServer_Servant servant, ql = QUERY_LISTENER (bonobo_object_from_servant (servant)); priv = ql->priv; + if (!priv->notify) + return; + g_assert (priv->query_done_fn != NULL); (* priv->query_done_fn) (ql, corba_status, error_str, priv->fn_data); } @@ -201,6 +217,9 @@ impl_notifyEvalError (PortableServer_Servant servant, ql = QUERY_LISTENER (bonobo_object_from_servant (servant)); priv = ql->priv; + if (!priv->notify) + return; + g_assert (priv->eval_error_fn != NULL); (* priv->eval_error_fn) (ql, error_str, priv->fn_data); } @@ -279,3 +298,25 @@ query_listener_new (QueryListenerObjUpdatedFn obj_updated_fn, eval_error_fn, fn_data); } + +/** + * query_listener_stop_notification: + * @ql: A query listener. + * + * Informs a query listener that no further notification is desired. The + * callbacks specified when the listener was created will no longer be invoked + * after this function is called. + **/ +void +query_listener_stop_notification (QueryListener *ql) +{ + QueryListenerPrivate *priv; + + g_return_if_fail (ql != NULL); + g_return_if_fail (IS_QUERY_LISTENER (ql)); + + priv = ql->priv; + g_return_if_fail (priv->notify != FALSE); + + priv->notify = FALSE; +} diff --git a/calendar/cal-client/query-listener.h b/calendar/cal-client/query-listener.h index 53be9f3229..1330216260 100644 --- a/calendar/cal-client/query-listener.h +++ b/calendar/cal-client/query-listener.h @@ -89,6 +89,8 @@ QueryListener *query_listener_new (QueryListenerObjUpdatedFn obj_updated_fn, QueryListenerEvalErrorFn eval_error_fn, gpointer fn_data); +void query_listener_stop_notification (QueryListener *ql); + END_GNOME_DECLS -- cgit v1.2.3