diff options
author | Rodrigo Moya <rodrigo@ximian.com> | 2002-08-16 20:56:14 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@src.gnome.org> | 2002-08-16 20:56:14 +0800 |
commit | f245eb32c54f5f98e79643338f192abea871f2cf (patch) | |
tree | a9017040ec0bb4aff911c53780d824b30f9cc24d /calendar | |
parent | 83c35905a8146b88be28545604ec96c4358270d2 (diff) | |
download | gsoc2013-evolution-f245eb32c54f5f98e79643338f192abea871f2cf.tar.gz gsoc2013-evolution-f245eb32c54f5f98e79643338f192abea871f2cf.tar.zst gsoc2013-evolution-f245eb32c54f5f98e79643338f192abea871f2cf.zip |
added internal EComponentListener object, to listen for the activated Cal.
2002-08-16 Rodrigo Moya <rodrigo@ximian.com>
* cal-client/cal-client.[ch]: added internal EComponentListener
object, to listen for the activated Cal.
(cal_client_class_init): added "backend_died" signal.
(cal_client_destroy): clean up component listener.
(backend_died_cb): new callback for getting signals from the
EComponentListener.
(cal_opened_cb): setup component listener.
* cal-client/Makefile.am: added libetuil to needed LIBS.
* gui/gnome-cal.c (backend_died_cb): new callback.
(gnome_calendar_construct): connect to "backend_died" signal
on all CalClient's we create.
svn path=/trunk/; revision=17787
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 16 | ||||
-rw-r--r-- | calendar/cal-client/Makefile.am | 1 | ||||
-rw-r--r-- | calendar/cal-client/cal-client.c | 38 | ||||
-rw-r--r-- | calendar/cal-client/cal-client.h | 2 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.c | 32 |
5 files changed, 89 insertions, 0 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 406b18dc12..f547769669 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,19 @@ +2002-08-16 Rodrigo Moya <rodrigo@ximian.com> + + * cal-client/cal-client.[ch]: added internal EComponentListener + object, to listen for the activated Cal. + (cal_client_class_init): added "backend_died" signal. + (cal_client_destroy): clean up component listener. + (backend_died_cb): new callback for getting signals from the + EComponentListener. + (cal_opened_cb): setup component listener. + + * cal-client/Makefile.am: added libetuil to needed LIBS. + + * gui/gnome-cal.c (backend_died_cb): new callback. + (gnome_calendar_construct): connect to "backend_died" signal + on all CalClient's we create. + 2002-08-14 JP Rosevear <jpr@ximian.com> * gui/dialogs/cal-prefs-dialog.c (init_widgets): listen for the diff --git a/calendar/cal-client/Makefile.am b/calendar/cal-client/Makefile.am index de4b85e51f..c1ede1e84f 100644 --- a/calendar/cal-client/Makefile.am +++ b/calendar/cal-client/Makefile.am @@ -77,6 +77,7 @@ client_test_INCLUDES = \ client_test_LDADD = \ $(EVOLUTION_CALENDAR_LIBS) \ + $(top_builddir)/e-util/libeutil.la \ $(top_builddir)/calendar/cal-util/libcal-util.la \ $(top_builddir)/libversit/libversit.a \ $(top_builddir)/libical/src/libical/libical-evolution.la \ diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c index 992f0bf157..b46dc3a215 100644 --- a/calendar/cal-client/cal-client.c +++ b/calendar/cal-client/cal-client.c @@ -29,6 +29,7 @@ #include <bonobo-conf/bonobo-config-database.h> #include <libgnome/gnome-util.h> +#include "e-util/e-component-listener.h" #include "cal-client-types.h" #include "cal-client.h" #include "cal-listener.h" @@ -69,6 +70,9 @@ struct _CalClientPrivate { /* The default timezone to use to resolve DATE and floating DATE-TIME values. */ icaltimezone *default_zone; + + /* The component listener to keep track of the lifetime of backends */ + EComponentListener *comp_listener; }; @@ -81,6 +85,7 @@ enum { OBJ_REMOVED, CATEGORIES_CHANGED, FORGET_PASSWORD, + BACKEND_DIED, LAST_SIGNAL }; @@ -196,6 +201,13 @@ cal_client_class_init (CalClientClass *class) gtk_marshal_NONE__STRING, GTK_TYPE_NONE, 1, GTK_TYPE_STRING); + cal_client_signals[BACKEND_DIED] = + gtk_signal_new ("backend_died", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (CalClientClass, backend_died), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); gtk_object_class_add_signals (object_class, cal_client_signals, LAST_SIGNAL); @@ -204,6 +216,7 @@ cal_client_class_init (CalClientClass *class) class->obj_removed = NULL; class->categories_changed = NULL; class->forget_password = NULL; + class->backend_died = NULL; object_class->destroy = cal_client_destroy; } @@ -223,6 +236,7 @@ cal_client_init (CalClient *client) priv->timezones = g_hash_table_new (g_str_hash, g_str_equal); priv->w_client = NULL; priv->default_zone = icaltimezone_get_utc_timezone (); + priv->comp_listener = NULL; } /* Gets rid of the factories that a client knows about */ @@ -332,6 +346,12 @@ cal_client_destroy (GtkObject *object) priv->listener = NULL; } + if (priv->comp_listener) { + gtk_signal_disconnect_by_data (GTK_OBJECT (priv->comp_listener), client); + gtk_object_unref (GTK_OBJECT (priv->comp_listener)); + priv->comp_listener = NULL; + } + priv->w_client = NULL; destroy_factories (client); destroy_cal (client); @@ -356,6 +376,19 @@ cal_client_destroy (GtkObject *object) +static void +backend_died_cb (EComponentListener *cl, gpointer user_data) +{ + CalClientPrivate *priv; + CalClient *client = (CalClient *) user_data; + + g_return_if_fail (IS_CAL_CLIENT (client)); + + priv = client->priv; + priv->load_state = CAL_CLIENT_LOAD_NOT_LOADED; + gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[BACKEND_DIED]); +} + /* Signal handlers for the listener's signals */ /* Handle the cal_opened notification from the listener */ static void @@ -394,6 +427,11 @@ cal_opened_cb (CalListener *listener, priv->load_state = CAL_CLIENT_LOAD_LOADED; client_status = CAL_CLIENT_OPEN_SUCCESS; + + /* setup component listener */ + priv->comp_listener = e_component_listener_new (priv->cal, 0); + gtk_signal_connect (GTK_OBJECT (priv->comp_listener), "component_died", + GTK_SIGNAL_FUNC (backend_died_cb), client); goto out; case GNOME_Evolution_Calendar_Listener_ERROR: diff --git a/calendar/cal-client/cal-client.h b/calendar/cal-client/cal-client.h index 68bef1e96c..de5e19ffdf 100644 --- a/calendar/cal-client/cal-client.h +++ b/calendar/cal-client/cal-client.h @@ -110,6 +110,8 @@ struct _CalClientClass { void (* categories_changed) (CalClient *client, GPtrArray *categories); void (* forget_password) (CalClient *client, const char *key); + + void (* backend_died) (CalClient *client); }; typedef gchar * (* CalClientAuthFunc) (CalClient *client, diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index d26ad60e56..939b4c6d5c 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -1717,6 +1717,34 @@ client_categories_changed_cb (CalClient *client, GPtrArray *categories, gpointer free_categories (merged); } +/* Callback when the backend dies */ +static void +backend_died_cb (CalClient *client, gpointer data) +{ + GnomeCalendar *gcal; + GnomeCalendarPrivate *priv; + char *message; + + gcal = GNOME_CALENDAR (data); + priv = gcal->priv; + + if (client == priv->client) { + 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"), + cal_client_get_uri (priv->client)); + } 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"), + cal_client_get_uri (priv->task_pad_client)); + } else + g_assert_not_reached (); + + gnome_error_dialog_parented (message, GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gcal)))); + g_free (message); +} + GtkWidget * gnome_calendar_construct (GnomeCalendar *gcal) { @@ -1740,6 +1768,8 @@ gnome_calendar_construct (GnomeCalendar *gcal) GTK_SIGNAL_FUNC (client_cal_opened_cb), gcal); gtk_signal_connect (GTK_OBJECT (priv->client), "categories_changed", GTK_SIGNAL_FUNC (client_categories_changed_cb), gcal); + gtk_signal_connect (GTK_OBJECT (priv->client), "backend_died", + GTK_SIGNAL_FUNC (backend_died_cb), gcal); e_day_view_set_cal_client (E_DAY_VIEW (priv->day_view), priv->client); @@ -1761,6 +1791,8 @@ gnome_calendar_construct (GnomeCalendar *gcal) GTK_SIGNAL_FUNC (client_cal_opened_cb), gcal); gtk_signal_connect (GTK_OBJECT (priv->task_pad_client), "categories_changed", GTK_SIGNAL_FUNC (client_categories_changed_cb), gcal); + gtk_signal_connect (GTK_OBJECT (priv->task_pad_client), "backend_died", + GTK_SIGNAL_FUNC (backend_died_cb), gcal); model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo)); g_assert (model != NULL); |