--- clock.c.orig	2006-05-29 16:48:22.000000000 -0400
+++ clock.c	2006-06-26 19:32:11.366891047 -0400
@@ -1400,6 +1400,30 @@
         GtkWidget                 *vbox;
 	GtkCalendarDisplayOptions  options;
         struct tm                 *tm;
+	GtkWidget		  *calendar;
+
+	calendar = gtk_calendar_new ();
+
+	if (calendar == NULL)
+	{
+		GtkWidget *dialog;
+
+		dialog = gtk_message_dialog_new (NULL,
+						 GTK_DIALOG_DESTROY_WITH_PARENT,
+						 GTK_MESSAGE_ERROR,
+						 GTK_BUTTONS_OK,
+						 _("Got NULL calendar from gtk_calendar_new"));
+
+		g_signal_connect (dialog, "response",
+				  G_CALLBACK (gtk_widget_destroy), NULL);
+
+		gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+		gtk_window_set_screen (GTK_WINDOW (dialog), screen);
+
+		gtk_widget_show_all (dialog);			
+
+		return NULL;
+	}
 
 	window = GTK_WINDOW (gtk_window_new (GTK_WINDOW_TOPLEVEL));
         gtk_window_set_screen (window, screen);
@@ -1426,7 +1450,8 @@
 	g_signal_connect (window, "key_press_event",
 			  G_CALLBACK (close_on_escape), cd);
 			
-	cd->calendar = gtk_calendar_new ();
+	cd->calendar = calendar;
+	
         g_object_add_weak_pointer (G_OBJECT (cd->calendar),
                                    (gpointer *) &cd->calendar);
 
@@ -1575,11 +1600,20 @@
                 return;
         }
 
-        if (!cd->calendar_popup) {
-                cd->calendar_popup = create_calendar (cd, gtk_widget_get_screen (cd->applet));
-                g_object_add_weak_pointer (G_OBJECT (cd->calendar_popup),
-                                           (gpointer *) &cd->calendar_popup);
-        }
+	if (!cd->calendar_popup) {
+		GtkWidget *calendar_popup;
+
+		calendar_popup = create_calendar (cd, gtk_widget_get_screen (cd->applet));
+
+		if (calendar_popup != NULL) {
+			cd->calendar_popup = calendar_popup;
+			g_object_add_weak_pointer (G_OBJECT (cd->calendar_popup),
+						   (gpointer *) &cd->calendar_popup);
+		} else {
+			/* depress the clock if showing the calendar popup
+			 * failed */
+		}
+	}
 
         if (cd->calendar_popup && GTK_WIDGET_REALIZED (cd->toggle)) {
 #ifdef HAVE_LIBECAL
